Commit 9d52a18a authored by Simo Sorce's avatar Simo Sorce

Fix export_public to return also all public params

Signed-off-by: default avatarSimo Sorce <simo@redhat.com>
parent dbeabb87
......@@ -329,7 +329,12 @@ class JWK(object):
def export_public(self):
"""Exports the public key in the standard JSON format"""
pub = {'kty': self._params['kty']}
pub = {}
preg = JWKParamsRegistry
for name in preg:
if preg[name][1] == 'Public':
if name in self._params:
pub[name] = self._params[name]
reg = JWKValuesRegistry[self._params['kty']]
for param in reg:
if reg[param][1] == 'Public':
......
......@@ -189,6 +189,13 @@ class TestJWK(unittest.TestCase):
jwk.JWK(generate='RSA', size=4096)
jwk.JWK(generate='EC', curve='P-521')
def test_export_public_keys(self):
k = jwk.JWK(**RSAPrivateKey)
jk = k.export_public()
self.assertFalse('d' in json_decode(jk))
k2 = jwk.JWK(**json_decode(jk))
self.assertEqual(k.key_id, k2.key_id)
# RFC 7515 - A.1
A1_protected = \
[123, 34, 116, 121, 112, 34, 58, 34, 74, 87, 84, 34, 44, 13, 10, 32,
......
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