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

Merge psa api branch into development #212

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
383 commits
Select commit Hold shift + click to select a range
dd835cb
Add a few tests for persistent attributes
gilles-peskine-arm May 15, 2019
98dd779
Put handle parameter last: psa_generate_derived_key
gilles-peskine-arm May 15, 2019
806051f
Update an obsolete use of psa_import_key in documentation
gilles-peskine-arm May 15, 2019
73676cb
Put handle parameter last: psa_import_key
gilles-peskine-arm May 15, 2019
049c753
Split long lines after psa_import_key refactoring
gilles-peskine-arm May 15, 2019
6c95144
New macro to get the bit size of an elliptic curve
gilles-peskine-arm May 13, 2019
c9d910b
EC key pair import: check the buffer size
gilles-peskine-arm May 13, 2019
e2f62ba
Fix unused variable in builds without storage
gilles-peskine-arm May 15, 2019
beb0cc2
Merge pull request #111 from gilles-peskine-arm/psa-handle-param-order
Patater May 16, 2019
826e326
Merge pull request #107 from gilles-peskine-arm/psa-curve_size_macro
Patater May 16, 2019
76be7f9
Merge pull request #108 from gilles-peskine-arm/psa-copy_key-policy
Patater May 16, 2019
16ab391
Merge pull request #102 from gilles-peskine-arm/psa-aead_multipart-delay
Patater May 16, 2019
280948a
Fix copypasta in the documentation of PSA_KEY_ID_xxx_{MIN,MAX}
gilles-peskine-arm May 16, 2019
f1b7694
Minor documentation improvements
gilles-peskine-arm May 16, 2019
99e8d26
Merge pull request #104 from gilles-peskine-arm/psa-global_key_id
Patater May 16, 2019
d35249e
Merge pull request #109 from gilles-peskine-arm/psa-key_attributes-se…
Patater May 16, 2019
a99d3fb
Rename generator functions to psa_key_derivation_xxx
gilles-peskine-arm May 16, 2019
03410b5
Rename PSA_KDF_STEP_xxx -> PSA_KEY_DERIVATION_INPUT_xxx
gilles-peskine-arm May 16, 2019
cbe6650
Rename generator-related internal identifiers
gilles-peskine-arm May 16, 2019
35675b6
Terminology: say "key derivation operation", not "generator"
gilles-peskine-arm May 16, 2019
51ae0e4
Rename "generator" to "operation"
gilles-peskine-arm May 16, 2019
cf7292e
Wrap and reindent some lines
gilles-peskine-arm May 16, 2019
1cb9a08
Reorder key derivation functions in the header file
gilles-peskine-arm May 16, 2019
be697d8
Shorten the name of psa_key_agreement_raw_shared_secret
gilles-peskine-arm May 16, 2019
58fe9e8
Correct the description of psa_raw_key_agreement
gilles-peskine-arm May 16, 2019
eef988f
Merge pull request #113 from gilles-peskine-arm/psa-generator_to_deri…
Patater May 16, 2019
24f10f8
Remove domain parameters from the official API
gilles-peskine-arm May 16, 2019
dcaefae
Parametrize Diffie-Hellman keys by a group identifier
gilles-peskine-arm May 16, 2019
e38ab1a
Move DSA definitions out of the specification
gilles-peskine-arm May 16, 2019
a130219
Move remaining text about DSA out of the specification
gilles-peskine-arm May 16, 2019
20a77ae
RSA key generation: require e=65537
gilles-peskine-arm May 16, 2019
27a983d
Grammar fix
gilles-peskine-arm May 16, 2019
4b3eb69
Rename PSA_ERROR_TAMPERING_DETECTED to ..._CORRUPTION_DETECTED
gilles-peskine-arm May 16, 2019
67e1c7a
Remove remaining mentions of slots
May 14, 2019
d56456c
Improve descriptions that mention handles and fix incorrect mention o…
May 15, 2019
52d83da
Mention psa_close_key in the description of psa_open_key
May 15, 2019
0a695bd
Simplify description of psa_copy_key
May 15, 2019
683898c
Merge pull request #112 from gilles-peskine-arm/psa-remove_domain_par…
Patater May 17, 2019
c93b80c
Rename *KEYPAIR* to *KEY_PAIR*
gilles-peskine-arm May 16, 2019
35ef36b
Rename psa_generate_random_key back to psa_generate_key
gilles-peskine-arm May 16, 2019
1d8f3b5
Merge pull request #114 from gilles-peskine-arm/psa-keypair-to-key_pair
Patater May 17, 2019
eff4942
Merge pull request #268 from ARMmbed/psa-error_tampering_detected
gilles-peskine-arm May 17, 2019
fba7539
Merge pull request #269 from ARMmbed/psa-slots_to_handles
Patater May 17, 2019
a0c0655
Add missing declarations to the API document
gilles-peskine-arm May 21, 2019
d7d43b9
Convert code samples to the new attribute-based key creation API
gilles-peskine-arm May 21, 2019
4754cde
Improve description of psa_open_key()
gilles-peskine-arm May 21, 2019
6c6195d
Remove implementation comment from API specification
gilles-peskine-arm May 21, 2019
2cb9e39
Convert TLS1.2 KDF descriptions to multistep key derivation
gilles-peskine-arm May 21, 2019
56e2dc8
Use "sufficient buffer size" in buffer size macros
gilles-peskine-arm May 21, 2019
737c6be
Fix grammar
gilles-peskine-arm May 21, 2019
a741d39
State that all error codes are negative
gilles-peskine-arm May 21, 2019
5b93990
Merge pull request #119 from gilles-peskine-arm/psa-api-1.0-beta-beta…
Patater May 21, 2019
6a21123
Remove obsolete mentions of PSA_ERROR_EMPTY_SLOT
gilles-peskine-arm May 21, 2019
a9b9cf7
Document macros that are referenced
gilles-peskine-arm May 21, 2019
4719db3
Merge pull request #121 from gilles-peskine-arm/psa-api-1.0-beta-beta…
Patater May 21, 2019
1ecf92c
Align test functions to usage/alg parameter order
gilles-peskine-arm May 24, 2019
d3bb7bb
Persistent key reload: test more metadata
gilles-peskine-arm May 13, 2019
96f0b3b
Keys may allow a second algorithm
gilles-peskine-arm May 10, 2019
f25c9ec
Minor documentation improvements
gilles-peskine-arm May 22, 2019
183442c
Enrollment algorithm in policy: test persistent keys
gilles-peskine-arm May 13, 2019
110aff4
Enrollment algorithm in policy: implement persistent keys
gilles-peskine-arm May 13, 2019
b4e0cda
Enrollment algorithm in policy: update persistent key tests
gilles-peskine-arm May 14, 2019
bcdd44b
Enrollment algorithm in policy: add support in psa_copy_key tests
gilles-peskine-arm May 20, 2019
3027ba6
Enrollment algorithm in policy: add tests of psa_copy_key
gilles-peskine-arm May 20, 2019
6562dd3
Merge pull request #128 from gilles-peskine-arm/psa-policy_alg2-api
gilles-peskine-arm May 29, 2019
2938268
Merge remote-tracking branch 'upstream-crypto/development' into psa-a…
gilles-peskine-arm May 29, 2019
6f3c30e
Merge follow-up: remove unused code from the development branch
gilles-peskine-arm May 27, 2019
0bbad74
Switch script to Python3
gilles-peskine-arm May 27, 2019
9d4d750
Add a bit of documentation
gilles-peskine-arm May 27, 2019
42a0a0a
Obey Python naming and method structure conventions
gilles-peskine-arm May 27, 2019
54f5445
Pacify Pylint
gilles-peskine-arm May 27, 2019
a3b93ff
Make docstring style consistent
gilles-peskine-arm Jun 3, 2019
c143b31
Merge pull request #130 from gilles-peskine-arm/psa-api-1.0-beta-merg…
gilles-peskine-arm Jun 5, 2019
5163a92
Remove spurious obsolete function call
gilles-peskine-arm May 27, 2019
baea7aa
Convert remaining obsolete function call
gilles-peskine-arm May 27, 2019
f46f81c
Remove obsolete key creation functions
gilles-peskine-arm May 27, 2019
d2d45c1
Convert cipher and pk to PSA attribute-based key creation
gilles-peskine-arm May 27, 2019
1139249
Don't refer to PSA keys as slots anymore
gilles-peskine-arm May 27, 2019
267c656
Simplify key slot allocation
gilles-peskine-arm May 27, 2019
70e085a
Simplify psa_open_key
gilles-peskine-arm May 27, 2019
bfcae2e
Improve documentation of psa_internal_allocate_key_slot
gilles-peskine-arm Jun 5, 2019
894b424
Merge pull request #131 from gilles-peskine-arm/psa-remove_half_fille…
Patater Jun 5, 2019
952f409
Create PSA-specific helper function file
gilles-peskine-arm May 23, 2019
4bac9a4
New function to get key slot statistics
gilles-peskine-arm May 23, 2019
a6d252a
New macro PSA_DONE for a clean PSA shutdown
gilles-peskine-arm May 23, 2019
1153e7b
Replace all calls to mbedtls_psa_crypto_free by PSA_DONE
gilles-peskine-arm May 28, 2019
76b29a7
Close or destroy keys explicitly in tests
gilles-peskine-arm May 28, 2019
dd413d3
Test shutdown without closing handles
gilles-peskine-arm May 28, 2019
982fe79
Remove unused functions
gilles-peskine-arm Jun 19, 2019
1838e82
Rename psa_helpers.function to psa_crypto_helpers.h
gilles-peskine-arm Jun 20, 2019
3cff768
Move the one non-crypto-specific PSA helper macro to a new header
gilles-peskine-arm Jun 20, 2019
1d10257
Copy the new header files to Mbed OS on-target test directories
gilles-peskine-arm Jun 20, 2019
e6d5781
Merge pull request #132 from gilles-peskine-arm/mbedtls-stats-api
gilles-peskine-arm Jun 24, 2019
b6cadea
Secure element driver structure
gilles-peskine-arm Jun 24, 2019
d910e92
Declare a function to register a secure element driver
gilles-peskine-arm Jun 24, 2019
2c2243d
Smoke test for secure element driver registration
gilles-peskine-arm Jun 24, 2019
a899a72
Implement the secure element driver registration function
gilles-peskine-arm Jun 24, 2019
d089021
Unregister drivers on library deinitialization
gilles-peskine-arm Jun 24, 2019
55a6acf
Add negative tests for driver registration
gilles-peskine-arm Jun 24, 2019
45a8ca3
Fix typos in function argument names
gilles-peskine-arm Jun 24, 2019
7a52464
Driver registration: more future-proof bad-version test
gilles-peskine-arm Jun 24, 2019
8f2a6dc
Support PSA_KEY_DERIVATION_INPUT_SEED
gilles-peskine-arm May 29, 2019
ed87d31
Specify the order of inputs for TLS-1.2 KDFs
gilles-peskine-arm May 29, 2019
71a4c91
Add flag for removing deprecated API
yanesca Jun 11, 2019
999f648
Add new psa_tls12_prf_key_derivation_t
yanesca Jun 11, 2019
6a1d262
Adapt psa_key_derivation_abort to the new context
yanesca Jun 11, 2019
b03233e
Add stubs for psa_tls12_prf_input
yanesca Jun 11, 2019
af3c2a0
Add a test for psa_key_derivation_input
yanesca Jun 12, 2019
99dd6ac
Add test cases for derive_input
yanesca Jun 12, 2019
4b7effd
Add more tests for TLS 1.2 PRF input
yanesca Jun 12, 2019
b80a94e
Rename psa_key_derivation_input_raw
yanesca Jun 12, 2019
ef83f5e
Move raw key derivation input to a new function
yanesca Jun 12, 2019
f08e265
Add seed input for psa_tls12_prf_input
yanesca Jun 13, 2019
8155054
Add key import for psa_tls12_prf_input
yanesca Jun 13, 2019
63028dd
Add label input for psa_tls12_prf_input
yanesca Jun 13, 2019
ba3fab9
Adapt derive_key_policy test to the new API
yanesca Jun 11, 2019
16de4a4
Adapt the derive_setup tests to the new API
yanesca Jun 13, 2019
a27c927
Add test for psa_key_derivation_set_capacity
yanesca Jun 14, 2019
adbec81
Remove the deprecated PSA_ALG_SELECT_RAW option
yanesca Jun 14, 2019
c562151
Simplify psa_key_derivation_input_bytes
yanesca Jun 14, 2019
51f4a0f
Style: enforce 80 column limit
yanesca Jun 14, 2019
6660f0e
Add TLS 1.2 PSK master secret generation
yanesca Jun 17, 2019
1468da7
Convert derive_output to the new KDF API
gilles-peskine-arm May 29, 2019
6c6c8fc
Improve style
yanesca Jun 17, 2019
7742fee
Add stub for new tls12_prf_generate_next_block
yanesca Jun 17, 2019
844eb0e
Add tls12_prf_read for the new API
yanesca Jun 19, 2019
ea29bfb
Add tls12_prf key derivation to the new API
yanesca Jun 19, 2019
5fe1973
Make key derivation initialisation consistent
yanesca Jun 20, 2019
30090bc
Fix error code
yanesca Jun 25, 2019
083036a
Safely erase key material upon abort
yanesca Jun 11, 2019
e3e8166
Move PSA_PRE_1_0_KEY_DERIVATION to crypto_struct.h
yanesca Jun 11, 2019
c93a43b
Improve documentation
gilles-peskine-arm Jun 26, 2019
76c3984
Clarify TLS PRF algorithm description
yanesca Jun 26, 2019
40e1393
Optimize TLS PRF PSK key calculation
yanesca Jun 26, 2019
a8ade16
Gate secure element support by a separate config option
gilles-peskine-arm Jun 26, 2019
9717d10
Explain that lifetime=0 from static initialization means VOLATILE
gilles-peskine-arm Jun 26, 2019
6514479
Fix typo in invalid-lifetime test and add explicit test for 0
gilles-peskine-arm Jun 26, 2019
0c1ed84
Improve style
yanesca Jun 28, 2019
14fde3f
Merge pull request #155 from gilles-peskine-arm/psa-se_driver-registr…
Patater Jul 2, 2019
d6dce9f
Fix zero-length seed or label in TLS 1.2 PRF
yanesca Jul 4, 2019
c19dceb
Merge pull request #154 from yanesca/iotcrypt-789-update-tls-prf-to-m…
Patater Jul 4, 2019
7607cd6
Convert exercise_key_derivation_key to the new KDF API
gilles-peskine-arm May 29, 2019
46d9fbc
Add test cases for exercise_key_derivation_key
yanesca Jul 2, 2019
47f27ed
Convert derive_full test to the new KDF API
yanesca Jun 25, 2019
e7e4706
Add derive_full test cases for TLS 1.2 PRF
yanesca Jun 25, 2019
f2815ea
Refactor key derivation setup in tests
yanesca Jul 3, 2019
e60c905
Convert derive_key_exercise to the new KDF API
yanesca Jul 3, 2019
8d98a1e
Add derive_key_exercise test cases for TLS 1.2 PRF
yanesca Jul 3, 2019
42fd888
Convert derive_key_export to the new KDF API
yanesca Jul 3, 2019
5ab0e0b
Add derive_key_export test cases for TLS 1.2 PRF
yanesca Jul 3, 2019
d958bb7
Convert invalid_key_derivation_state to new API
yanesca Jul 3, 2019
343067e
Add invalid_key_derivation test cases for TLS PRF
yanesca Jul 3, 2019
4e2cc53
Update key_ladder_demo to the current key derivation API
gilles-peskine-arm May 29, 2019
2a38e24
Slightly simplify derive_wrapping_key
gilles-peskine-arm May 29, 2019
93fe3a1
Merge pull request #160 from yanesca/iotcrypt-790-update-tests-to-mul…
Patater Jul 4, 2019
fd2aed4
Document cipher modes
adrianlshaw Jul 11, 2019
2282cfa
Remove GMAC algorithm (for now)
adrianlshaw Jul 11, 2019
1168ef9
Merge pull request #167 from adrianlshaw/document_algorithms2
gilles-peskine-arm Jul 12, 2019
e62b74e
Add public-key export method
gilles-peskine-arm Jun 25, 2019
f989dbe
SE driver lookup functions
gilles-peskine-arm Jun 26, 2019
6e59c42
Split the secure element driver method table memory layout
gilles-peskine-arm Jun 26, 2019
011e428
Look up the SE driver when creating a key
gilles-peskine-arm Jun 26, 2019
f03143a
Change driver key slot numbers to 64 bits
gilles-peskine-arm Jul 12, 2019
7a86da1
Define a driver context structure type
gilles-peskine-arm Jul 12, 2019
8597bc1
Pass the driver context to most driver methods
gilles-peskine-arm Jul 12, 2019
f2223c8
New driver method: allocate
gilles-peskine-arm Jul 12, 2019
94cc42c
Pass a writable pointer to the persistent data when needed
gilles-peskine-arm Jul 12, 2019
5243a20
Driver context manipulation functions
gilles-peskine-arm Jul 12, 2019
8abe6a2
Driver table entries are now mutable
gilles-peskine-arm Jul 12, 2019
73167e1
SE keys: store the slot number in the memory slot
gilles-peskine-arm Jul 12, 2019
cbaff46
SE keys: allocate a slot before creating the key
gilles-peskine-arm Jul 12, 2019
354f767
SE keys: support destroy
gilles-peskine-arm Jul 12, 2019
5d30967
SE keys: support import and export
gilles-peskine-arm Jul 12, 2019
5dc742c
SE keys: smoke test import, export, destroy
gilles-peskine-arm Jul 12, 2019
47629d0
Use stdint.h types
athoelke Mar 22, 2019
163639b
Apply same changes to implementation source code
athoelke May 15, 2019
d16bdac
Use stdint.h types in multipart AEAD functions
athoelke May 15, 2019
f82088a
Favor stdint.h types in example code
gilles-peskine-arm Jul 15, 2019
7228da2
Favor stdint.h types in implementation-specific API
gilles-peskine-arm Jul 15, 2019
c11c4dc
Favor stdint.h types in internal types
gilles-peskine-arm Jul 15, 2019
f61bf9c
Merge pull request #170 from gilles-peskine-arm/at-misra-2012
gilles-peskine-arm Jul 15, 2019
c8336cb
Implement a transaction record storage for resilience
gilles-peskine-arm Jul 22, 2019
fc76265
Do secure element key creation and destruction in a transaction
gilles-peskine-arm Jul 22, 2019
6032673
Fix Doxygen reference
gilles-peskine-arm Jul 22, 2019
274a263
Make whitespace consistent
gilles-peskine-arm Jul 23, 2019
bfd322f
Use a key attribute structure in the internal storage interface
gilles-peskine-arm Jul 23, 2019
0e8d495
Add the lifetime to the key storage format
gilles-peskine-arm Jul 23, 2019
1df83d4
SE keys: implement persistent storage
gilles-peskine-arm Jul 23, 2019
8b96cad
SE drivers: implement persistent storage
gilles-peskine-arm Jul 23, 2019
1d04b05
Dear check-names, where you accept struct, also accept union.
gilles-peskine-arm Jul 23, 2019
9dd125d
Fix overly complex Doxygen markup
gilles-peskine-arm Jul 23, 2019
105f67f
Move the definition of psa_key_attributes_t to crypto_types.h
gilles-peskine-arm Jul 23, 2019
831ac72
Add transaction file and driver storage; new key file format
gilles-peskine-arm Jul 23, 2019
573bbc1
Error out if a driver tries to store more than ITS can handle
gilles-peskine-arm Jul 23, 2019
28f8f30
SE keys: ensure that functions that lack support properly error out
gilles-peskine-arm Jul 24, 2019
89870eb
Cosmetic improvements in SE driver tests
gilles-peskine-arm Jul 24, 2019
f4ee662
SE keys: error out in key creation function that lack support
gilles-peskine-arm Jul 24, 2019
d1cd766
SE keys: test NOT_SUPPORTED error from generate_key
gilles-peskine-arm Jul 24, 2019
1057366
SE keys: test that no function goes crazy
gilles-peskine-arm Jul 24, 2019
d0e66b0
Turn off secure element support by default
gilles-peskine-arm Jul 24, 2019
f96aefe
Test with secure element support
gilles-peskine-arm Jul 24, 2019
75c126b
Explain some non-obvious parts of the code
gilles-peskine-arm Jul 24, 2019
4b73422
Transaction support: be more future-proof
gilles-peskine-arm Jul 24, 2019
f77a6ac
Fix indentation
gilles-peskine-arm Jul 25, 2019
6a3dd89
Improve alignment in comments
gilles-peskine-arm Jul 25, 2019
adad813
psa_key_slot_is_external exists. Use it.
gilles-peskine-arm Jul 25, 2019
725f22a
Bug fix: save the driver's persistent data in destroy_key
gilles-peskine-arm Jul 25, 2019
60450a4
Improve comments
gilles-peskine-arm Jul 25, 2019
2e0f388
Don't explicitly dereference function pointers
gilles-peskine-arm Jul 25, 2019
0c3ae1f
Improve documentation of SE driver persistent state
gilles-peskine-arm Jul 25, 2019
340b127
psa_destroy_se_key: explain why the error is NOT_PERMITTED
gilles-peskine-arm Jul 25, 2019
4aea103
Bug fix: don't start a transaction for non-SE keys
gilles-peskine-arm Jul 25, 2019
f9bb29e
Add boilerplate to recover a transaction during init
gilles-peskine-arm Jul 25, 2019
2ea06fd
Improve documentation of transaction storage
gilles-peskine-arm Jul 25, 2019
66be51c
If starting a transaction fails, wipe the transaction data
gilles-peskine-arm Jul 25, 2019
adb1c52
Merge pull request #157 from gilles-peskine-arm/psa-se_driver-create_key
gilles-peskine-arm Jul 26, 2019
424f894
SE keys: store the bit size internally (partial implementation)
gilles-peskine-arm Jul 15, 2019
dc5bfe9
SE keys: implement and test psa_get_key_attributes
gilles-peskine-arm Jul 24, 2019
1801740
SE driver: report the bit size on key import
gilles-peskine-arm Jul 24, 2019
e60d1d0
SE keys: save the bit size in storage
gilles-peskine-arm Jul 24, 2019
fc321f1
SE keys: test that the bit size is saved and loaded correctly
gilles-peskine-arm Jul 24, 2019
7e0cff9
Move attribute fields to a substructure
gilles-peskine-arm Jul 30, 2019
c744d99
Limit keys to 65528 bits
gilles-peskine-arm Jul 30, 2019
68cc433
Store key sizes in 16 bits in attributes
gilles-peskine-arm Jul 30, 2019
8e33870
Use psa_core_key_attributes_t in key slots in memory
gilles-peskine-arm Jul 30, 2019
4ed0e6f
Switch storage functions over to psa_core_key_attributes_t
gilles-peskine-arm Jul 30, 2019
2431859
Take advantage of psa_core_key_attributes_t internally: key loading
gilles-peskine-arm Jul 30, 2019
b46bef2
Store the key size in the slot in memory
gilles-peskine-arm Jul 30, 2019
76aa09c
Take advantage of psa_core_key_attributes_t internally #2
gilles-peskine-arm Jul 31, 2019
41e50d2
Remove "allocated" flag from key slots
gilles-peskine-arm Jul 31, 2019
7c227ae
Test key creation with an invalid type (0 and nonzero)
gilles-peskine-arm Jul 31, 2019
6edfa29
Add test function for import with a bad policy
gilles-peskine-arm Jul 31, 2019
3825e14
Fix policy validity check on key creation.
gilles-peskine-arm Jul 31, 2019
1b8594a
More refactoring: consolidate attribute validation
gilles-peskine-arm Jul 31, 2019
72c8c5b
Merge remote-tracking branch 'upstream-crypto/development' into psa-a…
gilles-peskine-arm Jul 31, 2019
8b66389
Adjust secure element code to the new ITS interface
gilles-peskine-arm Jul 31, 2019
8908c5e
Make psa_calculate_key_bits return psa_key_bits_t
gilles-peskine-arm Jul 31, 2019
5386f6b
Fix PSA init/deinit in mbedtls_xxx tests when using PSA
gilles-peskine-arm Aug 1, 2019
640804b
Merge pull request #191 from gilles-peskine-arm/psa-se_driver-key_bits
gilles-peskine-arm Aug 5, 2019
1b9505c
Correct some comments
gilles-peskine-arm Aug 7, 2019
49232e8
Avoid a lowercase letter in a macro name
gilles-peskine-arm Aug 7, 2019
b1f6c5f
Fix copypasta in test data
gilles-peskine-arm Aug 7, 2019
a6b2f60
Fix double free in psa_generate_key when psa_generate_random fails
gilles-peskine-arm Aug 7, 2019
bdc96fd
Add tests to generate more random than MBEDTLS_CTR_DRBG_MAX_REQUEST
gilles-peskine-arm Aug 7, 2019
f181eca
Fix psa_generate_random for >1024 bytes
gilles-peskine-arm Aug 7, 2019
82a5711
Merge pull request #197 from gilles-peskine-arm/psa-refactor-attribut…
gilles-peskine-arm Aug 8, 2019
0c77b0e
Merge pull request #198 from gilles-peskine-arm/psa-api-1.0-beta-merg…
gilles-peskine-arm Aug 8, 2019
8aa7e9b
Merge branch 'psa-api-1.0-beta' into merge-psa-api-branch-into-develo…
yanesca Aug 8, 2019
849b05a
Fix PSA tests
yanesca Aug 9, 2019
1d57a20
Make TODO comments consistent
yanesca Aug 13, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions docs/architecture/mbed-crypto-storage-specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,92 @@ The layout of a key file is:
* key material length (4 bytes)
* key material: output of `psa_export_key`
* Any trailing data is rejected on load.

