Refactored ntru_param_sets
authorAndreas Steffen <andreas.steffen@strongswan.org>
Fri, 7 Mar 2014 14:43:42 +0000 (15:43 +0100)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Fri, 7 Mar 2014 20:56:33 +0000 (21:56 +0100)
src/libstrongswan/plugins/ntru/Makefile.am
src/libstrongswan/plugins/ntru/ntru_crypto/ntru_crypto.h
src/libstrongswan/plugins/ntru/ntru_crypto/ntru_crypto_ntru_encrypt.c
src/libstrongswan/plugins/ntru/ntru_crypto/ntru_crypto_ntru_encrypt_key.c
src/libstrongswan/plugins/ntru/ntru_crypto/ntru_crypto_ntru_encrypt_key.h
src/libstrongswan/plugins/ntru/ntru_crypto/ntru_crypto_ntru_encrypt_param_sets.c [deleted file]
src/libstrongswan/plugins/ntru/ntru_crypto/ntru_crypto_ntru_encrypt_param_sets.h [deleted file]
src/libstrongswan/plugins/ntru/ntru_ke.c
src/libstrongswan/plugins/ntru/ntru_param_set.c [new file with mode: 0644]
src/libstrongswan/plugins/ntru/ntru_param_set.h [new file with mode: 0644]

index b33cbc8..d5bf8b9 100644 (file)
@@ -15,6 +15,7 @@ libstrongswan_ntru_la_SOURCES = \
        ntru_drbg.h ntru_drbg.c \
        ntru_ke.h ntru_ke.c \
        ntru_mgf1.h ntru_mgf1.c \
+       ntru_param_set.h ntru_param_set.c \
        ntru_poly.h ntru_poly.c \
        ntru_trits.h ntru_trits.c \
        ntru_crypto/ntru_crypto.h \
@@ -23,8 +24,6 @@ libstrongswan_ntru_la_SOURCES = \
        ntru_crypto/ntru_crypto_ntru_encrypt.c \
        ntru_crypto/ntru_crypto_ntru_encrypt_key.h \
        ntru_crypto/ntru_crypto_ntru_encrypt_key.c \
-       ntru_crypto/ntru_crypto_ntru_encrypt_param_sets.h \
-       ntru_crypto/ntru_crypto_ntru_encrypt_param_sets.c \
        ntru_crypto/ntru_crypto_ntru_poly.h \
        ntru_crypto/ntru_crypto_ntru_poly.c
 
index 72f4703..677b6d0 100644 (file)
@@ -36,6 +36,7 @@
 
 #include <library.h>
 
+#include "ntru_param_set.h"
 #include "ntru_drbg.h"
 
 #if !defined( NTRUCALL )
   #endif
 #endif /* NTRUCALL */
 
-/* parameter set ID list */
-
-typedef enum _NTRU_ENCRYPT_PARAM_SET_ID {
-    NTRU_EES401EP1,
-    NTRU_EES449EP1,
-    NTRU_EES677EP1,
-    NTRU_EES1087EP2,
-    NTRU_EES541EP1,
-    NTRU_EES613EP1,
-    NTRU_EES887EP1,
-    NTRU_EES1171EP1,
-    NTRU_EES659EP1,
-    NTRU_EES761EP1,
-    NTRU_EES1087EP1,
-    NTRU_EES1499EP1,
-    NTRU_EES401EP2,
-    NTRU_EES439EP1,
-    NTRU_EES593EP1,
-    NTRU_EES743EP1,
-} NTRU_ENCRYPT_PARAM_SET_ID;
-
-
 /* error codes */
 
 #define NTRU_OK                     0
