Skip to content

Commit d0dae03

Browse files
author
Netanel Gonen
committed
Fix SPM returning the wrong value
1 parent 31da50e commit d0dae03

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
@@ -142,7 +142,7 @@ psa_status_t psa_mac_update(psa_mac_operation_t *operation,
142142
};
143143

144144
if (operation->handle <= 0) {
145-
return (PSA_ERROR_INVALID_ARGUMENT);
145+
return (PSA_ERROR_BAD_STATE);
146146
}
147147

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

171171
if (operation->handle <= 0) {
172-
return (PSA_ERROR_INVALID_ARGUMENT);
172+
return (PSA_ERROR_BAD_STATE);
173173
}
174174

175175
err_call = psa_call(operation->handle, in_vec, 2, out_vec, 2);
@@ -198,7 +198,7 @@ psa_status_t psa_mac_verify_finish(psa_mac_operation_t *operation,
198198
};
199199

200200
if (operation->handle <= 0) {
201-
return (PSA_ERROR_INVALID_ARGUMENT);
201+
return (PSA_ERROR_BAD_STATE);
202202
}
203203

204204
err_call = psa_call(operation->handle, in_vec, 3, NULL, 0);
@@ -279,7 +279,7 @@ psa_status_t psa_hash_update(psa_hash_operation_t *operation,
279279
};
280280

281281
if (operation->handle <= 0) {
282-
return (PSA_ERROR_INVALID_ARGUMENT);
282+
return (PSA_ERROR_BAD_STATE);
283283
}
284284

285285
err = psa_call(operation->handle, in_vec, 2, NULL, 0);
@@ -308,7 +308,7 @@ psa_status_t psa_hash_finish(psa_hash_operation_t *operation,
308308
};
309309

310310
if (operation->handle <= 0) {
311-
return (PSA_ERROR_INVALID_ARGUMENT);
311+
return (PSA_ERROR_BAD_STATE);
312312
}
313313

314314
err_call = psa_call(operation->handle, in_vec, 2, out_vec, 2);
@@ -337,7 +337,7 @@ psa_status_t psa_hash_verify(psa_hash_operation_t *operation,
337337
};
338338

339339
if (operation->handle <= 0) {
340-
return (PSA_ERROR_INVALID_ARGUMENT);
340+
return (PSA_ERROR_BAD_STATE);
341341
}
342342

343343
err_call = psa_call(operation->handle, in_vec, 3, NULL, 0);
@@ -1213,7 +1213,7 @@ psa_status_t psa_get_generator_capacity(const psa_crypto_generator_t *generator,
12131213
psa_outvec out_vec = { capacity, sizeof(*capacity) };
12141214

12151215
if (generator->handle <= 0) {
1216-
return (PSA_ERROR_INVALID_ARGUMENT);
1216+
return (PSA_ERROR_BAD_STATE);
12171217
}
12181218

12191219
err_call = psa_call(generator->handle, &in_vec, 1, &out_vec, 1);
@@ -1235,7 +1235,7 @@ psa_status_t psa_generator_read(psa_crypto_generator_t *generator,
12351235
psa_outvec out_vec = { output, output_length };
12361236

12371237
if (generator->handle <= 0) {
1238-
return (PSA_ERROR_INVALID_ARGUMENT);
1238+
return (PSA_ERROR_BAD_STATE);
12391239
}
12401240

12411241
err_call = psa_call(generator->handle, &in_vec, 1, &out_vec, 1);
@@ -1261,7 +1261,7 @@ psa_status_t psa_generator_import_key(psa_key_handle_t key_handle,
12611261
};
12621262

12631263
if (generator->handle <= 0) {
1264-
return (PSA_ERROR_INVALID_ARGUMENT);
1264+
return (PSA_ERROR_BAD_STATE);
12651265
}
12661266

12671267
err_call = psa_call(generator->handle, in_vec, 3, NULL, 0);
@@ -1439,7 +1439,7 @@ psa_status_t psa_cipher_generate_iv(psa_cipher_operation_t *operation,
14391439
};
14401440

14411441
if (operation->handle <= 0) {
1442-
return (PSA_ERROR_INVALID_ARGUMENT);
1442+
return (PSA_ERROR_BAD_STATE);
14431443
}
14441444

14451445
err = psa_call(operation->handle, &in_vec, 1, out_vec, 2);
@@ -1467,7 +1467,7 @@ psa_status_t psa_cipher_set_iv(psa_cipher_operation_t *operation,
14671467
};
14681468

14691469
if (operation->handle <= 0) {
1470-
return (PSA_ERROR_INVALID_ARGUMENT);
1470+
return (PSA_ERROR_BAD_STATE);
14711471
}
14721472

14731473
err = psa_call(operation->handle, in_vec, 2, NULL, 0);
@@ -1507,7 +1507,7 @@ psa_status_t psa_cipher_update(psa_cipher_operation_t *operation,
15071507
};
15081508

15091509
if (operation->handle <= 0) {
1510-
return (PSA_ERROR_INVALID_ARGUMENT);
1510+
return (PSA_ERROR_BAD_STATE);
15111511
}
15121512

15131513
err = psa_call(operation->handle, in_vec, 2, out_vec, 2);
@@ -1542,7 +1542,7 @@ psa_status_t psa_cipher_finish(psa_cipher_operation_t *operation,
15421542
};
15431543

15441544
if (operation->handle <= 0) {
1545-
return (PSA_ERROR_INVALID_ARGUMENT);
1545+
return (PSA_ERROR_BAD_STATE);
15461546
}
15471547

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

0 commit comments

Comments
 (0)