nettle-types.h 2.83 KB
Newer Older
1 2 3 4
/* nettle-types.h */

/* nettle, low-level cryptographics library
 *
Niels Möller's avatar
Niels Möller committed
5
 * Copyright (C) 2005 Niels Möller
6 7 8 9 10 11 12 13 14 15 16 17 18
 *  
 * The nettle library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at your
 * option) any later version.
 * 
 * The nettle library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 * License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with the nettle library; see the file COPYING.LIB.  If not, write to
19 20
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02111-1301, USA.
21 22 23 24 25
 */

#ifndef NETTLE_TYPES_H
#define NETTLE_TYPES_H

26 27 28
/* Pretend these types always exists. Nettle doesn't use them. */
#define _STDINT_HAVE_INT_FAST32_T 1

29 30
#include "nettle-stdint.h"

Niels Möller's avatar
Niels Möller committed
31 32 33 34
#ifdef __cplusplus
extern "C" {
#endif

35
/* Randomness. Used by key generation and dsa signature creation. */
36 37
typedef void nettle_random_func(void *ctx,
				unsigned length, uint8_t *dst);
38 39

/* Progress report function, mainly for key generation. */
40 41 42 43
typedef void nettle_progress_func(void *ctx, int c);

/* Realloc function, used by struct nettle_buffer. */
typedef void *nettle_realloc_func(void *ctx, void *p, unsigned length);
44 45

/* Ciphers */
46
typedef void nettle_set_key_func(void *ctx,
47
				 size_t length,
48
				 const uint8_t *key);
49

50 51 52 53 54 55
/* Uses a void * for cipher contexts.

   For block ciphers it would make sense with a const void * for the
   context, but we use the same typedef for stream ciphers where the
   internal state changes during the encryption. */

56
typedef void nettle_crypt_func(void *ctx,
57
			       size_t length, uint8_t *dst,
58
			       const uint8_t *src);
59 60

/* Hash algorithms */
61 62 63 64 65 66
typedef void nettle_hash_init_func(void *ctx);
typedef void nettle_hash_update_func(void *ctx,
				     unsigned length,
				     const uint8_t *src);
typedef void nettle_hash_digest_func(void *ctx,
				     unsigned length, uint8_t *dst);
67 68 69

/* ASCII armor codecs. NOTE: Experimental and subject to change. */

70 71
typedef unsigned nettle_armor_length_func(unsigned length);
typedef void nettle_armor_init_func(void *ctx);
72

73 74 75 76
typedef unsigned nettle_armor_encode_update_func(void *ctx,
						 uint8_t *dst,
						 unsigned src_length,
						 const uint8_t *src);
77

78
typedef unsigned nettle_armor_encode_final_func(void *ctx, uint8_t *dst);
79

80 81 82 83 84
typedef int nettle_armor_decode_update_func(void *ctx,
					    unsigned *dst_length,
					    uint8_t *dst,
					    unsigned src_length,
					    const uint8_t *src);
85

86
typedef int nettle_armor_decode_final_func(void *ctx);
87

Niels Möller's avatar
Niels Möller committed
88 89 90
#ifdef __cplusplus
}
#endif
91

Niels Möller's avatar
Niels Möller committed
92
#endif /* NETTLE_TYPES_H */