Annotation of embedaddon/strongswan/src/libstrongswan/plugins/ntru/ntru_public_key.h, revision 1.1.1.1

1.1       misho       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_public_key ntru_public_key
                     18:  * @{ @ingroup ntru_p
                     19:  */
                     20: 
                     21: #ifndef NTRU_PUBLIC_KEY_H_
                     22: #define NTRU_PUBLIC_KEY_H_
                     23: 
                     24: typedef struct ntru_public_key_t ntru_public_key_t;
                     25: 
                     26: #include "ntru_param_set.h"
                     27: 
                     28: #include <library.h>
                     29: #include <crypto/drbgs/drbg.h>
                     30: 
                     31: /**
                     32:  * Implements an NTRU encryption public key
                     33:  */
                     34: struct ntru_public_key_t {
                     35: 
                     36:        /**
                     37:         * Returns NTRU parameter set ID of the public key
                     38:         *
                     39:         * @return                      NTRU parameter set ID
                     40:         */
                     41:        ntru_param_set_id_t (*get_id)(ntru_public_key_t *this);
                     42: 
                     43:        /**
                     44:         * Returns the packed encoding of the NTRU encryption public key
                     45:         *
                     46:         * @return                      Packed encoding of NTRU encryption public key
                     47:         */
                     48:        chunk_t (*get_encoding)(ntru_public_key_t *this);
                     49: 
                     50:        /**
                     51:         * Encrypts a plaintext with the NTRU public key
                     52:         *
                     53:         * @param ciphertext    Plaintext
                     54:         * @param plaintext             Ciphertext
                     55:         * @return                              TRUE if encryption was successful
                     56:         */
                     57:        bool (*encrypt)(ntru_public_key_t *this, chunk_t plaintext,
                     58:                                        chunk_t *ciphertext);
                     59: 
                     60:        /**
                     61:         * Destroy ntru_public_key_t object
                     62:         */
                     63:        void (*destroy)(ntru_public_key_t *this);
                     64: };
                     65: 
                     66: /**
                     67:  * Creates an NTRU encryption public key from coefficients
                     68:  *
                     69:  * @param drbg                 Deterministic random bit generator
                     70:  * @param params               NTRU encryption parameter set to be used
                     71:  * @param pubkey               Coefficients of public key polynomial h
                     72:  */
                     73: ntru_public_key_t *ntru_public_key_create(drbg_t *drbg,
                     74:                                                                                  const ntru_param_set_t *params,
                     75:                                                                                  uint16_t *pubkey);
                     76: 
                     77: /**
                     78:  * Creates an NTRU encryption public key from encoding
                     79:  *
                     80:  * @param drbg                 Deterministic random bit generator
                     81:  * @param data                 Encoded NTRU public key
                     82:  */
                     83: ntru_public_key_t *ntru_public_key_create_from_data(drbg_t *drbg,
                     84:                                                                                                        chunk_t data);
                     85: 
                     86: 
                     87: #endif /** NTRU_PUBLIC_KEY_H_ @}*/
                     88: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>