Mbed Crypto TBD
---------------

Tags: TBD

Released in TBD 2019. <br>
Integrated in Mbed OS TBD.

### Changes introduced in TBD

* The layout of a key file now has a lifetime field before the type field.
* Key files can store references to keys in a secure element. In such key files, the key material contains the slot number.

### File namespace on a PSA platform on TBD

Assumption: ITS provides a 64-bit file identifier namespace. The Crypto service can use arbitrary file identifiers and no other part of the system accesses the same file identifier namespace.

Assumption: the owner identifier is a nonzero value of type `int32_t`.

* Files 0 through 0xfffeffff: unused.
* Files 0xffff0000 through 0xffffffff: reserved for internal use of the crypto library or crypto service. See [non-key files](#non-key-files-on-tbd).
* Files 0x100000000 through 0xffffffffffff: [content](#key-file-format-for-1.0.0) of the [key whose identifier is the file identifier](#key-names-for-1.0.0). The upper 32 bits determine the owner.

### File namespace on ITS as a library on TBD

Assumption: ITS provides a 64-bit file identifier namespace. The entity using the crypto library can use arbitrary file identifiers and no other part of the system accesses the same file identifier namespace.

This is a library integration, so there is no owner. The key file identifier is identical to the key identifier.

* File 0: unused.
* Files 1 through 0xfffeffff: [content](#key-file-format-for-1.0.0) of the [key whose identifier is the file identifier](#key-names-for-1.0.0).
* Files 0xffff0000 through 0xffffffff: reserved for internal use of the crypto library or crypto service. See [non-key files](#non-key-files-on-tbd).
* Files 0x100000000 through 0xffffffffffffffff: unused.

### Non-key files on TBD

File identifiers in the range 0xffff0000 through 0xffffffff are reserved for internal use in Mbed Crypto.

* Files 0xfffffe02 through 0xfffffeff (`PSA_CRYPTO_SE_DRIVER_ITS_UID_BASE + lifetime`): secure element driver storage. The content of the file is the secure element driver's persistent data.
* File 0xffffff52 (`PSA_CRYPTO_ITS_RANDOM_SEED_UID`): [nonvolatile random seed](#nonvolatile-random-seed-file-format-for-1.0.0).
* File 0xffffff54 (`PSA_CRYPTO_ITS_TRANSACTION_UID`): [transaction file](#transaction-file-format-for-tbd).
* Other files are unused and reserved for future use.

### Key file format for TBD

All integers are encoded in little-endian order in 8-bit bytes except where otherwise indicated.

The layout of a key file is:

* magic (8 bytes): `"PSA\0KEY\0"`.
* version (4 bytes): 0.
* lifetime (4 bytes): `psa_key_lifetime_t` value.
* type (4 bytes): `psa_key_type_t` value.
* policy usage flags (4 bytes): `psa_key_usage_t` value.
* policy usage algorithm (4 bytes): `psa_algorithm_t` value.
* policy enrollment algorithm (4 bytes): `psa_algorithm_t` value.
* key material length (4 bytes).
* key material:
* For a transparent key: output of `psa_export_key`.
* For an opaque key (key in a secure element): slot number (8 bytes), in platform endianness.
* Any trailing data is rejected on load.

### Transaction file format for TBD

The transaction file contains data about an ongoing action that cannot be completed atomically. It exists only if there is an ongoing transaction.

All integers are encoded in platform endianness.

All currently existing transactions concern a key in a secure element.

The layout of a transaction file is:

* type (2 bytes): the [transaction type](#transaction-types-on-tbd).
* unused (2 bytes)
* lifetime (4 bytes): `psa_key_lifetime_t` value that corresponds to a key in a secure element.
* slot number (8 bytes): `psa_key_slot_number_t` value. This is the unique designation of the key for the secure element driver.
* key identifier (4 bytes in a library integration, 8 bytes on a PSA platform): the internal representation of the key identifier. On a PSA platform, this encodes the key owner in the same way as [in file identifiers for key files](#file-namespace-on-a-psa-platform-on-tbd)).

#### Transaction types on TBD

* 0x0001: key creation. The following locations may or may not contain data about the key that is being created:
* The slot in the secure element designated by the slot number.
* The file containing the key metadata designated by the key identifier.
* The driver persistent data.
* 0x0002: key destruction. The following locations may or may not still contain data about the key that is being destroyed:
* The slot in the secure element designated by the slot number.
* The file containing the key metadata designated by the key identifier.
* The driver persistent data.
14 changes: 7 additions & 7 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Importing a key and checking key information:
1. Test the information stored in this slot:
```C
int key_slot = 1;
uint8_t *data = "KEYPAIR_KEY_DATA";
uint8_t *data = "KEY_PAIR_KEY_DATA";
size_t data_size;
psa_key_type_t type = PSA_KEY_TYPE_RSA_PUBLIC_KEY;
size_t got_bits;
Expand Down Expand Up @@ -127,7 +127,7 @@ This allows the key in the key slot to be used for RSA signing.
PSA_ALG_RSA_PKCS1V15_SIGN_RAW);
status = psa_set_key_policy(key_slot, &policy);

status = psa_import_key(key_slot, PSA_KEY_TYPE_RSA_KEYPAIR,
status = psa_import_key(key_slot, PSA_KEY_TYPE_RSA_KEY_PAIR,
key, sizeof(key));

/* Sing message using the key */
Expand Down Expand Up @@ -335,7 +335,7 @@ Deriving a new AES-CTR 128-bit encryption key into a given key slot using HKDF w
1. Set up the generator using the `psa_key_derivation` function providing a key slot containing a key that can be used for key derivation and a salt and label (Note: salt and label are optional).
1. Initiate a key policy to for the derived key by calling `psa_key_policy_set_usage()` with `PSA_KEY_USAGE_ENCRYPT` parameter and the algorithm `PSA_ALG_CTR`.
1. Set the key policy to the derived key slot.
1. Import a key from generator into the desired key slot using (`psa_generator_import_key`).
1. Import a key from generator into the desired key slot using (`psa_key_derivation_output_key`).
1. Clean up generator.

At this point the derived key slot holds a new 128-bit AES-CTR encryption key derived from the key, salt and label provided:
Expand All @@ -358,7 +358,7 @@ At this point the derived key slot holds a new 128-bit AES-CTR encryption key de

psa_algorithm_t alg = PSA_ALG_HKDF(PSA_ALG_SHA_256);
psa_key_policy_t policy = PSA_KEY_POLICY_INIT;
psa_crypto_generator_t generator = PSA_CRYPTO_GENERATOR_INIT;
psa_key_derivation_operation_t generator = PSA_KEY_DERIVATION_OPERATION_INIT;
size_t derived_bits = 128;
size_t capacity = PSA_BITS_TO_BYTES(derived_bits);

Expand All @@ -378,10 +378,10 @@ At this point the derived key slot holds a new 128-bit AES-CTR encryption key de

psa_set_key_policy(derived_key, &policy);

psa_generator_import_key(derived_key, PSA_KEY_TYPE_AES, derived_bits, &generator);
psa_key_derivation_output_key(derived_key, PSA_KEY_TYPE_AES, derived_bits, &generator);

/* Clean up generator and key */
psa_generator_abort(&generator);
psa_key_derivation_abort(&generator);
/* as part of clean up you may want to clean up the keys used by calling:
* psa_destroy_key( base_key ); or psa_destroy_key( derived_key ); */
mbedtls_psa_crypto_free();
Expand Down Expand Up @@ -510,7 +510,7 @@ Generate a piece of random 128-bit AES data:
psa_set_key_policy(slot, &policy);

/* Generate a key */
psa_generate_key(slot, PSA_KEY_TYPE_AES, bits, NULL, 0);
psa_generate_key(slot, PSA_KEY_TYPE_AES, bits);

psa_export_key(slot, exported, exported_size, &exported_length)

Expand Down
6 changes: 6 additions & 0 deletions include/mbedtls/check_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,12 @@
#error "MBEDTLS_PSA_CRYPTO_SPM defined, but not all prerequisites"
#endif

#if defined(MBEDTLS_PSA_CRYPTO_SE_C) && \
! ( defined(MBEDTLS_PSA_CRYPTO_C) && \
defined(MBEDTLS_PSA_CRYPTO_STORAGE_C) )
#error "MBEDTLS_PSA_CRYPTO_SE_C defined, but not all prerequisites"
#endif

#if defined(MBEDTLS_PSA_CRYPTO_STORAGE_C) && \
! defined(MBEDTLS_PSA_CRYPTO_C)
#error "MBEDTLS_PSA_CRYPTO_STORAGE_C defined, but not all prerequisites"
Expand Down
13 changes: 6 additions & 7 deletions include/mbedtls/cipher_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,13 @@ typedef enum
MBEDTLS_CIPHER_PSA_KEY_UNSET = 0,
MBEDTLS_CIPHER_PSA_KEY_OWNED, /* Used for PSA-based cipher contexts which */
/* use raw key material internally imported */
/* into a allocated key slot, and which */
/* hence need to destroy that key slot */
/* when they are no longer needed. */
/* as a volatile key, and which hence need */
/* to destroy that key when the context is */
/* freed. */
MBEDTLS_CIPHER_PSA_KEY_NOT_OWNED, /* Used for PSA-based cipher contexts */
/* which use a key from a key slot */
/* provided by the user, and which */
/* hence should not be destroyed when */
/* the context is no longer needed. */
/* which use a key provided by the */
/* user, and which hence will not be */
/* destroyed when the context is freed. */
} mbedtls_cipher_psa_key_ownership;

typedef struct
Expand Down
16 changes: 16 additions & 0 deletions include/mbedtls/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -1746,6 +1746,22 @@
*/
#define MBEDTLS_PSA_CRYPTO_C

/**
* \def MBEDTLS_PSA_CRYPTO_SE_C
*
* Enable secure element support in the Platform Security Architecture
* cryptography API.
*
* \warning This feature is not yet suitable for production. It is provided
* for API evaluation and testing purposes only.
*
* Module: library/psa_crypto_se.c
*
* Requires: MBEDTLS_PSA_CRYPTO_C, MBEDTLS_PSA_CRYPTO_STORAGE_C
*
*/
//#define MBEDTLS_PSA_CRYPTO_SE_C

/**
* \def MBEDTLS_PSA_CRYPTO_STORAGE_C
*
Expand Down
29 changes: 15 additions & 14 deletions include/mbedtls/pk.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void mbedtls_pk_init( mbedtls_pk_context *ctx );
*
* \note For contexts that have been set up with
* mbedtls_pk_setup_opaque(), this does not free the underlying
* key slot and you still need to call psa_destroy_key()
* PSA key and you still need to call psa_destroy_key()
* independently if you want to destroy that key.
*/
void mbedtls_pk_free( mbedtls_pk_context *ctx );
Expand Down Expand Up @@ -259,29 +259,29 @@ int mbedtls_pk_setup( mbedtls_pk_context *ctx, const mbedtls_pk_info_t *info );

#if defined(MBEDTLS_USE_PSA_CRYPTO)
/**
* \brief Initialize a PK context to wrap a PSA key slot.
* \brief Initialize a PK context to wrap a PSA key.
*
* \note This function replaces mbedtls_pk_setup() for contexts
* that wrap a (possibly opaque) PSA key slot instead of
* that wrap a (possibly opaque) PSA key instead of
* storing and manipulating the key material directly.
*
* \param ctx The context to initialize. It must be empty (type NONE).
* \param key The PSA key slot to wrap, which must hold an ECC key pair
* \param key The PSA key to wrap, which must hold an ECC key pair
* (see notes below).
*
* \note The wrapped key slot must remain valid as long as the
* \note The wrapped key must remain valid as long as the
* wrapping PK context is in use, that is at least between
* the point this function is called and the point
* mbedtls_pk_free() is called on this context. The wrapped
* key slot might then be independently used or destroyed.
* key might then be independently used or destroyed.
*
* \note This function is currently only available for ECC key
* pairs (that is, ECC keys containing private key material).
* Support for other key types may be added later.
*
* \return \c 0 on success.
* \return #MBEDTLS_ERR_PK_BAD_INPUT_DATA on invalid input
* (context already used, invalid key slot).
* (context already used, invalid key handle).
* \return #MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE if the key is not an
* ECC key pair.
* \return #MBEDTLS_ERR_PK_ALLOC_FAILED on allocation failure.
Expand Down Expand Up @@ -788,26 +788,27 @@ int mbedtls_pk_load_file( const char *path, unsigned char **buf, size_t *n );

#if defined(MBEDTLS_USE_PSA_CRYPTO)
/**
* \brief Turn an EC key into an Opaque one
* \brief Turn an EC key into an opaque one.
*
* \warning This is a temporary utility function for tests. It might
* change or be removed at any time without notice.
*
* \note Only ECDSA keys are supported so far. Signing with the
* specified hash is the only allowed use of that key.
*
* \param pk Input: the EC key to transfer to a PSA key slot.
* Output: a PK context wrapping that PSA key slot.
* \param slot Output: the chosen slot for storing the key.
* It's the caller's responsibility to destroy that slot
* after calling mbedtls_pk_free() on the PK context.
* \param pk Input: the EC key to import to a PSA key.
* Output: a PK context wrapping that PSA key.
* \param handle Output: a PSA key handle.
* It's the caller's responsibility to call
* psa_destroy_key() on that handle after calling
* mbedtls_pk_free() on the PK context.
* \param hash_alg The hash algorithm to allow for use with that key.
*
* \return \c 0 if successful.
* \return An Mbed TLS error code otherwise.
*/
int mbedtls_pk_wrap_as_opaque( mbedtls_pk_context *pk,
psa_key_handle_t *slot,
psa_key_handle_t *handle,
psa_algorithm_t hash_alg );
#endif /* MBEDTLS_USE_PSA_CRYPTO */

Expand Down
2 changes: 1 addition & 1 deletion include/mbedtls/psa_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ static inline int mbedtls_psa_err_translate_pk( psa_status_t status )
/* All other failures */
case PSA_ERROR_COMMUNICATION_FAILURE:
case PSA_ERROR_HARDWARE_FAILURE:
case PSA_ERROR_TAMPERING_DETECTED:
case PSA_ERROR_CORRUPTION_DETECTED:
return( MBEDTLS_ERR_PK_HW_ACCEL_FAILED );
default: /* We return the same as for the 'other failures',
* but list them separately nonetheless to indicate
Expand Down
Loading