Implemented ntru_private_key class
[strongswan.git] / src / libstrongswan / plugins / ntru / ntru_private_key.h
1 /*
2 * Copyright (C) 2014 Andreas Steffen
3 * HSR Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup ntru_private_key ntru_private_key
18 * @{ @ingroup ntru_p
19 */
20
21 #ifndef NTRU_PRIVATE_KEY_H_
22 #define NTRU_PRIVATE_KEY_H_
23
24 typedef struct ntru_private_key_t ntru_private_key_t;
25
26 #include "ntru_drbg.h"
27 #include "ntru_param_set.h"
28 #include "ntru_public_key.h"
29
30 #include <library.h>
31
32 /**
33 * Implements an NTRU encryption public/private key pair
34 */
35 struct ntru_private_key_t {
36
37
38 /**
39 * Returns the NTRU encryption public key as an encoded binary blob
40 *
41 * @return NTRU encryption public key (must be freed after use)
42 */
43 ntru_public_key_t* (*get_public_key)(ntru_private_key_t *this);
44
45 /**
46 * Returns the packed encoding of the NTRU encryption private key
47 *
48 * @return Packed encoding of NTRU encryption private key
49 */
50 chunk_t (*get_encoding)(ntru_private_key_t *this);
51
52 /**
53 * Decrypts an NTRU ciphertext
54 *
55 * @param ciphertext NTRU Ciphertext
56 * @param plaintext Plaintext
57 * @return TRUE if decryption was successful
58 */
59 bool (*decrypt)(ntru_private_key_t *this, chunk_t ciphertext,
60 chunk_t *plaintext);
61
62 /**
63 * Destroy ntru_private_key_t object
64 */
65 void (*destroy)(ntru_private_key_t *this);
66 };
67
68 /**
69 * Creates an NTRU encryption public/private key pair using a NIST DRBG
70 *
71 * @param drbg Digital Random Bit Generator used for key generation
72 * @param params NTRU encryption parameter set to be used
73 */
74 ntru_private_key_t *ntru_private_key_create(ntru_drbg_t *drbg, ntru_param_set_t *params);
75
76
77 #endif /** NTRU_PRIVATE_KEY_H_ @}*/
78