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)
def test_symmetric_mac(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.compute_tag(pl, algo) # switch to another key operation key.key_ops = KeyOps.MAC_VERIFY assert key.verify_tag(ct, pl, algo)
def test_symmetric_key_aeads(kid, alg, key_ops, base_iv, k, pl, aad, nonce, algo, ct): key = SymmetricKey(kid=kid, alg=alg, key_ops=key_ops, base_iv=base_iv, k=k) assert ct == key.encrypt(pl, aad, nonce, algo) # switch to another key operation key.key_ops = KeyOps.DECRYPT assert pl == key.decrypt(ct, aad, nonce, algo)