2 * Copyright (C) 2017 Tobias Brunner
3 * Copyright (C) 2016 Andreas Steffen
5 * Copyright (C) secunet Security Networks AG
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
12 * This program 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 General Public License
26 typedef enum ext_out_function_t ext_out_function_t
;
27 typedef struct xof_t xof_t
;
32 * Extendable Output Functions.
34 enum ext_out_function_t
{
36 /** RFC 8017 PKCS#1 */
38 /** RFC 8017 PKCS#1 */
40 /** RFC 8017 PKCS#1 */
42 /** RFC 8017 PKCS#1 */
44 /** RFC 8017 PKCS#1 */
50 /** RFC 7539 ChaCha20 */
55 * enum name for ext_out_function_t.
57 extern enum_name_t
*ext_out_function_names
;
60 * Generic interface for Extended Output Function (XOF)
65 * Return the type of the Extended Output Function
69 ext_out_function_t (*get_type
)(xof_t
*this);
72 * Generates pseudo random bytes and writes them in the buffer.
74 * @param out_len number of output bytes requested
75 * @param buffer pointer where the generated bytes will be written
76 * @return TRUE if bytes generated successfully
78 bool (*get_bytes
)(xof_t
*this, size_t out_len
,
79 uint8_t *buffer
) __attribute__((warn_unused_result
));
82 * Generates pseudo random bytes and allocate space for them.
84 * @param out_len number of output bytes requested
85 * @param chunk chunk which will hold generated bytes
86 * @return TRUE if bytes allocated and generated successfully
88 bool (*allocate_bytes
)(xof_t
*this, size_t out_len
,
89 chunk_t
*chunk
) __attribute__((warn_unused_result
));
92 * Get the output block size
94 * @return block size in bytes
96 size_t (*get_block_size
)(xof_t
*this);
99 * Get the recommended minimum seed size
101 * @return seed size in bytes
103 size_t (*get_seed_size
)(xof_t
*this);
106 * Set the key for this xof_t object.
108 * @param seed seed to set
109 * @return TRUE if XOF initialized with seed successfully
111 bool (*set_seed
)(xof_t
*this,
112 chunk_t seed
) __attribute__((warn_unused_result
));
115 * Destroys a xof object.
117 void (*destroy
)(xof_t
*this);
121 * Determine an MGF1 XOF type for the given hash algorithm.
123 * @param alg hash algorithm to map
124 * @return MGF1 XOF type if available, XOF_UNDEFINED otherwise
126 ext_out_function_t
xof_mgf1_from_hash_algorithm(hash_algorithm_t alg
);
128 #endif /** XOF_H_ @}*/