1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-06-15 06:41:43 +03:00

Test attempts to use a public key for a private-key operation

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine
2021-04-29 21:56:59 +02:00
parent 739c98c5e8
commit c2fc241e46
5 changed files with 5371 additions and 4419 deletions

View File

@ -104,6 +104,10 @@ class KeyType:
`self.name`.
"""
def is_public(self) -> bool:
"""Whether the key type is for public keys."""
return self.name.endswith('_PUBLIC_KEY')
ECC_KEY_SIZES = {
'PSA_ECC_FAMILY_SECP_K1': (192, 224, 256),
'PSA_ECC_FAMILY_SECP_R1': (225, 256, 384, 521),
@ -240,8 +244,17 @@ class AlgorithmCategory(enum.Enum):
PAKE = 10
def requires_key(self) -> bool:
"""Whether operations in this category are set up with a key."""
return self not in {self.HASH, self.KEY_DERIVATION}
def is_asymmetric(self) -> bool:
"""Whether operations in this category involve asymmetric keys."""
return self in {
self.SIGN,
self.ASYMMETRIC_ENCRYPTION,
self.KEY_AGREEMENT
}
class AlgorithmNotRecognized(Exception):
def __init__(self, expr: str) -> None: