summaryrefslogtreecommitdiff
path: root/src/libstrongswan/plugins/ntru/ntru_trits.h
blob: e489aae7a288788b8510efa24e3eaac88750fcf5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
 * Copyright (C) 2013-2016 Andreas Steffen
 * HSR Hochschule fuer Technik Rapperswil
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
 *
 * This program 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 General Public License
 * for more details.
 */

/**
 * @defgroup ntru_trits ntru_trits
 * @{ @ingroup ntru_p
 */

#ifndef NTRU_TRITS_H_
#define NTRU_TRITS_H_

typedef struct ntru_trits_t ntru_trits_t;

#include <library.h>
#include <crypto/xofs/xof.h>

/**
 * Implements an array of trinary elements (trits) 
 */
struct ntru_trits_t {

	/**
	 * Get the size of the trits array
	 *
	 * @return			number of trinary elements
	 */
	size_t (*get_size)(ntru_trits_t *this);

	/**
	 * @return			octet array containing a trit per octet
	 */
	uint8_t* (*get_trits)(ntru_trits_t *this);

	/**
	 * Destroy ntru_trits_t object
	 */
	void (*destroy)(ntru_trits_t *this);
};

/**
 * Create a trits array from a seed using MGF1 with a base hash function
 *
 * @param size			size of the trits array
 * @param alg			MGF1 algorithm used (XOF_MGF1_SHA1 or XOF_MGF_SHA256)
 * @param seed			seed used by MGF1 to generate trits from
 */
ntru_trits_t *ntru_trits_create(size_t size, ext_out_function_t alg,
								chunk_t seed);

#endif /** NTRU_TRITS_H_ @}*/