mirror of
https://github.com/theupdateframework/python-tuf
synced 2026-05-24 10:08:28 +00:00
ASN.1: deal with empty private values in public key dicts
by removing them. This is potentially problematic as it might change the keyid when converting to ASN.1 and back, but it'll have to do for now, and we shouldn't have these things in there in the first place. It's an edge case, and this is a compromise. Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
This commit is contained in:
parent
da726fed76
commit
1fda798d40
1 changed files with 10 additions and 2 deletions
|
|
@ -180,8 +180,16 @@ def public_key_to_pyasn1(public_key_dict):
|
|||
# whether it replaces the previous one or is a second check_match on the same
|
||||
# arg.
|
||||
if 'private' in public_key_dict['keyval']:
|
||||
raise tuf.exceptions.FormatError('Expected public key, received key dict '
|
||||
'containing a private key entry!')
|
||||
|
||||
# TODO: Clean this conditional up! Removing an empty 'private' value is
|
||||
# not ideal, and might change the keyid based on how we currently calculate
|
||||
# keyids.... Empty strings don't seem to be OK as OctetStrings, though, so
|
||||
# for now, we're doing this....
|
||||
if not public_key_dict['keyval']['private']:
|
||||
del public_key_dict['keyval']['private']
|
||||
else:
|
||||
raise tuf.exceptions.FormatError('Expected public key, received key dict '
|
||||
'containing a private key entry!')
|
||||
|
||||
# TODO: Intelligently handle PEM-style RSA keys, which have value set to an
|
||||
# ASCII-prefixed Base64 string like:
|
||||
|
|
|
|||
Loading…
Reference in a new issue