Skip to content

Commit 270420b

Browse files
Merge pull request #47 from gilles-peskine-arm/psa-api-1.0-beta-beta1_minor_fixes
Minor API specification fixes after 1.0beta1
2 parents dad0832 + bf7a98b commit 270420b

File tree

3 files changed

+57
-53
lines changed

3 files changed

+57
-53
lines changed

include/psa/crypto.h

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ psa_status_t psa_export_public_key(psa_key_handle_t handle,
754754
* to another. The target key retains its lifetime and location.
755755
*
756756
* In an implementation where slots have different ownerships,
757-
* this functin may be used to share a key with a different party,
757+
* this function may be used to share a key with a different party,
758758
* subject to implementation-defined restrictions on key sharing.
759759
* In this case \p constraint would typically prevent the recipient
760760
* from exporting the key.
@@ -830,8 +830,7 @@ psa_status_t psa_copy_key(psa_key_handle_t source_handle,
830830
* \param hash_size Size of the \p hash buffer in bytes.
831831
* \param[out] hash_length On success, the number of bytes
832832
* that make up the hash value. This is always
833-
* #PSA_HASH_SIZE(\c alg) where \c alg is the
834-
* hash algorithm that is calculated.
833+
* #PSA_HASH_SIZE(\p alg).
835834
*
836835
* \retval #PSA_SUCCESS
837836
* Success.
@@ -1139,15 +1138,13 @@ psa_status_t psa_hash_clone(const psa_hash_operation_t *source_operation,
11391138
*
11401139
* \param handle Handle to the key to use for the operation.
11411140
* \param alg The MAC algorithm to compute (\c PSA_ALG_XXX value
1142-
* such that #PSA_ALG_IS_MAC(alg) is true).
1141+
* such that #PSA_ALG_IS_MAC(\p alg) is true).
11431142
* \param[in] input Buffer containing the input message.
11441143
* \param input_length Size of the \p input buffer in bytes.
11451144
* \param[out] mac Buffer where the MAC value is to be written.
11461145
* \param mac_size Size of the \p mac buffer in bytes.
11471146
* \param[out] mac_length On success, the number of bytes
1148-
* that make up the mac value. This is always
1149-
* #PSA_HASH_SIZE(\c alg) where \c alg is the
1150-
* hash algorithm that is calculated.
1147+
* that make up the MAC value.
11511148
*
11521149
* \retval #PSA_SUCCESS
11531150
* Success.
@@ -1179,7 +1176,7 @@ psa_status_t psa_mac_compute(psa_key_handle_t handle,
11791176
*
11801177
* \param handle Handle to the key to use for the operation.
11811178
* \param alg The MAC algorithm to compute (\c PSA_ALG_XXX value
1182-
* such that #PSA_ALG_IS_MAC(alg) is true).
1179+
* such that #PSA_ALG_IS_MAC(\p alg) is true).
11831180
* \param[in] input Buffer containing the input message.
11841181
* \param input_length Size of the \p input buffer in bytes.
11851182
* \param[out] mac Buffer containing the expected MAC value.
@@ -1289,7 +1286,7 @@ static psa_mac_operation_t psa_mac_operation_init(void);
12891286
* It must remain valid until the operation
12901287
* terminates.
12911288
* \param alg The MAC algorithm to compute (\c PSA_ALG_XXX value
1292-
* such that #PSA_ALG_IS_MAC(alg) is true).
1289+
* such that #PSA_ALG_IS_MAC(\p alg) is true).
12931290
*
12941291
* \retval #PSA_SUCCESS
12951292
* Success.
@@ -1962,7 +1959,7 @@ psa_status_t psa_cipher_abort(psa_cipher_operation_t *operation);
19621959
* #PSA_AEAD_ENCRYPT_OUTPUT_SIZE(\p alg,
19631960
* \p plaintext_length).
19641961
* \param[out] ciphertext_length On success, the size of the output
1965-
* in the \b ciphertext buffer.
1962+
* in the \p ciphertext buffer.
19661963
*
19671964
* \retval #PSA_SUCCESS
19681965
* Success.
@@ -2018,7 +2015,7 @@ psa_status_t psa_aead_encrypt(psa_key_handle_t handle,
20182015
* #PSA_AEAD_DECRYPT_OUTPUT_SIZE(\p alg,
20192016
* \p ciphertext_length).
20202017
* \param[out] plaintext_length On success, the size of the output
2021-
* in the \b plaintext buffer.
2018+
* in the \p plaintext buffer.
20222019
*
20232020
* \retval #PSA_SUCCESS
20242021
* Success.
@@ -3129,9 +3126,9 @@ psa_status_t psa_key_derivation_input_key(psa_crypto_generator_t *generator,
31293126
* public key type corresponding to the type of
31303127
* private_key. That is, this function performs the
31313128
* equivalent of
3132-
* `psa_import_key(internal_public_key_handle,
3133-
* PSA_KEY_TYPE_PUBLIC_KEY_OF_KEYPAIR(private_key_type),
3134-
* peer_key, peer_key_length)` where
3129+
* #psa_import_key(`internal_public_key_handle`,
3130+
* #PSA_KEY_TYPE_PUBLIC_KEY_OF_KEYPAIR(`private_key_type`),
3131+
* `peer_key`, `peer_key_length`) where
31353132
* `private_key_type` is the type of `private_key`.
31363133
* For example, for EC keys, this means that peer_key
31373134
* is interpreted as a point on the curve that the
@@ -3175,6 +3172,10 @@ psa_status_t psa_key_agreement(psa_crypto_generator_t *generator,
31753172
* a key derivation, use psa_key_agreement() and other functions from
31763173
* the key derivation and generator interface.
31773174
*
3175+
* \param alg The key agreement algorithm to compute
3176+
* (\c PSA_ALG_XXX value such that
3177+
* #PSA_ALG_IS_RAW_KEY_AGREEMENT(\p alg)
3178+
* is true).
31783179
* \param private_key Handle to the private key to use.
31793180
* \param[in] peer_key Public key of the peer. It must be
31803181
* in the same format that psa_import_key()

include/psa/crypto_sizes.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@
228228
* \param key_type The type of the MAC key.
229229
* \param key_bits The size of the MAC key in bits.
230230
* \param alg A MAC algorithm (\c PSA_ALG_XXX value such that
231-
* #PSA_ALG_IS_MAC(alg) is true).
231+
* #PSA_ALG_IS_MAC(\p alg) is true).
232232
*
233233
* \return The MAC size for the specified algorithm with
234234
* the specified key parameters.
@@ -253,7 +253,7 @@
253253
*
254254
* \param alg An AEAD algorithm
255255
* (\c PSA_ALG_XXX value such that
256-
* #PSA_ALG_IS_AEAD(alg) is true).
256+
* #PSA_ALG_IS_AEAD(\p alg) is true).
257257
* \param plaintext_length Size of the plaintext in bytes.
258258
*
259259
* \return The AEAD ciphertext size for the specified
@@ -277,7 +277,7 @@
277277
*
278278
* \param alg An AEAD algorithm
279279
* (\c PSA_ALG_XXX value such that
280-
* #PSA_ALG_IS_AEAD(alg) is true).
280+
* #PSA_ALG_IS_AEAD(\p alg) is true).
281281
*
282282
* \return The maximum trailing ciphertext size for the
283283
* specified algorithm.
@@ -286,7 +286,7 @@
286286
* correct size for an AEAD algorithm that it
287287
* recognizes, but does not support.
288288
*/
289-
#define PSA_AEAD_FINISH_OUTPUT_SIZE(alg, plaintext_length) \
289+
#define PSA_AEAD_FINISH_OUTPUT_SIZE(alg) \
290290
((size_t)0)
291291

292292
/** The maximum size of the output of psa_aead_decrypt(), in bytes.
@@ -298,7 +298,7 @@
298298
*
299299
* \param alg An AEAD algorithm
300300
* (\c PSA_ALG_XXX value such that
301-
* #PSA_ALG_IS_AEAD(alg) is true).
301+
* #PSA_ALG_IS_AEAD(\p alg) is true).
302302
* \param ciphertext_length Size of the plaintext in bytes.
303303
*
304304
* \return The AEAD ciphertext size for the specified

include/psa/crypto_values.h

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
* the global integrity of the keystore. Depending on the global
188188
* integrity guarantees offered by the implementation, access to other
189189
* data may or may not fail even if the data is still readable but
190-
* its integrity canont be guaranteed.
190+
* its integrity cannot be guaranteed.
191191
*
192192
* Implementations should only use this error code to report a
193193
* permanent storage corruption. However application writers should
@@ -613,7 +613,6 @@
613613
#define PSA_ALG_IS_ASYMMETRIC_ENCRYPTION(alg) \
614614
(((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION)
615615

616-
#define PSA_ALG_KEY_SELECTION_FLAG ((psa_algorithm_t)0x01000000)
617616
/** Whether the specified algorithm is a key agreement algorithm.
618617
*
619618
* \param alg An algorithm identifier (value of type #psa_algorithm_t).
@@ -623,8 +622,7 @@
623622
* algorithm identifier.
624623
*/
625624
#define PSA_ALG_IS_KEY_AGREEMENT(alg) \
626-
(((alg) & PSA_ALG_CATEGORY_MASK & ~PSA_ALG_KEY_SELECTION_FLAG) == \
627-
PSA_ALG_CATEGORY_KEY_AGREEMENT)
625+
(((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_KEY_AGREEMENT)
628626

629627
/** Whether the specified algorithm is a key derivation algorithm.
630628
*
@@ -637,17 +635,6 @@
637635
#define PSA_ALG_IS_KEY_DERIVATION(alg) \
638636
(((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_KEY_DERIVATION)
639637

640-
/** Whether the specified algorithm is a key selection algorithm.
641-
*
642-
* \param alg An algorithm identifier (value of type #psa_algorithm_t).
643-
*
644-
* \return 1 if \p alg is a key selection algorithm, 0 otherwise.
645-
* This macro may return either 0 or 1 if \p alg is not a supported
646-
* algorithm identifier.
647-
*/
648-
#define PSA_ALG_IS_KEY_SELECTION(alg) \
649-
(((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_KEY_SELECTION)
650-
651638
#define PSA_ALG_HASH_MASK ((psa_algorithm_t)0x000000ff)
652639

653640
#define PSA_ALG_MD2 ((psa_algorithm_t)0x01000001)
@@ -898,7 +885,12 @@
898885
*/
899886
#define PSA_ALG_CBC_PKCS7 ((psa_algorithm_t)0x04600101)
900887

888+
/** The CCM authenticated encryption algorithm.
889+
*/
901890
#define PSA_ALG_CCM ((psa_algorithm_t)0x06001001)
891+
892+
/** The GCM authenticated encryption algorithm.
893+
*/
902894
#define PSA_ALG_GCM ((psa_algorithm_t)0x06001002)
903895

904896
/* In the encoding of a AEAD algorithm, the bits corresponding to
@@ -1020,6 +1012,20 @@
10201012
(PSA_ALG_DSA_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))
10211013
#define PSA_ALG_DETERMINISTIC_DSA_BASE ((psa_algorithm_t)0x10050000)
10221014
#define PSA_ALG_DSA_DETERMINISTIC_FLAG ((psa_algorithm_t)0x00010000)
1015+
/** Deterministic DSA signature with hashing.
1016+
*
1017+
* This is the deterministic variant defined by RFC 6979 of
1018+
* the signature scheme defined by FIPS 186-4.
1019+
*
1020+
* \param hash_alg A hash algorithm (\c PSA_ALG_XXX value such that
1021+
* #PSA_ALG_IS_HASH(\p hash_alg) is true).
1022+
* This includes #PSA_ALG_ANY_HASH
1023+
* when specifying the algorithm in a usage policy.
1024+
*
1025+
* \return The corresponding DSA signature algorithm.
1026+
* \return Unspecified if \p alg is not a supported
1027+
* hash algorithm.
1028+
*/
10231029
#define PSA_ALG_DETERMINISTIC_DSA(hash_alg) \
10241030
(PSA_ALG_DETERMINISTIC_DSA_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))
10251031
#define PSA_ALG_IS_DSA(alg) \
@@ -1313,8 +1319,23 @@
13131319
#define PSA_ALG_KEY_AGREEMENT_GET_BASE(alg) \
13141320
(((alg) & PSA_ALG_KEY_AGREEMENT_MASK) | PSA_ALG_CATEGORY_KEY_AGREEMENT)
13151321

1322+
/** Whether the specified algorithm is a raw key agreement algorithm.
1323+
*
1324+
* A raw key agreement algorithm is one that does not specify
1325+
* a key derivation function.
1326+
* Usually, raw key agreement algorithms are constructed directly with
1327+
* a \c PSA_ALG_xxx macro while non-raw key agreement algorithms are
1328+
* constructed with PSA_ALG_KEY_AGREEMENT().
1329+
*
1330+
* \param alg An algorithm identifier (value of type #psa_algorithm_t).
1331+
*
1332+
* \return 1 if \p alg is a raw key agreement algorithm, 0 otherwise.
1333+
* This macro may return either 0 or 1 if \p alg is not a supported
1334+
* algorithm identifier.
1335+
*/
13161336
#define PSA_ALG_IS_RAW_KEY_AGREEMENT(alg) \
1317-
(PSA_ALG_KEY_AGREEMENT_GET_KDF(alg) == PSA_ALG_CATEGORY_KEY_DERIVATION)
1337+
(PSA_ALG_IS_KEY_AGREEMENT(alg) && \
1338+
PSA_ALG_KEY_AGREEMENT_GET_KDF(alg) == PSA_ALG_CATEGORY_KEY_DERIVATION)
13181339

13191340
#define PSA_ALG_IS_KEY_DERIVATION_OR_AGREEMENT(alg) \
13201341
((PSA_ALG_IS_KEY_DERIVATION(alg) || PSA_ALG_IS_KEY_AGREEMENT(alg)))
@@ -1404,24 +1425,6 @@
14041425
PSA_ALG_SIGN_GET_HASH(alg) == PSA_ALG_ANY_HASH : \
14051426
(alg) == PSA_ALG_ANY_HASH)
14061427

1407-
/** Whether the specified algorithm encoding is a wildcard.
1408-
*
1409-
* Wildcard values may only be used to set the usage algorithm field in
1410-
* a policy, not to perform an operation.
1411-
*
1412-
* \param alg An algorithm identifier (value of type #psa_algorithm_t).
1413-
*
1414-
* \return 1 if \c alg is a wildcard algorithm encoding.
1415-
* \return 0 if \c alg is a non-wildcard algorithm encoding (suitable for
1416-
* an operation).
1417-
* \return This macro may return either 0 or 1 if \c alg is not a supported
1418-
* algorithm identifier.
1419-
*/
1420-
#define PSA_ALG_IS_WILDCARD(alg) \
1421-
(PSA_ALG_IS_HASH_AND_SIGN(alg) ? \
1422-
PSA_ALG_SIGN_GET_HASH(alg) == PSA_ALG_ANY_HASH : \
1423-
(alg) == PSA_ALG_ANY_HASH)
1424-
14251428
/**@}*/
14261429

14271430
/** \defgroup key_lifetimes Key lifetimes

0 commit comments

Comments
 (0)