예제 #1
0
    def _parse_credentials(
        cred: Union[CBOR, Callable]
    ) -> Tuple[Union[CBOR, Callable], Union[Key, Callable]]:
        if isinstance(cred, bytes):

            if isinstance(cbor2.loads(cred), dict):
                # this is an RPK
                cose_key = CoseKey.decode(cbor2.loads(cred))
                return cred, cose_key

            else:
                # TODO: update when test vectors for CBOR encoded certificates are correct
                return cred, None
        else:

            return cred, cred
예제 #2
0
def test_cosekey_decode(encoded_key_obj):
    key = CoseKey.decode(encoded_key_obj)
    assert type(key) == EC2
    assert key.kty == KTY.EC2
    assert key.crv == CoseEllipticCurves.P_256