Initial cut of the open ath9k htc firmware.
[open-ath9k-htc-firmware.git] / target_firmware / magpie_fw_dev / target / inc / adf_os_crypto.h
1 /**
2  * @ingroup adf_os_public
3  * @file adf_os_crypto.h
4  * This file defines crypto APIs
5  */
6
7 #ifndef __ADF_OS_CRYPTO_H
8 #define __ADF_OS_CRYPTO_H
9
10 #include <adf_os_crypto_pvt.h>
11
12 /**
13  * @brief Representation of a cipher context.
14  */ 
15 typedef __adf_os_cipher_t     adf_os_cipher_t;
16
17 /**
18  * @brief Types of crypto algorithms
19  */ 
20 typedef enum adf_os_crypto_alg{
21     ADF_OS_CRYPTO_AES = __ADF_OS_CRYPTO_AES,
22     ADF_OS_CRYPTO_OTHER = __ADF_OS_CRYPTO_OTHER,
23 }adf_os_crypto_alg_t;
24
25
26 /**
27  * @brief allocate the cipher context
28  * @param[in] type crypto algorithm
29  * 
30  * @return the new cipher context
31  */
32 static inline adf_os_cipher_t
33 adf_os_crypto_alloc_cipher(adf_os_crypto_alg_t type)
34 {
35     return __adf_os_crypto_alloc_cipher(type);
36 }
37
38 /**
39  * @brief free the cipher context
40  * 
41  * @param[in] cipher cipher context
42  */
43 static inline void
44 adf_os_crypto_free_cipher(adf_os_cipher_t cipher)
45 {
46     __adf_os_crypto_free_cipher(cipher);
47 }
48
49 /**
50  * @brief set the key for cipher context with length keylen
51  * 
52  * @param[in] cipher    cipher context
53  * @param[in] key       key material
54  * @param[in] keylen    length of key material
55  * 
56  * @return a_uint32_t
57  */
58 static inline a_uint32_t
59 adf_os_crypto_cipher_setkey(adf_os_cipher_t cipher, const a_uint8_t *key, a_uint8_t keylen)
60 {
61     return __adf_os_crypto_cipher_setkey(cipher, key, keylen);
62 }
63
64 /**
65  * @brief encrypt the data with AES
66  * 
67  * @param[in]   cipher  cipher context
68  * @param[in]   src     unencrypted data
69  * @param[out]  dst     encrypted data
70  */
71 static inline void
72 adf_os_crypto_rijndael_encrypt(adf_os_cipher_t cipher, const void *src, void *dst)
73 {
74     __adf_os_crypto_rijndael_encrypt(cipher, src, dst);
75 }
76 #endif