Commit f7edc391 authored by Simo Sorce's avatar Simo Sorce

Consistently use bit for key sizes

Always use bits to mesure key material sizes through the code.
Resolves #49
Signed-off-by: 's avatarSimo Sorce <simo@redhat.com>
Reviewed-by: 's avatarChristian Heimes <cheimes@redhat.com>
Closes #60
parent 06da1cd5
......@@ -56,7 +56,7 @@ class InvalidCEKeyLength(Exception):
"""
def __init__(self, expected, obtained):
msg = 'Expected key of length %d, got %d' % (expected, obtained)
msg = 'Expected key of length %d bits, got %d' % (expected, obtained)
super(InvalidCEKeyLength, self).__init__(msg)
......
This diff is collapsed.
......@@ -223,7 +223,7 @@ class JWE(object):
if header:
rec['header'] = header
wrapped = alg.wrap(key, enc.key_size, self.cek, jh)
wrapped = alg.wrap(key, enc.wrap_key_size, self.cek, jh)
self.cek = wrapped['cek']
if 'ek' in wrapped:
......@@ -350,7 +350,8 @@ class JWE(object):
if 'aad' in self.objects:
aad += '.' + base64url_encode(self.objects['aad'])
cek = alg.unwrap(key, enc.key_size, ppe.get('encrypted_key', b''), jh)
cek = alg.unwrap(key, enc.wrap_key_size,
ppe.get('encrypted_key', b''), jh)
data = enc.decrypt(cek, aad.encode('utf-8'),
self.objects['iv'],
self.objects['ciphertext'],
......
......@@ -238,7 +238,7 @@ class JWK(object):
alg = JWA.instantiate_alg(params['alg'])
except KeyError:
raise ValueError("Invalid 'alg' parameter")
size = alg.min_key_size
size = alg.keysize
return size
def _generate_oct(self, params):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment