2 * @ingroup adf_os_public
3 * @file adf_os_crypto.h
4 * This file defines crypto APIs
7 #ifndef __ADF_OS_CRYPTO_H
8 #define __ADF_OS_CRYPTO_H
10 #include <adf_os_crypto_pvt.h>
13 * @brief Representation of a cipher context.
15 typedef __adf_os_cipher_t adf_os_cipher_t;
18 * @brief Types of crypto algorithms
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,
27 * @brief allocate the cipher context
28 * @param[in] type crypto algorithm
30 * @return the new cipher context
32 static inline adf_os_cipher_t
33 adf_os_crypto_alloc_cipher(adf_os_crypto_alg_t type)
35 return __adf_os_crypto_alloc_cipher(type);
39 * @brief free the cipher context
41 * @param[in] cipher cipher context
44 adf_os_crypto_free_cipher(adf_os_cipher_t cipher)
46 __adf_os_crypto_free_cipher(cipher);
50 * @brief set the key for cipher context with length keylen
52 * @param[in] cipher cipher context
53 * @param[in] key key material
54 * @param[in] keylen length of key material
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)
61 return __adf_os_crypto_cipher_setkey(cipher, key, keylen);
65 * @brief encrypt the data with AES
67 * @param[in] cipher cipher context
68 * @param[in] src unencrypted data
69 * @param[out] dst encrypted data
72 adf_os_crypto_rijndael_encrypt(adf_os_cipher_t cipher, const void *src, void *dst)
74 __adf_os_crypto_rijndael_encrypt(cipher, src, dst);