Skip to content

Commit abf9f1a

Browse files
PSA interruptible sign/verify: detect invalid curve family in start
Detect attempts to do ECDSA with a Montgomery curve in psa_sign_hash_start() and psa_verify_hash_start(), whereas before start() would succeed and complete() would fail. This avoids an inconsistency between psa_sign_hash() and psa_sign_hash_start() that would be annoying to handle in test_suite_psa_crypto_op_fail. Signed-off-by: Gilles Peskine <[email protected]>
1 parent 9058998 commit abf9f1a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

library/psa_crypto.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3969,9 +3969,13 @@ psa_status_t mbedtls_psa_sign_hash_start(
39693969
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
39703970
size_t required_hash_length;
39713971

3972-
if (!PSA_KEY_TYPE_IS_ECC(attributes->type)) {
3972+
if (!PSA_KEY_TYPE_IS_ECC_KEY_PAIR(attributes->type)) {
39733973
return PSA_ERROR_NOT_SUPPORTED;
39743974
}
3975+
psa_ecc_family_t curve = PSA_KEY_TYPE_ECC_GET_FAMILY(attributes->type);
3976+
if (!PSA_ECC_FAMILY_IS_WEIERSTRASS(curve)) {
3977+
return PSA_ERROR_INVALID_ARGUMENT;
3978+
}
39753979

39763980
if (!can_do_interruptible_sign_verify(alg)) {
39773981
return PSA_ERROR_NOT_SUPPORTED;
@@ -4188,6 +4192,10 @@ psa_status_t mbedtls_psa_verify_hash_start(
41884192
if (!PSA_KEY_TYPE_IS_ECC(attributes->type)) {
41894193
return PSA_ERROR_NOT_SUPPORTED;
41904194
}
4195+
psa_ecc_family_t curve = PSA_KEY_TYPE_ECC_GET_FAMILY(attributes->type);
4196+
if (!PSA_ECC_FAMILY_IS_WEIERSTRASS(curve)) {
4197+
return PSA_ERROR_INVALID_ARGUMENT;
4198+
}
41914199

41924200
if (!can_do_interruptible_sign_verify(alg)) {
41934201
return PSA_ERROR_NOT_SUPPORTED;

0 commit comments

Comments
 (0)