def aes256gcm_nist_encrypt_observation

qasim-bend-kit@0.1.0.2 · LAWS.bend:510

import qasim-bend-kit@0.1.0.2/LAWS.bend as LAWS
import Base
import qasim-bend-kit@0.1.0.2/libs/AES256GCM.bend as AES

510# Compare the protocol-visible result while leaving internal certificate terms
511# out of the NIST contract: success, nonce bytes, ciphertext, and tag bytes.
512def aes256gcm_nist_encrypt_observation(result: Result<&2, &2, AES.Error, AES.Envelope>) -> List<&2, U32>:
513    match result:
514        case Fail{error}: []
515        case Done{envelope}:
516            match envelope:
517                case AES.Envelope{nonce, ciphertext, tag, valid}:
518                    match nonce tag:
519                        case AES.Nonce{nonce_bytes, nonce_size, nonce_valid}
520                             AES.Tag{tag_bytes, tag_size, tag_valid}:
521                            List.append(&2, U32, nonce_bytes,
522                                List.append(&2, U32, ciphertext, tag_bytes))

Uses (8)

Used by (15)