Annotation of embedaddon/strongswan/src/libstrongswan/crypto/xofs/xof.h, revision 1.1.1.1
1.1 misho 1: /*
2: * Copyright (C) 2017 Tobias Brunner
3: * Copyright (C) 2016 Andreas Steffen
4: * HSR Hochschule fuer Technik Rapperswil
5: *
6: * This program is free software; you can redistribute it and/or modify it
7: * under the terms of the GNU General Public License as published by the
8: * Free Software Foundation; either version 2 of the License, or (at your
9: * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14: * for more details.
15: */
16:
17: /**
18: * @defgroup xof xof
19: * @{ @ingroup crypto
20: */
21:
22: #ifndef XOF_H_
23: #define XOF_H_
24:
25: typedef enum ext_out_function_t ext_out_function_t;
26: typedef struct xof_t xof_t;
27:
28: #include <library.h>
29:
30: /**
31: * Extendable Output Functions.
32: */
33: enum ext_out_function_t {
34: XOF_UNDEFINED,
35: /** RFC 8017 PKCS#1 */
36: XOF_MGF1_SHA1,
37: /** RFC 8017 PKCS#1 */
38: XOF_MGF1_SHA224,
39: /** RFC 8017 PKCS#1 */
40: XOF_MGF1_SHA256,
41: /** RFC 8017 PKCS#1 */
42: XOF_MGF1_SHA384,
43: /** RFC 8017 PKCS#1 */
44: XOF_MGF1_SHA512,
45: /** FIPS 202 */
46: XOF_SHAKE_128,
47: /** FIPS 202 */
48: XOF_SHAKE_256,
49: /** RFC 7539 ChaCha20 */
50: XOF_CHACHA20,
51: };
52:
53: /**
54: * enum name for ext_out_function_t.
55: */
56: extern enum_name_t *ext_out_function_names;
57:
58: /**
59: * Generic interface for Extended Output Function (XOF)
60: */
61: struct xof_t {
62:
63: /**
64: * Return the type of the Extended Output Function
65: *
66: * @return XOF type
67: */
68: ext_out_function_t (*get_type)(xof_t *this);
69:
70: /**
71: * Generates pseudo random bytes and writes them in the buffer.
72: *
73: * @param out_len number of output bytes requested
74: * @param buffer pointer where the generated bytes will be written
75: * @return TRUE if bytes generated successfully
76: */
77: bool (*get_bytes)(xof_t *this, size_t out_len,
78: uint8_t *buffer) __attribute__((warn_unused_result));
79:
80: /**
81: * Generates pseudo random bytes and allocate space for them.
82: *
83: * @param out_len number of output bytes requested
84: * @param chunk chunk which will hold generated bytes
85: * @return TRUE if bytes allocated and generated successfully
86: */
87: bool (*allocate_bytes)(xof_t *this, size_t out_len,
88: chunk_t *chunk) __attribute__((warn_unused_result));
89:
90: /**
91: * Get the output block size
92: *
93: * @return block size in bytes
94: */
95: size_t (*get_block_size)(xof_t *this);
96:
97: /**
98: * Get the recommended minimum seed size
99: *
100: * @return seed size in bytes
101: */
102: size_t (*get_seed_size)(xof_t *this);
103:
104: /**
105: * Set the key for this xof_t object.
106: *
107: * @param sed seed to set
108: * @return TRUE if XOF initialized with seed successfully
109: */
110: bool (*set_seed)(xof_t *this,
111: chunk_t seed) __attribute__((warn_unused_result));
112:
113: /**
114: * Destroys a xof object.
115: */
116: void (*destroy)(xof_t *this);
117: };
118:
119: /**
120: * Determine an MGF1 XOF type for the given hash algorithm.
121: *
122: * @param alg hash algorithm to map
123: * @return MGF1 XOF type if available, XOF_UNDEFINED otherwise
124: */
125: ext_out_function_t xof_mgf1_from_hash_algorithm(hash_algorithm_t alg);
126:
127: #endif /** XOF_H_ @}*/
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>