Skip to content

Commit 7e2cda1

Browse files
authored
Merge pull request #11 from gilles-peskine-arm/psa-setup_bad_state-document
Document that multipart operation setup can return BAD_STATE
2 parents 065c426 + 8e1addc commit 7e2cda1

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

include/psa/crypto.h

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ typedef struct psa_hash_operation_s psa_hash_operation_t;
782782
*/
783783
static psa_hash_operation_t psa_hash_operation_init(void);
784784

785-
/** Start a multipart hash operation.
785+
/** Set up a multipart hash operation.
786786
*
787787
* The sequence of operations to calculate a hash (message digest)
788788
* is as follows:
@@ -816,6 +816,9 @@ static psa_hash_operation_t psa_hash_operation_init(void);
816816
* Success.
817817
* \retval #PSA_ERROR_NOT_SUPPORTED
818818
* \p alg is not supported or is not a hash algorithm.
819+
* \retval #PSA_ERROR_BAD_STATE
820+
* The operation state is not valid (already set up and not
821+
* subsequently completed).
819822
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
820823
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
821824
* \retval #PSA_ERROR_HARDWARE_FAILURE
@@ -837,7 +840,7 @@ psa_status_t psa_hash_setup(psa_hash_operation_t *operation,
837840
* \retval #PSA_SUCCESS
838841
* Success.
839842
* \retval #PSA_ERROR_BAD_STATE
840-
* The operation state is not valid (not started, or already completed).
843+
* The operation state is not valid (not set up, or already completed).
841844
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
842845
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
843846
* \retval #PSA_ERROR_HARDWARE_FAILURE
@@ -874,7 +877,7 @@ psa_status_t psa_hash_update(psa_hash_operation_t *operation,
874877
* \retval #PSA_SUCCESS
875878
* Success.
876879
* \retval #PSA_ERROR_BAD_STATE
877-
* The operation state is not valid (not started, or already completed).
880+
* The operation state is not valid (not set up, or already completed).
878881
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
879882
* The size of the \p hash buffer is too small. You can determine a
880883
* sufficient buffer size by calling #PSA_HASH_SIZE(\c alg)
@@ -914,7 +917,7 @@ psa_status_t psa_hash_finish(psa_hash_operation_t *operation,
914917
* The hash of the message was calculated successfully, but it
915918
* differs from the expected hash.
916919
* \retval #PSA_ERROR_BAD_STATE
917-
* The operation state is not valid (not started, or already completed).
920+
* The operation state is not valid (not set up, or already completed).
918921
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
919922
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
920923
* \retval #PSA_ERROR_HARDWARE_FAILURE
@@ -1032,7 +1035,7 @@ typedef struct psa_mac_operation_s psa_mac_operation_t;
10321035
*/
10331036
static psa_mac_operation_t psa_mac_operation_init(void);
10341037

