def seal

bend-collections-laws-crypto@1.0.0.0 · src/crypto/aead.bend:60

import bend-collections-laws-crypto@1.0.0.0/src/crypto/aead.bend as Aead
import Base
import bend-collections-laws-crypto@1.0.0.0/src/crypto/aead/chacha20poly1305.bend as CP
import bend-collections-laws-crypto@1.0.0.0/src/crypto/aesgcm.bend as GCM

60# ciphertext || tag (encrypt checks the key and nonce lengths first).
61def seal(alg: Alg, +key: List<&2, U32>, +nonce: List<&2, U32>, +aad: List<&2, U32>, +pt: List<&2, U32>) -> Maybe<&2, List<&2, U32>>:
62  match alg:
63    case CHACHA20_POLY1305{}: Some{CP.seal(key, nonce, aad, pt)}
64    case XCHACHA20_POLY1305{}: Some{CP.xseal(key, nonce, aad, pt)}
65    case AES_128_GCM{}: GCM.aes128_gcm_encrypt(key, nonce, aad, pt)
66    case AES_256_GCM{}: GCM.aes256_gcm_encrypt(key, nonce, aad, pt)

Uses (8)

Used by (15)