author | zautrix <zautrix> | 2004-10-19 20:16:14 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-19 20:16:14 (UTC) |
commit | eca49bb06a71980ef61d078904573f25890fc7f2 (patch) (unidiff) | |
tree | c5338e3b12430248979a9ac2c1c7e6646ea9ecdf /pwmanager/libcrypt/crypt/g10lib.h | |
parent | 53cc32b6e7b1f672bf91b2baf2df6c1e8baf3e0a (diff) | |
download | kdepimpi-eca49bb06a71980ef61d078904573f25890fc7f2.zip kdepimpi-eca49bb06a71980ef61d078904573f25890fc7f2.tar.gz kdepimpi-eca49bb06a71980ef61d078904573f25890fc7f2.tar.bz2 |
Initial revision
Diffstat (limited to 'pwmanager/libcrypt/crypt/g10lib.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | pwmanager/libcrypt/crypt/g10lib.h | 250 |
1 files changed, 250 insertions, 0 deletions
diff --git a/pwmanager/libcrypt/crypt/g10lib.h b/pwmanager/libcrypt/crypt/g10lib.h new file mode 100644 index 0000000..0aef376 --- a/dev/null +++ b/pwmanager/libcrypt/crypt/g10lib.h | |||
@@ -0,0 +1,250 @@ | |||
1 | /* g10lib.h - internal defintions for libgcrypt | ||
2 | * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. | ||
3 | * | ||
4 | * This header is to be used inside of libgcrypt in place of gcrypt.h. | ||
5 | * This way we can better distinguish between internal and external | ||
6 | * usage of gcrypt.h | ||
7 | * | ||
8 | * This file is part of Libgcrypt. | ||
9 | * | ||
10 | * Libgcrypt is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU Lesser general Public License as | ||
12 | * published by the Free Software Foundation; either version 2.1 of | ||
13 | * the License, or (at your option) any later version. | ||
14 | * | ||
15 | * Libgcrypt is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU Lesser General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU Lesser General Public | ||
21 | * License along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | ||
23 | */ | ||
24 | |||
25 | #ifndef G10LIB_H | ||
26 | #define G10LIB_H 1 | ||
27 | |||
28 | #ifdef _GCRYPT_H | ||
29 | #error gcrypt.h already included | ||
30 | #endif | ||
31 | |||
32 | #ifndef _GCRYPT_IN_LIBGCRYPT | ||
33 | #error something is wrong with config.h | ||
34 | #endif | ||
35 | |||
36 | #include <gcrypt.h> | ||
37 | #include "types.h" | ||
38 | |||
39 | #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 ) | ||
40 | #define JNLIB_GCC_M_FUNCTION 1 | ||
41 | #define JNLIB_GCC_A_NR __attribute__ ((noreturn)) | ||
42 | #define JNLIB_GCC_A_PRINTF( f, a ) __attribute__ ((format (printf,f,a))) | ||
43 | #define JNLIB_GCC_A_NR_PRINTF( f, a ) \ | ||
44 | __attribute__ ((noreturn, format (printf,f,a))) | ||
45 | #define GCC_ATTR_NORETURN __attribute__ ((__noreturn__)) | ||
46 | #else | ||
47 | #define JNLIB_GCC_A_NR | ||
48 | #define JNLIB_GCC_A_PRINTF( f, a ) | ||
49 | #define JNLIB_GCC_A_NR_PRINTF( f, a ) | ||
50 | #define GCC_ATTR_NORETURN | ||
51 | #endif | ||
52 | |||
53 | #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96 ) | ||
54 | #define GCC_ATTR_PURE __attribute__ ((__pure__)) | ||
55 | #else | ||
56 | #define GCC_ATTR_PURE | ||
57 | #endif | ||
58 | |||
59 | /* (The malloc attribute might be defined prior to 3.2 - I am just not sure) */ | ||
60 | #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2 ) | ||
61 | #define GCC_ATTR_MALLOC __attribute__ ((__malloc__)) | ||
62 | #else | ||
63 | #define GCC_ATTR_MALLOC | ||
64 | #endif | ||
65 | |||
66 | #ifdef G10_I18N_H | ||
67 | #error i18n should not be included here | ||
68 | #endif | ||
69 | |||
70 | #define _(a) _gcry_gettext(a) | ||
71 | #define N_(a) (a) | ||
72 | |||
73 | void _gcry_check_heap( const void *a ); | ||
74 | |||
75 | int _gcry_get_debug_flag( unsigned int mask ); | ||
76 | |||
77 | |||
78 | /*-- gcrypt/misc.c --*/ | ||
79 | |||
80 | #ifdef JNLIB_GCC_M_FUNCTION | ||
81 | void _gcry_bug (const char *file, int line, | ||
82 | const char *func) GCC_ATTR_NORETURN; | ||
83 | #else | ||
84 | void _gcry_bug (const char *file, int line); | ||
85 | #endif | ||
86 | |||
87 | const char *_gcry_gettext (const char *key); | ||
88 | void _gcry_fatal_error(int rc, const char *text ) JNLIB_GCC_A_NR; | ||
89 | void _gcry_log( int level, const char *fmt, ... ) JNLIB_GCC_A_PRINTF(2,3); | ||
90 | void _gcry_log_bug( const char *fmt, ... ) JNLIB_GCC_A_NR_PRINTF(1,2); | ||
91 | void _gcry_log_fatal( const char *fmt, ... ) JNLIB_GCC_A_NR_PRINTF(1,2); | ||
92 | void _gcry_log_error( const char *fmt, ... ) JNLIB_GCC_A_PRINTF(1,2); | ||
93 | void _gcry_log_info( const char *fmt, ... ) JNLIB_GCC_A_PRINTF(1,2); | ||
94 | void _gcry_log_debug( const char *fmt, ... ) JNLIB_GCC_A_PRINTF(1,2); | ||
95 | void _gcry_log_printf ( const char *fmt, ... ) JNLIB_GCC_A_PRINTF(1,2); | ||
96 | |||
97 | void _gcry_set_log_verbosity( int level ); | ||
98 | int _gcry_log_verbosity( int level ); | ||
99 | |||
100 | #ifdef JNLIB_GCC_M_FUNCTION | ||
101 | #define BUG() _gcry_bug( __FILE__ , __LINE__, __FUNCTION__ ) | ||
102 | #else | ||
103 | #define BUG() _gcry_bug( __FILE__ , __LINE__ ) | ||
104 | #endif | ||
105 | |||
106 | #define log_hexdump _gcry_log_hexdump | ||
107 | #define log_bug _gcry_log_bug | ||
108 | #define log_fatal _gcry_log_fatal | ||
109 | #define log_error _gcry_log_error | ||
110 | #define log_info _gcry_log_info | ||
111 | #define log_debug _gcry_log_debug | ||
112 | #define log_printf _gcry_log_printf | ||
113 | |||
114 | |||
115 | |||
116 | |||
117 | /*-- cipher/pubkey.c --*/ | ||
118 | |||
119 | #ifndef mpi_powm | ||
120 | #define mpi_powm(w,b,e,m) gcry_mpi_powm( (w), (b), (e), (m) ) | ||
121 | #endif | ||
122 | |||
123 | /*-- primegen.c --*/ | ||
124 | gcry_mpi_t _gcry_generate_secret_prime (unsigned int nbits, | ||
125 | int (*extra_check)(void*, gcry_mpi_t), | ||
126 | void *extra_check_arg); | ||
127 | gcry_mpi_t _gcry_generate_public_prime (unsigned int nbits, | ||
128 | int (*extra_check)(void*, gcry_mpi_t), | ||
129 | void *extra_check_arg); | ||
130 | gcry_mpi_t _gcry_generate_elg_prime( int mode, unsigned pbits, unsigned qbits, | ||
131 | gcry_mpi_t g, gcry_mpi_t **factors ); | ||
132 | |||
133 | |||
134 | /* replacements of missing functions (missing-string.c)*/ | ||
135 | #ifndef HAVE_STPCPY | ||
136 | char *stpcpy (char *a, const char *b); | ||
137 | #endif | ||
138 | #ifndef HAVE_STRCASECMP | ||
139 | int strcasecmp (const char *a, const char *b) GCC_ATTR_PURE; | ||
140 | #endif | ||
141 | |||
142 | /* macros used to rename missing functions */ | ||
143 | #ifndef HAVE_STRTOUL | ||
144 | #define strtoul(a,b,c) ((unsigned long)strtol((a),(b),(c))) | ||
145 | #endif | ||
146 | #ifndef HAVE_MEMMOVE | ||
147 | #define memmove(d, s, n) bcopy((s), (d), (n)) | ||
148 | #endif | ||
149 | #ifndef HAVE_STRICMP | ||
150 | #define stricmp(a,b) strcasecmp( (a), (b) ) | ||
151 | #endif | ||
152 | #ifndef HAVE_ATEXIT | ||
153 | #define atexit(a) (on_exit((a),0)) | ||
154 | #endif | ||
155 | #ifndef HAVE_RAISE | ||
156 | #define raise(a) kill(getpid(), (a)) | ||
157 | #endif | ||
158 | |||
159 | |||
160 | /* some handy macros */ | ||
161 | #ifndef STR | ||
162 | #define STR(v) #v | ||
163 | #endif | ||
164 | #define STR2(v) STR(v) | ||
165 | #define DIM(v) (sizeof(v)/sizeof((v)[0])) | ||
166 | #define DIMof(type,member) DIM(((type *)0)->member) | ||
167 | |||
168 | /* Stack burning. */ | ||
169 | |||
170 | void _gcry_burn_stack (int bytes); | ||
171 | |||
172 | |||
173 | /* To avoid that a compiler optimizes certain memset calls away, these | ||
174 | macros may be used instead. */ | ||
175 | #define wipememory2(_ptr,_set,_len) do { \ | ||
176 | volatile char *_vptr=(volatile char *)(_ptr); \ | ||
177 | size_t _vlen=(_len); \ | ||
178 | while(_vlen) { *_vptr=(_set); _vptr++; _vlen--; } \ | ||
179 | } while(0) | ||
180 | #define wipememory(_ptr,_len) wipememory2(_ptr,0,_len) | ||
181 | |||
182 | |||
183 | |||
184 | /* Digit predicates. */ | ||
185 | |||
186 | #define digitp(p) (*(p) >= '0' && *(p) <= '9') | ||
187 | #define octdigitp(p) (*(p) >= '0' && *(p) <= '7') | ||
188 | #define alphap(a) ( (*(a) >= 'A' && *(a) <= 'Z') \ | ||
189 | || (*(a) >= 'a' && *(a) <= 'z')) | ||
190 | #define hexdigitp(a) (digitp (a) \ | ||
191 | || (*(a) >= 'A' && *(a) <= 'F') \ | ||
192 | || (*(a) >= 'a' && *(a) <= 'f')) | ||
193 | |||
194 | /* Management for ciphers/digests/pubkey-ciphers. */ | ||
195 | |||
196 | /* Structure for each registered `module'. */ | ||
197 | struct gcry_module | ||
198 | { | ||
199 | struct gcry_module *next; /* List pointers. */ | ||
200 | struct gcry_module **prevp; | ||
201 | void *spec; /* The acctual specs. */ | ||
202 | int flags; /* Associated flags. */ | ||
203 | int counter; /* Use counter. */ | ||
204 | unsigned int mod_id; /* ID of this module. */ | ||
205 | }; | ||
206 | |||
207 | /* Flags for the `flags' member of gcry_module_t. */ | ||
208 | #define FLAG_MODULE_DISABLED 1 << 0 | ||
209 | |||
210 | gcry_err_code_t _gcry_module_add (gcry_module_t *entries, | ||
211 | unsigned int id, | ||
212 | void *spec, | ||
213 | gcry_module_t *module); | ||
214 | |||
215 | typedef int (*gcry_module_lookup_t) (void *spec, void *data); | ||
216 | |||
217 | /* Lookup a module specification by it's ID. After a successfull | ||
218 | lookup, the module has it's resource counter incremented. */ | ||
219 | gcry_module_t _gcry_module_lookup_id (gcry_module_t entries, | ||
220 | unsigned int id); | ||
221 | |||
222 | /* Internal function. Lookup a module specification. */ | ||
223 | gcry_module_t _gcry_module_lookup (gcry_module_t entries, void *data, | ||
224 | gcry_module_lookup_t func); | ||
225 | |||
226 | /* Release a module. In case the use-counter reaches zero, destroy | ||
227 | the module. */ | ||
228 | void _gcry_module_release (gcry_module_t entry); | ||
229 | |||
230 | /* Add a reference to a module. */ | ||
231 | void _gcry_module_use (gcry_module_t module); | ||
232 | |||
233 | /* Return a list of module IDs. */ | ||
234 | gcry_err_code_t _gcry_module_list (gcry_module_t modules, | ||
235 | int *list, int *list_length); | ||
236 | |||
237 | gcry_err_code_t _gcry_cipher_init (void); | ||
238 | gcry_err_code_t _gcry_md_init (void); | ||
239 | gcry_err_code_t _gcry_pk_init (void); | ||
240 | |||
241 | gcry_err_code_t _gcry_pk_module_lookup (int id, gcry_module_t *module); | ||
242 | void _gcry_pk_module_release (gcry_module_t module); | ||
243 | |||
244 | /* Memory management. */ | ||
245 | |||
246 | gcry_err_code_t _gcry_malloc (size_t n, unsigned int flags, void **mem); | ||
247 | |||
248 | #define GCRY_ALLOC_FLAG_SECURE (1 << 0) | ||
249 | |||
250 | #endif /* G10LIB_H */ | ||