xref: /dflybsd-src/contrib/wpa_supplicant/src/crypto/aes_wrap.h (revision 3a84a4273475ed07d0ab1c2dfeffdfedef35d9cd)
16d49e1aeSJan Lentfer /*
26d49e1aeSJan Lentfer  * AES-based functions
36d49e1aeSJan Lentfer  *
4*a1157835SDaniel Fojt  * - AES Key Wrap Algorithm (RFC3394)
5*a1157835SDaniel Fojt  * - One-Key CBC MAC (OMAC1) hash with AES-128 and AES-256
6*a1157835SDaniel Fojt  * - AES-128/192/256 CTR mode encryption
76d49e1aeSJan Lentfer  * - AES-128 EAX mode encryption/decryption
86d49e1aeSJan Lentfer  * - AES-128 CBC
93ff40c12SJohn Marino  * - AES-GCM
103ff40c12SJohn Marino  * - AES-CCM
116d49e1aeSJan Lentfer  *
123ff40c12SJohn Marino  * Copyright (c) 2003-2012, Jouni Malinen <j@w1.fi>
136d49e1aeSJan Lentfer  *
143ff40c12SJohn Marino  * This software may be distributed under the terms of the BSD license.
153ff40c12SJohn Marino  * See README for more details.
166d49e1aeSJan Lentfer  */
176d49e1aeSJan Lentfer 
186d49e1aeSJan Lentfer #ifndef AES_WRAP_H
196d49e1aeSJan Lentfer #define AES_WRAP_H
206d49e1aeSJan Lentfer 
21*a1157835SDaniel Fojt int __must_check aes_wrap(const u8 *kek, size_t kek_len, int n, const u8 *plain,
22*a1157835SDaniel Fojt 			  u8 *cipher);
23*a1157835SDaniel Fojt int __must_check aes_unwrap(const u8 *kek, size_t kek_len, int n,
24*a1157835SDaniel Fojt 			    const u8 *cipher, u8 *plain);
25*a1157835SDaniel Fojt int __must_check omac1_aes_vector(const u8 *key, size_t key_len,
26*a1157835SDaniel Fojt 				  size_t num_elem, const u8 *addr[],
27*a1157835SDaniel Fojt 				  const size_t *len, u8 *mac);
286d49e1aeSJan Lentfer int __must_check omac1_aes_128_vector(const u8 *key, size_t num_elem,
296d49e1aeSJan Lentfer 				      const u8 *addr[], const size_t *len,
306d49e1aeSJan Lentfer 				      u8 *mac);
316d49e1aeSJan Lentfer int __must_check omac1_aes_128(const u8 *key, const u8 *data, size_t data_len,
326d49e1aeSJan Lentfer 			       u8 *mac);
33*a1157835SDaniel Fojt int __must_check omac1_aes_256(const u8 *key, const u8 *data, size_t data_len,
34*a1157835SDaniel Fojt 			       u8 *mac);
356d49e1aeSJan Lentfer int __must_check aes_128_encrypt_block(const u8 *key, const u8 *in, u8 *out);
36*a1157835SDaniel Fojt int __must_check aes_ctr_encrypt(const u8 *key, size_t key_len, const u8 *nonce,
37*a1157835SDaniel Fojt 				 u8 *data, size_t data_len);
386d49e1aeSJan Lentfer int __must_check aes_128_ctr_encrypt(const u8 *key, const u8 *nonce,
396d49e1aeSJan Lentfer 				     u8 *data, size_t data_len);
406d49e1aeSJan Lentfer int __must_check aes_128_eax_encrypt(const u8 *key,
416d49e1aeSJan Lentfer 				     const u8 *nonce, size_t nonce_len,
426d49e1aeSJan Lentfer 				     const u8 *hdr, size_t hdr_len,
436d49e1aeSJan Lentfer 				     u8 *data, size_t data_len, u8 *tag);
446d49e1aeSJan Lentfer int __must_check aes_128_eax_decrypt(const u8 *key,
456d49e1aeSJan Lentfer 				     const u8 *nonce, size_t nonce_len,
466d49e1aeSJan Lentfer 				     const u8 *hdr, size_t hdr_len,
476d49e1aeSJan Lentfer 				     u8 *data, size_t data_len, const u8 *tag);
486d49e1aeSJan Lentfer int __must_check aes_128_cbc_encrypt(const u8 *key, const u8 *iv, u8 *data,
496d49e1aeSJan Lentfer 				     size_t data_len);
506d49e1aeSJan Lentfer int __must_check aes_128_cbc_decrypt(const u8 *key, const u8 *iv, u8 *data,
516d49e1aeSJan Lentfer 				     size_t data_len);
523ff40c12SJohn Marino int __must_check aes_gcm_ae(const u8 *key, size_t key_len,
533ff40c12SJohn Marino 			    const u8 *iv, size_t iv_len,
543ff40c12SJohn Marino 			    const u8 *plain, size_t plain_len,
553ff40c12SJohn Marino 			    const u8 *aad, size_t aad_len,
563ff40c12SJohn Marino 			    u8 *crypt, u8 *tag);
573ff40c12SJohn Marino int __must_check aes_gcm_ad(const u8 *key, size_t key_len,
583ff40c12SJohn Marino 			    const u8 *iv, size_t iv_len,
593ff40c12SJohn Marino 			    const u8 *crypt, size_t crypt_len,
603ff40c12SJohn Marino 			    const u8 *aad, size_t aad_len, const u8 *tag,
613ff40c12SJohn Marino 			    u8 *plain);
623ff40c12SJohn Marino int __must_check aes_gmac(const u8 *key, size_t key_len,
633ff40c12SJohn Marino 			  const u8 *iv, size_t iv_len,
643ff40c12SJohn Marino 			  const u8 *aad, size_t aad_len, u8 *tag);
653ff40c12SJohn Marino int __must_check aes_ccm_ae(const u8 *key, size_t key_len, const u8 *nonce,
663ff40c12SJohn Marino 			    size_t M, const u8 *plain, size_t plain_len,
673ff40c12SJohn Marino 			    const u8 *aad, size_t aad_len, u8 *crypt, u8 *auth);
683ff40c12SJohn Marino int __must_check aes_ccm_ad(const u8 *key, size_t key_len, const u8 *nonce,
693ff40c12SJohn Marino 			    size_t M, const u8 *crypt, size_t crypt_len,
703ff40c12SJohn Marino 			    const u8 *aad, size_t aad_len, const u8 *auth,
713ff40c12SJohn Marino 			    u8 *plain);
726d49e1aeSJan Lentfer 
736d49e1aeSJan Lentfer #endif /* AES_WRAP_H */
74