mirror of
https://github.com/Mbed-TLS/mbedtls-framework.git
synced 2026-09-12 21:29:55 +00:00
crypto_knowledge: improve return values for get_inner_algorithm()
Return a ValueError exception instead of None if the given algorithm is not a composed one. Signed-off-by: Valerio Setti <[email protected]>
This commit is contained in:
@@ -505,10 +505,13 @@ class Algorithm:
|
||||
return True
|
||||
|
||||
def get_inner_algorithm(self) -> "Algorithm":
|
||||
"""Given an algorithm composed as outer_alg(inner_alg) return inner_alg."""
|
||||
"""Given an algorithm composed as outer_alg(inner_alg) return inner_alg.
|
||||
|
||||
Raise ValueError if the algorithm is not a composed one.
|
||||
"""
|
||||
m = re.match(r'\w+\(\s*(.*)\)\Z', self.expression)
|
||||
if not m:
|
||||
return None
|
||||
raise ValueError('Not a composed algorithm: ' + self.expression)
|
||||
inner_alg = m.group(1)
|
||||
return Algorithm(inner_alg)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user