@@ -219,7 +198,7 @@ ntru_crypto_ntru_decrypt(
 NTRUCALL
 ntru_crypto_ntru_encrypt_keygen(
     ntru_drbg_t               *drbg,             /*     in - handle of DRBG */
-    NTRU_ENCRYPT_PARAM_SET_ID  param_set_id,     /*     in - parameter set ID */
+    ntru_param_set_id_t        param_set_id,     /*     in - parameter set ID */
     uint16_t                  *pubkey_blob_len,  /* in/out - no. of octets in
                                                              pubkey_blob, addr
                                                              for no. of octets
index dba8191..8ebcf2c 100644 (file)
 #include <string.h>
 #include <assert.h>
 #include "ntru_crypto.h"
-#include "ntru_crypto_ntru_encrypt_param_sets.h"
 #include "ntru_crypto_ntru_encrypt_key.h"
 #include "ntru_crypto_ntru_convert.h"
 #include "ntru_crypto_ntru_poly.h"
-#
+
+#include "ntru_param_set.h"
 #include "ntru_trits.h"
 #include "ntru_poly.h"
 
@@ -87,7 +87,7 @@ ntru_crypto_ntru_encrypt(
                                                  no. of octets in ciphertext */
     uint8_t        *ct)              /*    out - address for ciphertext */
 {
-    NTRU_ENCRYPT_PARAM_SET *params = NULL;
+    ntru_param_set_t       *params = NULL;
     uint8_t const          *pubkey_packed = NULL;
     uint8_t                 pubkey_pack_type = 0x00;
     uint16_t                packed_ct_len;
@@ -216,7 +216,7 @@ ntru_crypto_ntru_encrypt(
                {
 
             /* form sData (OID || m || b || hTrunc) */
-            memcpy(ptr, params->OID, 3);
+            memcpy(ptr, params->oid, 3);
             ptr += 3;
             memcpy(ptr, pt, pt_len);
             ptr += pt_len;
@@ -411,7 +411,7 @@ ntru_crypto_ntru_decrypt(
                                                  no. of octets in plaintext */
     uint8_t       *pt)               /*    out - address for plaintext */
 {
-    NTRU_ENCRYPT_PARAM_SET *params = NULL;
+    ntru_param_set_t       *params = NULL;
     uint8_t const          *privkey_packed = NULL;
     uint8_t const          *pubkey_packed = NULL;
     uint8_t                 privkey_pack_type = 0x00;
@@ -691,7 +691,7 @@ ntru_crypto_ntru_decrypt(
         /* form sData (OID || m || b || hTrunc) */
 
         ptr = tmp_buf;
-        memcpy(ptr, params->OID, 3);
+        memcpy(ptr, params->oid, 3);
         ptr += 3;
         memcpy(ptr, m_buf, cm_len);
         ptr += cm_len;
@@ -803,7 +803,7 @@ ntru_crypto_ntru_decrypt(
 uint32_t
 ntru_crypto_ntru_encrypt_keygen(
     ntru_drbg_t               *drbg,             /*     in - handle of DRBG */
-    NTRU_ENCRYPT_PARAM_SET_ID  param_set_id,     /*     in - parameter set ID */
+    ntru_param_set_id_t        param_set_id,     /*     in - parameter set ID */
     uint16_t                  *pubkey_blob_len,  /* in/out - no. of octets in
                                                              pubkey_blob, addr
                                                              for no. of octets
@@ -817,7 +817,7 @@ ntru_crypto_ntru_encrypt_keygen(
     uint8_t                   *privkey_blob)     /*    out - address for
                                                              private key blob */
 {
-    NTRU_ENCRYPT_PARAM_SET *params = NULL;
+    ntru_param_set_t       *params = NULL;
     uint16_t                public_key_blob_len;
     uint16_t                private_key_blob_len;
     uint8_t                 pubkey_pack_type;
@@ -840,22 +840,20 @@ ntru_crypto_ntru_encrypt_keygen(
        ntru_poly_t            *g_poly = NULL;
        uint16_t                           *F_indices;
 
-    /* get a pointer to the parameter-set parameters */
-
-    if ((params = ntru_encrypt_get_params_with_id(param_set_id)) == NULL)
+       /* get a pointer to the parameter-set parameters */
+       params = ntru_param_set_get_by_id(param_set_id);
+       if (!params)
        {
                return NTRU_INVALID_PARAMETER_SET;
        }
 
     /* check for bad parameters */
-
     if (!pubkey_blob_len || !privkey_blob_len)
        {
                return NTRU_BAD_PARAMETER;
        }
 
     /* get public and private key packing types and blob lengths */
-
     ntru_crypto_ntru_encrypt_key_get_blob_params(params, &pubkey_pack_type,
                                                  &public_key_blob_len,
                                                  &privkey_pack_type,
index 90baaad..dec6bbc 100644 (file)
@@ -60,7 +60,7 @@ ntru_crypto_ntru_encrypt_key_parse(
                                                          packing type */
     uint8_t                 *privkey_pack_type, /* out - addr for privkey
                                                          packing type */
-    NTRU_ENCRYPT_PARAM_SET **params,            /* out - addr for ptr to
+    ntru_param_set_t       **params,            /* out - addr for ptr to
                                                          parameter set */
     uint8_t const          **pubkey,            /* out - addr for ptr to
                                                          packed pubkey */
@@ -69,14 +69,7 @@ ntru_crypto_ntru_encrypt_key_parse(
 {
     uint8_t tag;
 
-    assert(key_blob_len);
-    assert(key_blob);
-    assert(pubkey_pack_type);
-    assert(params);
-    assert(pubkey);
-
     /* parse key blob based on tag */
-
     tag = key_blob[0];
     switch (tag) {
         case NTRU_ENCRYPT_PUBKEY_TAG:
@@ -110,7 +103,7 @@ ntru_crypto_ntru_encrypt_key_parse(
              */
 
         {
-            NTRU_ENCRYPT_PARAM_SET *p = NULL;
+            ntru_param_set_t *p = NULL;
             uint16_t pubkey_packed_len;
 
             /* check OID length and minimum blob length for tag and OID */
@@ -118,10 +111,12 @@ ntru_crypto_ntru_encrypt_key_parse(
             if ((key_blob_len < 5) || (key_blob[1] != 3))
                 return FALSE;
 
-            /* get a pointer to the parameter set corresponding to the OID */
-
-            if ((p = ntru_encrypt_get_params_with_OID(key_blob + 2)) == NULL)
-                return FALSE;
+                       /* get a pointer to the parameter set corresponding to the OID */
+                       p = ntru_param_set_get_by_oid(key_blob + 2);
+                       if (!p)
+                       {
+                               return FALSE;
+                       }
 
             /* check blob length and assign pointers to blob fields */
 
@@ -203,7 +198,7 @@ ntru_crypto_ntru_encrypt_key_parse(
 
 void
 ntru_crypto_ntru_encrypt_key_get_blob_params(
-    NTRU_ENCRYPT_PARAM_SET const *params,             /*  in - pointer to
+    ntru_param_set_t             *params,             /*  in - pointer to
                                                                param set
                                                                parameters */
     uint8_t                      *pubkey_pack_type,   /* out - addr for pubkey
@@ -260,7 +255,7 @@ ntru_crypto_ntru_encrypt_key_get_blob_params(
 
 void
 ntru_crypto_ntru_encrypt_key_create_pubkey_blob(
-    NTRU_ENCRYPT_PARAM_SET const *params,             /*  in - pointer to
+    ntru_param_set_t             *params,             /*  in - pointer to
                                                                param set
                                                                parameters */
     uint16_t const               *pubkey,             /*  in - pointer to the
@@ -278,9 +273,9 @@ ntru_crypto_ntru_encrypt_key_create_pubkey_blob(
     switch (pubkey_pack_type) {
         case NTRU_ENCRYPT_KEY_PACKED_COEFFICIENTS:
             *pubkey_blob++ = NTRU_ENCRYPT_PUBKEY_TAG;
-            *pubkey_blob++ = (uint8_t)sizeof(params->OID);
-            memcpy(pubkey_blob, params->OID, sizeof(params->OID));
-            pubkey_blob += sizeof(params->OID);
+            *pubkey_blob++ = (uint8_t)sizeof(params->oid);
+            memcpy(pubkey_blob, params->oid, sizeof(params->oid));
+            pubkey_blob += sizeof(params->oid);
             ntru_elements_2_octets(params->N, pubkey, params->q_bits,
                                    pubkey_blob);
             break;
@@ -297,7 +292,7 @@ ntru_crypto_ntru_encrypt_key_create_pubkey_blob(
 
 void
 ntru_crypto_ntru_encrypt_key_create_privkey_blob(
-    NTRU_ENCRYPT_PARAM_SET const *params,             /*  in - pointer to
+    ntru_param_set_t             *params,             /*  in - pointer to
                                                                param set
                                                                parameters */
     uint16_t const               *pubkey,             /*  in - pointer to the
@@ -324,9 +319,9 @@ ntru_crypto_ntru_encrypt_key_create_privkey_blob(
             /* format header and packed public key */
 
             *privkey_blob++ = NTRU_ENCRYPT_PRIVKEY_DEFAULT_TAG;
-            *privkey_blob++ = (uint8_t)sizeof(params->OID);
-            memcpy(privkey_blob, params->OID, sizeof(params->OID));
-            privkey_blob += sizeof(params->OID);
+            *privkey_blob++ = (uint8_t)sizeof(params->oid);
+            memcpy(privkey_blob, params->oid, sizeof(params->oid));
+            privkey_blob += sizeof(params->oid);
             ntru_elements_2_octets(params->N, pubkey, params->q_bits,
                                    privkey_blob);
             privkey_blob += (params->N * params->q_bits + 7) >> 3;
index 6734f2a..c38c3fc 100644 (file)
@@ -27,8 +27,8 @@
 #define NTRU_CRYPTO_NTRU_ENCRYPT_KEY_H
 
 #include "ntru_crypto_ntru_convert.h"
-#include "ntru_crypto_ntru_encrypt_param_sets.h"
 
+#include "ntru_param_set.h"
 
 /* key-blob definitions */
 
@@ -68,7 +68,7 @@ ntru_crypto_ntru_encrypt_key_parse(
                                                          packing type */
     uint8_t                 *privkey_pack_type, /* out - addr for privkey
                                                          packing type */
-    NTRU_ENCRYPT_PARAM_SET **params,            /* out - addr for ptr to
+    ntru_param_set_t       **params,            /* out - addr for ptr to
                                                          parameter set */
     uint8_t const          **pubkey,            /* out - addr for ptr to
                                                          packed pubkey */
@@ -87,7 +87,7 @@ ntru_crypto_ntru_encrypt_key_parse(
 
 extern void
 ntru_crypto_ntru_encrypt_key_get_blob_params(
-    NTRU_ENCRYPT_PARAM_SET const *params,             /*  in - pointer to
+    ntru_param_set_t             *params,             /*  in - pointer to
                                                                param set
                                                                parameters */
     uint8_t                      *pubkey_pack_type,   /* out - addr for pubkey
@@ -109,7 +109,7 @@ ntru_crypto_ntru_encrypt_key_get_blob_params(
 
 extern void
 ntru_crypto_ntru_encrypt_key_create_pubkey_blob(
-    NTRU_ENCRYPT_PARAM_SET const *params,             /*  in - pointer to
+    ntru_param_set_t             *params,             /*  in - pointer to
                                                                param set
                                                                parameters */
     uint16_t const               *pubkey,             /*  in - pointer to the
@@ -128,7 +128,7 @@ ntru_crypto_ntru_encrypt_key_create_pubkey_blob(
 
 extern void
 ntru_crypto_ntru_encrypt_key_recreate_pubkey_blob(
-    NTRU_ENCRYPT_PARAM_SET const *params,             /*  in - pointer to
+    ntru_param_set_t             *params,             /*  in - pointer to
                                                                param set
                                                                parameters */
     uint16_t                      packed_pubkey_len,  /*  in - no. octets in
@@ -148,7 +148,7 @@ ntru_crypto_ntru_encrypt_key_recreate_pubkey_blob(
 
 extern void
 ntru_crypto_ntru_encrypt_key_create_privkey_blob(
-    NTRU_ENCRYPT_PARAM_SET const *params,             /*  in - pointer to
+    ntru_param_set_t             *params,             /*  in - pointer to
                                                                param set
                                                                parameters */
     uint16_t const               *pubkey,             /*  in - pointer to the
diff --git a/src/libstrongswan/plugins/ntru/ntru_crypto/ntru_crypto_ntru_encrypt_param_sets.c b/src/libstrongswan/plugins/ntru/ntru_crypto/ntru_crypto_ntru_encrypt_param_sets.c
deleted file mode 100644 (file)
index 5ddf91d..0000000
+++ /dev/null
@@ -1,384 +0,0 @@
-/******************************************************************************
- * NTRU Cryptography Reference Source Code
- * Copyright (c) 2009-2013, by Security Innovation, Inc. All rights reserved. 
- *
- * ntru_crypto_ntru_param_sets.c is a component of ntru-crypto.
- *
- * Copyright (C) 2009-2013  Security Innovation
- * 
- * 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.
- * 
- * 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.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *****************************************************************************/
-/******************************************************************************
- *
- * File: ntru_crypto_ntru_encrypt_param_sets.c
- *
- * Contents: Defines the NTRUEncrypt parameter sets.
- *
- *****************************************************************************/
-
-#include <stdlib.h>
-#include <string.h>
-#include "ntru_crypto_ntru_encrypt_param_sets.h"
-
-
-/* parameter sets */
-
-static NTRU_ENCRYPT_PARAM_SET ntruParamSets[] = {
-
-    {
-        NTRU_EES401EP1,              /* parameter-set id */
-        {0x00, 0x02, 0x04},          /* OID */
-        0x22,                        /* DER id */
-        9,                           /* no. of bits in N (i.e., in an index) */
-        401,                         /* N */
-        14,                          /* security strength in octets */
-        2048,                        /* q */
-        11,                          /* no. of bits in q (i.e., in a coeff) */
-        FALSE,                       /* product form */
-        113,                         /* df, dr */
-        133,                         /* dg */
-        60,                          /* maxMsgLenBytes */
-        113,                         /* dm0 */
-        11,                          /* c */
-        1,                           /* lLen */
-    },
-
-    {
-        NTRU_EES449EP1,              /* parameter-set id */
-        {0x00, 0x03, 0x03},          /* OID */
-        0x23,                        /* DER id */
-        9,                           /* no. of bits in N (i.e., in an index) */
-        449,                         /* N */
-        16,                          /* security strength in octets */
-        2048,                        /* q */
-        11,                          /* no. of bits in q (i.e., in a coeff) */
-        FALSE,                       /* product form */
-        134,                         /* df, dr */
-        149,                         /* dg */
-        67,                          /* maxMsgLenBytes */
-        134,                         /* dm0 */
-        9,                           /* c */
-        1,                           /* lLen */
-    },
-
-    {
-        NTRU_EES677EP1,              /* parameter-set id */
-        {0x00, 0x05, 0x03},          /* OID */
-        0x24,                        /* DER id */
-        10,                          /* no. of bits in N (i.e., in an index) */
-        677,                         /* N */
-        24,                          /* security strength in octets */
-        2048,                        /* q */
-        11,                          /* no. of bits in q (i.e., in a coeff) */
-        FALSE,                       /* product form */
-        157,                         /* df, dr */
-        225,                         /* dg */
-        101,                         /* maxMsgLenBytes */
-        157,                         /* dm0 */
-        11,                          /* c */
-        1,                           /* lLen */
-    },
-
-    {
-        NTRU_EES1087EP2,             /* parameter-set id */
-        {0x00, 0x06, 0x03},          /* OID */
-        0x25,                        /* DER id */
-        10,                          /* no. of bits in N (i.e., in an index) */
-        1087,                        /* N */
-        32,                          /* security strength in octets */
-        2048,                        /* q */
-        11,                          /* no. of bits in q (i.e., in a coeff) */
-        FALSE,                       /* product form */
-        120,                         /* df, dr */
-        362,                         /* dg */
-        170,                         /* maxMsgLenBytes */
-        120,                         /* dm0 */
-        13,                          /* c */
-        1,                           /* lLen */
-    },
-
-    {
-        NTRU_EES541EP1,              /* parameter-set id */
-        {0x00, 0x02, 0x05},          /* OID */
-        0x26,                        /* DER id */
-        10,                          /* no. of bits in N (i.e., in an index) */
-        541,                         /* N */
-        14,                          /* security strength in octets */
-        2048,                        /* q */
-        11,                          /* no. of bits in q (i.e., in a coeff) */
-        FALSE,                       /* product form */
-        49,                          /* df, dr */
-        180,                         /* dg */
-        86,                          /* maxMsgLenBytes */
-        49,                          /* dm0 */
-        12,                          /* c */
-        1,                           /* lLen */
-    },
-
-    {
-        NTRU_EES613EP1,              /* parameter-set id */
-        {0x00, 0x03, 0x04},          /* OID */
-        0x27,                        /* DER id */
-        10,                          /* no. of bits in N (i.e., in an index) */
-        613,                         /* N */
-        16,                          /* securuity strength in octets */
-        2048,                        /* q */
-        11,                          /* no. of bits in q (i.e., in a coeff) */
-        FALSE,                       /* product form */
-        55,                          /* df, dr */
-        204,                         /* dg */
-        97,                          /* maxMsgLenBytes */
-        55,                          /* dm0 */
-        11,                          /* c */
-        1,                           /* lLen */
-    },
-
-    {
-        NTRU_EES887EP1,              /* parameter-set id */
-        {0x00, 0x05, 0x04},          /* OID */
-        0x28,                        /* DER id */
-        10,                          /* no. of bits in N (i.e., in an index) */
-        887,                         /* N */
-        24,                          /* security strength in octets */
-        2048,                        /* q */
-        11,                          /* no. of bits in q (i.e., in a coeff) */
-        FALSE,                       /* product form */
-        81,                          /* df, dr */
-        295,                         /* dg */
-        141,                         /* maxMsgLenBytes */
-        81,                          /* dm0 */
-        10,                          /* c */
-        1,                           /* lLen */
-    },
-
-    {
-        NTRU_EES1171EP1,             /* parameter-set id */
-        {0x00, 0x06, 0x04},          /* OID */
-        0x29,                        /* DER id */
-        11,                          /* no. of bits in N (i.e., in an index) */
-        1171,                        /* N */
-        32,                          /* security strength in octets */
-        2048,                        /* q */
-        11,                          /* no. of bits in q (i.e., in a coeff) */
-        FALSE,                       /* product form */
-        106,                         /* df, dr */
-        390,                         /* dg */
-        186,                         /* maxMsgLenBytes */
-        106,                         /* dm0 */
-        12,                          /* c */
-        1,                           /* lLen */
-    },
-
-    {
-        NTRU_EES659EP1,              /* parameter-set id */
-        {0x00, 0x02, 0x06},          /* OID */
-        0x2a,                        /* DER id */
-        10,                          /* no. of bits in N (i.e., in an index) */
-        659,                         /* N */
-        14,                          /* security strength in octets */
-        2048,                        /* q */
-        11,                          /* no. of bits in q (i.e., in a coeff) */
-        FALSE,                       /* product form */
-        38,                          /* df, dr */
-        219,                         /* dg */
-        108,                         /* maxMsgLenBytes */
-        38,                          /* dm0 */
-        11,                          /* c */
-        1,                           /* lLen */
-    },
-
-    {
-        NTRU_EES761EP1,              /* parameter-set id */
-        {0x00, 0x03, 0x05},          /* OID */
-        0x2b,                        /* DER id */
-        10,                          /* no. of bits in N (i.e., in an index) */
-        761,                         /* N */
-        16,                          /* security strength in octets */
-        2048,                        /* q */
-        11,                          /* no. of bits in q (i.e., in a coeff) */
-        FALSE,                       /* product form */
-        42,                          /* df, dr */
-        253,                         /* dg */
-        125,                         /* maxMsgLenBytes */
-        42,                          /* dm0 */
-        12,                          /* c */
-        1,                           /* lLen */
-    },
-
-    {
-        NTRU_EES1087EP1,             /* parameter-set id */
-        {0x00, 0x05, 0x05},          /* OID */
-        0x2c,                        /* DER id */
-        11,                          /* no. of bits in N (i.e., in an index) */
-        1087,                        /* N */
-        24,                          /* security strength in octets */
-        2048,                        /* q */
-        11,                          /* no. of bits in q (i.e., in a coeff) */
-        FALSE,                       /* product form */
-        63,                          /* df, dr */
-        362,                         /* dg */
-        178,                         /* maxMsgLenBytes */
-        63,                          /* dm0 */
-        13,                          /* c */
-        1,                           /* lLen */
-    },
-
-    {
-        NTRU_EES1499EP1,             /* parameter-set id */
-        {0x00, 0x06, 0x05},          /* OID */
-        0x2d,                        /* DER id */
-        11,                          /* no. of bits in N (i.e., in an index) */
-        1499,                        /* N */
-        32,                          /* security strength in octets */
-        2048,                        /* q */
-        11,                          /* no. of bits in q (i.e., in a coeff) */
-        FALSE,                       /* product form */
-        79,                          /* df, dr */
-        499,                         /* dg */
-        247,                         /* maxMsgLenBytes */
-        79,                          /* dm0 */
-        13,                          /* c */
-        1,                           /* lLen */
-    },
-
-    {
-        NTRU_EES401EP2,              /* parameter-set id */
-        {0x00, 0x02, 0x10},          /* OID */
-        0x2e,                        /* DER id */
-        9,                           /* no. of bits in N (i.e., in an index) */
-        401,                         /* N */
-        14,                          /* security strength in octets */
-        2048,                        /* q */
-        11,                          /* no. of bits in q (i.e., in a coeff) */
-        TRUE,                        /* product form */
-        8 + (8 << 8) + (6 << 16),    /* df, dr */
-        133,                         /* dg */
-        60,                          /* maxMsgLenBytes */
-        136,                         /* m(1)_max */
-        11,                          /* c */
-        1,                           /* lLen */
-   },
-
-    {
-        NTRU_EES439EP1,              /* parameter-set id */
-        {0x00, 0x03, 0x10},          /* OID */
-        0x2f,                        /* DER id */
-        9,                           /* no. of bits in N (i.e., in an index) */
-        439,                         /* N */
-        16,                          /* security strength in octets */
-        2048,                        /* q */
-        11,                          /* no. of bits in q (i.e., in a coeff) */
-        TRUE,                        /* product form */
-        9 + (8 << 8) + (5 << 16),    /* df, dr */
-        146,                         /* dg */
-        65,                          /* maxMsgLenBytes */
-        126,                         /* m(1)_max */
-        9,                           /* c */
-        1,                           /* lLen */
-    },
-
-    {
-        NTRU_EES593EP1,              /* parameter-set id */
-        {0x00, 0x05, 0x10},          /* OID */
-        0x30,                        /* DER id */
-        10,                          /* no. of bits in N (i.e., in an index) */
-        593,                         /* N */
-        24,                          /* security strength in octets */
-        2048,                        /* q */
-        11,                          /* no. of bits in q (i.e., in a coeff) */
-        TRUE,                        /* product form */
-        10 + (10 << 8) + (8 << 16),  /* df, dr */
-        197,                         /* dg */
-        86,                          /* maxMsgLenBytes */
-        90,                          /* m(1)_max */
-        11,                          /* c */
-        1,                           /* lLen */
-    },
-
-    {
-        NTRU_EES743EP1,              /* parameter-set id */
-        {0x00, 0x06, 0x10},          /* OID */
-        0x31,                        /* DER id */
-        10,                          /* no. of bits in N (i.e., in an index) */
-        743,                         /* N */
-        32,                          /* security strength in octets */
-        2048,                        /* q */
-        11,                          /* no. of bits in q (i.e., in a coeff) */
-        TRUE,                        /* product form */
-        11 + (11 << 8) + (15 << 16), /* df, dr */
-        247,                         /* dg */
-        106,                         /* maxMsgLenBytes */
-        60,                          /* m(1)_max */
-        13,                          /* c */
-        1,                           /* lLen */
-    },
-
-};
-
-static size_t numParamSets =
-                sizeof(ntruParamSets)/sizeof(NTRU_ENCRYPT_PARAM_SET);
-
-
-/* functions */
-
-/* ntru_encrypt_get_params_with_id
- *
- * Looks up a set of NTRUEncrypt parameters based on the id of the
- * parameter set.
- *
- * Returns a pointer to the parameter set parameters if successful.
- * Returns NULL if the parameter set cannot be found.
- */
-
-NTRU_ENCRYPT_PARAM_SET *
-ntru_encrypt_get_params_with_id(
-    NTRU_ENCRYPT_PARAM_SET_ID id)   /*  in - parameter-set id */
-{
-    size_t i;
-
-    for (i = 0; i < numParamSets; i++) {
-        if (ntruParamSets[i].id == id) {
-            return &(ntruParamSets[i]);
-        }
-    }
-    return NULL;
-}
-
-
-/* ntru_encrypt_get_params_with_OID
- *
- * Looks up a set of NTRUEncrypt parameters based on the OID of the
- * parameter set.
- *
- * Returns a pointer to the parameter set parameters if successful.
- * Returns NULL if the parameter set cannot be found.
- */
-
-NTRU_ENCRYPT_PARAM_SET *
-ntru_encrypt_get_params_with_OID(
-    uint8_t const *oid)             /*  in - pointer to parameter-set OID */
-{
-    size_t i;
-
-    for (i = 0; i < numParamSets; i++) {
-        if (!memcmp(ntruParamSets[i].OID, oid, 3)) {
-            return &(ntruParamSets[i]);
-        }
-    }
-    return NULL;
-}
-
diff --git a/src/libstrongswan/plugins/ntru/ntru_crypto/ntru_crypto_ntru_encrypt_param_sets.h b/src/libstrongswan/plugins/ntru/ntru_crypto/ntru_crypto_ntru_encrypt_param_sets.h
deleted file mode 100644 (file)
index e5e977a..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/******************************************************************************
- * NTRU Cryptography Reference Source Code
- * Copyright (c) 2009-2013, by Security Innovation, Inc. All rights reserved. 
- *
- * ntru_crypto_ntru_encrypt_param_sets.h is a component of ntru-crypto.
- *
- * Copyright (C) 2009-2013  Security Innovation
- * 
- * 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.
- * 
- * 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.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *****************************************************************************/
-/******************************************************************************
- *
- * File: ntru_crypto_ntru_encrypt_param_sets.h
- *
- * Contents: Definitions and declarations for the NTRUEncrypt parameter sets.
- *
- *****************************************************************************/
-
-#ifndef NTRU_CRYPTO_NTRU_ENCRYPT_PARAM_SETS_H
-#define NTRU_CRYPTO_NTRU_ENCRYPT_PARAM_SETS_H
-
-#include "ntru_crypto.h"
-
-/* structures */
-
-typedef struct _NTRU_ENCRYPT_PARAM_SET {
-    NTRU_ENCRYPT_PARAM_SET_ID id;                 /* parameter-set ID */
-    uint8_t const             OID[3];             /* pointer to OID */
-    uint8_t                   der_id;             /* parameter-set DER id */
-    uint8_t                   N_bits;             /* no. of bits in N (i.e. in
-                                                     an index */
-    uint16_t                  N;                  /* ring dimension */
-    uint16_t                  sec_strength_len;   /* no. of octets of
-                                                     security strength */
-    uint16_t                  q;                  /* big modulus */
-    uint8_t                   q_bits;             /* no. of bits in q (i.e. in
-                                                     a coefficient */
-    bool                      is_product_form;    /* if product form used */
-    uint32_t                  dF_r;               /* no. of 1 or -1 coefficients
-                                                     in ring elements F, r */
-    uint16_t                  dg;                 /* no. - 1 of 1 coefficients
-                                                     or no. of -1 coefficients
-                                                     in ring element g */
-    uint16_t                  m_len_max;          /* max no. of plaintext
-                                                     octets */
-    uint16_t                  min_msg_rep_wt;     /* min. message
-                                                     representative weight */
-    uint8_t                   c_bits;             /* no. bits in candidate for
-                                                     deriving an index in
-                                                     IGF-2 */
-    uint8_t                   m_len_len;          /* no. of octets to hold
-                                                     mLenOctets */
-} NTRU_ENCRYPT_PARAM_SET;
-
-
-
-/* function declarations */
-
-/* ntru_encrypt_get_params_with_id
- *
- * Looks up a set of NTRU Encrypt parameters based on the id of the
- * parameter set.
- *
- * Returns a pointer to the parameter set parameters if successful.
- * Returns NULL if the parameter set cannot be found.
- */
-
-extern NTRU_ENCRYPT_PARAM_SET *
-ntru_encrypt_get_params_with_id(
-    NTRU_ENCRYPT_PARAM_SET_ID id);  /*  in - parameter-set id */
-
-
-/* ntru_encrypt_get_params_with_OID
- *
- * Looks up a set of NTRU Encrypt parameters based on the OID of the
- * parameter set.
- *
- * Returns a pointer to the parameter set parameters if successful.
- * Returns NULL if the parameter set cannot be found.
- */
-
-extern NTRU_ENCRYPT_PARAM_SET *
-ntru_encrypt_get_params_with_OID(
-    uint8_t const *oid);            /*  in - pointer to parameter-set OID */
-
-#endif /* NTRU_CRYPTO_NTRU_ENCRYPT_PARAM_SETS_H */
-
index 39fb261..a954ed1 100644 (file)
@@ -15,6 +15,7 @@
 
 #include "ntru_ke.h"
 #include "ntru_drbg.h"
+#include "ntru_param_set.h"
 
 #include "ntru_crypto/ntru_crypto.h"
 
@@ -28,7 +29,7 @@ typedef struct param_set_t param_set_t;
  * Defines an NTRU parameter set by ID or OID
  */
 struct param_set_t {
-       NTRU_ENCRYPT_PARAM_SET_ID id;
+       ntru_param_set_id_t id;
        char oid[3];
        char *name;
 };
diff --git a/src/libstrongswan/plugins/ntru/ntru_param_set.c b/src/libstrongswan/plugins/ntru/ntru_param_set.c
new file mode 100644 (file)
index 0000000..0d8a774
--- /dev/null
@@ -0,0 +1,349 @@
+/*
+ * Copyright (C) 2014 Andreas Steffen
+ * HSR Hochschule fuer Technik Rapperswil
+ *
+ * Copyright (C) 2009-2013  Security Innovation
+ *
+ * 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.
+ */
+
+#include "ntru_param_set.h"
+
+/**
+ * NTRU encryption parameter set definitions
+ */
+static ntru_param_set_t ntru_param_sets[] = {
+
+    {
+        NTRU_EES401EP1,              /* parameter-set id */
+        {0x00, 0x02, 0x04},          /* OID */
+        0x22,                        /* DER id */
+        9,                           /* no. of bits in N (i.e., in an index) */
+        401,                         /* N */
+        14,                          /* security strength in octets */
+        2048,                        /* q */
+        11,                          /* no. of bits in q (i.e., in a coeff) */
+        FALSE,                       /* product form */
+        113,                         /* df, dr */
+        133,                         /* dg */
+        60,                          /* maxMsgLenBytes */
+        113,                         /* dm0 */
+        11,                          /* c */
+        1,                           /* lLen */
+    },
+
+    {
+        NTRU_EES449EP1,              /* parameter-set id */
+        {0x00, 0x03, 0x03},          /* OID */
+        0x23,                        /* DER id */
+        9,                           /* no. of bits in N (i.e., in an index) */
+        449,                         /* N */
+        16,                          /* security strength in octets */
+        2048,                        /* q */
+        11,                          /* no. of bits in q (i.e., in a coeff) */
+        FALSE,                       /* product form */
+        134,                         /* df, dr */
+        149,                         /* dg */
+        67,                          /* maxMsgLenBytes */
+        134,                         /* dm0 */
+        9,                           /* c */
+        1,                           /* lLen */
+    },
+
+    {
+        NTRU_EES677EP1,              /* parameter-set id */
+        {0x00, 0x05, 0x03},          /* OID */
+        0x24,                        /* DER id */
+        10,                          /* no. of bits in N (i.e., in an index) */
+        677,                         /* N */
+        24,                          /* security strength in octets */
+        2048,                        /* q */
+        11,                          /* no. of bits in q (i.e., in a coeff) */
+        FALSE,                       /* product form */
+        157,                         /* df, dr */
+        225,                         /* dg */
+        101,                         /* maxMsgLenBytes */
+        157,                         /* dm0 */
+        11,                          /* c */
+        1,                           /* lLen */
+    },
+
+    {
+        NTRU_EES1087EP2,             /* parameter-set id */
+        {0x00, 0x06, 0x03},          /* OID */
+        0x25,                        /* DER id */
+        10,                          /* no. of bits in N (i.e., in an index) */
+        1087,                        /* N */
+        32,                          /* security strength in octets */
+        2048,                        /* q */
+        11,                          /* no. of bits in q (i.e., in a coeff) */
+        FALSE,                       /* product form */
+        120,                         /* df, dr */
+        362,                         /* dg */
+        170,                         /* maxMsgLenBytes */
+        120,                         /* dm0 */
+        13,                          /* c */
+        1,                           /* lLen */
+    },
+
+    {
+        NTRU_EES541EP1,              /* parameter-set id */
+        {0x00, 0x02, 0x05},          /* OID */
+        0x26,                        /* DER id */
+        10,                          /* no. of bits in N (i.e., in an index) */
+        541,                         /* N */
+        14,                          /* security strength in octets */
+        2048,                        /* q */
+        11,                          /* no. of bits in q (i.e., in a coeff) */
+        FALSE,                       /* product form */
+        49,                          /* df, dr */
+        180,                         /* dg */
+        86,                          /* maxMsgLenBytes */
+        49,                          /* dm0 */
+        12,                          /* c */
+        1,                           /* lLen */
+    },
+
+    {
+        NTRU_EES613EP1,              /* parameter-set id */
+        {0x00, 0x03, 0x04},          /* OID */
+        0x27,                        /* DER id */
+        10,                          /* no. of bits in N (i.e., in an index) */
+        613,                         /* N */
+        16,                          /* securuity strength in octets */
+        2048,                        /* q */
+        11,                          /* no. of bits in q (i.e., in a coeff) */
+        FALSE,                       /* product form */
+        55,                          /* df, dr */
+        204,                         /* dg */
+        97,                          /* maxMsgLenBytes */
+        55,                          /* dm0 */
+        11,                          /* c */
+        1,                           /* lLen */
+    },
+
+    {
+        NTRU_EES887EP1,              /* parameter-set id */
+        {0x00, 0x05, 0x04},          /* OID */
+        0x28,                        /* DER id */
+        10,                          /* no. of bits in N (i.e., in an index) */
+        887,                         /* N */
+        24,                          /* security strength in octets */
+        2048,                        /* q */
+        11,                          /* no. of bits in q (i.e., in a coeff) */
+        FALSE,                       /* product form */
+        81,                          /* df, dr */
+        295,                         /* dg */
+        141,                         /* maxMsgLenBytes */
+        81,                          /* dm0 */
+        10,                          /* c */
+        1,                           /* lLen */
+    },
+
+    {
+        NTRU_EES1171EP1,             /* parameter-set id */
+        {0x00, 0x06, 0x04},          /* OID */
+        0x29,                        /* DER id */
+        11,                          /* no. of bits in N (i.e., in an index) */
+        1171,                        /* N */
+        32,                          /* security strength in octets */
+        2048,                        /* q */
+        11,                          /* no. of bits in q (i.e., in a coeff) */
+        FALSE,                       /* product form */
+        106,                         /* df, dr */
+        390,                         /* dg */
+        186,                         /* maxMsgLenBytes */
+        106,                         /* dm0 */
+        12,                          /* c */
+        1,                           /* lLen */
+    },
+
+    {
+        NTRU_EES659EP1,              /* parameter-set id */
+        {0x00, 0x02, 0x06},          /* OID */
+        0x2a,                        /* DER id */
+        10,                          /* no. of bits in N (i.e., in an index) */
+        659,                         /* N */
+        14,                          /* security strength in octets */
+        2048,                        /* q */
+        11,                          /* no. of bits in q (i.e., in a coeff) */
+        FALSE,                       /* product form */
+        38,                          /* df, dr */
+        219,                         /* dg */
+        108,                         /* maxMsgLenBytes */
+        38,                          /* dm0 */
+        11,                          /* c */
+        1,                           /* lLen */
+    },
+
+    {
+        NTRU_EES761EP1,              /* parameter-set id */
+        {0x00, 0x03, 0x05},          /* OID */
+        0x2b,                        /* DER id */
+        10,                          /* no. of bits in N (i.e., in an index) */
+        761,                         /* N */
+        16,                          /* security strength in octets */
+        2048,                        /* q */
+        11,                          /* no. of bits in q (i.e., in a coeff) */
+        FALSE,                       /* product form */
+        42,                          /* df, dr */
+        253,                         /* dg */
+        125,                         /* maxMsgLenBytes */
+        42,                          /* dm0 */
+        12,                          /* c */
+        1,                           /* lLen */
+    },
+
+    {
+        NTRU_EES1087EP1,             /* parameter-set id */
+        {0x00, 0x05, 0x05},          /* OID */
+        0x2c,                        /* DER id */
+        11,                          /* no. of bits in N (i.e., in an index) */
+        1087,                        /* N */
+        24,                          /* security strength in octets */
+        2048,                        /* q */
+        11,                          /* no. of bits in q (i.e., in a coeff) */
+        FALSE,                       /* product form */
+        63,                          /* df, dr */
+        362,                         /* dg */
+        178,                         /* maxMsgLenBytes */
+        63,                          /* dm0 */
+        13,                          /* c */
+        1,                           /* lLen */
+    },
+
+    {
+        NTRU_EES1499EP1,             /* parameter-set id */
+        {0x00, 0x06, 0x05},          /* OID */
+        0x2d,                        /* DER id */
+        11,                          /* no. of bits in N (i.e., in an index) */
+        1499,                        /* N */
+        32,                          /* security strength in octets */
+        2048,                        /* q */
+        11,                          /* no. of bits in q (i.e., in a coeff) */
+        FALSE,                       /* product form */
+        79,                          /* df, dr */
+        499,                         /* dg */
+        247,                         /* maxMsgLenBytes */
+        79,                          /* dm0 */
+        13,                          /* c */
+        1,                           /* lLen */
+    },
+
+    {
+        NTRU_EES401EP2,              /* parameter-set id */
+        {0x00, 0x02, 0x10},          /* OID */
+        0x2e,                        /* DER id */
+        9,                           /* no. of bits in N (i.e., in an index) */
+        401,                         /* N */
+        14,                          /* security strength in octets */
+        2048,                        /* q */
+        11,                          /* no. of bits in q (i.e., in a coeff) */
+        TRUE,                        /* product form */
+        8 + (8 << 8) + (6 << 16),    /* df, dr */
+        133,                         /* dg */
+        60,                          /* maxMsgLenBytes */
+        136,                         /* m(1)_max */
+        11,                          /* c */
+        1,                           /* lLen */
+   },
+
+    {
+        NTRU_EES439EP1,              /* parameter-set id */
+        {0x00, 0x03, 0x10},          /* OID */
+        0x2f,                        /* DER id */
+        9,                           /* no. of bits in N (i.e., in an index) */
+        439,                         /* N */
+        16,                          /* security strength in octets */
+        2048,                        /* q */
+        11,                          /* no. of bits in q (i.e., in a coeff) */
+        TRUE,                        /* product form */
+        9 + (8 << 8) + (5 << 16),    /* df, dr */
+        146,                         /* dg */
+        65,                          /* maxMsgLenBytes */
+        126,                         /* m(1)_max */
+        9,                           /* c */
+        1,                           /* lLen */
+    },
+
+    {
+        NTRU_EES593EP1,              /* parameter-set id */
+        {0x00, 0x05, 0x10},          /* OID */
+        0x30,                        /* DER id */
+        10,                          /* no. of bits in N (i.e., in an index) */
+        593,                         /* N */
+        24,                          /* security strength in octets */
+        2048,                        /* q */
+        11,                          /* no. of bits in q (i.e., in a coeff) */
+        TRUE,                        /* product form */
+        10 + (10 << 8) + (8 << 16),  /* df, dr */
+        197,                         /* dg */
+        86,                          /* maxMsgLenBytes */
+        90,                          /* m(1)_max */
+        11,                          /* c */
+        1,                           /* lLen */
+    },
+
+    {
+        NTRU_EES743EP1,              /* parameter-set id */
+        {0x00, 0x06, 0x10},          /* OID */
+        0x31,                        /* DER id */
+        10,                          /* no. of bits in N (i.e., in an index) */
+        743,                         /* N */
+        32,                          /* security strength in octets */
+        2048,                        /* q */
+        11,                          /* no. of bits in q (i.e., in a coeff) */
+        TRUE,                        /* product form */
+        11 + (11 << 8) + (15 << 16), /* df, dr */
+        247,                         /* dg */
+        106,                         /* maxMsgLenBytes */
+        60,                          /* m(1)_max */
+        13,                          /* c */
+        1,                           /* lLen */
+    },
+
+};
+
+/**
+ * See header.
+ */
+ntru_param_set_t* ntru_param_set_get_by_id(ntru_param_set_id_t id)
+{
+       int i;
+
+       for (i = 0; i < countof(ntru_param_sets); i++)
+       {
+               if (ntru_param_sets[i].id == id)
+               {
+                       return &ntru_param_sets[i];
+               }
+       }
+       return NULL;
+}
+
+
+/**
+ * See header.
+ */
+ntru_param_set_t* ntru_param_set_get_by_oid(uint8_t const *oid)
+{
+       int i;
+
+       for (i = 0; i < countof(ntru_param_sets); i++)
+       {
+               if (memeq(ntru_param_sets[i].oid, oid, 3))
+               {
+                       return &ntru_param_sets[i];
+               }
+       }
+       return NULL;
+}
+
diff --git a/src/libstrongswan/plugins/ntru/ntru_param_set.h b/src/libstrongswan/plugins/ntru/ntru_param_set.h
new file mode 100644 (file)
index 0000000..548e866
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2014 Andreas Steffen
+ * HSR Hochschule fuer Technik Rapperswil
+ *
+ * Copyright (C) 2009-2013  Security Innovation
+ *
+ * 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_param_set ntru_param_set
+ * @{ @ingroup ntru_p
+ */
+
+#ifndef NTRU_PARAM_SET_H_
+#define NTRU_PARAM_SET_H_
+
+typedef enum ntru_param_set_id_t ntru_param_set_id_t;
+typedef struct ntru_param_set_t ntru_param_set_t;
+
+#include <library.h>
+
+/**
+ * NTRU encryption parameter set ID list
+ */
+enum ntru_param_set_id_t {
+       NTRU_EES401EP1,
+       NTRU_EES449EP1,
+       NTRU_EES677EP1,
+       NTRU_EES1087EP2,
+       NTRU_EES541EP1,
+       NTRU_EES613EP1,
+       NTRU_EES887EP1,
+       NTRU_EES1171EP1,
+       NTRU_EES659EP1,
+       NTRU_EES761EP1,
+       NTRU_EES1087EP1,
+       NTRU_EES1499EP1,
+       NTRU_EES401EP2,
+       NTRU_EES439EP1,
+       NTRU_EES593EP1,
+       NTRU_EES743EP1,
+};
+
+/**
+ * NTRU encryption parameter set definitions
+ */
+struct ntru_param_set_t {
+       ntru_param_set_id_t id;    /* NTRU parameter set ID */
+       uint8_t  oid[3];           /* pointer to OID */
+       uint8_t  der_id;           /* parameter-set DER id */
+       uint8_t  N_bits;           /* no. of bits in N (i.e. in an index */
+       uint16_t N;                /* ring dimension */
+       uint16_t sec_strength_len; /* no. of octets of security strength */
+       uint16_t q;                /* big modulus */
+       uint8_t  q_bits;           /* no. of bits in q (i.e. in a coefficient */
+       bool     is_product_form;  /* if product form used */
+       uint32_t dF_r;             /* no. of +1 or -1 coefficients in ring elements
+                                  F, r */
+       uint16_t dg;               /* no. - 1 of +1 coefficients or
+                                  no.     of -1 coefficients in ring element g */
+       uint16_t m_len_max;        /* max no. of plaintext octets */
+       uint16_t min_msg_rep_wt;   /* min. message representative weight */
+       uint8_t  c_bits;           /* no. bits in candidate for deriving an index */
+       uint8_t  m_len_len;        /* no. of octets to hold mLenOctets */
+};
+
+/**
+ * Get NTRU encryption parameter set by NTRU parameter set ID
+ *
+ * @param id   NTRU parameter set ID
+ * @return             NTRU parameter set
+*/
+ntru_param_set_t* ntru_param_set_get_by_id(ntru_param_set_id_t id);
+
+/**
+ * Get NTRU encryption parameter set by NTRU parameter set OID
+ *
+ * @param oid  NTRU parameter set OID
+ * @return             NTRU parameter set
+*/
+ntru_param_set_t* ntru_param_set_get_by_oid(uint8_t const *oid);
+
+#endif /** NTRU_PARAM_SET_H_ @}*/
+