Skip to content

Commit b5b0e98

Browse files
author
Netanel Gonen
committed
reopening #9754 after the changes where overrun
changing the SPM error codes from invalid argument to bad state aligned to PSA spec
1 parent 5f38878 commit b5b0e98

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

components/TARGET_PSA/services/crypto/COMPONENT_PSA_SRV_IPC/psa_crypto_spm.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ psa_status_t psa_mac_update(psa_mac_operation_t *operation,
129129
};
130130

131131
if (operation->handle <= 0) {
132-
return (PSA_ERROR_INVALID_ARGUMENT);
132+
return (PSA_ERROR_BAD_STATE);
133133
}
134134

135135
err = psa_call(operation->handle, in_vec, 2, NULL, 0);
@@ -153,7 +153,7 @@ psa_status_t psa_mac_sign_finish(psa_mac_operation_t *operation,
153153
psa_outvec out_vec[2] = { { mac, mac_size }, { mac_length, sizeof(*mac_length) } };
154154

155155
if (operation->handle <= 0) {
156-
return (PSA_ERROR_INVALID_ARGUMENT);
156+
return (PSA_ERROR_BAD_STATE);
157157
}
158158

159159
err_call = psa_call(operation->handle, in_vec, 2, out_vec, 2);
@@ -178,7 +178,7 @@ psa_status_t psa_mac_verify_finish(psa_mac_operation_t *operation,
178178
};
179179

180180
if (operation->handle <= 0) {
181-
return (PSA_ERROR_INVALID_ARGUMENT);
181+
return (PSA_ERROR_BAD_STATE);
182182
}
183183

184184
err_call = psa_call(operation->handle, in_vec, 3, NULL, 0);
@@ -248,7 +248,7 @@ psa_status_t psa_hash_update(psa_hash_operation_t *operation,
248248
};
249249

250250
if (operation->handle <= 0) {
251-
return (PSA_ERROR_INVALID_ARGUMENT);
251+
return (PSA_ERROR_BAD_STATE);
252252
}
253253

254254
err = psa_call(operation->handle, in_vec, 2, NULL, 0);
@@ -274,7 +274,7 @@ psa_status_t psa_hash_finish(psa_hash_operation_t *operation,
274274
};
275275

276276
if (operation->handle <= 0) {
277-
return (PSA_ERROR_INVALID_ARGUMENT);
277+
return (PSA_ERROR_BAD_STATE);
278278
}
279279

280280
err_call = psa_call(operation->handle, in_vec, 2, out_vec, 2);
@@ -299,7 +299,7 @@ psa_status_t psa_hash_verify(psa_hash_operation_t *operation,
299299
};
300300

301301
if (operation->handle <= 0) {
302-
return (PSA_ERROR_INVALID_ARGUMENT);
302+
return (PSA_ERROR_BAD_STATE);
303303
}
304304

305305
err_call = psa_call(operation->handle, in_vec, 3, NULL, 0);
@@ -1103,7 +1103,7 @@ psa_status_t psa_get_generator_capacity(const psa_crypto_generator_t *generator,
11031103
psa_outvec out_vec = { capacity, sizeof(*capacity) };
11041104

11051105
if (generator->handle <= 0) {
1106-
return (PSA_ERROR_INVALID_ARGUMENT);
1106+
return (PSA_ERROR_BAD_STATE);
11071107
}
11081108

11091109
err_call = psa_call(generator->handle, &in_vec, 1, &out_vec, 1);
@@ -1122,7 +1122,7 @@ psa_status_t psa_generator_read(psa_crypto_generator_t *generator,
11221122
psa_outvec out_vec = { output, output_length };
11231123

11241124
if (generator->handle <= 0) {
1125-
return (PSA_ERROR_INVALID_ARGUMENT);
1125+
return (PSA_ERROR_BAD_STATE);
11261126
}
11271127

11281128
err_call = psa_call(generator->handle, &in_vec, 1, &out_vec, 1);
@@ -1145,7 +1145,7 @@ psa_status_t psa_generator_import_key(psa_key_handle_t key_handle,
11451145
};
11461146

11471147
if (generator->handle <= 0) {
1148-
return (PSA_ERROR_INVALID_ARGUMENT);
1148+
return (PSA_ERROR_BAD_STATE);
11491149
}
11501150

11511151
err_call = psa_call(generator->handle, in_vec, 3, NULL, 0);
@@ -1306,7 +1306,7 @@ psa_status_t psa_cipher_generate_iv(psa_cipher_operation_t *operation,
13061306
};
13071307

13081308
if (operation->handle <= 0) {
1309-
return (PSA_ERROR_INVALID_ARGUMENT);
1309+
return (PSA_ERROR_BAD_STATE);
13101310
}
13111311

13121312
err = psa_call(operation->handle, &in_vec, 1, out_vec, 2);
@@ -1332,7 +1332,7 @@ psa_status_t psa_cipher_set_iv(psa_cipher_operation_t *operation,
13321332
};
13331333

13341334
if (operation->handle <= 0) {
1335-
return (PSA_ERROR_INVALID_ARGUMENT);
1335+
return (PSA_ERROR_BAD_STATE);
13361336
}
13371337

13381338
err = psa_call(operation->handle, in_vec, 2, NULL, 0);
@@ -1370,7 +1370,7 @@ psa_status_t psa_cipher_update(psa_cipher_operation_t *operation,
13701370
};
13711371

13721372
if (operation->handle <= 0) {
1373-
return (PSA_ERROR_INVALID_ARGUMENT);
1373+
return (PSA_ERROR_BAD_STATE);
13741374
}
13751375

13761376
err = psa_call(operation->handle, in_vec, 2, out_vec, 2);
@@ -1403,7 +1403,7 @@ psa_status_t psa_cipher_finish(psa_cipher_operation_t *operation,
14031403
};
14041404

14051405
if (operation->handle <= 0) {
1406-
return (PSA_ERROR_INVALID_ARGUMENT);
1406+
return (PSA_ERROR_BAD_STATE);
14071407
}
14081408

14091409
err_call = psa_call(operation->handle, &in_vec, 1, out_vec, 2);

0 commit comments

Comments
 (0)