| 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 | }; | 
|---|
| 52 |  | 
|---|
| 53 | /* Randomness. Used by key generation and dsa signature creation. */ | 
|---|
| 54 | typedef void nettle_random_func(void *ctx, | 
|---|
| 55 | size_t length, uint8_t *dst); | 
|---|
| 56 |  | 
|---|
| 57 | /* Progress report function, mainly for key generation. */ | 
|---|
| 58 | typedef void nettle_progress_func(void *ctx, int c); | 
|---|
| 59 |  | 
|---|
| 60 | /* Realloc function, used by struct nettle_buffer. */ | 
|---|
| 61 | typedef void *nettle_realloc_func(void *ctx, void *p, size_t length); | 
|---|
| 62 |  | 
|---|
| 63 | /* Ciphers */ | 
|---|
| 64 | typedef void nettle_set_key_func(void *ctx, const uint8_t *key); | 
|---|
| 65 |  | 
|---|
| 66 | /* For block ciphers, const context. */ | 
|---|
| 67 | typedef void nettle_cipher_func(const void *ctx, | 
|---|
| 68 | size_t length, uint8_t *dst, | 
|---|
| 69 | const uint8_t *src); | 
|---|
| 70 |  | 
|---|
| 71 |  | 
|---|
| 72 | /* Uses a void * for cipher contexts. Used for crypt operations where | 
|---|
| 73 | the internal state changes during the encryption. */ | 
|---|
| 74 | typedef void nettle_crypt_func(void *ctx, | 
|---|
| 75 | size_t length, uint8_t *dst, | 
|---|
| 76 | const uint8_t *src); | 
|---|
| 77 |  | 
|---|
| 78 | /* Hash algorithms */ | 
|---|
| 79 | typedef void nettle_hash_init_func(void *ctx); | 
|---|
| 80 | typedef void nettle_hash_update_func(void *ctx, | 
|---|
| 81 | size_t length, | 
|---|
| 82 | const uint8_t *src); | 
|---|
| 83 | typedef void nettle_hash_digest_func(void *ctx, | 
|---|
| 84 | size_t length, uint8_t *dst); | 
|---|
| 85 |  | 
|---|
| 86 | /* ASCII armor codecs. NOTE: Experimental and subject to change. */ | 
|---|
| 87 |  | 
|---|
| 88 | typedef size_t nettle_armor_length_func(size_t length); | 
|---|
| 89 | typedef void nettle_armor_init_func(void *ctx); | 
|---|
| 90 |  | 
|---|
| 91 | typedef size_t nettle_armor_encode_update_func(void *ctx, | 
|---|
| 92 | char *dst, | 
|---|
| 93 | size_t src_length, | 
|---|
| 94 | const uint8_t *src); | 
|---|
| 95 |  | 
|---|
| 96 | typedef size_t nettle_armor_encode_final_func(void *ctx, char *dst); | 
|---|
| 97 |  | 
|---|
| 98 | typedef int nettle_armor_decode_update_func(void *ctx, | 
|---|
| 99 | size_t *dst_length, | 
|---|
| 100 | uint8_t *dst, | 
|---|
| 101 | size_t src_length, | 
|---|
| 102 | const char *src); | 
|---|
| 103 |  | 
|---|
| 104 | typedef int nettle_armor_decode_final_func(void *ctx); | 
|---|
| 105 |  | 
|---|
| 106 | #ifdef __cplusplus | 
|---|
| 107 | } | 
|---|
| 108 | #endif | 
|---|
| 109 |  | 
|---|
| 110 | #endif /* NETTLE_TYPES_H */ | 
|---|
| 111 |  | 
|---|