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

Crypto Service - keys access control #9638

Merged
merged 5 commits into from Feb 27, 2019

Conversation

itayzafrir
Copy link
Contributor

@itayzafrir itayzafrir commented Feb 7, 2019

Description

Access control for crypto keys in crypto service.

This is in continuation of PR #9575 which ensured that only the key creator is allowed to open a key & obtain a handle to it.

This PR, validates that the psa_key_handle_t argument (passed in as an input argument to the crypto APIs) is associated with the calling partition, i.e. that the API caller is also the key owner/creator.

Please do not merge or run CI - needs preceding PR #9575

Reviewers, reviews should start from c9130428951d60d865826e431eb400d92223b163, previous commits are from #9575 and are being reviewed there.

Pull request type

[ ] Fix
[ ] Refactor
[ ] Target update
[X] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

Reviewers

@avolinski

@ciarmcom
Copy link
Member

ciarmcom commented Feb 7, 2019

@itayzafrir, thank you for your changes.
@avolinski @ARMmbed/mbed-os-crypto @ARMmbed/mbed-os-maintainers please review.

Copy link
Contributor

@alekshex alekshex left a comment

Choose a reason for hiding this comment

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

part 0.5

@itayzafrir itayzafrir changed the title WIP Crypto Service - keys access control Crypto Service - keys access control Feb 10, 2019
@@ -0,0 +1,5 @@
#ifdef PSA_CRYPTO_SECURE
Copy link
Contributor

Choose a reason for hiding this comment

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

license header files in each file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@0xc0170 these files were introduced in PR #9575, the commits relevant to this PR start from c913042. I've added the license in #9575 (3bc5f90), this branch will be rebased once 9575 goes through.

@cmonr
Copy link
Contributor

cmonr commented Feb 13, 2019

this branch will be rebased once #9575 goes through.

Just leaving a more visible note.

@NirSonnenschein
Copy link
Contributor

@0xc0170 your review comment seems to be fixed, please re-review.
@ARMmbed/mbed-os-crypto - this PR has been opened for a while, please review or comment on why you aren't going to.

@0xc0170 0xc0170 dismissed their stale review February 18, 2019 10:41

Will be rereviewed once rebased

@itayzafrir
Copy link
Contributor Author

@avolinski rebased on master, please take another look

#include "psa_crypto_core.h"
#include "crypto_platform.h"

void psa_crypto_access_control_init(void);
Copy link
Contributor

Choose a reason for hiding this comment

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

these functions should contain documentation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so, this is internal only. These could have been implemented as static functions in psa_crypto_partition.c...

Copy link
Contributor

@0xc0170 0xc0170 Feb 20, 2019

Choose a reason for hiding this comment

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

we could use \internal or using _internal suffix in the header or at least a comment in this header file.

Even internal functions should have documentation, hidden from public (using #if !defined(DOXYGEN_ONLY)). IF you look at some drivers headers like SPI.h

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added in 5ac58b84dfa06f1c6cd76293dd4f01a5511124a0

@itayzafrir
Copy link
Contributor Author

itayzafrir commented Feb 20, 2019

PSA spec suggests abort() should be called

@alzix it's been used like that repeatedly as of cf3fd85

#define PSA_CRYPTO_ACCESS_CONTROL_RESET() (memset(crypto_access_control_arr, 0, sizeof(crypto_access_control_arr)))
static inline void psa_crypto_access_control_reset()
{
memset(crypto_access_control_arr, 0, sizeof(crypto_access_control_arr));
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't it
psa_crypto_access_control_reset();?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The macro was removed in 6475bc65d818fc9ff4fc6c2c02de3d1b7ecde24a in favor of the static inline function.

itayzafrir added 5 commits February 24, 2019 15:07
Implement crypto keys access control in crypto service:
- Only the key owner (the partition which created the key)
  is allowed to manage (import/export/open/close/destroy/etc.)
  the key.
- Only the key owner (the partition which created the key)
  is allowed to use the key handle for crypto operations which
  require a key handle.
This file is for internal use only.
@itayzafrir
Copy link
Contributor Author

Rebased on master

@NirSonnenschein
Copy link
Contributor

@0xc0170 @alzix @ARMmbed/mbed-os-crypto please review/re-review (rebased and comments addressed).

@NirSonnenschein NirSonnenschein removed the request for review from a team February 26, 2019 12:53
@NirSonnenschein
Copy link
Contributor

removing @ARMmbed/mbed-os-crypto as a reviewer. if you would still like to review please do so ASAP

@NirSonnenschein
Copy link
Contributor

@0xc0170 @alzix , please re-review after the rebase

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 27, 2019

Please do not merge or run CI - needs preceding PR #9575

Merged, this should be ready for review and CI

@itayzafrir
Copy link
Contributor Author

Merged, this should be ready for review and CI

Yes this is unblocked now

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 27, 2019

CI started

@mbed-ci
Copy link

mbed-ci commented Feb 27, 2019

Test run: SUCCESS

Summary: 12 of 12 test jobs passed
Build number : 1
Build artifacts

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 27, 2019

@alzix Happy with the latest update? This is ready to land otherwise

@itayzafrir
Copy link
Contributor Author

Not sure about the availability of @alzix, he might be OOO for a while...

@0xc0170 0xc0170 merged commit 7656891 into ARMmbed:master Feb 27, 2019
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

8 participants