def _jwk_to_key(jwk): if jwk['kty'] != 'EC': raise exceptions.DXFUnexpectedKeyTypeError(jwk['kty'], 'EC') if jwk['crv'] != 'P-256': raise exceptions.DXFUnexpectedKeyTypeError(jwk['crv'], 'P-256') # pylint: disable=bad-continuation return ecdsa.VerifyingKey.from_public_point( ecdsa.ellipticcurve.Point(ecdsa.NIST256p.curve, _base64_to_num(jwk['x']), _base64_to_num(jwk['y'])), ecdsa.NIST256p)
def _import_key(expkey): if expkey['kty'] != 'EC': raise exceptions.DXFUnexpectedKeyTypeError(expkey['kty'], 'EC') if expkey['crv'] != 'P-256': raise exceptions.DXFUnexpectedKeyTypeError(expkey['crv'], 'P-256') return jwk.JWK(kty='EC', crv='P-256', x=expkey['x'], y=expkey['y'])