00001 00042 #ifndef AES_H_INCLUDED 00043 #define AES_H_INCLUDED 00044 00045 #include <stdint.h> 00046 #include <stdbool.h> 00047 #include <compiler.h> 00048 #include <dmac/dma_controller.h> 00049 00050 #define AES_DECRYPT 0 << 0 00051 #define AES_ENCRYPT 1 << 0 00052 #define AES_KEYSIZE_128 0 << 10 00053 #define AES_KEYSIZE_192 1 << 10 00054 #define AES_KEYSIZE_256 2 << 10 00055 #define AES_KEYSIZE_MASK 3 << 10 00056 #define AES_OPMODE_ECB 0 << 12 00057 #define AES_OPMODE_CBC 1 << 12 00058 #define AES_OPMODE_OFB 2 << 12 00059 #define AES_OPMODE_CFB 3 << 12 00060 #define AES_OPMODE_CTR 4 << 12 00061 00062 00063 struct aes_module { 00064 void *port; 00065 uint32_t mode; 00066 00067 struct dmac_channel *dma_tx_channel; 00068 struct dmac_channel *dma_rx_channel; 00069 00070 int counter; 00071 }; 00072 00074 struct aes_request { 00075 struct aes_module *module; 00076 struct slist tx_buf_list; 00077 struct slist rx_buf_list; 00078 struct dmac_request tx_req; 00079 struct dmac_request rx_req; 00081 void (*req_done)(struct aes_request *, struct slist *, void *); 00083 void *context; 00084 int done_counter; 00085 }; 00086 00087 void aes_init(struct aes_module *module, uint32_t mode); 00088 void aes_free(struct aes_module *module); 00089 void aes_load_key(struct aes_module *module, const uint32_t *key); 00090 void aes_set_cipher(struct aes_module *module, uint32_t mode); 00091 uint32_t aes_get_cipher(struct aes_module *module); 00092 void aes_load_init_vector(struct aes_module *module, const uint32_t *key); 00093 00094 void aes_submit_request(struct aes_request *req); 00095 int aes_duplicate_buffer_refs(struct slist *copy, struct slist *original); 00096 void aes_free_duplicate_buffers(struct slist *buf_list); 00097 struct aes_request *aes_alloc_request(struct aes_module *module); 00098 void aes_free_request(struct aes_request *req); 00099 void aes_prepare_request(struct aes_request *req, struct slist *buf_list); 00100 00101 #endif /* AES_H_INCLUDED */
1.5.8