Change compiler flag definition place to fix ASAN build break on ARM
[platform/upstream/nettle.git] / nettle-types.h
1 /* nettle-types.h */
2
3 /* nettle, low-level cryptographics library
4  *
5  * Copyright (C) 2005 Niels Möller
6  *  
7  * The nettle library is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License as published by
9  * the Free Software Foundation; either version 2.1 of the License, or (at your
10  * option) any later version.
11  * 
12  * The nettle library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
15  * License for more details.
16  * 
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with the nettle library; see the file COPYING.LIB.  If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20  * MA 02111-1301, USA.
21  */
22
23 #ifndef NETTLE_TYPES_H
24 #define NETTLE_TYPES_H
25
26 /* Pretend these types always exists. Nettle doesn't use them. */
27 #define _STDINT_HAVE_INT_FAST32_T 1
28
29 #include "nettle-stdint.h"
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 /* Randomness. Used by key generation and dsa signature creation. */
36 typedef void nettle_random_func(void *ctx,
37                                 unsigned length, uint8_t *dst);
38
39 /* Progress report function, mainly for key generation. */
40 typedef void nettle_progress_func(void *ctx, int c);
41
42 /* Realloc function, used by struct nettle_buffer. */
43 typedef void *nettle_realloc_func(void *ctx, void *p, unsigned length);
44
45 /* Ciphers */
46 typedef void nettle_set_key_func(void *ctx,
47                                  unsigned length,
48                                  const uint8_t *key);
49
50 /* Uses a void * for cipher contexts.
51
52    For block ciphers it would make sense with a const void * for the
53    context, but we use the same typedef for stream ciphers where the
54    internal state changes during the encryption. */
55
56 typedef void nettle_crypt_func(void *ctx,
57                                unsigned length, uint8_t *dst,
58                                const uint8_t *src);
59
60 /* Hash algorithms */
61 typedef void nettle_hash_init_func(void *ctx);
62 typedef void nettle_hash_update_func(void *ctx,
63                                      unsigned length,
64                                      const uint8_t *src);
65 typedef void nettle_hash_digest_func(void *ctx,
66                                      unsigned length, uint8_t *dst);
67
68 /* ASCII armor codecs. NOTE: Experimental and subject to change. */
69
70 typedef unsigned nettle_armor_length_func(unsigned length);
71 typedef void nettle_armor_init_func(void *ctx);
72
73 typedef unsigned nettle_armor_encode_update_func(void *ctx,
74                                                  uint8_t *dst,
75                                                  unsigned src_length,
76                                                  const uint8_t *src);
77
78 typedef unsigned nettle_armor_encode_final_func(void *ctx, uint8_t *dst);
79
80 typedef int nettle_armor_decode_update_func(void *ctx,
81                                             unsigned *dst_length,
82                                             uint8_t *dst,
83                                             unsigned src_length,
84                                             const uint8_t *src);
85
86 typedef int nettle_armor_decode_final_func(void *ctx);
87
88 #ifdef __cplusplus
89 }
90 #endif
91
92 #endif /* NETTLE_TYPES_H */