Commit Graph

2447 Commits

Author SHA1 Message Date
Gilles Peskine
f5f442a50c More accurate description of the shared secret for ECDH
Don't refer to the "curve size", call it the "size of the order of the
curve".
2018-11-14 21:17:16 +01:00
Gilles Peskine
211a436f2e Document that key agreement produces a maximum-capacity generator 2018-11-14 21:15:37 +01:00
Gilles Peskine
79dd6229e4 Clarify the format of the (EC)DH shared secret 2018-11-14 21:15:37 +01:00
Gilles Peskine
2607bca666 Give "DH" and "DHM" as alternative names
Be consistent about calling it just "Diffie-Hellman", except once
where I state that "Diffie-Hellman-Merkle" is an alternative name.
2018-11-14 21:15:37 +01:00
Gilles Peskine
01d718cee8 New API function: psa_key_agreement
Set up a generator from a key agreement.
2018-11-14 21:15:37 +01:00
Gilles Peskine
8feb3a886d Support key derivation with non-predefined capacity
psa_key_derivation requires the caller to specify a maximum capacity.
This commit adds a special value that indicates that the maximum
capacity should be the maximum supported by the algorithm. This is
currently meant only for selection algorithms used on the shared
secret produced by a key agreement.
2018-11-14 21:15:37 +01:00
Gilles Peskine
93098fd996 Key agreement: macros for finite-field Diffie-Hellman, ECDH
Declare macros to represent key agreement algorithms.
2018-11-14 21:15:37 +01:00
Gilles Peskine
e8f0e3dc3c New algorithm category: key selection
A key selection algorithm is similar to a key derivation algorithm in
that it takes a secret input and produces a secret output stream.
However, unlike key derivation algorithms, there is no expectation
that the input cannot be reconstructed from the output. Key selection
algorithms are exclusively meant to be used on the output of a key
agreement algorithm to select chunks of the shared secret.
2018-11-14 21:15:37 +01:00
Gilles Peskine
92587dbf2b Write missing bit of the documentation of psa_key_derivation 2018-11-14 21:15:37 +01:00
Gilles Peskine
e19b7d54d0 Revert "New function mbedtls_rsa_get_bitlen"
This reverts commit 1d26709dbd.
2018-11-12 19:14:34 +01:00
Jaeden Amero
40f1cb104f
Merge pull request #182 from ARMmbed/psa-asymmetric-format-raw_private_key
Asymmetric import/export format: raw private EC keys
2018-11-06 09:02:25 +00:00
Gilles Peskine
f7933939b3 Expand the documentation of import/export formats
Clarify that the key type determines the syntax of the input.

Clarify the constraints on implementations that support extra import
formats.
2018-10-31 14:10:07 +01:00
Gilles Peskine
5eb1521957 Private EC key format: update key representation size macro 2018-10-31 14:10:06 +01:00
Gilles Peskine
f76aa7789b Private EC key format: change to raw secret value (doc, import)
Change the import/export format of private elliptic curve keys from
RFC 5915 to the raw secret value. This commit updates the format
specification and the import code, but not the export code.
2018-10-31 14:10:06 +01:00
Derek D. Miller
f015feced9
Some changes from 'pcd_' to 'psa_drv_' were missed
In the comments, some of the changes from `pcd_` to `psa_drv_` omitted the `_drv_` part.
Changed them to be consistent
2018-10-26 10:56:11 -05:00
Jaeden Amero
9411db74c4 psa: driver: Wrap types and symbols for C/C++ use
Add extern "C" wrappers around type and function declarations to enable C++
interoperability of the driver header. This is done so that the driver
functions and types can be used or implmented by C++ code.
2018-10-26 13:39:43 +01:00
Jaeden Amero
20b8a4f2ff psa: driver: Convert struct types to typedefs
Convert PSA Crypto driver model structs to typedefs so that the `struct`
name doesn't need to be used and for consistent style with other PSA
structures.
2018-10-26 13:39:42 +01:00
Jaeden Amero
4155850dd9 psa: driver: Use header guard style consistently
The file crypto_driver.h was not using the header guard style as other PSA
Crypto header files. Remove the `__` prefix and suffix. Use C-style
comments for the end-of-guard comment.
2018-10-26 12:25:05 +01:00
Jaeden Amero
7632f628d7 psa: driver: Prefix "encrypt or decrypt" type
The driver model's "encrypt or decrypt" type, encrypt_or_decrypt_t, is
publicly exposed and needs to have a `psa_` prefix in order to properly
communicate that it is part of the PSA driver model.
2018-10-26 12:25:05 +01:00
Jaeden Amero
1acb2c4317 psa: driver: Replace pcd_ prefix with psa_drv_
The `pcd_` prefix is ambiguous and does not make it clear that the types
and symbols are standardized by PSA. Replace `pcd_` with a prefix that can
be shared with all PSA drivers, `psa_drv_`.
2018-10-26 12:25:05 +01:00
Jaeden Amero
e095d60d95 psa: driver: Use "Driver Model" terminology
"Driver APIs" can be interpreted to mean APIs used when you want to write a
driver, not the set of functions you implement to make a driver. See
https://www.kernel.org/doc/html/latest/driver-api/index.html "The kernel
offers a wide variety of interfaces to support the development of device
drivers."

