ccm.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Freie Universität Berlin
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 
9 #pragma once
10 
22 #include "crypto/ciphers.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
32 #define CCM_ERR_INVALID_NONCE_LENGTH (-2)
33 #define CCM_ERR_INVALID_CBC_MAC (-3)
34 #define CCM_ERR_INVALID_DATA_LENGTH (-3)
35 #define CCM_ERR_INVALID_LENGTH_ENCODING (-4)
36 #define CCM_ERR_INVALID_MAC_LENGTH (-5)
42 #define CCM_BLOCK_SIZE 16
43 
47 #define CCM_MAC_MAX_LEN 16
48 
71 int cipher_encrypt_ccm(const cipher_t *cipher,
72  const uint8_t *auth_data, uint32_t auth_data_len,
73  uint8_t mac_length, uint8_t length_encoding,
74  const uint8_t *nonce, size_t nonce_len,
75  const uint8_t *input, size_t input_len,
76  uint8_t *output);
77 
100 int cipher_decrypt_ccm(const cipher_t *cipher,
101  const uint8_t *auth_data, uint32_t auth_data_len,
102  uint8_t mac_length, uint8_t length_encoding,
103  const uint8_t *nonce, size_t nonce_len,
104  const uint8_t *input, size_t input_len,
105  uint8_t *output);
106 
107 #ifdef __cplusplus
108 }
109 #endif
110 
int cipher_decrypt_ccm(const cipher_t *cipher, const uint8_t *auth_data, uint32_t auth_data_len, uint8_t mac_length, uint8_t length_encoding, const uint8_t *nonce, size_t nonce_len, const uint8_t *input, size_t input_len, uint8_t *output)
Decrypt data of arbitrary length in ccm mode.
int cipher_encrypt_ccm(const cipher_t *cipher, const uint8_t *auth_data, uint32_t auth_data_len, uint8_t mac_length, uint8_t length_encoding, 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 ccm mode.
Headers for the packet encryption class.
basic struct for using block ciphers contains the cipher interface and the context
Definition: ciphers.h:118