Make eccdata warn about poor parameters.
[gd/nettle] / nettle-types.h
1 /* nettle-types.h
2
3    Copyright (C) 2005, 2014 Niels Möller
4
5    This file is part of GNU Nettle.
6
7    GNU Nettle is free software: you can redistribute it and/or
8    modify it under the terms of either:
9
10      * the GNU Lesser General Public License as published by the Free
11        Software Foundation; either version 3 of the License, or (at your
12        option) any later version.
13
14    or
15
16      * the GNU General Public License as published by the Free
17        Software Foundation; either version 2 of the License, or (at your
18        option) any later version.
19
20    or both in parallel, as here.
21
22    GNU Nettle is distributed in the hope that it will be useful,
23    but WITHOUT ANY WARRANTY; without even the implied warranty of
24    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
25    General Public License for more details.
26
27    You should have received copies of the GNU General Public License and
28    the GNU Lesser General Public License along with this program.  If
29    not, see http://www.gnu.org/licenses/.
30 */
31
32 #ifndef NETTLE_TYPES_H
33 #define NETTLE_TYPES_H
34
35 /* For size_t */
36 #include <stddef.h>
37
38 /* Pretend these types always exists. Nettle doesn't use them. */
39 #define _STDINT_HAVE_INT_FAST32_T 1
40 #include "nettle-stdint.h"
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46 /* An aligned 16-byte block. */
47 union nettle_block16
48 {
49   uint8_t b[16];
50   unsigned long w[16 / sizeof(unsigned long)];
51   uint64_t u64[2];
52 };
53
54 /* Randomness. Used by key generation and dsa signature creation. */
55 typedef void nettle_random_func(void *ctx,
56                                 size_t length, uint8_t *dst);
57
58 /* Progress report function, mainly for key generation. */
59 typedef void nettle_progress_func(void *ctx, int c);
60
61 /* Realloc function, used by struct nettle_buffer. */
62 typedef void *nettle_realloc_func(void *ctx, void *p, size_t length);
63
64 /* Ciphers */
65 typedef void nettle_set_key_func(void *ctx, const uint8_t *key);
66
67 /* For block ciphers, const context. */
68 typedef void nettle_cipher_func(const void *ctx,
69                                 size_t length, uint8_t *dst,
70                                 const uint8_t *src);
71
72
73 /* Uses a void * for cipher contexts. Used for crypt operations where
74    the internal state changes during the encryption. */
75 typedef void nettle_crypt_func(void *ctx,
76                                size_t length, uint8_t *dst,
77                                const uint8_t *src);
78
79 /* Hash algorithms */
80 typedef void nettle_hash_init_func(void *ctx);
81 typedef void nettle_hash_update_func(void *ctx,
82                                      size_t length,
83                                      const uint8_t *src);
84 typedef void nettle_hash_digest_func(void *ctx,
85                                      size_t length, uint8_t *dst);
86
87 /* ASCII armor codecs. NOTE: Experimental and subject to change. */
88
89 typedef size_t nettle_armor_length_func(size_t length);
90 typedef void nettle_armor_init_func(void *ctx);
91
92 typedef size_t nettle_armor_encode_update_func(void *ctx,
93                                                char *dst,
94                                                size_t src_length,
95                                                const uint8_t *src);
96
97 typedef size_t nettle_armor_encode_final_func(void *ctx, char *dst);
98
99 typedef int nettle_armor_decode_update_func(void *ctx,
100                                             size_t *dst_length,
101                                             uint8_t *dst,
102                                             size_t src_length,
103                                             const char *src);
104
105 typedef int nettle_armor_decode_final_func(void *ctx);
106
107 #ifdef __cplusplus
108 }
109 #endif
110
111 #endif /* NETTLE_TYPES_H */