return EBADMSG instead of ECANCELED on tag verification failure.
[cryptodev-linux.git] / examples / aes-gcm.h
blob1ddc5fe464fcb4b4dfabe029e21c955ab03aa975
1 #ifndef AES_H
2 # define AES_H
4 #include <stdint.h>
6 struct cryptodev_ctx {
7 int cfd;
8 struct session_op sess;
9 uint16_t alignmask;
12 #define AES_BLOCK_SIZE 16
14 int aes_gcm_ctx_init(struct cryptodev_ctx* ctx, int cfd, const uint8_t *key, unsigned int key_size);
15 void aes_gcm_ctx_deinit();
17 /* Note that encryption assumes that ciphertext has enough size
18 * for the tag to be appended. In decryption the tag is assumed
19 * to be the last bytes of ciphertext.
21 int aes_gcm_encrypt(struct cryptodev_ctx* ctx, const void* iv,
22 const void* auth, size_t auth_size,
23 const void* plaintext, void* ciphertext, size_t size);
24 int aes_gcm_decrypt(struct cryptodev_ctx* ctx, const void* iv,
25 const void* auth, size_t auth_size,
26 const void* ciphertext, void* plaintext, size_t size);
28 #endif