Skip to content
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

DRAFT: Enable MBEDTLS_FS_IO when this feature can be used #3955

Closed
wants to merge 2 commits into from

Conversation

andresag01
Copy link

@andresag01 andresag01 commented Mar 16, 2017

Description

This patch is the first step towards integrating the mbed TLS NV Seed feature with mbed OS. The change enables the macro MBEDTLS_FS_IO when filesystem support is present in mbed OS. To use NV Seed, users will need to define the macros MBEDTLS_ENTROPY_NV_SEED and MBEDTLS_PLATFORM_STD_NV_SEED_FILE either through the user config file or the mbed_app.json.

NOTE: The entropy seed file will be stored unencrypted in the non-volatile storage.

@RonEld @sbutcher-arm @yanesca: Please review.

Status

IN DEVELOPMENT

Migrations

NO

Related PRs

List related PRs against other branches:

Todos

  • Tests

@0xc0170
Copy link
Contributor

0xc0170 commented Apr 10, 2017

retest uvisor

@theotherjimmy
Copy link
Contributor

@yanesca @sbutcher-arm @RonEld Bump. Could you review?

@0xc0170
Copy link
Contributor

0xc0170 commented Sep 4, 2017

@andresag01 Shall we close this? is this still relevant and we keep it open?

@ciarmcom
Copy link
Member

ciarmcom commented Sep 7, 2017

ARM Internal Ref: IOTSSL-1723

Copy link
Contributor

@RonEld RonEld left a comment

Choose a reason for hiding this comment

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

I approve this, but is this still a draft?

@andresag01
Copy link
Author

andresag01 commented Sep 12, 2017

@RonEld: Thanks for the review! I have marked it as DRAFT because I would like the changes to be reviewed by at least two mbed TLS developers before removing the label.

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 13, 2017

bump, is this still active, and targeting master?

@andresag01
Copy link
Author

@0xc0170: This is still active, we are currently waiting for other mbed TLS team members to take a look (CC @yanesca, @sbutcher-arm)

@adbridge
Copy link
Contributor

@mazimkhan @hanno-arm I think this falls to you two now

"\n" \
"\/*\n" \
" * Only use features that do not require an entropy source when\n" \
" * DEVICE_ENTROPY_SOURCE is not defined in mbed OS.\n" \

Choose a reason for hiding this comment

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

@andresag01 Where is DEVICE_ENTROPY_SOURCE defined? It doesn't occur in the mbed-OS repository (I only found DEVICE_TRNG in relation to entropy). Depending on its definition, it might need to be updated to incorporate the new potential source of entropy from the NV seed.

Copy link
Author

Choose a reason for hiding this comment

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

This is simply an out-of-date comment from PR #2716. I think my original idea was to create a simple macro that would make it easy to tell if an entropy source is available. However, I think this idea was scraped at some point (due to some complications with config/implementation) and unfortunately the comment was not updated.

Note that I did not change this line in the PR other than to align the \ character. I will update the comment before removing the DRAFT label. However, could you please look at the actual code changes for the time being? Thanks!

@@ -21,6 +21,10 @@
#define MBEDTLS_ENTROPY_HARDWARE_ALT
#endif

#if defined(MBED_CONF_FILESYSTEM_PRESENT)

Choose a reason for hiding this comment

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

Where is it documented what this option entails? Does it ensure the presence of FS IO functions that Mbed TLS is using, with the same (standard) signatures?

@hanno-becker
Copy link

Will the use of the NV seed be configured by manually setting MBEDTLS_NV_SEED, or will there be an option DEVICE_NV_SEED like NV_SEED and a line in platform_mbed.h defining MBEDTLS_NV_SEED if DEVICE_NV_SEED is set?

Copy link

@hanno-becker hanno-becker left a comment

Choose a reason for hiding this comment

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

The documentation is outdated and should be adapted. Overall the change looks good, but I'd like to have more confidence that MBED_CONF_FILESYSTEM_PRESENT and MBEDTLS_FS_IO are compatible.

@andresag01
Copy link
Author

@hanno-arm: I do not think that you have been reviewing this PR by taking into account all the background information. Please refer to the internal ticket IOTSSL-1283 that contains information on how this can be used for NV Seed and some security considerations.

@hanno-becker
Copy link

@andresag01 I'll look at that. Please add the reference to the PR description.

@andresag01
Copy link
Author

@hanno-arm: Regarding the correspondence between MBED_CONF_FILESYSTEM_PRESENT and wha. I am not aware of any documentation from mbed OS that describes what MBED_CONF_FILESYSTEM_PRESENT does. I looked into the code in mbed_retarget.h which I believe is the place where some of the libc functions end up being implemented and observed:

#if MBED_CONF_FILESYSTEM_PRESENT
#include "filesystem/FileSystem.h"
#include "filesystem/File.h"
#include "filesystem/Dir.h"
#endif

If you continue looking into that file you will see that for example the file opening code has:

#if MBED_CONF_FILESYSTEM_PRESENT
        } else {
            FileSystem *fs = path.fileSystem();
            if (fs == NULL) {
                /* The filesystem instance managing the namespace under the mount point
                 * has not been found. Free file handle */
                errno = ENOENT;
                filehandles[fh_i] = NULL;
                return -1;
            }
            int posix_mode = openmode_to_posix(openmode);
            File *file = new ManagedFile;
            int err = file->open(fs, path.fileName(), posix_mode);
            if (err < 0) {
                errno = -err;
                delete file;
            } else {
                res = file;
            }
#endif

So I thought that MBED_CONF_FILESYSTEM_PRESENT is probably a superset of whats needed for MBEDTLS_FS_IO. But we could certainly ask for more information...

We enable MBEDTLS_FS_IO whenever MBED_CONF_FILESYSTEM_PRESENT is
defined in mbed OS. It is assumed that MBED_CONF_FILESYSTEM_PRESENT
defines at least the filesystem functionality required by MBEDTLS_FS_IO
The config.h now takes into consideration whether the mbed TLS NV Seed
feature is present to decide which configuration is actually going to
be used.
@adbridge
Copy link
Contributor

@hanno-arm Could you please re-review ?

@cmonr
Copy link
Contributor

cmonr commented Jan 25, 2018

@hanno-arm @andresag01, any progress?

@hanno-becker
Copy link

@adbridge @cmonr Apologies for not getting back to you sooner. I am busy with urgent tasks at the moment but plan to come back to this next week.

@cmonr cmonr requested a review from mazimkhan February 23, 2018 06:40
@cmonr
Copy link
Contributor

cmonr commented Feb 23, 2018

@hanno-arm @RonEld @yanesca @sbutcher-arm Thoughts? This PR has been sitting for a while. I've also added @mazimkhan since this is a TLS-related PR.

@cmonr
Copy link
Contributor

cmonr commented Mar 6, 2018

@hanno-arm @RonEld @yanesca @sbutcher-arm @mazimkhan
Second ping.

@simonbutcher
Copy link
Contributor

@k-stachowiak is looking into this PR, and confirming it's current status.

Based on new requirements we know are coming, we may close this PR and start again, or alternatively build on @andresag01 's existing work.

@0xc0170
Copy link
Contributor

0xc0170 commented Apr 9, 2018

Please reopen with an update if needed, I'll close this one now.

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.

None yet

9 participants