dlopen-test: Use libnettle.dylib on MacOS.
[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 #include <stdint.h>
38
39 /* Attributes we want to use in installed header files, and hence
40    can't rely on config.h. */
41 #ifdef __GNUC__
42
43 #define _NETTLE_ATTRIBUTE_PURE __attribute__((pure))
44 #ifndef _NETTLE_ATTRIBUTE_DEPRECATED
45 /* Variant without message is supported since gcc-3.1 or so. */
46 #define _NETTLE_ATTRIBUTE_DEPRECATED __attribute__((deprecated))
47 #endif
48
49 #else /* !__GNUC__ */
50
51 #define _NETTLE_ATTRIBUTE_PURE
52 #define _NETTLE_ATTRIBUTE_DEPRECATED
53
54 #endif /* !__GNUC__ */
55
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59
60 /* An aligned 16-byte block. */
61 union nettle_block16
62 {
63   uint8_t b[16];
64   unsigned long w[16 / sizeof(unsigned long)] _NETTLE_ATTRIBUTE_DEPRECATED;
65   uint64_t u64[2];
66 };
67
68 union nettle_block8
69 {
70   uint8_t b[8];
71   uint64_t u64;
72 };
73
74 /* Randomness. Used by key generation and dsa signature creation. */
75 typedef void nettle_random_func(void *ctx,
76                                 size_t length, uint8_t *dst);
77
78 /* Progress report function, mainly for key generation. */
79 typedef void nettle_progress_func(void *ctx, int c);
80
81 /* Realloc function, used by struct nettle_buffer. */
82 typedef void *nettle_realloc_func(void *ctx, void *p, size_t length);
83
84 /* Ciphers */
85 typedef void nettle_set_key_func(void *ctx, const uint8_t *key);
86
87 /* For block ciphers, const context. */
88 typedef void nettle_cipher_func(const void *ctx,
89                                 size_t length, uint8_t *dst,
90                                 const uint8_t *src);
91
92
93 /* Uses a void * for cipher contexts. Used for crypt operations where
94    the internal state changes during the encryption. */
95 typedef void nettle_crypt_func(void *ctx,
96                                size_t length, uint8_t *dst,
97                                const uint8_t *src);
98
99 /* Hash algorithms */
100 typedef void nettle_hash_init_func(void *ctx);
101 typedef void nettle_hash_update_func(void *ctx,
102                                      size_t length,
103                                      const uint8_t *src);
104 typedef void nettle_hash_digest_func(void *ctx,
105                                      size_t length, uint8_t *dst);
106
107 /* ASCII armor codecs. NOTE: Experimental and subject to change. */
108
109 typedef size_t nettle_armor_length_func(size_t length);
110 typedef void nettle_armor_init_func(void *ctx);
111
112 typedef size_t nettle_armor_encode_update_func(void *ctx,
113                                                char *dst,
114                                                size_t src_length,
115                                                const uint8_t *src);
116
117 typedef size_t nettle_armor_encode_final_func(void *ctx, char *dst);
118
119 typedef int nettle_armor_decode_update_func(void *ctx,
120                                             size_t *dst_length,
121                                             uint8_t *dst,
122                                             size_t src_length,
123                                             const char *src);
124
125 typedef int nettle_armor_decode_final_func(void *ctx);
126
127 #ifdef __cplusplus
128 }
129 #endif
130
131 #endif /* NETTLE_TYPES_H */