1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-01 09:41:40 +03:00

Merge pull request #6844 from gilles-peskine-arm/test_suite_psa_crypto_metadata-20221215-2.28

Backport 2.28: Add metadata tests for CCM* and TLS1.2-ECJPAKE-to-PMS
This commit is contained in:
Manuel Pégourié-Gonnard
2023-01-27 10:05:04 +01:00
committed by GitHub
2 changed files with 18 additions and 7 deletions

View File

@ -212,9 +212,7 @@ class KeyType:
This function does not currently handle key derivation or PAKE.
"""
#pylint: disable=too-many-branches,too-many-return-statements
if alg.is_wildcard:
return False
if alg.is_invalid_truncation():
if not alg.is_valid_for_operation():
return False
if self.head == 'HMAC' and alg.head == 'HMAC':
return True
@ -495,6 +493,19 @@ class Algorithm:
return True
return False
def is_valid_for_operation(self) -> bool:
"""Whether this algorithm construction is valid for an operation.
This function assumes that the algorithm is constructed in a
"grammatically" correct way, and only rejects semantically invalid
combinations.
"""
if self.is_wildcard:
return False
if self.is_invalid_truncation():
return False
return True
def can_do(self, category: AlgorithmCategory) -> bool:
"""Whether this algorithm can perform operations in the given category.
"""