4
* API for authenticated encryption crypto algorithms
11
* Copyright (c) 2001-2006 Cisco Systems, Inc.
12
* All rights reserved.
14
* Redistribution and use in source and binary forms, with or without
15
* modification, are permitted provided that the following conditions
18
* Redistributions of source code must retain the above copyright
19
* notice, this list of conditions and the following disclaimer.
21
* Redistributions in binary form must reproduce the above
22
* copyright notice, this list of conditions and the following
23
* disclaimer in the documentation and/or other materials provided
24
* with the distribution.
26
* Neither the name of the Cisco Systems, Inc. nor the names of its
27
* contributors may be used to endorse or promote products derived
28
* from this software without specific prior written permission.
30
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
33
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
34
* COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
35
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
36
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
37
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
41
* OF THE POSSIBILITY OF SUCH DAMAGE.
51
* @defgroup Crypto Cryptography
53
* Zed uses a simple interface to a cryptographic transform.
59
* @brief applies a crypto algorithm
61
* The function pointer cryptoalg_func_t points to a function that
62
* implements a crypto transform, and provides a uniform API for
63
* accessing crypto mechanisms.
65
* @param key location of secret key
67
* @param clear data to be authenticated but not encrypted
69
* @param clear_len length of data to be authenticated but not encrypted
71
* @param iv location to write the Initialization Vector (IV)
73
* @param protect location of the data to be encrypted and
74
* authenticated (before the function call), and the ciphertext
75
* and authentication tag (after the call)
77
* @param protected_len location of the length of the data to be
78
* encrypted and authenticated (before the function call), and the
79
* length of the ciphertext (after the call)
83
typedef err_status_t (*cryptoalg_func_t)
89
unsigned *protected_len);
92
err_status_t (*cryptoalg_inv_t)
93
(void *key, /* location of secret key */
94
const void *clear, /* data to be authenticated only */
95
unsigned clear_len, /* length of data to be authenticated only */
96
void *iv, /* location of iv */
97
void *opaque, /* data to be decrypted and authenticated */
98
unsigned *opaque_len /* location of the length of data to be
99
* decrypted and authd (before and after)
103
typedef struct cryptoalg_ctx_t {
104
cryptoalg_func_t enc;
108
unsigned auth_tag_len;
109
unsigned max_expansion;
112
typedef cryptoalg_ctx_t *cryptoalg_t;
114
#define cryptoalg_get_key_len(cryptoalg) ((cryptoalg)->key_len)
116
#define cryptoalg_get_iv_len(cryptoalg) ((cryptoalg)->iv_len)
118
#define cryptoalg_get_auth_tag_len(cryptoalg) ((cryptoalg)->auth_tag_len)
121
cryptoalg_get_id(cryptoalg_t c);
124
cryptoalg_find_by_id(int id);
131
#endif /* CRYPTOALG_H */