ocb.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Mathias Tausig
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
23 #ifndef CRYPTO_MODES_OCB_H
24 #define CRYPTO_MODES_OCB_H
25 
26 #include "crypto/ciphers.h"
27 #include <stdint.h>
28 #include <stddef.h>
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
42 #define OCB_ERR_INVALID_NONCE_LENGTH (-2)
43 
46 #define OCB_ERR_INVALID_BLOCK_LENGTH (-3)
47 
50 #define OCB_ERR_INVALID_DATA_LENGTH (-3)
51 
54 #define OCB_ERR_INVALID_TAG_LENGTH (-4)
55 
58 #define OCB_ERR_INVALID_TAG (-5)
59 
80 int32_t cipher_encrypt_ocb(const cipher_t *cipher,
81  const uint8_t *auth_data, size_t auth_data_len,
82  uint8_t tag_len,
83  const uint8_t *nonce, size_t nonce_len,
84  const uint8_t *input, size_t input_len,
85  uint8_t *output);
86 
105 int32_t cipher_decrypt_ocb(const cipher_t *cipher,
106  const uint8_t *auth_data, size_t auth_data_len,
107  uint8_t tag_len,
108  const uint8_t *nonce, size_t nonce_len,
109  const uint8_t *input, size_t input_len,
110  uint8_t *output);
111 #ifdef __cplusplus
112 }
113 #endif
114 
115 #endif /* CRYPTO_MODES_OCB_H */
116 
cipher_t
basic struct for using block ciphers contains the cipher interface and the context
Definition: ciphers.h:104
ciphers.h
Headers for the packet encryption class. They are used to encrypt single packets.
cipher_encrypt_ocb
int32_t cipher_encrypt_ocb(const cipher_t *cipher, const uint8_t *auth_data, size_t auth_data_len, uint8_t tag_len, const uint8_t *nonce, size_t nonce_len, const uint8_t *input, size_t input_len, uint8_t *output)
Encrypt and authenticate data of arbitrary length in OCB mode.
cipher_decrypt_ocb
int32_t cipher_decrypt_ocb(const cipher_t *cipher, const uint8_t *auth_data, size_t auth_data_len, uint8_t tag_len, const uint8_t *nonce, size_t nonce_len, const uint8_t *input, size_t input_len, uint8_t *output)
Decrypt and verify the authentication of OCB encrypted data.