Skip to content

Update feature/mbedtls from mbedtls feature-opaque-keys branch #6176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Feb 25, 2018

Conversation

mazimkhan
Copy link

This PR updates branch feature-opaque-keys with mbedtls feature-opaque-keys branch. For demonstrating mbedtls opaque keys feature with mbed-os. Related PR #6104.

@mazimkhan
Copy link
Author

@0xc0170 please add @gilles-peskine-arm and @AndrzejKurek as reviewers to confirm that changes belong to mbedtls/feature-opaque-keys branch.

@ciarmcom
Copy link
Member

ARM Internal Ref: IOTSSL-2106

@gilles-peskine-arm
Copy link

As in #5973, we'll need to update the Mbed TLS code to 2.7.1. Step 1: merge 2.7.1 into the feature branch on the Mbed TLS side (Mbed-TLS/mbedtls#1398).

@mazimkhan
Copy link
Author

@0xc0170 can you please run morph test on it. Please

Copy link

@gilles-peskine-arm gilles-peskine-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a faithful import of the Mbed TLS feature-opaque-keys branch (all files in inc and src are identical except for inc/config.h which is the result of running importer/adjust-config.sh).

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 23, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Feb 23, 2018

Build : FAILURE

Build number : 1232
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/6176/

@mazimkhan
Copy link
Author

mazimkhan commented Feb 23, 2018

@0xc0170 @cmonr Can you please help with reproducing following log:
https://jenkins-internal.mbed.com/job/ARMmbed/job/mbed-os-cliapp/job/master/9494/artifact/mbed-os-cliapp/UBLOX_EVK_ODIN_W2_armcc_eth0_ipv6.log

Here md_wrap.c is calling mbedtls_internal_md5_process and similar functions. But fails to find them. This is not possible normally since config.h has MBEDTLS_MD5_C and other related flags disabled. Seems like md_wrap.c is compiled with MBEDTLS_MD5_C enabled (some other config) and md5.c containing the function is compiled with config.h hence function not present.

We do not understand how above build environment is configured. There is something unusual causing the error.

Link: mbed-os-cliapp
Error: L6218E: Undefined symbol mbedtls_internal_md5_process (referred from .build/UBLOX_EVK_ODIN_W2_armcc_eth0_ipv6/mbed-os/features/mbedtls/src/md_wrap.o).
Error: L6218E: Undefined symbol mbedtls_internal_sha1_process (referred from .build/UBLOX_EVK_ODIN_W2_armcc_eth0_ipv6/mbed-os/features/mbedtls/src/md_wrap.o).
Error: L6218E: Undefined symbol mbedtls_internal_sha256_process (referred from .build/UBLOX_EVK_ODIN_W2_armcc_eth0_ipv6/mbed-os/features/mbedtls/src/md_wrap.o).
Finished: 0 information, 0 warning and 3 error messages.
[ERROR] Error: L6218E: Undefined symbol mbedtls_internal_md5_process (referred from .build/UBLOX_EVK_ODIN_W2_armcc_eth0_ipv6/mbed-os/features/mbedtls/src/md_wrap.o).
Error: L6218E: Undefined symbol mbedtls_internal_sha1_process (referred from .build/UBLOX_EVK_ODIN_W2_armcc_eth0_ipv6/mbed-os/features/mbedtls/src/md_wrap.o).
Error: L6218E: Undefined symbol mbedtls_internal_sha256_process (referred from .build/UBLOX_EVK_ODIN_W2_armcc_eth0_ipv6/mbed-os/features/mbedtls/src/md_wrap.o).
Finished: 0 information, 0 warning and 3 error messages.

@gilles-peskine-arm
Copy link

@mazimkhan I haven't followed everything, but it looks like the problem is caused by a binary that was built against mbedtls compiled with a different configuration.

strings targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_MODULE_UBLOX_ODIN_W2/sdk/TOOLCHAIN_GCC_ARM/libublox-odin-w2-driver.a |less |grep mbedtls_ |sort -u
mbedtls_aes_crypt_ecb
mbedtls_aes_setkey_enc
mbedtls_arc4_crypt
mbedtls_arc4_setup
mbedtls_des_crypt_ecb
mbedtls_des_setkey_enc
mbedtls_md4
mbedtls_md5_finish
mbedtls_md5_starts
mbedtls_md5_update
mbedtls_md_hmac
mbedtls_md_info_from_type
mbedtls_sha1_finish
mbedtls_sha1_starts
mbedtls_sha1_update

Either this binary needs to be rebuilt against the current version of Mbed TLS, with the official Mbed TLS configuration (which doesn't include MD4 (‽), MD5 or SHA-1); or the linker scripts need to be modified so that these symbols aren't exported.

@mazimkhan
Copy link
Author

@gilles-peskine-arm the undefined reference complaint comes from md_wrap.c. How does it make call to one of those functions when mbedtls config have them disabled?

@mazimkhan
Copy link
Author

mazimkhan commented Feb 24, 2018

Ok I see the problem Ublox inherits TARGET_STM. Its header is here https://github.com/ARMmbed/mbed-os/blob/master/features/mbedtls/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F437xG/mbedtls_device.h

This header defines SHAx_ALT but not _PROCESS_ALT. If it has the definition of ````_PROCESS_ALT``` it should also define those macros.

#ifndef MBEDTLS_DEVICE_H
#define MBEDTLS_DEVICE_H

#define MBEDTLS_AES_ALT

#define MBEDTLS_SHA256_ALT

#define MBEDTLS_SHA1_ALT

#define MBEDTLS_MD5_ALT

#endif /* MBEDTLS_DEVICE_H */

@mazimkhan
Copy link
Author

Fixed build issues by

  • Providing wrappers for new _process functions to link using old implementation.
  • Defining _PROCESS_ALT in mbedtls/target/.../mbedtls_device.h

@0xc0170 @cmonr mbedtls imported here is not a true copy of mbedtls/feature-opaque-keys. Some extra commits are for resolving breaking API changes done in mbedtls 2.7.0 on which feature-opaque-keys is based.

This does not impact the purpose of testing opaque keys feature. Please merge it.

Once the API incompatibility issue is fixed, a fresh import of mbedtls can be done.

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 24, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Feb 24, 2018

Build : FAILURE

Build number : 1246
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/6176/

@mazimkhan
Copy link
Author

/morph build

@mbed-ci
Copy link

mbed-ci commented Feb 24, 2018

Build : FAILURE

Build number : 1247
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/6176/

@cmonr
Copy link
Contributor

cmonr commented Feb 24, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Feb 25, 2018

Build : SUCCESS

Build number : 1249
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/6176/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

@mazimkhan
Copy link
Author

AWS-CI uVisor Build & Test — Failed
Failed due to serial issue.

@mbed-ci
Copy link

mbed-ci commented Feb 25, 2018

@mbed-ci
Copy link

mbed-ci commented Feb 25, 2018

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 25, 2018

/morph uvisor-test

@0xc0170 0xc0170 merged commit 2a075bb into ARMmbed:feature-opaque-keys Feb 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants