Remove ad hoc is_valid_for_signature method
Use the new generic is_public method. Impact on generated cases: there are new HMAC test cases for SIGN_HASH. It was a bug that these test cases were previously not generated. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
09dc05b880
commit
fa70ced195
2 changed files with 6 additions and 19 deletions
|
@ -20,7 +20,7 @@ This module is entirely based on the PSA API.
|
|||
|
||||
import enum
|
||||
import re
|
||||
from typing import Dict, Iterable, Optional, Pattern, Tuple
|
||||
from typing import Iterable, Optional, Tuple
|
||||
|
||||
from mbedtls_dev.asymmetric_key_data import ASYMMETRIC_KEY_DATA
|
||||
|
||||
|
@ -178,21 +178,6 @@ class KeyType:
|
|||
return b''.join([self.DATA_BLOCK] * (length // len(self.DATA_BLOCK)) +
|
||||
[self.DATA_BLOCK[:length % len(self.DATA_BLOCK)]])
|
||||
|
||||
KEY_TYPE_FOR_SIGNATURE = {
|
||||
'PSA_KEY_USAGE_SIGN_HASH': re.compile('.*KEY_PAIR'),
|
||||
'PSA_KEY_USAGE_VERIFY_HASH': re.compile('.*KEY.*')
|
||||
} #type: Dict[str, Pattern]
|
||||
"""Use a regexp to determine key types for which signature is possible
|
||||
when using the actual usage flag.
|
||||
"""
|
||||
def is_valid_for_signature(self, usage: str) -> bool:
|
||||
"""Determine if the key type is compatible with the specified
|
||||
signitute type.
|
||||
|
||||
"""
|
||||
# This is just temporaly solution for the implicit usage flags.
|
||||
return re.match(self.KEY_TYPE_FOR_SIGNATURE[usage], self.name) is not None
|
||||
|
||||
def can_do(self, alg: 'Algorithm') -> bool:
|
||||
"""Whether this key type can be used for operations with the given algorithm.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue