Пример #1
0
    def encrypt(self, key: SymmetricKey, alg: Optional['CoseAlgorithms'] = None) -> bytes:
        """ Key wrapping. """

        if key is None:
            raise CoseIllegalKeyType("COSE Key cannot be None")

        return key.key_wrap(self.payload, alg=alg)
Пример #2
0
def test_symmetric_key_wrap(kid, alg, key_ops, base_iv, k, pl, algo, ct):
    key = SymmetricKey(kid=kid, alg=alg, key_ops=key_ops, base_iv=base_iv, k=k)

    assert ct == key.key_wrap(pl, algo)

    # switch to another key operation
    key.key_ops = KeyOps.UNWRAP
    assert pl == key.key_unwrap(ct, algo)