As such, we are renaming "Driver API" to "Driver Model" and updating our
work so far to reflect this change.
2018-10-26 12:25:05 +01:00
Jaeden Amero
72244ae595 psa: driver: Fix names of AEAD functions
The driver AEAD functions had a `psa_` prefix. They should have had a
`pcd_` prefix like the other driver functions.
2018-10-26 12:12:49 +01:00
Jaeden Amero
0a09f77357 psa: driver: Fix comment whitespace format
Fix comment formatting whitespace issues in crypto_driver.h to match our
style.
2018-10-26 12:12:08 +01:00
Jaeden Amero
d3d26aa6b2 psa: driver: Fix trailing whitespace issues
Remove all trailing whitespace from crypto_driver.h. Ensure there is a new
line at the end of crypto_driver.h.
2018-10-26 12:04:14 +01:00
Jaeden Amero
ec57c5579a
Merge pull request #161 from ARMmbed/driver_api
Added the crypto driver API header file
2018-10-24 16:15:58 +01:00
Derek Miller
6f960ab063 Additional fixes per comments in PR#92 in psa-crypto 2018-10-23 15:58:06 -05:00
Derek Miller
81133a6f76 More changes due to PR feedback 2018-10-23 14:55:32 -05:00
Derek Miller
765682cf09 Added detailed descriptions for modules. Additional small edits. 2018-10-22 15:27:27 -05:00
Derek Miller
f3d0a56841 Integrated mostly cosmetic feedback from Alex 2018-10-18 16:41:08 -05:00
Gilles Peskine
e0e9c7c417 New macro PSA_ALG_FULL_LENGTH_MAC
Provide a documented way of constructing the full-length MAC algorithm
from a truncated version.
2018-10-17 18:30:47 +02:00
Gilles Peskine
6d72ff9e79 Document that the minimum truncated MAC length is implementation-defined 2018-10-17 13:54:47 +02:00
Gilles Peskine
e1f2d7d1ac Document and check the consistency of truncated MAC encodings
Add comments noting that the maximum length of a MAC must fit in
PSA_ALG_MAC_TRUNCATION_MASK. Add a unit test that verifies that the
maximum MAC size fits.
2018-10-17 13:54:47 +02:00
Derek Miller
16e72299cd Changed crypto_driver.h based on PR feedback 2018-10-15 16:14:24 -05:00
Derek Miller
5b3417a3d1 Added the crypto driver API header file 2018-10-10 17:55:03 -05:00
Gilles Peskine
3111981d94 Fix parameter name in Doxygen documentation 2018-10-08 14:45:35 +02:00
Gilles Peskine
70f46e17e8 New macro PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH
Useful to analyze algorithm values.
2018-10-08 14:45:35 +02:00
Gilles Peskine
23cc2ff9a8 Add support for non-default-tag-size AEAD (CCM and GCM) 2018-10-08 14:42:11 +02:00
Gilles Peskine
d911eb7915 Add support for truncated MAC algorithms 2018-10-08 14:42:11 +02:00
Gilles Peskine
159ebf3b8e
Merge pull request #142 from ARMmbed/psa-metadata_validation
Algorithm and key type encoding validation
2018-09-24 10:38:39 +02:00
Jaeden Amero
40363fe3f5
Merge pull request #139 from ARMmbed/psa-PSA_ALG-block_cipher_padding
Correct and simplify block-based cipher modes
2018-09-21 09:38:27 +01:00
Gilles Peskine
3052f53c37 Add block sizes to HMAC metadata validation tests 2018-09-20 12:00:21 +02:00
Gilles Peskine
35fe2034c1 PSA_MAC_FINAL_SIZE: we don't use key_bits at the moment
None of the currently defined MAC algorithms have a MAC size that
depends on the key size, so the key_bits parameter is unused. The
key_type parameter may be unused on an implementation where there is
no block cipher MAC. Declare the key_type and key_bits parameters as
used so that callers who define a variable just for this don't risk
getting "unused variable" warnings.
2018-09-20 12:00:21 +02:00
Gilles Peskine
00709fafb8 Rename PSA_ALG_HMAC_HASH to PSA_ALG_HMAC_GET_HASH
Be consistent with other GET_HASH macros.
2018-09-20 12:00:21 +02:00
Gilles Peskine
9df2dc87ab Fix name of PSA_ALG_IS_BLOCK_CIPHER_MAC
The macro was used under the name PSA_ALG_IS_BLOCK_CIPHER_MAC but
defined as PSA_ALG_IS_CIPHER_MAC. That wouldn't have worked if we used
this macro (we currently don't but it may become useful).
2018-09-20 12:00:21 +02:00
Gilles Peskine
70ce2c6170 FFDHE groups are not elliptic curves
TLS now defines named curves in the "TLS Supported Groups registry",
but we're using the encoding only for elliptic curves, so don't
include values that aren't named curve.

While we're at it, upgrade the reference to the shiny new RFC 8422.
2018-09-20 12:00:21 +02:00
Gilles Peskine
583b55d97d Add PSA_KEY_TYPE_IS_DSA to go with PSA_KEY_TYPE_IS_RSA
Also move PSA_KEY_TYPE_IS_RSA to a more logical location.
2018-09-20 12:00:21 +02:00
Gilles Peskine
daea26f70f Correct and simplify block-based cipher modes
OFB and CFB are streaming modes. XTS is a not a cipher mode but it
doesn't use a separate padding step. This leaves only CBC as a block
cipher mode that needs a padding step.

Since CBC is the only mode that uses a separate padding step, and is
likely to remain the only mode in the future, encode the padding mode
directly in the algorithm constant, rather than building up an
algorithm value from a chaining mode and a padding mode. This greatly
simplifies the interface as well as some parts of the implementation.
2018-09-20 11:58:22 +02:00
itayzafrir
1861709e5c Add documentation describing behavior of not calling psa_crypto_init 2018-09-16 12:42:53 +03:00
itayzafrir
90d8c7a728 Ensure the module is initialized in key based functions 2018-09-16 12:15:47 +03:00
itayzafrir
0adf0fc31c Ensure the module is initialized in psa_generate_random 2018-09-16 12:15:46 +03:00