Hello,
Is it possible to output a mbedtls_x509_crt as PEM or DER? I’ve been combing the API docs but don’t see how I can do this export. I see controls for exporting a newly-built cert, but not one that comes from, e.g., mbedtls_ssl_get_peer_cert().
Thank you!
Cheers,
-Felipe Gasper
https://gist.github.com/FGasper/43758d13e987518009d18ec8951ffcbb
^^ With 3.0.0 this prints:
seeded entropy
mbedtls connected
trust loaded ok
SNI set ok
handshake tried
handshake: X509 - Certificate verification failed, e.g. CRL, CA or signature check failed
… but if I switch to the development branch, it works.
Same trust chain, same code … but the production code fails while the dev one works …
Am I just “holding it wrong”?
Thank you in advance!
-FG
Hi All,
I am new here.
With a colleague, I am working on a product which previously used
PolarSSL but was later changed to MbedTLS which, in the ST ARM 32F417
implementation, is believed to be less buggy.
It is working ok as far as we have got, but we are finding that as
well as needing some 100k more FLASH, it needs nearly 50k of RAM,
which on the 32F417 (128k RAM) would normally be OK but due to other
required functionality it leaves us just 10k.
The architecture we are using for MbedTLS is a 48k (48k was found to
be the smallest that works) static buffer within which TLS runs its
own heap. I am aware that in the most generic case one has to have
enough for one 16k buffer (plus a bit) for HTTPS, but what concerns me
is that there appears to be no way to determine the worst case memory
usage, across various usage scenarios.
It would also be great to reduce this 48k to say 30k.
Some of the protocols we know we don't need (e.g. PPP) but within any
of them there is the question of which cipher suite needs supporting.
What is the minimum cipher suite required to be able to use MbedTLS as
an HTTPS client for use with typical current cloud-based file storage
or data logging APIs such as Dropbox, Google Drive, Loggly etc?
And what is the recommended minimum cipher suite required to implement
an HTTPS server that would be able to negotiate a session with most
current web-browsers?
The goal is to ideally reduce both RAM and code size requirements for
use in an embedded device that needs to work both as a general purpose
server and client, without requiring support for multiple concurrent
sessions.
The other thing is that even the ST port of MbedTLS doesn't appear to
make use of ST CPU hardware features such as AES256, DES, etc, which
the 32F417 has in hardware. This speeds things up hugely but much more
importantly in our case, saves a lot of RAM. For example AES256 can
use about 10k if done in software.
Thank you very much in advance for any input on what can be done.
Peter
Hello,
I am Marco Portoni and I am working on a thesis research for the University
of Study of Milan. It is focused on cryptographic libraries in the IoT
world, and my question is: is it possible to run the benchmark on a ESP32?
I have already runned the benchmark on 2 of my laptops to test and
collected the results, but my ultimate goal is to make the benchmark run
on the ESP. Is it possible to do it? Thanks for every help!
Marco
Hello,
I’m trying to build shared from git on macOS and having no luck. I’m doing:
> mkdir build; cd build
> cmake DUSE_SHARED_MBEDTLS_LIBRARY=On ..
…
> make
…
> ls -la library
total 2944
drwxr-xr-x 10 felipe staff 320 Dec 1 08:49 .
drwxr-xr-x 15 felipe staff 480 Dec 1 08:49 ..
drwxr-xr-x 8 felipe staff 256 Dec 1 08:49 CMakeFiles
-rw-r--r-- 1 felipe staff 92755 Dec 1 08:49 Makefile
-rw-r--r-- 1 felipe staff 2942 Dec 1 08:49 cmake_install.cmake
-rw-r--r-- 1 felipe staff 34055 Dec 1 08:49 error.c
-rw-r--r-- 1 felipe staff 916112 Dec 1 08:49 libmbedcrypto.a
-rw-r--r-- 1 felipe staff 315856 Dec 1 08:49 libmbedtls.a
-rw-r--r-- 1 felipe staff 104072 Dec 1 08:49 libmbedx509.a
-rw-r--r-- 1 felipe staff 26265 Dec 1 08:49 version_features.c
Am I just missing something? It seems like I’m following what the README says to do; I also did `export SHARED=1` just in case, but that made no difference.
Thank you in advance!
-FG
Hi Radhika,
We do not plan to extend support for Mbed TLS 2.16 beyond the three year support period.
We do plan to release a 2.x LTS (probably 2.28) alongside the final 2.16 release, so that we always have an LTS available.
Regards
Dave Rodgman
From: mbed-tls <mbed-tls-bounces(a)lists.trustedfirmware.org> on behalf of Radhika Jandhyala via mbed-tls <mbed-tls(a)lists.trustedfirmware.org>
Reply to: Radhika Jandhyala <radhikaj(a)microsoft.com>
Date: Monday, 22 November 2021 at 10:50
To: "mbed-tls(a)lists.trustedfirmware.org" <mbed-tls(a)lists.trustedfirmware.org>
Subject: [mbed-tls] End of Life of LTS branch 2.16
Hi,
I am a maintainer for https://github.com/openenclave/openenclave. We include mbedtls 2.16 as a submodule in our project.
Reading the article below, it states that 2.16 support will last at least till Dec 2021. Will you continue to support 2.16 in 2022?
https://tls.mbed.org/tech-updates/blog/announcing-lts-branch-mbedtls-2.16
We are specifically interested in CVE fixes being backported to 2.16 and the timeframe where that will continue. Is there an updated timeline for this?
We do plan to upgrade to 3.0 in early 2022, but we anticipate that will take some effort due to breaking changes.
Thank you very much!
Radhika
Hi,
Mbed TLS 2.16 LTS is approaching the end of its support period – it was originally announced that it would be maintained for at least 3 years up until the end of 2021 – and currently there is no other LTS branch.
To ensure that there is no period of time without a supported LTS branch, we plan to release 2.28 LTS in the near future (which will have the usual 3 year support period). We will continue supporting 2.16 LTS until this is available. The expectation is that as 2.28 will be API-compatible with 2.16, users of 2.16 LTS will be able to upgrade to 2.28 very easily.
Progress towards 2.28 LTS can be followed here: https://github.com/orgs/ARMmbed/projects/18#column-15836286
Dave Rodgman
Hi,
I am a maintainer for https://github.com/openenclave/openenclave. We include mbedtls 2.16 as a submodule in our project.
Reading the article below, it states that 2.16 support will last at least till Dec 2021. Will you continue to support 2.16 in 2022?
https://tls.mbed.org/tech-updates/blog/announcing-lts-branch-mbedtls-2.16
We are specifically interested in CVE fixes being backported to 2.16 and the timeframe where that will continue. Is there an updated timeline for this?
We do plan to upgrade to 3.0 in early 2022, but we anticipate that will take some effort due to breaking changes.
Thank you very much!
Radhika
Hi,
We'd like to announce a change we intend to make: starting with Mbed TLS 3.1, it will no longer be possible to build with TLS, X.509, or PK without support for PSA Crypto.
Details: currently, use of PSA Crypto APIs from the TLS, X.509 and PK layers is controlled by the option MBEDTLS_USE_PSA_CRYPTO. When this option is disabled (which is the default), it's possible to build without MBEDTLS_PSA_CRYPTO_C. Starting with 3.1, we intend to start making TLS, X.509 and PK use PSA Crypto unconditionally, so MBEDTLS_PSA_CRYPTO_C will be automatically enabled in the build as soon as TLS, X.509 or PK is enabled.
Impact: for users who already build with PSA Crypto enabled (the default), no impact. For users who currently disable MBEDTLS_PSA_CRYPTO_C in their configuration, starting with 3.1 there will be no functional changes, but the size of the built library will increase due to the additional features enabled. The increase depends on the configuration, application, platform, and toolchain, but the order of magnitude currently ranges from about 9 KB for a minimal TLS configuration with LTO (link-time optimisation) to about 30 KB for a full configuration without link-time garbage collection (though size-constrained devices are very unlikely to use such a configuration); we aim to reduce this overhead in the future.
Rationale: maintaining two versions of every cryptographic operation in upper layers (one PSA, one non-PSA) imposes a significant burden on new developments. By removing that burden, we hope to progress faster on things that are more important in the long run, including better integration of PSA Crypto in TLS and X.509, and future code size optimisation of PSA Crypto. We realise the impact on users who were excluding PSA Crypto is significant. We're going to release Mbed TLS 2.28 in the coming months, which is not affected by this change and will receive bug fixes and security fixes for at least 3 years; we hope it provides an acceptable fall-back solution to affected users.
In the long run, PSA Crypto will become the only Crypto API we offer; we want to make its footprint as small as possible considering its feature set and we hope this change will enable us to make faster progress towards that goal.
Best regards,
Manuel Pégourié-Gonnard for the Mbed TLS team.
Hi,
While working on updating mbedtls to v3.0, I saw that the internal fields in MBEDTLS have been made private. ( ref- here<https://github.com/ARMmbed/mbedtls/blob/development/docs/3.0-migration-guid…>). It says there and I quote
"As a last resort, you can access the field foo of a structure bar by writing bar.MBEDTLS_PRIVATE(foo). Note that you do so at your own risk, since such code is likely to break in a future minor version of Mbed TLS.”
I just wanted to know if there is any alternative solution to this, rather than using `MBEDTLS_PRIVATE` everywhere. I know the next release of mbedtls probably plans to fix this with appropriate solution. But we wanted to push out our feature branch As early as possible.
I saw in the PR<https://github.com/zephyrproject-rtos/zephyr/pull/37753> in zephyr RTOS about updating to mbedtls-3.0. They have just added this line<https://github.com/ceolin/zephyr/blob/5bf3128a9703561e578651218f5bcdafb96f8…>
#if !defined(MBEDTLS_ALLOW_PRIVATE_ACCESS) #define MBEDTLS_ALLOW_PRIVATE_ACCESS
# endif
Is this an alternative solution to using `MBEDTLS_PRIVATE` for accessing a private field. If yes, can somebody please point me to respective document as this would greatly reduce our code-changes.
I understand there is some discussion going on in mbedtls about this change, and appropriate getter-setter functions shall be provided. But we wanted to push out out feature branch for early testing.
Thanks and Regards,
Aditya
Hi,
On Monday 8th we will have the next Mbed TLS Tech Forum. Please reply to the list if you have any agenda topics to raise.
As a starter for the agenda, we will likely discuss: https://github.com/ARMmbed/mbedtls/pull/5067 Proposal for driver dispatch code gen
Dave Rodgman
Zoom details below. The call will be recorded and made available on the TF website : https://www.trustedfirmware.org/meetings/
Join Zoom Meeting
https://linaro-org.zoom.us/j/99948462765?pwd=SGlHYlF1Z2owUDNFWWppaGlSRDh5UT…
Meeting ID: 999 4846 2765
Passcode: 196117
One tap mobile
+12532158782,,99948462765# US (Tacoma)
+13462487799,,99948462765# US (Houston)
Dial by your location
+1 253 215 8782 US (Tacoma)
+1 346 248 7799 US (Houston)
+1 669 900 9128 US (San Jose)
+1 301 715 8592 US (Washington DC)
+1 312 626 6799 US (Chicago)
+1 646 558 8656 US (New York)
888 788 0099 US Toll-free
877 853 5247 US Toll-free
Meeting ID: 999 4846 2765
Find your local number: https://linaro-org.zoom.us/u/anpWWkRdt
I need to use mbedtls (bundled with Nordic SDK, and unsure of version) to
do some cloud-based functionality (AWS cloud, using OpenAM with a CA chain
containing 4 certs). According to something I read, I need to use a pkcs7
container? If so, it seems that mbedtls does not support pkcs7? I did
hand-copy some code from a PR, but as I was looking through the pkcs7.c, it
seems that it still only supports the CA Root. Is this true?
Is there anyone that can give me a hand in solving what I am attempting to
do?
Thank you
/Loren Rogers
Dear Sir,/Madam
We need to convert the files - root.cer,client1.cer
and client1-key.pem to jks using the tool keystore explorer. For that, the
password for the files are needed.Please provide passwords.We need to
establish connection between java client and mbedtls c server.Kindly
provide help.
Regards
Lekshmi G
Dear Madam/Sir,
We are working on a project which requires IEC 62351 standards.
For that we had developed a TLS server in C language and we had the
requirement of developing a TLS client in Java language. We had used
the *mbedTLS
library for server* and *OpenMUC libraries for client*. But we are getting
exception while certificate exchange phase and all. We had attached the
listed exceptions and errors. Kindly provide necessary support for the
same. Also please confirm whether we can develop above specified
architecture, ie TLS based server in C language and client in Java. If
available please share some sample programs also. Please reply ASAP.
We have debugged the code and the following are the messages we have got in
mbedtls java server and OPENMUC java tls client . During certificate
exchange from client to server (MBEDTLS_SSL_CLIENT_CERTIFICATE case in
server), the function returns a nonzero value and the alert shows in
server is 49 (ie, MBEDTLS_SSL_ALERT_MSG_ACCESS_DENIED). *Please check Fig
1 and Fig 2* for the messages displayed during connection
establishment.Kindly help us to solve the issues.
[image: image.png]
Fig 1- case:MBEDTLS_SSL_CLIENT_CERTIFICATE fails
[image: image.png]
Fig 2-OPENMUC java client error when connecting to mbedtlsserver
ReplyForward
<https://drive.google.com/u/0/settings/storage?hl=en&utm_medium=web&utm_sour…>
<https://www.google.com/intl/en/policies/terms/>
<https://www.google.com/intl/en/policies/privacy/>
<https://www.google.com/gmail/about/policy/>
Hi,
I would like to announce the Mbed TLS Tech Forum, a regular engineering call to discuss topics of interest to the Mbed TLS community.
The call is currently planned to take place every two weeks, alternating between US-friendly and China-friendly times (16:30 and 10:00 UK time), starting on the 25th October at 16:30 BST.
Please reply to the list if you have any agenda topics to raise. As a starting point, we will cover:
Format – check if times & cadence are suitable
TLS 1.3 – high-level update on progress & direction
PSA Cryptoprocessor Driver Interface – code generation for driver dispatch as per https://github.com/ARMmbed/mbedtls/pull/5067
Zoom details below. The call will be recorded and made available on the TF website: https://www.trustedfirmware.org/meetings/
Dave Rodgman
Mbed TLS tech lead
--
Dave Rodgman is inviting you to a scheduled Zoom meeting.
Join Zoom Meeting
https://armltd.zoom.us/j/93259847316?pwd=N0d4Z0o5RXRLKzZFaE1sd044bm14dz09&f…
Meeting ID: 932 5984 7316
Passcode: 991642 One tap mobile
+442034815240,,93259847316#,,,,*991642# United Kingdom
Dial by your location
+44 203 481 5240 United Kingdom
+1 346 248 7799 US (Houston)
+1 408 638 0968 US (San Jose)
+1 646 518 9805 US (New York)
+91 116 480 2722 India
+91 224 879 8012 India
+91 406 480 2722 India
+91 806 480 2722 India
+852 5803 3730 Hong Kong SAR
+46 8 4468 2488 Sweden
+972 3 978 6688 Israel
+353 1 536 9320 Ireland
+36 1 408 8456 Hungary
+33 1 7037 2246 France
+358 3 4109 2129 Finland
+45 32 70 12 06 Denmark
+1 438 809 7799 Canada
+65 3158 7288 Singapore
+27 87 550 3946 South Africa
+32 1579 5132 Belgium
+48 22 307 3488 Poland
+386 1600 3102 Slovenia
+60 3 3099 2229 Malaysia
+886 (2) 7741 7473 Taiwan
Meeting ID: 932 5984 7316
Passcode: 991642 Find your local number: https://armltd.zoom.us/u/adTMafG7oQ
Join by SIP
93259847316(a)zoomcrc.com
Join by H.323
162.255.37.11 (US West)
162.255.36.11 (US East)
115.114.131.7 (India Mumbai)
115.114.115.7 (India Hyderabad)
213.19.144.110 (Amsterdam Netherlands)
213.244.140.110 (Germany)
103.122.166.55 (Australia Sydney)
103.122.167.55 (Australia Melbourne)
209.9.211.110 (Hong Kong SAR)
149.137.40.110 (Singapore)
64.211.144.160 (Brazil)
69.174.57.160 (Canada Toronto)
65.39.152.160 (Canada Vancouver)
207.226.132.110 (Japan Tokyo)
149.137.24.110 (Japan Osaka)
Meeting ID: 932 5984 7316
Passcode: 991642
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
--
Mbed-tls-announce mailing list
Mbed-tls-announce(a)lists.trustedfirmware.org
https://lists.trustedfirmware.org/mailman/listinfo/mbed-tls-announce
I'm hoping to make the switch from libressl to MbedTLS. I'm working
on a Linux from scratch style project. Curl works fine with MbedTLS
and most of the utilities I work with use libcurl. I'm also using
libtomcrypt for some of its hash and cryptographic functionality. The
only place I'm having a problem making the switch at present is when I
follow the LFS logic to make certificates (make-ca). There's a
openssl/libressl command in the script that looks like the following:
openssl x509 -hash -noout -in "$1"
Is there a way to replace this functionality with a command or
procedure or function from another program so that libressl or openssl
isn't needed to perform this step?
Thanks.
Hello,
I'm using mbedTLS on baremetal lwip+stm32f4 system as a Server. TLS working
successfully with the TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 but when I
receive the Client Hello message than my receive proccess function in
ethernetif_input: err = netif->input(p, netif); takes 300ms time. This
function normaly takes 1ms. I need to reduce this time. How Can I do that ?
This is my config file: https://paste.ofcode.org/Bdt4FapskKY7M5ggm3uViJ
Best Regards.
--
Embeded System Engineer
Dear Madam/Sir
We need to establish connection with security between
MMS client application in java(OPENMUC java client) and MMS server
(tls_server_example
in mbedtls).The java client application uses keystore.jks and
truststore.jks (*jks format* ) instead of certificate in *cer *format.Is it
possible to establish connection between OPENMUC java mms client and
libiec61850 1.5 with mbedtls-2.16.6* ?* . We have added the *root.cer
details *(certificate in the sample mbedtls server program ) to
* truststore.jks* in client (openmuc java) and *client1.cer details*
(client1 certificate in the sample mbedtls server program ) *to
keystore.jks* .When trying to establish connection server hello messages
are completed ,but showing the following error:
*MBEDTLS_ERR_SSL_NO_CLIENT_CERTIFICATE.*
* Please help...*
*Regards*
*Lekshmi G*
Hi Roman,
My understanding is that you would like to add features to the Crypto
service API, but the features which you would like to add are not
cryptographic in nature.
Have you considered creating your own service for those features, instead of
modifying the Crypto service? Or is there anything makes this not a viable
option?
If you are thinking about adding hardware acceleration for some Crypto
features, that's indeed covered in Shebu's link.
Greetings,
Fabian Schmidt
From: TF-M <tf-m-bounces(a)lists.trustedfirmware.org> On Behalf Of Shebu
Varghese Kuriakose via TF-M
Sent: Dienstag, 12. Oktober 2021 11:46
To: David Hu <David.Hu(a)arm.com>; Roman.Mazurak(a)infineon.com;
tf-m(a)lists.trustedfirmware.org; mbed-tls(a)lists.trustedfirmware.org
Cc: nd <nd(a)arm.com>
Subject: [EXT] Re: [TF-M] Adding platform specific functions to Crypto
Service.
Caution: EXT Email
Hi Roman,
I also might not have understood the question completely.
As you mention crypto HAL API, here is the specification which defines a
standardized mechanism for PSA Crypto implementations to interface with
Secure elements and crypto accelerators -
https://github.com/ARMmbed/mbedtls/blob/development/docs/proposed/psa-driver
-interface.md
<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.co
m%2FARMmbed%2Fmbedtls%2Fblob%2Fdevelopment%2Fdocs%2Fproposed%2Fpsa-driver-in
terface.md&data=04%7C01%7Cfabian.schmidt%40nxp.com%7C17489158b6384ef5caa308d
98d654ead%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637696288543072051%7C
Unknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLC
JXVCI6Mn0%3D%7C1000&sdata=uKX4sUH37jNx1%2BvACuN8tBQl05OaXPPnMT9FqMwbhdU%3D&r
eserved=0>
Also adding mbed-tls mailing list as the thread is crypto related..
Regards,
Shebu
From: TF-M <tf-m-bounces(a)lists.trustedfirmware.org
<mailto:tf-m-bounces@lists.trustedfirmware.org> > On Behalf Of David Hu via
TF-M
Sent: Tuesday, October 12, 2021 4:18 AM
To: Roman.Mazurak(a)infineon.com <mailto:Roman.Mazurak@infineon.com> ;
tf-m(a)lists.trustedfirmware.org <mailto:tf-m@lists.trustedfirmware.org>
Cc: nd <nd(a)arm.com <mailto:nd@arm.com> >
Subject: Re: [TF-M] Adding platform specific functions to Crypto Service.
Hi Roman,
Are you asking about adding platform specific HAL API to implement PSA
Crypto API function?
Please correct me if I misunderstand your question.
Best regards,
Hu Ziji
From: TF-M <tf-m-bounces(a)lists.trustedfirmware.org
<mailto:tf-m-bounces@lists.trustedfirmware.org> > On Behalf Of Roman Mazurak
via TF-M
Sent: Monday, October 11, 2021 9:45 PM
To: tf-m(a)lists.trustedfirmware.org <mailto:tf-m@lists.trustedfirmware.org>
Subject: [TF-M] Adding platform specific functions to Crypto Service.
Hi all,
We would like to add a number of platform specific functions to Crypto
Service API. Is it ok if such functions will not be related to cryptographic
service, but such approach allows us to optimize platform design? Is there
any initiative to create a Crypto Service HAL API to extend Crypto with
custom functions?
Best regards,
Roman.
Hi Roman,
I also might not have understood the question completely.
As you mention crypto HAL API, here is the specification which defines a standardized mechanism for PSA Crypto implementations to interface with Secure elements and crypto accelerators - https://github.com/ARMmbed/mbedtls/blob/development/docs/proposed/psa-drive…
Also adding mbed-tls mailing list as the thread is crypto related..
Regards,
Shebu
From: TF-M <tf-m-bounces(a)lists.trustedfirmware.org> On Behalf Of David Hu via TF-M
Sent: Tuesday, October 12, 2021 4:18 AM
To: Roman.Mazurak(a)infineon.com; tf-m(a)lists.trustedfirmware.org
Cc: nd <nd(a)arm.com>
Subject: Re: [TF-M] Adding platform specific functions to Crypto Service.
Hi Roman,
Are you asking about adding platform specific HAL API to implement PSA Crypto API function?
Please correct me if I misunderstand your question.
Best regards,
Hu Ziji
From: TF-M <tf-m-bounces(a)lists.trustedfirmware.org<mailto:tf-m-bounces@lists.trustedfirmware.org>> On Behalf Of Roman Mazurak via TF-M
Sent: Monday, October 11, 2021 9:45 PM
To: tf-m(a)lists.trustedfirmware.org<mailto:tf-m@lists.trustedfirmware.org>
Subject: [TF-M] Adding platform specific functions to Crypto Service.
Hi all,
We would like to add a number of platform specific functions to Crypto Service API. Is it ok if such functions will not be related to cryptographic service, but such approach allows us to optimize platform design? Is there any initiative to create a Crypto Service HAL API to extend Crypto with custom functions?
Best regards,
Roman.
Hello,
I am using this example for the source of the my main purpose :
https://github.com/straight-coding/LPC407x-NoOS-LWIP-MBEDTLS-HTTPD-KEIL/blo…
This example using https but I'm trying to use this example on Modbus
Server.
This is init function for the server tcp connections:
BOOL
xMBTCPPortInit( USHORT usTCPPort )
{
struct altcp_pcb *pxPCBListenNew, *pxPCBListenOld;
BOOL bOkay = (BOOL)FALSE;
USHORT usPort;
extern struct altcp_tls_config* getTlsConfig(void);
tls_config = getTlsConfig();
mbedtls_ssl_conf_dbg(tls_config, my_debug, NULL);
mbedtls_debug_set_threshold(5);
if( usTCPPort == 0 )
{
usPort = MB_TCP_DEFAULT_PORT;
}
else
{
usPort = ( USHORT ) usTCPPort;
}
if( ( pxPCBListenNew = pxPCBListenOld = altcp_tls_new(
tls_config,IPADDR_TYPE_ANY) ) == NULL )
{
/* Can't create TCP socket. */
bOkay = (BOOL)FALSE;
}
else
if( altcp_bind( pxPCBListenNew, IP_ANY_TYPE, ( u16_t ) usPort ) !=
ERR_OK )
{
/* Bind failed - Maybe illegal port value or in use. */
( void )altcp_close( pxPCBListenOld );
bOkay = (BOOL)FALSE;
}
else if( ( pxPCBListenNew = altcp_listen( pxPCBListenNew ) ) == NULL )
{
( void )altcp_close( pxPCBListenOld );
bOkay = (BOOL)FALSE;
}
else
{
// altcp_tls_new(pxPCBListenNew, IP_GET_TYPE(ip_addr))*/;
/* Register callback function for new clients. */
altcp_accept( pxPCBListenNew, prvxMBTCPPortAccept );
/* Everything okay. Set global variable. */
pxPCBListen = pxPCBListenNew;
#ifdef MB_TCP_DEBUG
vMBPortLog( MB_LOG_DEBUG, "MBTCP-ACCEPT", "Protocol stack
ready.\r\n" );
#endif
SerialPrint("MBTCTP-ACCEPT");
}
bOkay = (BOOL)TRUE;
return bOkay;
}
struct altcp_tls_config* getTlsConfig(void)
{
struct altcp_tls_config* conf;
size_t privkey_len = strlen(privkey) + 1;
size_t privkey_pass_len = strlen(privkey_pass) + 1;
size_t cert_len = strlen(cert) + 1;
conf = altcp_tls_create_config_server_privkey_cert((u8_t*)privkey,
privkey_len, (u8_t*)privkey_pass, privkey_pass_len, (u8_t*)cert, cert_len);
return conf;
}
And I am using basic python tls client example to show successful mbedtls
handshake.
This is my client.py codes:
import time
from socket import create_connection
from ssl import SSLContext, PROTOCOL_TLS_CLIENT
import ssl
hostname='example.org'
ip = '192.168.1.2'
port = 502
context = SSLContext(PROTOCOL_TLS_CLIENT)
context.options |= ssl.OP_NO_SSLv3
context.options |= ssl.OP_NO_TLSv1
context.options |= ssl.OP_NO_TLSv1_1
context.load_verify_locations('cert.pem')
with create_connection((ip, port)) as client:
with context.wrap_socket(client, server_hostname=hostname) as tls:
print(f'Using {tls.version()}\n')
tls.sendall(b'Hello world')
data = tls.recv(1024)
print(f'Server says: {data}')
When I try to start communication I get below outputs on wireshark:
[image: image.png]
When the server send hello message I've this error on the line:
[image: image.png]
When I checked the low_level_output functions I get sending data bytes 150
byte but Ipv4 length shows us 576 byte, opt.h file set as default but if I
changed TCP_MSS as a 250 byte so I can send 136 byte and Ipv4 packet
lenght shows me 136. But does not make sense. I couldnt do successful
handshaking.
My mbedtls debug outputs in this link
https://paste.ofcode.org/PP3zFmrLcKqPdRMT3LzETz How cna I solve this
problem ? What is the reason for the lenght problem ?
Best Regards.
--
Embeded System Engineer
Hello,
I am very sorry about last email by mistakes. I have some questions about multiplication on ecp curves.
I add an ecp curve parameter in ecp_curve.c form SM2 algorithm standard, and the parameter is as follow:
Then I followed the loading method of secp256r1 to load, but I don’t know how to perform fast calculations, so I commented NIST_MODP( p256 ).
#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED)
caseMBEDTLS_ECP_DP_SECP256R1:
NIST_MODP( p256 );
return( LOAD_GROUP( secp256r1 ) );
#endif
#if defined(MBEDTLS_ECP_DP_SM256_ENABLED)
caseMBEDTLS_ECP_DP_SM256:
//NIST_MODP( p256 );
return( LOAD_GROUP_A( sm256 ) );
#endif
Then I call the functional interface mbedtls_ecp_mul to perform the multiplication operation, but the heap memory keeps increasing .
voidtest()
{
intret;
mbedtls_mpiUd;
mbedtls_ecp_groupgrp;
mbedtls_ecp_pointT_Q;
mbedtls_mpi_init(&Ud);
mbedtls_ecp_group_init( &grp );
mbedtls_ecp_point_init( &T_Q );
ret=mbedtls_mpi_read_binary(&Ud, arrUd, sizeof(arr_U_d));
// ret = mbedtls_ecp_group_load(&grp,MBEDTLS_ECP_DP_SECP256R1);
ret=mbedtls_ecp_group_load(&grp,MBEDTLS_ECP_DP_SM256);
ret=mbedtls_ecp_mul(&grp, &T_Q, &Ud, &(grp.G), NULL, NULL) ;
printf("%x\n", -ret);
mbedtls_mpi_free(&Ud);
mbedtls_ecp_group_free( &grp );
mbedtls_ecp_point_free( &T_Q );
}
intmain()
{
for(inti=0; i<10; i++)
test();
return0;
}
The heap memory is mesaured by massif( valgring tools),
Can someone tell me what this is because of and how to fix this problem ?
Best Regards.
Shudong Zhang