Hi Songwei,
Welcome to the list and thank you for your interest in Mbed TLS!
I found a similar issue on stack overflow:
https://stackoverflow.com/questions/28895703/sbrk-function-not-found-when-p…
Is this the same issue as yours?
Regards,
Janos
From: mbed-tls <mbed-tls-bounces(a)lists.trustedfirmware.org> on behalf of songwei fu via mbed-tls <mbed-tls(a)lists.trustedfirmware.org>
Reply to: "songwei.fu(a)web.de" <songwei.fu(a)web.de>
Date: Wednesday, 17 June 2020 at 10:49
To: "mbed-tls(a)lists.trustedfirmware.org" <mbed-tls(a)lists.trustedfirmware.org>
Subject: [mbed-tls] Link error when calling "altcp_tls_create_config_client"
Hi guys,
I am new to the list and also to mbedTLS. Now I am trying to port mbedTLS to chibiOS. And when I called altcp_tls_create_config_client(cert, sizeof(cert)), I got a link error like following:
c:/chibistudio/tools/gnu tools arm embedded/7.0 2017q4/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7e-m\libg.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'
And these are my settings:
#define MBEDTLS_PLATFORM_C
#define MBEDTLS_PLATFORM_MEMORY
#define MBEDTLS_PLATFORM_CALLOC_MACRO chHeapAlloc
#define MBEDTLS_PLATFORM_FREE_MACRO chHeapFree
where chHeapAlloc and chHeapFree are the memory allocation functions from chibios.
(1) Did I miss some settings? or i did something wrong?
(2) I did not find much information about the porting from chibios side. Does anybody know where I can look for reference projects/docs?
Any suggestion will be appreciated. Thanks.
Songwei
Hi All,
I am working on Renesas RZA2M embedded board with Linux. It has limited memory of 6MB flash(R-Only)
I am using mbedtls version 2.16.5 for aws iot sdk for embedded c according to
https://docs.aws.amazon.com/iot/latest/developerguide/iot-embedded-c-sdk.ht…
When I run sample application, it is taking 15 secs for "Seeding random generator number..." and throwing below error
$ ./subscribe_publish_sample
AWS IoT SDK Version 3.0.1-
DEBUG: main L#159 rootCA /root/../certs/AmazonRootCA1.pem
DEBUG: main L#160 clientCRT /root/../certs/774a17950a-certificate.pem.crt
DEBUG: main L#161 clientKey /root/../certs/774a17950a-private.pem.key
Connecting...
DEBUG: iot_tls_connect L#130
. Seeding the random number generator...
DEBUG: iot_tls_connect L#138 . Loading the CA root certificate ...
DEBUG: iot_tls_connect L#144 ok (0 skipped)
DEBUG: iot_tls_connect L#146 . Loading the client cert. and key...
DEBUG: iot_tls_connect L#159 ok
DEBUG: iot_tls_connect L#161 . Connecting to a2g7twmqo7hg82-ats.iot.ap-south-1.amazonaws.com/443...
DEBUG: iot_tls_connect L#180 ok
DEBUG: iot_tls_connect L#182 . Setting up the SSL/TLS structure...
DEBUG: iot_tls_connect L#223
SSL state connect : 0
DEBUG: iot_tls_connect L#226 ok
DEBUG: iot_tls_connect L#228
SSL state connect : 0
DEBUG: iot_tls_connect L#229 . Performing the SSL/TLS handshake...
ERROR: iot_tls_connect L#232 failed
! mbedtls_ssl_handshake returned -0x50
ERROR: main L#190 Error(-4) connecting to a2g7twmqo7hg82-ats.iot.ap-south-1.amazonaws.com:443
For detailed debug log using ssl_client2, go through https://pastebin.com/mNXhB0xj<https://github.com/ARMmbed/mbedtls/issues/url>
https://pastebin.com/mNXhB0xj
my client device specifications
$ cat /proc/cpuinfo
processor : 0
model name : ARMv7 Processor rev 1 (v7l)
BogoMIPS : 1056.00
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpd32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x4
CPU part : 0xc09
CPU revision : 1
Hardware : Generic R7S9210 (Flattened Device Tree)
Revision : 0000
Serial : 0000000000000000
$ free
total used free shared buffers cached
Mem: 7544 4484 3060 40 0 304
-/+ buffers/cache: 4180 3364
Swap: 0 0 0
I am not getting any help to resolve this issue and spending days and days. I am suspecting the issue might be timing related (or) cpu clock related (or) memory footprint related (or) something else
I need this forum help badly to resolve the issue. Please ping me if you need any other data.
Thanks in advance,
Srinivas.
Regards,
Srinivas.
[cid:1eddf249-06f8-4cbd-a3e2-9c22437fd27f]
Hi,
I wanted to use TLS over BLE application. When I googled, I figured out that MbedTLS can work on BLE. If someone can share a sample application where-in MbedTLS APIs are used as part of a BT/BLE application, it will be of great help.
Regards,
Fariya
Hi,
we have an application which uses ASIO. And now we want to add mbed TLS to
provide a TLS layer.
ASIO can be used with OpenSSL and wolfSSL. But how to do this with mbed TLS?
Any hints on that?
See also this question at SO:
https://stackoverflow.com/questions/61875404/asio-c-with-mbed-tls-library
best regards,
Frank
I want to connect an ESP32 to a DTLS server using mbedtls' dtls_server demo. The code I used for the client is very similar to the dtls_client example, but is unable to finish the handshake process for some reason. According to Wireshark, the client is not responding to the "Server hello done" frame, causing a timeout that makes the server to send the certificate again and again until it gives up the connection. The dtls_client demo works correctly on the computer, but not on the ESP32. Has anyone tested DTLS on the ESP32?
I have attached the following files for further reference:
- dtls_esp32.pcapng: Wireshark file with the DTLS packets between client and server.
- mbedtls.tar.bz2: compressed (> 7k lines) plain text log as reported by the board. On line 7131, where the last message from the server is received, it looks like the client never receives the whole message, so it never reaches the "Server hello done" state. Could anyone please confirm this?
- dtls.c: client source code. Slightly modified from the dtls_client example.
Thank you very much for your help.
Xavi
Hi,
I was reviewing the proposal and had a few questions on usage of the new params.
1) When using plaintext keys, is the "attributes" param unused and should/could it be set to NULL?
2) If using key store (i.e. opaque), is the key ID the only attribute field which needs to be set? My assumption is attributes would be populated from the key store using the key ID?
3) If using key store, are the "key_buffer" and "key_buffer_size" params typically unused (i.e. can be set to null and zero respectively)? I do the proposal says the buffer content is up to the driver. Are there any usage cases in mind?
4) For drivers that support both opaque and transparent operation, which param would be used to determine the mode? (I had assumed key ID = 0 would be transparent, and non-zero is opaque)
I'm unclear how persistent_state for opaque driver's is used. Could you elaborate on how it's used by the driver and core and why it isn't needed for transparent drivers?
Key management with opaque drivers
Transparent drivers may provide the following key management functions:
Should this be "Opaque"?
Regards,
Brian Quach
SimpleLink MCU
Texas Instruments Inc.
12500 TI Blvd, MS F-4000
Dallas, TX 75243
214-479-4076
> On 11 Jun 2020, at 12:09, Gilles Peskine via mbed-tls <mbed-tls(a)lists.trustedfirmware.org> wrote:
>
> On 11/06/2020 11:24, Martin Man via mbed-tls wrote:
>>
>> I think this is a bug and the dn_gets should simply leave the UTF-8
>> multibyte untouched when parsing it out from a field tagged with ASN.1
>> tag 12 (utf-8).
>
> We are not going to do Unicode normalization in Mbed TLS: that would be
> far too complex for a library that runs on systems with ~1e5 bytes
> available for code. So Unicode strings would only be processed correctly
> if the application passes normalized strings and CAs only generate
> certificates with normalized strings. But that would be an improvement
> on converting non-ASCII characters to '?'.
Definitely agree that normalization is not needed. I think this problem could be split into two parts:
1) When a const char* is passed into mbedtls_x509write_crt_set_subject_name, the mbedtls will currently encode it into ASN tag 12 UTF8. Not sure what validation is done. But it could perhaps do at least a basic validation of what the C string passed in is to avoid generating a cert with crippled DN. Alternatively you can simply trust the developer to pass in correct UTF8 and document this. This is a API design decision of what input is allowed to be passed into the method and what validation is done on this.
2) When the mbedtls_x509_dn_gets extracts a C string from the ASN.1 tagged as 12, it could validate that it is indeed valid UTF-8, or just leave it as is and push it out. Again, this is about what we expect the library to do.
I’m not an expert on whether this can in any way be used to trick MBEDLTS to do bad things when sending in a malformed certificate, say a one where DN is encoded as UTF-8 but contains illegal UTF-8 in the payload.
thanks for listening,
Martin
On 11/06/2020 11:24, Martin Man via mbed-tls wrote:
> The code in mbedtls_x509_dn_gets fails to properly handle the UTF-8
> multibyte sequence 0xe2 0x80 0x99 and turns it into 0xe2 0x80 0x3f.
>
> There is a fix floating around development branch mentioned
> here https://github.com/ARMmbed/mbedtls/pull/3326/files which
> essentially replaces all control chars with question marks.
>
> I think this is a bug and the dn_gets should simply leave the UTF-8
> multibyte untouched when parsing it out from a field tagged with ASN.1
> tag 12 (utf-8).
That code is from an earlier era (mid 2000s, I think) when most systems
used an 8-bit encoding, but non-8-bit-clean systems were still common. A
'\x80' in text might be transformed to '\x00' with disastrous consequences.
But over a decade later, I don't think non-8-bit-clean systems are a
concern anymore. Leaving all non-ASCII characters alone sounds
reasonable to me.
We are not going to do Unicode normalization in Mbed TLS: that would be
far too complex for a library that runs on systems with ~1e5 bytes
available for code. So Unicode strings would only be processed correctly
if the application passes normalized strings and CAs only generate
certificates with normalized strings. But that would be an improvement
on converting non-ASCII characters to '?'.
--
Gilles Peskine
Mbed TLS developer
Hi guys,
I’m new to the list and bringing the discussion over here from https://github.com/ARMmbed/mbedtls/issues/3413 <https://github.com/ARMmbed/mbedtls/issues/3413>.
I’m creating a certificate using mbedtls and setting it’s issuer and and subject using the mbedtls_x509write_crt_set_subject_name, and mbedtls_x509write_crt_set_issuer_name.
The name passed in is in UTF8 and contains a sequence 0xe2 0x80 0x99 (apostrophe) in the CN string. If I debugged this correctly, the underlying sequence of bytes is correctly encoded in ASN.1 and tagged as 12 (UTF-8).
When I later parse the cert and try to extract its subject back using mbedtls_x509_dn_gets from crt.subject and crt.issuer the UTF-8 gets corrupted.
The code in mbedtls_x509_dn_gets fails to properly handle the UTF-8 multibyte sequence 0xe2 0x80 0x99 and turns it into 0xe2 0x80 0x3f.
There is a fix floating around development branch mentioned here https://github.com/ARMmbed/mbedtls/pull/3326/files <https://github.com/ARMmbed/mbedtls/pull/3326/files> which essentially replaces all control chars with question marks.
I think this is a bug and the dn_gets should simply leave the UTF-8 multibyte untouched when parsing it out from a field tagged with ASN.1 tag 12 (utf-8).
What’s your opinion?
Martin
Hi Palomo
All the documentation we have to share is already available, either in the upstream codebase, the wiki (https://developer.trustedfirmware.org/w/mbed-tls/) or the legacy website (https://tls.mbed.org/). Some of the info on the latter is out of date.
The core development team at Arm do not offer training. Arm has a Partner Enablement Group that does this kind of thing but I don't think they offer Mbed TLS specific training currently. I've asked them if they would consider this in future but I guess that's not going to help you in the short term.
Good luck with your learning and we'll try to answer any specific questions you have.
Regards
Dan.
From: mbed-tls <mbed-tls-bounces(a)lists.trustedfirmware.org> On Behalf Of Jesus Gualberto Palomo Garcia via mbed-tls
Sent: 08 June 2020 04:46
To: Gilles Peskine <Gilles.Peskine(a)arm.com>
Cc: mbed-tls(a)lists.trustedfirmware.org
Subject: Re: [mbed-tls] support mbedTLS no entropy source
Hi Gilles.
Thanks for follow my questions and attend it, regarding trainings, I want to understand how the encryption works, how the algorithms works inside the library, I can read the code and google the concepts but I want to accelerate the knowledge transfer, maybe for implement some optimization, I don't if that is possible, at the moment my PoC using uClinux works perfectly and the TLS 1.2 ir running over 80Mhz, so that is pretty awesome, but I want to learn more about encryption, maybe if you can share me some literature regarding this point?
Thank you very much and regards from Mexico!
On Tue, Jun 2, 2020 at 6:21 PM Gilles Peskine <gilles.peskine(a)arm.com<mailto:gilles.peskine@arm.com>> wrote:
Hi Palomo,
I don't think there's any other way at the moment. The patch in my email
is one possible solution, but I'm not sure if it's right, because not
all platforms with a Linux kernel have /dev/urandom.
I think the best solution would be to make the existence of /dev/urandom
a platform configuration option. But platform options are a little messy
already, between the MBEDTLS_HAVE_xxx options, the
MBEDTLS_PLATFORM_STD_xxx options, the MBEDTLS_PLATFORM_xxx_MACRO
options, the MBEDTLS_PLATFORM_xxx_ALT options. And this new option
wouldn't behave like any of the existing ones since it should have three
settings: guess (the default, identical to the current behavior of
observing preprocessor symbols like __unix__), off and on. We should
figure out what to do about platform options in 3.0 before making this
even more complex.
me.todo.add("collect my thoughts on simplifying platform customization
and post them to the list")
Regarding trainings, my team doesn't normally do that, but there are
other teams in Arm that do. What topic are you interested in?
--
Gilles Peskine
Mbed TLS developer
On 31/05/2020 20:06, Jesus Gualberto Palomo Garcia wrote:
> Hello Gilles thanks for your support, yes finally I could compile the
> library in the architecture that I used, I forced the compilation to
> entry in the "if _unix_" conditional compilation, but I assume that
> exist another way to do this. Do you have a example for enable that
> conditional compilation flags?
>
> regarding to my dev/urandom, yes my platform has this feature, the
> library runs very well, but I just have the point related to "force"
> the compilation because the library doesn't recognize the unix
> architecture.
>
> Thanks and we keep in touch!
>
> Regards from Mexico!
>
> BTW If I want to professional training, Do you offered this service?
>
> On Mon, May 25, 2020 at 11:07 AM Gilles Peskine via mbed-tls
> <mbed-tls(a)lists.trustedfirmware.org<mailto:mbed-tls@lists.trustedfirmware.org>
> <mailto:mbed-tls@lists.trustedfirmware.org<mailto:mbed-tls@lists.trustedfirmware.org>>> wrote:
>
> Hi Palomo,
>
> You seem to be compiling for a system with a Linux kernel, but
> with only
> a partial Unix userland. The “Unix” code in the entropy_poll module
> might work on your system, but it is only enabled if __unix__ or
> __unix
> (or a few others) is defined.
>
> Can you please try the attached patch? Does your runtime environment
> have /dev/urandom ?
>
> Regarding the knowledge base article, you need to remove the "."
> character at the end of the URL:
> https://tls.mbed.org/kb/how-to/add-a-random-generator--
>
> Gilles Peskine
> Mbed TLS developer
>
> On 19/05/2020 21:43, Jesus Gualberto Palomo Garcia via mbed-tls wrote:
> > Hello Hanno, Thanks for your thanks for you quickly replay.
> >
> > I have an error compilation, I'm using nios2-linux-uclibc for my
> cross
> > compilation and uclinux architecture,
> > the linux kernel is 2.60 but I have this error when I try to compile
> > the library, I want to use the library as a simple client using
> TLS1.2
> >
> > $ make static
> > CC aes.c
> > CC aesni.c
> > CC arc4.c
> > CC aria.c
> > CC asn1parse.c
> > CC asn1write.c
> > CC base64.c
> > CC bignum.c
> > CC blowfish.c
> > CC camellia.c
> > CC ccm.c
> > CC chacha20.c
> > CC chachapoly.c
> > CC cipher.c
> > CC cipher_wrap.c
> > CC cmac.c
> > CC ctr_drbg.c
> > CC des.c
> > CC dhm.c
> > CC ecdh.c
> > CC ecdsa.c
> > CC ecjpake.c
> > CC ecp.c
> > CC ecp_curves.c
> > CC entropy.c
> > CC entropy_poll.c
> > entropy_poll.c:56:2: #error "Platform entropy sources only work on
> > Unix and Windows, see MBEDTLS_NO_PLATFORM_ENTROPY in config.h"
> > Makefile:285: recipe for target 'entropy_poll.o' failed
> > make: *** [entropy_poll.o] Error 1
> >
> > BTW the article is not
> > found https://tls.mbed.org/kb/how-to/add-a-random-generator.
> > <https://tls.mbed.org/kb/how-to/add-a-random-generator.>
> >
> > Many thanks!!
> >
> >
> > On Tue, May 19, 2020 at 9:01 AM Hanno Becker
> <Hanno.Becker(a)arm.com<mailto:Hanno.Becker@arm.com> <mailto:Hanno.Becker@arm.com<mailto:Hanno.Becker@arm.com>>
> > <mailto:Hanno.Becker@arm.com<mailto:Hanno.Becker@arm.com> <mailto:Hanno.Becker@arm.com<mailto:Hanno.Becker@arm.com>>>> wrote:
> >
> > Hi Palomo,
> >
> > Please take a look at the recent
> >
> thread https://lists.trustedfirmware.org/pipermail/mbed-tls/2020-April/000069.html
> > which should give you a better understanding of how Mbed TLS
> > manages and uses entropy from the underlying system.
> >
> > Regards,
> > Hanno
> >
> ------------------------------------------------------------------------
> > *From:* mbed-tls <mbed-tls-bounces(a)lists.trustedfirmware.org<mailto:mbed-tls-bounces@lists.trustedfirmware.org>
> <mailto:mbed-tls-bounces@lists.trustedfirmware.org<mailto:mbed-tls-bounces@lists.trustedfirmware.org>>
> > <mailto:mbed-tls-bounces@lists.trustedfirmware.org<mailto:mbed-tls-bounces@lists.trustedfirmware.org>
> <mailto:mbed-tls-bounces@lists.trustedfirmware.org<mailto:mbed-tls-bounces@lists.trustedfirmware.org>>>> on behalf of
> > Jesus Gualberto Palomo Garcia via mbed-tls
> > <mbed-tls(a)lists.trustedfirmware.org<mailto:mbed-tls@lists.trustedfirmware.org>
> <mailto:mbed-tls@lists.trustedfirmware.org<mailto:mbed-tls@lists.trustedfirmware.org>>
> > <mailto:mbed-tls@lists.trustedfirmware.org<mailto:mbed-tls@lists.trustedfirmware.org>
> <mailto:mbed-tls@lists.trustedfirmware.org<mailto:mbed-tls@lists.trustedfirmware.org>>>>
> > *Sent:* Tuesday, May 19, 2020 2:56 PM
> > *To:* mbed-tls(a)lists.trustedfirmware.org<mailto:mbed-tls@lists.trustedfirmware.org>
> <mailto:mbed-tls@lists.trustedfirmware.org<mailto:mbed-tls@lists.trustedfirmware.org>>
> > <mailto:mbed-tls@lists.trustedfirmware.org<mailto:mbed-tls@lists.trustedfirmware.org>
> <mailto:mbed-tls@lists.trustedfirmware.org<mailto:mbed-tls@lists.trustedfirmware.org>>>
> > <mbed-tls(a)lists.trustedfirmware.org<mailto:mbed-tls@lists.trustedfirmware.org>
> <mailto:mbed-tls@lists.trustedfirmware.org<mailto:mbed-tls@lists.trustedfirmware.org>>
> > <mailto:mbed-tls@lists.trustedfirmware.org<mailto:mbed-tls@lists.trustedfirmware.org>
> <mailto:mbed-tls@lists.trustedfirmware.org<mailto:mbed-tls@lists.trustedfirmware.org>>>>
> > *Subject:* [mbed-tls] support mbedTLS no entropy source
> >
> > Hi all!
> >
> > I'm Palomo and I've been working with your library a few weeks
> > ago, I'm using Linux kernel 2.60 but my embedded system has a
> > limit entropy source, i now that this is a critical point,
> but How
> > can I use your library if I want to use a other entropy source?
> >
> > Thanks and waiting for you!
> >
> > --
> > *¡Saludos! Best wishes!*
> > *
> > *
> > *
> > /*Jesus** Palomo*/
> >
> > México, D.F.
> >
> > *
> >
> >
> >
> > --
> > *¡Saludos! Best wishes!*
> > *
> > *
> > *
> > /*Jesus** Palomo*/
> >
> > México, D.F.
> >
> > *
> >
>
> --
> mbed-tls mailing list
> mbed-tls(a)lists.trustedfirmware.org<mailto:mbed-tls@lists.trustedfirmware.org>
> <mailto:mbed-tls@lists.trustedfirmware.org<mailto:mbed-tls@lists.trustedfirmware.org>>
> https://lists.trustedfirmware.org/mailman/listinfo/mbed-tls
>
>
>
> --
> *¡Saludos! Best wishes!*
> *
> *
> *
> /*Jesus** Palomo*/
>
> México, D.F.
>
> *
--
¡Saludos! Best wishes!
Jesus Palomo
México, D.F.
Hello Gilles thanks for your support, yes finally I could compile the
library in the architecture that I used, I forced the compilation to entry
in the "if _unix_" conditional compilation, but I assume that exist another
way to do this. Do you have a example for enable that conditional
compilation flags?
regarding to my dev/urandom, yes my platform has this feature, the library
runs very well, but I just have the point related to "force" the
compilation because the library doesn't recognize the unix architecture.
Thanks and we keep in touch!
Regards from Mexico!
BTW If I want to professional training, Do you offered this service?
On Mon, May 25, 2020 at 11:07 AM Gilles Peskine via mbed-tls <
mbed-tls(a)lists.trustedfirmware.org> wrote:
> Hi Palomo,
>
> You seem to be compiling for a system with a Linux kernel, but with only
> a partial Unix userland. The “Unix” code in the entropy_poll module
> might work on your system, but it is only enabled if __unix__ or __unix
> (or a few others) is defined.
>
> Can you please try the attached patch? Does your runtime environment
> have /dev/urandom ?
>
> Regarding the knowledge base article, you need to remove the "."
> character at the end of the URL:
> https://tls.mbed.org/kb/how-to/add-a-random-generator--
>
> Gilles Peskine
> Mbed TLS developer
>
> On 19/05/2020 21:43, Jesus Gualberto Palomo Garcia via mbed-tls wrote:
> > Hello Hanno, Thanks for your thanks for you quickly replay.
> >
> > I have an error compilation, I'm using nios2-linux-uclibc for my cross
> > compilation and uclinux architecture,
> > the linux kernel is 2.60 but I have this error when I try to compile
> > the library, I want to use the library as a simple client using TLS1.2
> >
> > $ make static
> > CC aes.c
> > CC aesni.c
> > CC arc4.c
> > CC aria.c
> > CC asn1parse.c
> > CC asn1write.c
> > CC base64.c
> > CC bignum.c
> > CC blowfish.c
> > CC camellia.c
> > CC ccm.c
> > CC chacha20.c
> > CC chachapoly.c
> > CC cipher.c
> > CC cipher_wrap.c
> > CC cmac.c
> > CC ctr_drbg.c
> > CC des.c
> > CC dhm.c
> > CC ecdh.c
> > CC ecdsa.c
> > CC ecjpake.c
> > CC ecp.c
> > CC ecp_curves.c
> > CC entropy.c
> > CC entropy_poll.c
> > entropy_poll.c:56:2: #error "Platform entropy sources only work on
> > Unix and Windows, see MBEDTLS_NO_PLATFORM_ENTROPY in config.h"
> > Makefile:285: recipe for target 'entropy_poll.o' failed
> > make: *** [entropy_poll.o] Error 1
> >
> > BTW the article is not
> > found https://tls.mbed.org/kb/how-to/add-a-random-generator.
> > <https://tls.mbed.org/kb/how-to/add-a-random-generator.>
> >
> > Many thanks!!
> >
> >
> > On Tue, May 19, 2020 at 9:01 AM Hanno Becker <Hanno.Becker(a)arm.com
> > <mailto:Hanno.Becker@arm.com>> wrote:
> >
> > Hi Palomo,
> >
> > Please take a look at the recent
> > thread
> https://lists.trustedfirmware.org/pipermail/mbed-tls/2020-April/000069.html
>
> > which should give you a better understanding of how Mbed TLS
> > manages and uses entropy from the underlying system.
> >
> > Regards,
> > Hanno
> >
> ------------------------------------------------------------------------
> > *From:* mbed-tls <mbed-tls-bounces(a)lists.trustedfirmware.org
> > <mailto:mbed-tls-bounces@lists.trustedfirmware.org>> on behalf of
> > Jesus Gualberto Palomo Garcia via mbed-tls
> > <mbed-tls(a)lists.trustedfirmware.org
> > <mailto:mbed-tls@lists.trustedfirmware.org>>
> > *Sent:* Tuesday, May 19, 2020 2:56 PM
> > *To:* mbed-tls(a)lists.trustedfirmware.org
> > <mailto:mbed-tls@lists.trustedfirmware.org>
> > <mbed-tls(a)lists.trustedfirmware.org
> > <mailto:mbed-tls@lists.trustedfirmware.org>>
> > *Subject:* [mbed-tls] support mbedTLS no entropy source
> >
> > Hi all!
> >
> > I'm Palomo and I've been working with your library a few weeks
> > ago, I'm using Linux kernel 2.60 but my embedded system has a
> > limit entropy source, i now that this is a critical point, but How
> > can I use your library if I want to use a other entropy source?
> >
> > Thanks and waiting for you!
> >
> > --
> > *¡Saludos! Best wishes!*
> > *
> > *
> > *
> > /*Jesus** Palomo*/
> >
> > México, D.F.
> >
> > *
> >
> >
> >
> > --
> > *¡Saludos! Best wishes!*
> > *
> > *
> > *
> > /*Jesus** Palomo*/
> >
> > México, D.F.
> >
> > *
> >
>
> --
> mbed-tls mailing list
> mbed-tls(a)lists.trustedfirmware.org
> https://lists.trustedfirmware.org/mailman/listinfo/mbed-tls
>
--
*¡Saludos! Best wishes!*
*Jesus PalomoMéxico, D.F.*
Hello,
Arm is seeking early feedback on a proposed interface for cryptographic
drivers that can be plugged into an implementation of the PSA
Cryptography API. A copy of the current specification is attached. You
can find the current draft of the specification of this interface at
https://github.com/gilles-peskine-arm/mbedtls/blob/psa-unified-driver-proto…
Please note that this is work in progress. The document is not complete
yet. At this stage, it is intended to offer a general overview of the
design, not as an implementable specification. Our intention is to
continue refining this design, however we may change it based on the
feedback that we will receive and there is even a small chance that we
will abandon it.
The primary intent of this specification is to allow manufacturers of
cryptographic hardware to distribute drivers that can be added to a
pure-software, portable implementation of the PSA Cryptography API such
as Mbed TLS. The interface was designed to support three types of hardware:
* Cryptographic accelerators that operate on a key which is provided in
cleartext at the beginning of the operation. This type of driver can
also be used to plug in software engines.
* Protected environments that operate on a wrapped key which is stored
outside the protected environment.
* Protected environments that have internal key storage and operate on
keys designated by an identifier.
Concretely, a driver manufacturer would distribute:
* A JSON file specifying the driver's capabilities.
* C headers declaring the types and functions provided by the driver.
* The implementation of the functions provided by the driver, either in
the form of C source code or in the form of compiled code.
Then when an application uses a key:
* If the key is in the memory or local storage of the PSA crypto
subsystem and a driver is available for the requested cryptographic
mechanism, the core (e.g. Mbed TLS) dispatches the cryptographic
operation to the driver.
* If the key is in local storage and no driver is available, the core
performs the cryptographic operation itself.
* If the key is in some other location (as specified by its lifetime),
the core invokes the protected environment driver corresponding to that
location.
This proposal supersedes the previous drafts “PSA cryptographic
accelerator interface” (psa_crypto_accel.h) and “PSA secure element
driver interface” (crypto_se_driver.h).
We intend to implement this specification in Mbed TLS in such a way that
a platform distributor can combine drivers and distribute C source code,
object files or a mixture of the two in their system development kit. In
the long term, the accelerator interface defined here will replace the
current MBEDTLS_xxx_ALT mechanism.
Comments are welcome through the following venues:
* Public email to the psa-crypto or mbed-tls mailing list at
TrustedFirmware.
* Public comments on GitHub on the pull request
https://github.com/ARMmbed/mbedtls/pull/3313 .
* Private email to <mbed-crypto(a)arm.com>. These emails will only be
shared inside Arm. We may use your feedback to influence the design of
PSA Crypto, but your identity and the specifics will be kept confidential.
We do not have a specific deadline for feedback, however we intend to
start implementing this interface in Mbed TLS in June 2020, so feedback
received later will have a reduced chance of influencing the design if
it would entail major changes.
Best regards,
--
Gilles Peskine
Mbed TLS developer and PSA Cryptography architect
Hi Palomo,
You seem to be compiling for a system with a Linux kernel, but with only
a partial Unix userland. The “Unix” code in the entropy_poll module
might work on your system, but it is only enabled if __unix__ or __unix
(or a few others) is defined.
Can you please try the attached patch? Does your runtime environment
have /dev/urandom ?
Regarding the knowledge base article, you need to remove the "."
character at the end of the URL:
https://tls.mbed.org/kb/how-to/add-a-random-generator--
Gilles Peskine
Mbed TLS developer
On 19/05/2020 21:43, Jesus Gualberto Palomo Garcia via mbed-tls wrote:
> Hello Hanno, Thanks for your thanks for you quickly replay.
>
> I have an error compilation, I'm using nios2-linux-uclibc for my cross
> compilation and uclinux architecture,
> the linux kernel is 2.60 but I have this error when I try to compile
> the library, I want to use the library as a simple client using TLS1.2
>
> $ make static
> CC aes.c
> CC aesni.c
> CC arc4.c
> CC aria.c
> CC asn1parse.c
> CC asn1write.c
> CC base64.c
> CC bignum.c
> CC blowfish.c
> CC camellia.c
> CC ccm.c
> CC chacha20.c
> CC chachapoly.c
> CC cipher.c
> CC cipher_wrap.c
> CC cmac.c
> CC ctr_drbg.c
> CC des.c
> CC dhm.c
> CC ecdh.c
> CC ecdsa.c
> CC ecjpake.c
> CC ecp.c
> CC ecp_curves.c
> CC entropy.c
> CC entropy_poll.c
> entropy_poll.c:56:2: #error "Platform entropy sources only work on
> Unix and Windows, see MBEDTLS_NO_PLATFORM_ENTROPY in config.h"
> Makefile:285: recipe for target 'entropy_poll.o' failed
> make: *** [entropy_poll.o] Error 1
>
> BTW the article is not
> found https://tls.mbed.org/kb/how-to/add-a-random-generator.
> <https://tls.mbed.org/kb/how-to/add-a-random-generator.>
>
> Many thanks!!
>
>
> On Tue, May 19, 2020 at 9:01 AM Hanno Becker <Hanno.Becker(a)arm.com
> <mailto:Hanno.Becker@arm.com>> wrote:
>
> Hi Palomo,
>
> Please take a look at the recent
> thread https://lists.trustedfirmware.org/pipermail/mbed-tls/2020-April/000069.html
> which should give you a better understanding of how Mbed TLS
> manages and uses entropy from the underlying system.
>
> Regards,
> Hanno
> ------------------------------------------------------------------------
> *From:* mbed-tls <mbed-tls-bounces(a)lists.trustedfirmware.org
> <mailto:mbed-tls-bounces@lists.trustedfirmware.org>> on behalf of
> Jesus Gualberto Palomo Garcia via mbed-tls
> <mbed-tls(a)lists.trustedfirmware.org
> <mailto:mbed-tls@lists.trustedfirmware.org>>
> *Sent:* Tuesday, May 19, 2020 2:56 PM
> *To:* mbed-tls(a)lists.trustedfirmware.org
> <mailto:mbed-tls@lists.trustedfirmware.org>
> <mbed-tls(a)lists.trustedfirmware.org
> <mailto:mbed-tls@lists.trustedfirmware.org>>
> *Subject:* [mbed-tls] support mbedTLS no entropy source
>
> Hi all!
>
> I'm Palomo and I've been working with your library a few weeks
> ago, I'm using Linux kernel 2.60 but my embedded system has a
> limit entropy source, i now that this is a critical point, but How
> can I use your library if I want to use a other entropy source?
>
> Thanks and waiting for you!
>
> --
> *¡Saludos! Best wishes!*
> *
> *
> *
> /*Jesus** Palomo*/
>
> México, D.F.
>
> *
>
>
>
> --
> *¡Saludos! Best wishes!*
> *
> *
> *
> /*Jesus** Palomo*/
>
> México, D.F.
>
> *
>
Hi Palomo,
Please take a look at the recent thread https://lists.trustedfirmware.org/pipermail/mbed-tls/2020-April/000069.html
which should give you a better understanding of how Mbed TLS manages and uses entropy from the underlying system.
Regards,
Hanno
________________________________
From: mbed-tls <mbed-tls-bounces(a)lists.trustedfirmware.org> on behalf of Jesus Gualberto Palomo Garcia via mbed-tls <mbed-tls(a)lists.trustedfirmware.org>
Sent: Tuesday, May 19, 2020 2:56 PM
To: mbed-tls(a)lists.trustedfirmware.org <mbed-tls(a)lists.trustedfirmware.org>
Subject: [mbed-tls] support mbedTLS no entropy source
Hi all!
I'm Palomo and I've been working with your library a few weeks ago, I'm using Linux kernel 2.60 but my embedded system has a limit entropy source, i now that this is a critical point, but How can I use your library if I want to use a other entropy source?
Thanks and waiting for you!
--
¡Saludos! Best wishes!
Jesus Palomo
México, D.F.
Hi all!
I'm Palomo and I've been working with your library a few weeks ago, I'm
using Linux kernel 2.60 but my embedded system has a limit entropy source,
i now that this is a critical point, but How can I use your library if I
want to use a other entropy source?
Thanks and waiting for you!
--
*¡Saludos! Best wishes!*
*Jesus PalomoMéxico, D.F.*
Hello,
If you enable the use PSA for cryptography in TLS
(MBEDTLS_USE_PSA_CRYPTO) and configure the PSK with
mbedtls_ssl_conf_psk_opaque(), the key derivation is done through the
PSA API. You can then keep your key in the secure world. You'll need to
have a PSA crypto implementation where the PSA crypto core is in the
secure world and the frontend is in the application that performs the
TLS handshake. PSA crypto is designed for this, but you or your TEE
vendor will need to port the Mbed TLS code to your platform.
--
Gilles Peskine
Mbed TLS developer
On 13/05/2020 11:10, mayuri janawad via mbed-tls wrote:
> Hello,
>
> I am currently trying to establish pre shared key based tls handshake
> using mbedtls. However, I want to store the pre shared key in the
> trustzone and derive the session key inside the trustzone. Is it
> possible using mbedtls? Can I provide alternate implementation for psk
> based tls in mbedtls library?
>
> It would be really helpful if this could be answered as soon as
> possible. Thank you in advance for your assistance.
>
> Regards,
> Mayuri Janawad
>
Hello,
I am currently trying to establish pre shared key based tls handshake using
mbedtls. However, I want to store the pre shared key in the trustzone and
derive the session key inside the trustzone. Is it possible using mbedtls?
Can I provide alternate implementation for psk based tls in mbedtls library?
It would be really helpful if this could be answered as soon as possible.
Thank you in advance for your assistance.
Regards,
Mayuri Janawad
Hi Abhilash,
> I am trying to do the ECDH shared secret computation using the mbedTLS
> library. I am referring to multiple examples such as ecdh_curve25519.c
> and ecdh_main.c.
>
Ok. You should probably know a few things about those examples:
1. They both perform what's known as "ephemeral ECDH" (or sometimes ECDHE).
2. They're both using the low-level part of our ECDH API. For ecdh_curve25519,
that is because that curve is not supported by the higher-level API yet - for
the other example, I don't know what the reason is.
3. Curve25519 is quite different from other curves regarding how public keys
are represented.
> In my case, in my application firmware, I already have a device _priv
> key and I receive a server_public key; both generated using a curve
> ECP_DP_SECP256R1 in the bootloader itself. So in the application
> firmware, I would like to do generate a shared secret from here on and
> preserve it for future use.
>
Ok, so you want to do what's known as "static ECDH". So the example
ecdh_curve25519 is not a great example, due to points 1 and 3 above. Also,
since the curve you're using supports it, you may want to use the higher-level
part of our ECDH API (the functions that accept a context as an argument).
> The following is the steps that I do:
>
> 1. Create a new client context, entropy context, ctr_drbg context variables.
> 2. use mbedtls_"respective"_init() to initalize all the three variables
> 3. Seed a random number using mbedtls_ctr_drbg_seed() function.
> 4. load the P256 elliptic curve in client context using mbedtls_ecp_group_load()
All this looks absolutely correct.
> 5. Then use mbedtls_mpi_lset() to set Qp.Z =1
> 6. Then read the server pub key using mbedtls_mpi_read_binary(&ctx_cli.Qp.X, server_pub, 65);
>From the 65 I assume that the server public key as encoded as an uncompressed
point. Then you can read it with:
mbedtls_ecp_point_read_binary(&ctx_cli.grp, &ctx_cli.Qp, server_pub, 65);
(For Curve25519 mbedtls_ecp_point_read_binary() isn't implemented yet which is
why the example does a direct call to an MPI function and accesses individual
point coordinates, but Curve25519 and P-256 don't use the same coordinate
systems.)
> 7. Now the question is: Should I initialize the ctx_cli with my already generated device_priv key using
> mbedtls_mpi_read_binary(&ctx_cli.d, device_priv_key, 50) ?
That looks almost correct, except 50 does not look like a valid size for a
private key for the curve you're using.
> 8. Then I use mbedtls_ecdh_compute_shared(&ctx_cli.grp, &ctx_cli.z, &ctx_cli.Qp, &ctx_cli.d, mbedtls_ctr_drbg_random, &ctr_drbg); to compute the shared secret in z.
>
That's correct, but you could also call
mbedtls_ecdh_calc_secret( &ctx_cli, &olen, buf, blen,
mbedtls_ctr_drbg_random, &ctr_drbg );
which also serializes the secret to a buffer.
> Questions:
> 1. Do I need to generate a keypair for client context using
> mbedtls_ecdh_gen_public(&ctx_cli.grp, &ctx_cli.d, &ctx_cli.Q,
> mbedtls_ctr_drbg_random, &ctrDrbg)? And then set pvtkey as device priv
> key and pub key as service pub key?
>
I'm not sure I understand the context of the question, so I'll distinguish
two cases:
- When provisioning the device, you need to generate a key pair for it, which
can indeed be done as show.
- Once the device is working, it doesn't need to generate new key pairs, just
load the one that was provisioned as described below.
> 2. I see that ctx_cli.Q has two components, Q.x and Q.y. How do I
> extract these two values from a public key? Do I need to separately
> initialize them?
>
I don't recommend you manipulate those directly, but use the
`mbedtls_ecp_point_{read,write}_binary()` functions instead.
> Please let me know if the flow is correct. In all the examples, they
> generate a key pair and just update the public key part (Qp.X) of the
> key. They do not touch the private key part (d) of the key. Please
> confirm if I can upload my private key directly in my case.
>
Your flow looks correct, and the difference from the examples is that they're
demonstrating ephemeral ECDH while it looks like you want to do static ECDH.
> Also if my platform is a little endian, is there a recommended step
> before using mbedtls_mpi_read_binary_le functions?
Then endianness of your plaftorm should not matter, and you shouldn't need to
use that function.
Regards,
Manuel.
Hi Aurélien,
> I have submitted PR#3245 in order to add Edwards curves support to Mbed
> TLS, with the eventual goal to add support for the EdDSA algorithm.
> There are still a few things to fix that require discussion.
>
Thank you very much for your contribution, and for opening this discussion!
> Let's start the discussion with the first one. Adding a new curve type
> requires to add a new entry to the mbedtls_ecp_curve_type enum. The
> curve type used by a group is returned by the mbedtls_ecp_get_type
> function. It currently uses the coordinates type of the base point to
> determine the curve type. Montgomery curves are lacking the y
> coordinate, and the Short Weierstrass curves use the three x, y and z
> coordinates.
>
> The Edwards arithmetic implementation in this PR uses the projective
> coordinates. As such it also uses the x, y and z coordinates and this
> gives no way to differentiate a Short Weierstrass from an Edwards curve.
>
Indeed, the current implementation of `ecp_curve_type()` is a bit of a hack
and needs changing now that you're adding Edwards curves.
> I have currently implemented that by checking if the curves are the
> Ed25519 or Ed448 ones using the group id [1]. I am not sure it's very
> clean and it won't scale if more curves are added later. Another
> alternative would be to add another entry to mbedtls_ecp_group to hold
> the curve type.
>
> What do you think is the best option? Any other idea?
Honestly I think both options are fine. In the medium term (in 3.0 or 3.x) I'd
like to entirely rework the `ecp_group` structure, which currently potentially
wastes memory by having multiple instances for the same curve around (for
example, when verifying a chain of N certificates all signed with the same
curve, we'll have N instances of the `ecp_group` structure for that curve in
RAM, which is quite wasteful). So I think in the meantime we don't need to
sweat it too much.
I have a slight preference for the option you currently implemented (checking
the group ID), for two reasons:
1. Lack of scaling is not an issue, as it's unlikely a large number of Edwards
curves are going to be added soon (in particular, not before the rework of
ecp_group), since these last few years the tendency seems to be to focus on a
small number of trusted curves [1].
2. Adding a new member to `mbedtls_ecp_group` would be an ABI break, and while
we don't have a strict policy of ABI stability, it tends to cause pain to
packagers if we change the ABI too often, so it's probably better to avoid it
if we can.
Thanks,
Manuel.
[1] For example, compare https://tools.ietf.org/html/rfc4492#section-5.1.1 to
https://tools.ietf.org/html/rfc8422#section-5.1.1
Hi Simon,
> I appreciate I'm coming very late to this discussion, but I want to make a
> point and suggestion.
>
Well, I don't think we had reached a clear consensus yet, so it's not too
late to explore more options!
> These are very similar points to those Manuel was making to remove the feature
> in the first place - however - short of investing the time in rewriting the
> asymmetric functions, what we could do as a quick fix is to replace the
> existing memory code with a block allocation scheme - which should be much
> faster, speed up the asymmetric functions (in theory), avoid fragmentation, be
> more deterministic, and a better fit for embedded applications. That could
> then become the basis of the library for other projects too.
>
I think compared to our existing allocator, that would indeed be an
improvement, and as you say possibly a "quick fix" for some of the
performance issues of our asymmetric crypto (esp. ECC)... for people who
use our allocator. I'm still under the impression they're a minority of
users, even in the embedded world.
I think it comes back to a point we touched on earlier in the thread:
what other allocators are available, and how do they compare to the
design you have in mind? If existing allocators in popular embedded libc
implementations already handle small allocations efficiently, then
people are probably better off using them.
> I wouldn't mind contributing such a feature, as I had to write something very
> similar last week anyway.
>
> If I do it - will you accept it?
Thanks for the offer! Unfortunately I think it's hard to give you a
clear yes or no answer at this point.
Speaking only for myself (others in the team may disagree and are
welcome to say so in reply), I'm a bit concerned that for a "quick fix"
it would represent a significant review effort: there are obvious
security implications, it would be a complete re-design of a whole
module, and I'm not sure how many of the potential reviewers are very
familiar with allocators (I know I'm not). Considering we already have
a number of significant contributions that we just can't review as soon
as we'd like, I'd be concerned adding another one.
Adding to that concern is the fact that at this point it's still not
clear to me if in the long-term we want to keep maintaining this, or use
some existing allocator, or move it to a separate project possibly maintained by another team.
Would your offer still stand in a couple of months, when the future of
the module is perhaps a bit clearer, and when we've hopefully cleared a
few of the long-standing large PR awaiting review?
Thanks,
Manuel.