1035-
/** Start a multipart MAC calculation operation.
1038+
/** Set up a multipart MAC calculation operation.
10361039
*
10371040
* This function sets up the calculation of the MAC
10381041
* (message authentication code) of a byte string.
@@ -1082,6 +1085,9 @@ static psa_mac_operation_t psa_mac_operation_init(void);
10821085
* \retval #PSA_ERROR_HARDWARE_FAILURE
10831086
* \retval #PSA_ERROR_TAMPERING_DETECTED
10841087
* \retval #PSA_ERROR_BAD_STATE
1088+
* The operation state is not valid (already set up and not
1089+
* subsequently completed).
1090+
* \retval #PSA_ERROR_BAD_STATE
10851091
* The library has not been previously initialized by psa_crypto_init().
10861092
* It is implementation-dependent whether a failure to initialize
10871093
* results in this error code.
@@ -1090,7 +1096,7 @@ psa_status_t psa_mac_sign_setup(psa_mac_operation_t *operation,
10901096
psa_key_handle_t handle,
10911097
psa_algorithm_t alg);
10921098

1093-
/** Start a multipart MAC verification operation.
1099+
/** Set up a multipart MAC verification operation.
10941100
*
10951101
* This function sets up the verification of the MAC
10961102
* (message authentication code) of a byte string against an expected value.
@@ -1139,6 +1145,9 @@ psa_status_t psa_mac_sign_setup(psa_mac_operation_t *operation,
11391145
* \retval #PSA_ERROR_HARDWARE_FAILURE
11401146
* \retval #PSA_ERROR_TAMPERING_DETECTED
11411147
* \retval #PSA_ERROR_BAD_STATE
1148+
* The operation state is not valid (already set up and not
1149+
* subsequently completed).
1150+
* \retval #PSA_ERROR_BAD_STATE
11421151
* The library has not been previously initialized by psa_crypto_init().
11431152
* It is implementation-dependent whether a failure to initialize
11441153
* results in this error code.
@@ -1162,7 +1171,7 @@ psa_status_t psa_mac_verify_setup(psa_mac_operation_t *operation,
11621171
* \retval #PSA_SUCCESS
11631172
* Success.
11641173
* \retval #PSA_ERROR_BAD_STATE
1165-
* The operation state is not valid (not started, or already completed).
1174+
* The operation state is not valid (not set up, or already completed).
11661175
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
11671176
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
11681177
* \retval #PSA_ERROR_HARDWARE_FAILURE
@@ -1201,7 +1210,7 @@ psa_status_t psa_mac_update(psa_mac_operation_t *operation,
12011210
* \retval #PSA_SUCCESS
12021211
* Success.
12031212
* \retval #PSA_ERROR_BAD_STATE
1204-
* The operation state is not valid (not started, or already completed).
1213+
* The operation state is not valid (not set up, or already completed).
12051214
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
12061215
* The size of the \p mac buffer is too small. You can determine a
12071216
* sufficient buffer size by calling PSA_MAC_FINAL_SIZE().
@@ -1240,7 +1249,7 @@ psa_status_t psa_mac_sign_finish(psa_mac_operation_t *operation,
12401249
* The MAC of the message was calculated successfully, but it
12411250
* differs from the expected MAC.
12421251
* \retval #PSA_ERROR_BAD_STATE
1243-
* The operation state is not valid (not started, or already completed).
1252+
* The operation state is not valid (not set up, or already completed).
12441253
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
12451254
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
12461255
* \retval #PSA_ERROR_HARDWARE_FAILURE
@@ -1384,6 +1393,9 @@ static psa_cipher_operation_t psa_cipher_operation_init(void);
13841393
* \retval #PSA_ERROR_HARDWARE_FAILURE
13851394
* \retval #PSA_ERROR_TAMPERING_DETECTED
13861395
* \retval #PSA_ERROR_BAD_STATE
1396+
* The operation state is not valid (already set up and not
1397+
* subsequently completed).
1398+
* \retval #PSA_ERROR_BAD_STATE
13871399
* The library has not been previously initialized by psa_crypto_init().
13881400
* It is implementation-dependent whether a failure to initialize
13891401
* results in this error code.
@@ -1443,6 +1455,9 @@ psa_status_t psa_cipher_encrypt_setup(psa_cipher_operation_t *operation,
14431455
* \retval #PSA_ERROR_HARDWARE_FAILURE
14441456
* \retval #PSA_ERROR_TAMPERING_DETECTED
14451457
* \retval #PSA_ERROR_BAD_STATE
1458+
* The operation state is not valid (already set up and not
1459+
* subsequently completed).
1460+
* \retval #PSA_ERROR_BAD_STATE
14461461
* The library has not been previously initialized by psa_crypto_init().
14471462
* It is implementation-dependent whether a failure to initialize
14481463
* results in this error code.
@@ -1471,7 +1486,7 @@ psa_status_t psa_cipher_decrypt_setup(psa_cipher_operation_t *operation,
14711486
* \retval #PSA_SUCCESS
14721487
* Success.
14731488
* \retval #PSA_ERROR_BAD_STATE
1474-
* The operation state is not valid (not started, or IV already set).
1489+
* The operation state is not valid (not set up, or IV already set).
14751490
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
14761491
* The size of the \p iv buffer is too small.
14771492
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
@@ -1505,7 +1520,7 @@ psa_status_t psa_cipher_generate_iv(psa_cipher_operation_t *operation,
15051520
* \retval #PSA_SUCCESS
15061521
* Success.
15071522
* \retval #PSA_ERROR_BAD_STATE
1508-
* The operation state is not valid (not started, or IV already set).
1523+
* The operation state is not valid (not set up, or IV already set).
15091524
* \retval #PSA_ERROR_INVALID_ARGUMENT
15101525
* The size of \p iv is not acceptable for the chosen algorithm,
15111526
* or the chosen algorithm does not use an IV.
@@ -1541,7 +1556,7 @@ psa_status_t psa_cipher_set_iv(psa_cipher_operation_t *operation,
15411556
* \retval #PSA_SUCCESS
15421557
* Success.
15431558
* \retval #PSA_ERROR_BAD_STATE
1544-
* The operation state is not valid (not started, IV required but
1559+
* The operation state is not valid (not set up, IV required but
15451560
* not set, or already completed).
15461561
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
15471562
* The size of the \p output buffer is too small.
@@ -1579,7 +1594,7 @@ psa_status_t psa_cipher_update(psa_cipher_operation_t *operation,
15791594
* \retval #PSA_SUCCESS
15801595
* Success.
15811596
* \retval #PSA_ERROR_BAD_STATE
1582-
* The operation state is not valid (not started, IV required but
1597+
* The operation state is not valid (not set up, IV required but
15831598
* not set, or already completed).
15841599
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
15851600
* The size of the \p output buffer is too small.

0 commit comments

Comments
 (0)