upstream: https://github.com/mirage/mirage-crypto
at main 36 lines 1.0 kB view raw
1(** Counter with CBC-MAC (CCM) mode. 2 3 Internal implementation of the CCM authenticated encryption mode as 4 specified in NIST SP 800-38C. *) 5 6val unsafe_generation_encryption_into : 7 cipher:(key:'a -> string -> src_off:int -> bytes -> dst_off:int -> unit) -> 8 key:'a -> 9 nonce:string -> 10 adata:string -> 11 string -> 12 src_off:int -> 13 bytes -> 14 dst_off:int -> 15 tag_off:int -> 16 int -> 17 unit 18(** [unsafe_generation_encryption_into ~cipher ~key ~nonce ~adata src ~src_off 19 dst ~dst_off ~tag_off len] encrypts and generates the authentication tag. 20 No bounds checking. *) 21 22val unsafe_decryption_verification_into : 23 cipher:(key:'a -> string -> src_off:int -> bytes -> dst_off:int -> unit) -> 24 key:'a -> 25 nonce:string -> 26 adata:string -> 27 string -> 28 src_off:int -> 29 tag_off:int -> 30 bytes -> 31 dst_off:int -> 32 int -> 33 bool 34(** [unsafe_decryption_verification_into ~cipher ~key ~nonce ~adata src ~src_off 35 ~tag_off dst ~dst_off len] decrypts and verifies the tag. Returns [true] on 36 success. No bounds checking. *)