src/crypto/aesgcm.bend
bend-collections-laws-crypto@1.0.0.0 · 24 lines · 4 definitions
1import Base
2import bend-collections-laws-crypto@1.0.0.0/src/crypto/aes/gcm.bend as G
3
4
5
6
7
8
9
10
11
12def aes128_gcm_encrypt(+key: List<&2, U32>, +nonce: List<&2, U32>, +aad: List<&2, U32>, +pt: List<&2, U32>) -> Maybe<&2, List<&2, U32>>:
13 G.seal_key(G.schedule_of(16n, key), nonce, aad, pt)
14
15
16def aes128_gcm_decrypt(+key: List<&2, U32>, +nonce: List<&2, U32>, +aad: List<&2, U32>, +ct: List<&2, U32>) -> Maybe<&2, List<&2, U32>>:
17 G.open_key(G.schedule_of(16n, key), nonce, aad, ct)
18
19
20def aes256_gcm_encrypt(+key: List<&2, U32>, +nonce: List<&2, U32>, +aad: List<&2, U32>, +pt: List<&2, U32>) -> Maybe<&2, List<&2, U32>>:
21 G.seal_key(G.schedule_of(32n, key), nonce, aad, pt)
22
23def aes256_gcm_decrypt(+key: List<&2, U32>, +nonce: List<&2, U32>, +aad: List<&2, U32>, +ct: List<&2, U32>) -> Maybe<&2, List<&2, U32>>:
24 G.open_key(G.schedule_of(32n, key), nonce, aad, ct)