Webserver+3d print

Dependents:   Nucleo

Committer:
Sergunb
Date:
Sat Feb 04 18:15:49 2017 +0000
Revision:
0:8918a71cdbe9
nothing else

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Sergunb 0:8918a71cdbe9 1 /**
Sergunb 0:8918a71cdbe9 2 * @file ec_curves.c
Sergunb 0:8918a71cdbe9 3 * @brief Elliptic curves
Sergunb 0:8918a71cdbe9 4 *
Sergunb 0:8918a71cdbe9 5 * @section License
Sergunb 0:8918a71cdbe9 6 *
Sergunb 0:8918a71cdbe9 7 * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved.
Sergunb 0:8918a71cdbe9 8 *
Sergunb 0:8918a71cdbe9 9 * This file is part of CycloneCrypto Open.
Sergunb 0:8918a71cdbe9 10 *
Sergunb 0:8918a71cdbe9 11 * This program is free software; you can redistribute it and/or
Sergunb 0:8918a71cdbe9 12 * modify it under the terms of the GNU General Public License
Sergunb 0:8918a71cdbe9 13 * as published by the Free Software Foundation; either version 2
Sergunb 0:8918a71cdbe9 14 * of the License, or (at your option) any later version.
Sergunb 0:8918a71cdbe9 15 *
Sergunb 0:8918a71cdbe9 16 * This program is distributed in the hope that it will be useful,
Sergunb 0:8918a71cdbe9 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Sergunb 0:8918a71cdbe9 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Sergunb 0:8918a71cdbe9 19 * GNU General Public License for more details.
Sergunb 0:8918a71cdbe9 20 *
Sergunb 0:8918a71cdbe9 21 * You should have received a copy of the GNU General Public License
Sergunb 0:8918a71cdbe9 22 * along with this program; if not, write to the Free Software Foundation,
Sergunb 0:8918a71cdbe9 23 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Sergunb 0:8918a71cdbe9 24 *
Sergunb 0:8918a71cdbe9 25 * @author Oryx Embedded SARL (www.oryx-embedded.com)
Sergunb 0:8918a71cdbe9 26 * @version 1.7.6
Sergunb 0:8918a71cdbe9 27 **/
Sergunb 0:8918a71cdbe9 28
Sergunb 0:8918a71cdbe9 29 //Switch to the appropriate trace level
Sergunb 0:8918a71cdbe9 30 #define TRACE_LEVEL CRYPTO_TRACE_LEVEL
Sergunb 0:8918a71cdbe9 31
Sergunb 0:8918a71cdbe9 32 //Dependencies
Sergunb 0:8918a71cdbe9 33 #include <stdlib.h>
Sergunb 0:8918a71cdbe9 34 #include <string.h>
Sergunb 0:8918a71cdbe9 35 #include "crypto.h"
Sergunb 0:8918a71cdbe9 36 #include "ec_curves.h"
Sergunb 0:8918a71cdbe9 37 #include "oid.h"
Sergunb 0:8918a71cdbe9 38 #include "debug.h"
Sergunb 0:8918a71cdbe9 39
Sergunb 0:8918a71cdbe9 40 //Check crypto library configuration
Sergunb 0:8918a71cdbe9 41 #if (EC_SUPPORT == ENABLED)
Sergunb 0:8918a71cdbe9 42
Sergunb 0:8918a71cdbe9 43 //Macro definition
Sergunb 0:8918a71cdbe9 44 #define CLEAR_WORD32(a, i, n) memset((a)->data + i, 0, n * MPI_INT_SIZE);
Sergunb 0:8918a71cdbe9 45 #define COPY_WORD32(a, i, b, j, n) memcpy((a)->data + i, (b)->data + j, n * MPI_INT_SIZE);
Sergunb 0:8918a71cdbe9 46
Sergunb 0:8918a71cdbe9 47 //secp112r1 OID (1.3.132.0.6)
Sergunb 0:8918a71cdbe9 48 const uint8_t SECP112R1_OID[5] = {0x2B, 0x81, 0x04, 0x00, 0x06};
Sergunb 0:8918a71cdbe9 49 //secp112r2 OID (1.3.132.0.7)
Sergunb 0:8918a71cdbe9 50 const uint8_t SECP112R2_OID[5] = {0x2B, 0x81, 0x04, 0x00, 0x07};
Sergunb 0:8918a71cdbe9 51 //secp128r1 OID (1.3.132.0.28)
Sergunb 0:8918a71cdbe9 52 const uint8_t SECP128R1_OID[5] = {0x2B, 0x81, 0x04, 0x00, 0x1C};
Sergunb 0:8918a71cdbe9 53 //secp128r2 OID (1.3.132.0.29)
Sergunb 0:8918a71cdbe9 54 const uint8_t SECP128R2_OID[5] = {0x2B, 0x81, 0x04, 0x00, 0x1D};
Sergunb 0:8918a71cdbe9 55 //secp160k1 OID (1.3.132.0.9)
Sergunb 0:8918a71cdbe9 56 const uint8_t SECP160K1_OID[5] = {0x2B, 0x81, 0x04, 0x00, 0x09};
Sergunb 0:8918a71cdbe9 57 //secp160r1 OID (1.3.132.0.8)
Sergunb 0:8918a71cdbe9 58 const uint8_t SECP160R1_OID[5] = {0x2B, 0x81, 0x04, 0x00, 0x08};
Sergunb 0:8918a71cdbe9 59 //secp160r2 OID (1.3.132.0.30)
Sergunb 0:8918a71cdbe9 60 const uint8_t SECP160R2_OID[5] = {0x2B, 0x81, 0x04, 0x00, 0x1E};
Sergunb 0:8918a71cdbe9 61 //secp192k1 OID (1.3.132.0.31)
Sergunb 0:8918a71cdbe9 62 const uint8_t SECP192K1_OID[5] = {0x2B, 0x81, 0x04, 0x00, 0x1F};
Sergunb 0:8918a71cdbe9 63 //secp192r1 OID (1.2.840.10045.3.1.1)
Sergunb 0:8918a71cdbe9 64 const uint8_t SECP192R1_OID[8] = {0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x01};
Sergunb 0:8918a71cdbe9 65 //secp224k1 OID (1.3.132.0.32)
Sergunb 0:8918a71cdbe9 66 const uint8_t SECP224K1_OID[5] = {0x2B, 0x81, 0x04, 0x00, 0x20};
Sergunb 0:8918a71cdbe9 67 //secp224r1 OID (1.3.132.0.33)
Sergunb 0:8918a71cdbe9 68 const uint8_t SECP224R1_OID[5] = {0x2B, 0x81, 0x04, 0x00, 0x21};
Sergunb 0:8918a71cdbe9 69 //secp256k1 OID (1.3.132.0.10)
Sergunb 0:8918a71cdbe9 70 const uint8_t SECP256K1_OID[5] = {0x2B, 0x81, 0x04, 0x00, 0x0A};
Sergunb 0:8918a71cdbe9 71 //secp256r1 OID (1.2.840.10045.3.1.7)
Sergunb 0:8918a71cdbe9 72 const uint8_t SECP256R1_OID[8] = {0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07};
Sergunb 0:8918a71cdbe9 73 //secp384r1 OID (1.3.132.0.34)
Sergunb 0:8918a71cdbe9 74 const uint8_t SECP384R1_OID[5] = {0x2B, 0x81, 0x04, 0x00, 0x22};
Sergunb 0:8918a71cdbe9 75 //secp521r1 OID (1.3.132.0.35)
Sergunb 0:8918a71cdbe9 76 const uint8_t SECP521R1_OID[5] = {0x2B, 0x81, 0x04, 0x00, 0x23};
Sergunb 0:8918a71cdbe9 77 //brainpoolP160r1 OID (1.3.36.3.3.2.8.1.1.1)
Sergunb 0:8918a71cdbe9 78 const uint8_t BRAINPOOLP160R1_OID[10] = {0x2B, 0x03, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x01};
Sergunb 0:8918a71cdbe9 79 //brainpoolP192r1 OID (1.3.36.3.3.2.8.1.1.3)
Sergunb 0:8918a71cdbe9 80 const uint8_t BRAINPOOLP192R1_OID[10] = {0x2B, 0x03, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x03};
Sergunb 0:8918a71cdbe9 81 //brainpoolP224r1 OID (1.3.36.3.3.2.8.1.1.5)
Sergunb 0:8918a71cdbe9 82 const uint8_t BRAINPOOLP224R1_OID[10] = {0x2B, 0x03, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x05};
Sergunb 0:8918a71cdbe9 83 //brainpoolP256r1 OID (1.3.36.3.3.2.8.1.1.7)
Sergunb 0:8918a71cdbe9 84 const uint8_t BRAINPOOLP256R1_OID[10] = {0x2B, 0x03, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x07};
Sergunb 0:8918a71cdbe9 85 //brainpoolP320r1 OID (1.3.36.3.3.2.8.1.1.9)
Sergunb 0:8918a71cdbe9 86 const uint8_t BRAINPOOLP320R1_OID[10] = {0x2B, 0x03, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x09};
Sergunb 0:8918a71cdbe9 87 //brainpoolP384r1 OID (1.3.36.3.3.2.8.1.1.11)
Sergunb 0:8918a71cdbe9 88 const uint8_t BRAINPOOLP384R1_OID[10] = {0x2B, 0x03, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x0B};
Sergunb 0:8918a71cdbe9 89 //brainpoolP512r1 OID (1.3.36.3.3.2.8.1.1.13)
Sergunb 0:8918a71cdbe9 90 const uint8_t BRAINPOOLP512R1_OID[10] = {0x2B, 0x03, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x0D};
Sergunb 0:8918a71cdbe9 91
Sergunb 0:8918a71cdbe9 92
Sergunb 0:8918a71cdbe9 93 /**
Sergunb 0:8918a71cdbe9 94 * @brief secp112r1 elliptic curve
Sergunb 0:8918a71cdbe9 95 **/
Sergunb 0:8918a71cdbe9 96
Sergunb 0:8918a71cdbe9 97 const EcCurveInfo secp112r1Curve =
Sergunb 0:8918a71cdbe9 98 {
Sergunb 0:8918a71cdbe9 99 //Curve name
Sergunb 0:8918a71cdbe9 100 "secp112r1",
Sergunb 0:8918a71cdbe9 101 //Object identifier
Sergunb 0:8918a71cdbe9 102 SECP112R1_OID,
Sergunb 0:8918a71cdbe9 103 sizeof(SECP112R1_OID),
Sergunb 0:8918a71cdbe9 104 //Curve type
Sergunb 0:8918a71cdbe9 105 EC_CURVE_TYPE_SECP_R1,
Sergunb 0:8918a71cdbe9 106 //Prime modulus p
Sergunb 0:8918a71cdbe9 107 {0xDB, 0x7C, 0x2A, 0xBF, 0x62, 0xE3, 0x5E, 0x66, 0x80, 0x76, 0xBE, 0xAD, 0x20, 0x8B},
Sergunb 0:8918a71cdbe9 108 14,
Sergunb 0:8918a71cdbe9 109 //Curve parameter a
Sergunb 0:8918a71cdbe9 110 {0xDB, 0x7C, 0x2A, 0xBF, 0x62, 0xE3, 0x5E, 0x66, 0x80, 0x76, 0xBE, 0xAD, 0x20, 0x88},
Sergunb 0:8918a71cdbe9 111 14,
Sergunb 0:8918a71cdbe9 112 //Curve parameter b
Sergunb 0:8918a71cdbe9 113 {0x65, 0x9E, 0xF8, 0xBA, 0x04, 0x39, 0x16, 0xEE, 0xDE, 0x89, 0x11, 0x70, 0x2B, 0x22},
Sergunb 0:8918a71cdbe9 114 14,
Sergunb 0:8918a71cdbe9 115 //x-coordinate of the base point G
Sergunb 0:8918a71cdbe9 116 {0x09, 0x48, 0x72, 0x39, 0x99, 0x5A, 0x5E, 0xE7, 0x6B, 0x55, 0xF9, 0xC2, 0xF0, 0x98},
Sergunb 0:8918a71cdbe9 117 14,
Sergunb 0:8918a71cdbe9 118 //y-coordinate of the base point G
Sergunb 0:8918a71cdbe9 119 {0xA8, 0x9C, 0xE5, 0xAF, 0x87, 0x24, 0xC0, 0xA2, 0x3E, 0x0E, 0x0F, 0xF7, 0x75, 0x00},
Sergunb 0:8918a71cdbe9 120 14,
Sergunb 0:8918a71cdbe9 121 //Base point order q
Sergunb 0:8918a71cdbe9 122 {0xDB, 0x7C, 0x2A, 0xBF, 0x62, 0xE3, 0x5E, 0x76, 0x28, 0xDF, 0xAC, 0x65, 0x61, 0xC5},
Sergunb 0:8918a71cdbe9 123 14,
Sergunb 0:8918a71cdbe9 124 //Cofactor
Sergunb 0:8918a71cdbe9 125 1,
Sergunb 0:8918a71cdbe9 126 //Fast modular reduction
Sergunb 0:8918a71cdbe9 127 NULL
Sergunb 0:8918a71cdbe9 128 };
Sergunb 0:8918a71cdbe9 129
Sergunb 0:8918a71cdbe9 130
Sergunb 0:8918a71cdbe9 131 /**
Sergunb 0:8918a71cdbe9 132 * @brief secp112r2 elliptic curve
Sergunb 0:8918a71cdbe9 133 **/
Sergunb 0:8918a71cdbe9 134
Sergunb 0:8918a71cdbe9 135 const EcCurveInfo secp112r2Curve =
Sergunb 0:8918a71cdbe9 136 {
Sergunb 0:8918a71cdbe9 137 //Curve name
Sergunb 0:8918a71cdbe9 138 "secp112r2",
Sergunb 0:8918a71cdbe9 139 //Object identifier
Sergunb 0:8918a71cdbe9 140 SECP112R2_OID,
Sergunb 0:8918a71cdbe9 141 sizeof(SECP112R2_OID),
Sergunb 0:8918a71cdbe9 142 //Curve type
Sergunb 0:8918a71cdbe9 143 EC_CURVE_TYPE_SECP_R2,
Sergunb 0:8918a71cdbe9 144 //Prime modulus p
Sergunb 0:8918a71cdbe9 145 {0xDB, 0x7C, 0x2A, 0xBF, 0x62, 0xE3, 0x5E, 0x66, 0x80, 0x76, 0xBE, 0xAD, 0x20, 0x8B},
Sergunb 0:8918a71cdbe9 146 14,
Sergunb 0:8918a71cdbe9 147 //Curve parameter a
Sergunb 0:8918a71cdbe9 148 {0x61, 0x27, 0xC2, 0x4C, 0x05, 0xF3, 0x8A, 0x0A, 0xAA, 0xF6, 0x5C, 0x0E, 0xF0, 0x2C},
Sergunb 0:8918a71cdbe9 149 14,
Sergunb 0:8918a71cdbe9 150 //Curve parameter b
Sergunb 0:8918a71cdbe9 151 {0x51, 0xDE, 0xF1, 0x81, 0x5D, 0xB5, 0xED, 0x74, 0xFC, 0xC3, 0x4C, 0x85, 0xD7, 0x09},
Sergunb 0:8918a71cdbe9 152 14,
Sergunb 0:8918a71cdbe9 153 //x-coordinate of the base point G
Sergunb 0:8918a71cdbe9 154 {0x4B, 0xA3, 0x0A, 0xB5, 0xE8, 0x92, 0xB4, 0xE1, 0x64, 0x9D, 0xD0, 0x92, 0x86, 0x43},
Sergunb 0:8918a71cdbe9 155 14,
Sergunb 0:8918a71cdbe9 156 //y-coordinate of the base point G
Sergunb 0:8918a71cdbe9 157 {0xAD, 0xCD, 0x46, 0xF5, 0x88, 0x2E, 0x37, 0x47, 0xDE, 0xF3, 0x6E, 0x95, 0x6E, 0x97},
Sergunb 0:8918a71cdbe9 158 14,
Sergunb 0:8918a71cdbe9 159 //Base point order q
Sergunb 0:8918a71cdbe9 160 {0x36, 0xDF, 0x0A, 0xAF, 0xD8, 0xB8, 0xD7, 0x59, 0x7C, 0xA1, 0x05, 0x20, 0xD0, 0x4B},
Sergunb 0:8918a71cdbe9 161 14,
Sergunb 0:8918a71cdbe9 162 //Cofactor
Sergunb 0:8918a71cdbe9 163 4,
Sergunb 0:8918a71cdbe9 164 //Fast modular reduction
Sergunb 0:8918a71cdbe9 165 NULL
Sergunb 0:8918a71cdbe9 166 };
Sergunb 0:8918a71cdbe9 167
Sergunb 0:8918a71cdbe9 168
Sergunb 0:8918a71cdbe9 169 /**
Sergunb 0:8918a71cdbe9 170 * @brief secp128r1 elliptic curve
Sergunb 0:8918a71cdbe9 171 **/
Sergunb 0:8918a71cdbe9 172
Sergunb 0:8918a71cdbe9 173 const EcCurveInfo secp128r1Curve =
Sergunb 0:8918a71cdbe9 174 {
Sergunb 0:8918a71cdbe9 175 //Curve name
Sergunb 0:8918a71cdbe9 176 "secp128r1",
Sergunb 0:8918a71cdbe9 177 //Object identifier
Sergunb 0:8918a71cdbe9 178 SECP128R1_OID,
Sergunb 0:8918a71cdbe9 179 sizeof(SECP128R1_OID),
Sergunb 0:8918a71cdbe9 180 //Curve type
Sergunb 0:8918a71cdbe9 181 EC_CURVE_TYPE_SECP_R1,
Sergunb 0:8918a71cdbe9 182 //Prime modulus p
Sergunb 0:8918a71cdbe9 183 {0xFF, 0xFF, 0xFF, 0xFD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
Sergunb 0:8918a71cdbe9 184 16,
Sergunb 0:8918a71cdbe9 185 //Curve parameter a
Sergunb 0:8918a71cdbe9 186 {0xFF, 0xFF, 0xFF, 0xFD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC},
Sergunb 0:8918a71cdbe9 187 16,
Sergunb 0:8918a71cdbe9 188 //Curve parameter b
Sergunb 0:8918a71cdbe9 189 {0xE8, 0x75, 0x79, 0xC1, 0x10, 0x79, 0xF4, 0x3D, 0xD8, 0x24, 0x99, 0x3C, 0x2C, 0xEE, 0x5E, 0xD3},
Sergunb 0:8918a71cdbe9 190 16,
Sergunb 0:8918a71cdbe9 191 //x-coordinate of the base point G
Sergunb 0:8918a71cdbe9 192 {0x16, 0x1F, 0xF7, 0x52, 0x8B, 0x89, 0x9B, 0x2D, 0x0C, 0x28, 0x60, 0x7C, 0xA5, 0x2C, 0x5B, 0x86},
Sergunb 0:8918a71cdbe9 193 16,
Sergunb 0:8918a71cdbe9 194 //y-coordinate of the base point G
Sergunb 0:8918a71cdbe9 195 {0xCF, 0x5A, 0xC8, 0x39, 0x5B, 0xAF, 0xEB, 0x13, 0xC0, 0x2D, 0xA2, 0x92, 0xDD, 0xED, 0x7A, 0x83},
Sergunb 0:8918a71cdbe9 196 16,
Sergunb 0:8918a71cdbe9 197 //Base point order q
Sergunb 0:8918a71cdbe9 198 {0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x75, 0xA3, 0x0D, 0x1B, 0x90, 0x38, 0xA1, 0x15},
Sergunb 0:8918a71cdbe9 199 16,
Sergunb 0:8918a71cdbe9 200 //Cofactor
Sergunb 0:8918a71cdbe9 201 1,
Sergunb 0:8918a71cdbe9 202 //Fast modular reduction
Sergunb 0:8918a71cdbe9 203 secp128r1Mod
Sergunb 0:8918a71cdbe9 204 };
Sergunb 0:8918a71cdbe9 205
Sergunb 0:8918a71cdbe9 206
Sergunb 0:8918a71cdbe9 207 /**
Sergunb 0:8918a71cdbe9 208 * @brief secp128r2 elliptic curve
Sergunb 0:8918a71cdbe9 209 **/
Sergunb 0:8918a71cdbe9 210
Sergunb 0:8918a71cdbe9 211 const EcCurveInfo secp128r2Curve =
Sergunb 0:8918a71cdbe9 212 {
Sergunb 0:8918a71cdbe9 213 //Curve name
Sergunb 0:8918a71cdbe9 214 "secp128r2",
Sergunb 0:8918a71cdbe9 215 //Object identifier
Sergunb 0:8918a71cdbe9 216 SECP128R2_OID,
Sergunb 0:8918a71cdbe9 217 sizeof(SECP128R2_OID),
Sergunb 0:8918a71cdbe9 218 //Curve type
Sergunb 0:8918a71cdbe9 219 EC_CURVE_TYPE_SECP_R2,
Sergunb 0:8918a71cdbe9 220 //Prime modulus p
Sergunb 0:8918a71cdbe9 221 {0xFF, 0xFF, 0xFF, 0xFD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
Sergunb 0:8918a71cdbe9 222 16,
Sergunb 0:8918a71cdbe9 223 //Curve parameter a
Sergunb 0:8918a71cdbe9 224 {0xD6, 0x03, 0x19, 0x98, 0xD1, 0xB3, 0xBB, 0xFE, 0xBF, 0x59, 0xCC, 0x9B, 0xBF, 0xF9, 0xAE, 0xE1},
Sergunb 0:8918a71cdbe9 225 16,
Sergunb 0:8918a71cdbe9 226 //Curve parameter b
Sergunb 0:8918a71cdbe9 227 {0x5E, 0xEE, 0xFC, 0xA3, 0x80, 0xD0, 0x29, 0x19, 0xDC, 0x2C, 0x65, 0x58, 0xBB, 0x6D, 0x8A, 0x5D},
Sergunb 0:8918a71cdbe9 228 16,
Sergunb 0:8918a71cdbe9 229 //x-coordinate of the base point G
Sergunb 0:8918a71cdbe9 230 {0x7B, 0x6A, 0xA5, 0xD8, 0x5E, 0x57, 0x29, 0x83, 0xE6, 0xFB, 0x32, 0xA7, 0xCD, 0xEB, 0xC1, 0x40},
Sergunb 0:8918a71cdbe9 231 16,
Sergunb 0:8918a71cdbe9 232 //y-coordinate of the base point G
Sergunb 0:8918a71cdbe9 233 {0x27, 0xB6, 0x91, 0x6A, 0x89, 0x4D, 0x3A, 0xEE, 0x71, 0x06, 0xFE, 0x80, 0x5F, 0xC3, 0x4B, 0x44},
Sergunb 0:8918a71cdbe9 234 16,
Sergunb 0:8918a71cdbe9 235 //Base point order q
Sergunb 0:8918a71cdbe9 236 {0x3F, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xBE, 0x00, 0x24, 0x72, 0x06, 0x13, 0xB5, 0xA3},
Sergunb 0:8918a71cdbe9 237 16,
Sergunb 0:8918a71cdbe9 238 //Cofactor
Sergunb 0:8918a71cdbe9 239 4,
Sergunb 0:8918a71cdbe9 240 //Fast modular reduction
Sergunb 0:8918a71cdbe9 241 secp128r2Mod
Sergunb 0:8918a71cdbe9 242 };
Sergunb 0:8918a71cdbe9 243
Sergunb 0:8918a71cdbe9 244
Sergunb 0:8918a71cdbe9 245 /**
Sergunb 0:8918a71cdbe9 246 * @brief secp160k1 elliptic curve
Sergunb 0:8918a71cdbe9 247 **/
Sergunb 0:8918a71cdbe9 248
Sergunb 0:8918a71cdbe9 249 const EcCurveInfo secp160k1Curve =
Sergunb 0:8918a71cdbe9 250 {
Sergunb 0:8918a71cdbe9 251 //Curve name
Sergunb 0:8918a71cdbe9 252 "secp160k1",
Sergunb 0:8918a71cdbe9 253 //Object identifier
Sergunb 0:8918a71cdbe9 254 SECP160K1_OID,
Sergunb 0:8918a71cdbe9 255 sizeof(SECP160K1_OID),
Sergunb 0:8918a71cdbe9 256 //Curve type
Sergunb 0:8918a71cdbe9 257 EC_CURVE_TYPE_SECP_K1,
Sergunb 0:8918a71cdbe9 258 //Prime modulus p
Sergunb 0:8918a71cdbe9 259 {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE,
Sergunb 0:8918a71cdbe9 260 0xFF, 0xFF, 0xAC, 0x73},
Sergunb 0:8918a71cdbe9 261 20,
Sergunb 0:8918a71cdbe9 262 //Curve parameter a
Sergunb 0:8918a71cdbe9 263 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Sergunb 0:8918a71cdbe9 264 0x00, 0x00, 0x00, 0x00},
Sergunb 0:8918a71cdbe9 265 20,
Sergunb 0:8918a71cdbe9 266 //Curve parameter b
Sergunb 0:8918a71cdbe9 267 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Sergunb 0:8918a71cdbe9 268 0x00, 0x00, 0x00, 0x07},
Sergunb 0:8918a71cdbe9 269 20,
Sergunb 0:8918a71cdbe9 270 //x-coordinate of the base point G
Sergunb 0:8918a71cdbe9 271 {0x3B, 0x4C, 0x38, 0x2C, 0xE3, 0x7A, 0xA1, 0x92, 0xA4, 0x01, 0x9E, 0x76, 0x30, 0x36, 0xF4, 0xF5,
Sergunb 0:8918a71cdbe9 272 0xDD, 0x4D, 0x7E, 0xBB},
Sergunb 0:8918a71cdbe9 273 20,
Sergunb 0:8918a71cdbe9 274 //y-coordinate of the base point G
Sergunb 0:8918a71cdbe9 275 {0x93, 0x8C, 0xF9, 0x35, 0x31, 0x8F, 0xDC, 0xED, 0x6B, 0xC2, 0x82, 0x86, 0x53, 0x17, 0x33, 0xC3,
Sergunb 0:8918a71cdbe9 276 0xF0, 0x3C, 0x4F, 0xEE},
Sergunb 0:8918a71cdbe9 277 20,
Sergunb 0:8918a71cdbe9 278 //Base point order q
Sergunb 0:8918a71cdbe9 279 {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xB8, 0xFA, 0x16, 0xDF, 0xAB,
Sergunb 0:8918a71cdbe9 280 0x9A, 0xCA, 0x16, 0xB6, 0xB3},
Sergunb 0:8918a71cdbe9 281 21,
Sergunb 0:8918a71cdbe9 282 //Cofactor
Sergunb 0:8918a71cdbe9 283 1,
Sergunb 0:8918a71cdbe9 284 //Fast modular reduction
Sergunb 0:8918a71cdbe9 285 secp160k1Mod
Sergunb 0:8918a71cdbe9 286 };
Sergunb 0:8918a71cdbe9 287
Sergunb 0:8918a71cdbe9 288
Sergunb 0:8918a71cdbe9 289 /**
Sergunb 0:8918a71cdbe9 290 * @brief secp160r1 elliptic curve
Sergunb 0:8918a71cdbe9 291 **/
Sergunb 0:8918a71cdbe9 292
Sergunb 0:8918a71cdbe9 293 const EcCurveInfo secp160r1Curve =
Sergunb 0:8918a71cdbe9 294 {
Sergunb 0:8918a71cdbe9 295 //Curve name
Sergunb 0:8918a71cdbe9 296 "secp160r1",
Sergunb 0:8918a71cdbe9 297 //Object identifier
Sergunb 0:8918a71cdbe9 298 SECP160R1_OID,
Sergunb 0:8918a71cdbe9 299 sizeof(SECP160R1_OID),
Sergunb 0:8918a71cdbe9 300 //Curve type
Sergunb 0:8918a71cdbe9 301 EC_CURVE_TYPE_SECP_R1,
Sergunb 0:8918a71cdbe9 302 //Prime modulus p
Sergunb 0:8918a71cdbe9 303 {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
Sergunb 0:8918a71cdbe9 304 0x7F, 0xFF, 0xFF, 0xFF},
Sergunb 0:8918a71cdbe9 305 20,
Sergunb 0:8918a71cdbe9 306 //Curve parameter a
Sergunb 0:8918a71cdbe9 307 {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
Sergunb 0:8918a71cdbe9 308 0x7F, 0xFF, 0xFF, 0xFC},
Sergunb 0:8918a71cdbe9 309 20,
Sergunb 0:8918a71cdbe9 310 //Curve parameter b
Sergunb 0:8918a71cdbe9 311 {0x1C, 0x97, 0xBE, 0xFC, 0x54, 0xBD, 0x7A, 0x8B, 0x65, 0xAC, 0xF8, 0x9F, 0x81, 0xD4, 0xD4, 0xAD,
Sergunb 0:8918a71cdbe9 312 0xC5, 0x65, 0xFA, 0x45},
Sergunb 0:8918a71cdbe9 313 20,
Sergunb 0:8918a71cdbe9 314 //x-coordinate of the base point G
Sergunb 0:8918a71cdbe9 315 {0x4A, 0x96, 0xB5, 0x68, 0x8E, 0xF5, 0x73, 0x28, 0x46, 0x64, 0x69, 0x89, 0x68, 0xC3, 0x8B, 0xB9,
Sergunb 0:8918a71cdbe9 316 0x13, 0xCB, 0xFC, 0x82},
Sergunb 0:8918a71cdbe9 317 20,
Sergunb 0:8918a71cdbe9 318 //y-coordinate of the base point G
Sergunb 0:8918a71cdbe9 319 {0x23, 0xA6, 0x28, 0x55, 0x31, 0x68, 0x94, 0x7D, 0x59, 0xDC, 0xC9, 0x12, 0x04, 0x23, 0x51, 0x37,
Sergunb 0:8918a71cdbe9 320 0x7A, 0xC5, 0xFB, 0x32},
Sergunb 0:8918a71cdbe9 321 20,
Sergunb 0:8918a71cdbe9 322 //Base point order q
Sergunb 0:8918a71cdbe9 323 {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF4, 0xC8, 0xF9, 0x27, 0xAE,
Sergunb 0:8918a71cdbe9 324 0xD3, 0xCA, 0x75, 0x22, 0x57},
Sergunb 0:8918a71cdbe9 325 21,
Sergunb 0:8918a71cdbe9 326 //Cofactor
Sergunb 0:8918a71cdbe9 327 1,
Sergunb 0:8918a71cdbe9 328 //Fast modular reduction
Sergunb 0:8918a71cdbe9 329 secp160r1Mod
Sergunb 0:8918a71cdbe9 330 };
Sergunb 0:8918a71cdbe9 331
Sergunb 0:8918a71cdbe9 332
Sergunb 0:8918a71cdbe9 333 /**
Sergunb 0:8918a71cdbe9 334 * @brief secp160r2 elliptic curve
Sergunb 0:8918a71cdbe9 335 **/
Sergunb 0:8918a71cdbe9 336
Sergunb 0:8918a71cdbe9 337 const EcCurveInfo secp160r2Curve =
Sergunb 0:8918a71cdbe9 338 {
Sergunb 0:8918a71cdbe9 339 //Curve name
Sergunb 0:8918a71cdbe9 340 "secp160r2",
Sergunb 0:8918a71cdbe9 341 //Object identifier
Sergunb 0:8918a71cdbe9 342 SECP160R2_OID,
Sergunb 0:8918a71cdbe9 343 sizeof(SECP160R2_OID),
Sergunb 0:8918a71cdbe9 344 //Curve type
Sergunb 0:8918a71cdbe9 345 EC_CURVE_TYPE_SECP_R2,
Sergunb 0:8918a71cdbe9 346 //Prime modulus p
Sergunb 0:8918a71cdbe9 347 {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE,
Sergunb 0:8918a71cdbe9 348 0xFF, 0xFF, 0xAC, 0x73},
Sergunb 0:8918a71cdbe9 349 20,
Sergunb 0:8918a71cdbe9 350 //Curve parameter a
Sergunb 0:8918a71cdbe9 351 {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE,
Sergunb 0:8918a71cdbe9 352 0xFF, 0xFF, 0xAC, 0x70},
Sergunb 0:8918a71cdbe9 353 20,
Sergunb 0:8918a71cdbe9 354 //Curve parameter b
Sergunb 0:8918a71cdbe9 355 {0xB4, 0xE1, 0x34, 0xD3, 0xFB, 0x59, 0xEB, 0x8B, 0xAB, 0x57, 0x27, 0x49, 0x04, 0x66, 0x4D, 0x5A,
Sergunb 0:8918a71cdbe9 356 0xF5, 0x03, 0x88, 0xBA},
Sergunb 0:8918a71cdbe9 357 20,
Sergunb 0:8918a71cdbe9 358 //x-coordinate of the base point G
Sergunb 0:8918a71cdbe9 359 {0x52, 0xDC, 0xB0, 0x34, 0x29, 0x3A, 0x11, 0x7E, 0x1F, 0x4F, 0xF1, 0x1B, 0x30, 0xF7, 0x19, 0x9D,
Sergunb 0:8918a71cdbe9 360 0x31, 0x44, 0xCE, 0x6D},
Sergunb 0:8918a71cdbe9 361 20,
Sergunb 0:8918a71cdbe9 362 //y-coordinate of the base point G
Sergunb 0:8918a71cdbe9 363 {0xFE, 0xAF, 0xFE, 0xF2, 0xE3, 0x31, 0xF2, 0x96, 0xE0, 0x71, 0xFA, 0x0D, 0xF9, 0x98, 0x2C, 0xFE,
Sergunb 0:8918a71cdbe9 364 0xA7, 0xD4, 0x3F, 0x2E},
Sergunb 0:8918a71cdbe9 365 20,
Sergunb 0:8918a71cdbe9 366 //Base point order q
Sergunb 0:8918a71cdbe9 367 {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x35, 0x1E, 0xE7, 0x86, 0xA8,
Sergunb 0:8918a71cdbe9 368 0x18, 0xF3, 0xA1, 0xA1, 0x6B},
Sergunb 0:8918a71cdbe9 369 21,
Sergunb 0:8918a71cdbe9 370 //Cofactor
Sergunb 0:8918a71cdbe9 371 1,
Sergunb 0:8918a71cdbe9 372 //Fast modular reduction
Sergunb 0:8918a71cdbe9 373 secp160r2Mod
Sergunb 0:8918a71cdbe9 374 };
Sergunb 0:8918a71cdbe9 375
Sergunb 0:8918a71cdbe9 376
Sergunb 0:8918a71cdbe9 377 /**
Sergunb 0:8918a71cdbe9 378 * @brief secp192k1 elliptic curve
Sergunb 0:8918a71cdbe9 379 **/
Sergunb 0:8918a71cdbe9 380
Sergunb 0:8918a71cdbe9 381 const EcCurveInfo secp192k1Curve =
Sergunb 0:8918a71cdbe9 382 {
Sergunb 0:8918a71cdbe9 383 //Curve name
Sergunb 0:8918a71cdbe9 384 "secp192k1",
Sergunb 0:8918a71cdbe9 385 //Object identifier
Sergunb 0:8918a71cdbe9 386 SECP192K1_OID,
Sergunb 0:8918a71cdbe9 387 sizeof(SECP192K1_OID),
Sergunb 0:8918a71cdbe9 388 //Curve type
Sergunb 0:8918a71cdbe9 389 EC_CURVE_TYPE_SECP_K1,
Sergunb 0:8918a71cdbe9 390 //Prime modulus p
Sergunb 0:8918a71cdbe9 391 {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
Sergunb 0:8918a71cdbe9 392 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xEE, 0x37},
Sergunb 0:8918a71cdbe9 393 24,
Sergunb 0:8918a71cdbe9 394 //Curve parameter a
Sergunb 0:8918a71cdbe9 395 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Sergunb 0:8918a71cdbe9 396 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Sergunb 0:8918a71cdbe9 397 24,
Sergunb 0:8918a71cdbe9 398 //Curve parameter b
Sergunb 0:8918a71cdbe9 399 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Sergunb 0:8918a71cdbe9 400 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03},
Sergunb 0:8918a71cdbe9 401 24,
Sergunb 0:8918a71cdbe9 402 //x-coordinate of the base point G
Sergunb 0:8918a71cdbe9 403 {0xDB, 0x4F, 0xF1, 0x0E, 0xC0, 0x57, 0xE9, 0xAE, 0x26, 0xB0, 0x7D, 0x02, 0x80, 0xB7, 0xF4, 0x34,
Sergunb 0:8918a71cdbe9 404 0x1D, 0xA5, 0xD1, 0xB1, 0xEA, 0xE0, 0x6C, 0x7D},
Sergunb 0:8918a71cdbe9 405 24,
Sergunb 0:8918a71cdbe9 406 //y-coordinate of the base point G
Sergunb 0:8918a71cdbe9 407 {0x9B, 0x2F, 0x2F, 0x6D, 0x9C, 0x56, 0x28, 0xA7, 0x84, 0x41, 0x63, 0xD0, 0x15, 0xBE, 0x86, 0x34,
Sergunb 0:8918a71cdbe9 408 0x40, 0x82, 0xAA, 0x88, 0xD9, 0x5E, 0x2F, 0x9D},
Sergunb 0:8918a71cdbe9 409 24,
Sergunb 0:8918a71cdbe9 410 //Base point order q
Sergunb 0:8918a71cdbe9 411 {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x26, 0xF2, 0xFC, 0x17,
Sergunb 0:8918a71cdbe9 412 0x0F, 0x69, 0x46, 0x6A, 0x74, 0xDE, 0xFD, 0x8D},
Sergunb 0:8918a71cdbe9 413 24,
Sergunb 0:8918a71cdbe9 414 //Cofactor
Sergunb 0:8918a71cdbe9 415 1,
Sergunb 0:8918a71cdbe9 416 //Fast modular reduction
Sergunb 0:8918a71cdbe9 417 secp192k1Mod
Sergunb 0:8918a71cdbe9 418 };
Sergunb 0:8918a71cdbe9 419
Sergunb 0:8918a71cdbe9 420
Sergunb 0:8918a71cdbe9 421 /**
Sergunb 0:8918a71cdbe9 422 * @brief secp192r1 elliptic curve
Sergunb 0:8918a71cdbe9 423 **/
Sergunb 0:8918a71cdbe9 424
Sergunb 0:8918a71cdbe9 425 const EcCurveInfo secp192r1Curve =
Sergunb 0:8918a71cdbe9 426 {
Sergunb 0:8918a71cdbe9 427 //Curve name
Sergunb 0:8918a71cdbe9 428 "secp192r1",
Sergunb 0:8918a71cdbe9 429 //Object identifier
Sergunb 0:8918a71cdbe9 430 SECP192R1_OID,
Sergunb 0:8918a71cdbe9 431 sizeof(SECP192R1_OID),
Sergunb 0:8918a71cdbe9 432 //Curve type
Sergunb 0:8918a71cdbe9 433 EC_CURVE_TYPE_SECP_R1,
Sergunb 0:8918a71cdbe9 434 //Prime modulus p
Sergunb 0:8918a71cdbe9 435 {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE,
Sergunb 0:8918a71cdbe9 436 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
Sergunb 0:8918a71cdbe9 437 24,
Sergunb 0:8918a71cdbe9 438 //Curve parameter a
Sergunb 0:8918a71cdbe9 439 {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE,
Sergunb 0:8918a71cdbe9 440 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC},
Sergunb 0:8918a71cdbe9 441 24,
Sergunb 0:8918a71cdbe9 442 //Curve parameter b
Sergunb 0:8918a71cdbe9 443 {0x64, 0x21, 0x05, 0x19, 0xE5, 0x9C, 0x80, 0xE7, 0x0F, 0xA7, 0xE9, 0xAB, 0x72, 0x24, 0x30, 0x49,
Sergunb 0:8918a71cdbe9 444 0xFE, 0xB8, 0xDE, 0xEC, 0xC1, 0x46, 0xB9, 0xB1},
Sergunb 0:8918a71cdbe9 445 24,
Sergunb 0:8918a71cdbe9 446 //x-coordinate of the base point G
Sergunb 0:8918a71cdbe9 447 {0x18, 0x8D, 0xA8, 0x0E, 0xB0, 0x30, 0x90, 0xF6, 0x7C, 0xBF, 0x20, 0xEB, 0x43, 0xA1, 0x88, 0x00,
Sergunb 0:8918a71cdbe9 448 0xF4, 0xFF, 0x0A, 0xFD, 0x82, 0xFF, 0x10, 0x12},
Sergunb 0:8918a71cdbe9 449 24,
Sergunb 0:8918a71cdbe9 450 //y-coordinate of the base point G
Sergunb 0:8918a71cdbe9 451 {0x07, 0x19, 0x2B, 0x95, 0xFF, 0xC8, 0xDA, 0x78, 0x63, 0x10, 0x11, 0xED, 0x6B, 0x24, 0xCD, 0xD5,
Sergunb 0:8918a71cdbe9 452 0x73, 0xF9, 0x77, 0xA1, 0x1E, 0x79, 0x48, 0x11},
Sergunb 0:8918a71cdbe9 453 24,
Sergunb 0:8918a71cdbe9 454 //Base point order q
Sergunb 0:8918a71cdbe9 455 {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x99, 0xDE, 0xF8, 0x36,
Sergunb 0:8918a71cdbe9 456 0x14, 0x6B, 0xC9, 0xB1, 0xB4, 0xD2, 0x28, 0x31},
Sergunb 0:8918a71cdbe9 457 24,
Sergunb 0:8918a71cdbe9 458 //Cofactor
Sergunb 0:8918a71cdbe9 459 1,
Sergunb 0:8918a71cdbe9 460 //Fast modular reduction
Sergunb 0:8918a71cdbe9 461 secp192r1Mod
Sergunb 0:8918a71cdbe9 462 };
Sergunb 0:8918a71cdbe9 463
Sergunb 0:8918a71cdbe9 464
Sergunb 0:8918a71cdbe9 465 /**
Sergunb 0:8918a71cdbe9 466 * @brief secp224k1 elliptic curve
Sergunb 0:8918a71cdbe9 467 **/
Sergunb 0:8918a71cdbe9 468
Sergunb 0:8918a71cdbe9 469 const EcCurveInfo secp224k1Curve =
Sergunb 0:8918a71cdbe9 470 {
Sergunb 0:8918a71cdbe9 471 //Curve name
Sergunb 0:8918a71cdbe9 472 "secp224k1",
Sergunb 0:8918a71cdbe9 473 //Object identifier
Sergunb 0:8918a71cdbe9 474 SECP224K1_OID,
Sergunb 0:8918a71cdbe9 475 sizeof(SECP224K1_OID),
Sergunb 0:8918a71cdbe9 476 //Curve type
Sergunb 0:8918a71cdbe9 477 EC_CURVE_TYPE_SECP_K1,
Sergunb 0:8918a71cdbe9 478 //Prime modulus p
Sergunb 0:8918a71cdbe9 479 {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
Sergunb 0:8918a71cdbe9 480 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xE5, 0x6D},
Sergunb 0:8918a71cdbe9 481 28,
Sergunb 0:8918a71cdbe9 482 //Curve parameter a
Sergunb 0:8918a71cdbe9 483 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Sergunb 0:8918a71cdbe9 484 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Sergunb 0:8918a71cdbe9 485 28,
Sergunb 0:8918a71cdbe9 486 //Curve parameter b
Sergunb 0:8918a71cdbe9 487 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Sergunb 0:8918a71cdbe9 488 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05},
Sergunb 0:8918a71cdbe9 489 28,
Sergunb 0:8918a71cdbe9 490 //x-coordinate of the base point G
Sergunb 0:8918a71cdbe9 491 {0xA1, 0x45, 0x5B, 0x33, 0x4D, 0xF0, 0x99, 0xDF, 0x30, 0xFC, 0x28, 0xA1, 0x69, 0xA4, 0x67, 0xE9,
Sergunb 0:8918a71cdbe9 492 0xE4, 0x70, 0x75, 0xA9, 0x0F, 0x7E, 0x65, 0x0E, 0xB6, 0xB7, 0xA4, 0x5C},
Sergunb 0:8918a71cdbe9 493 28,
Sergunb 0:8918a71cdbe9 494 //y-coordinate of the base point G
Sergunb 0:8918a71cdbe9 495 {0x7E, 0x08, 0x9F, 0xED, 0x7F, 0xBA, 0x34, 0x42, 0x82, 0xCA, 0xFB, 0xD6, 0xF7, 0xE3, 0x19, 0xF7,
Sergunb 0:8918a71cdbe9 496 0xC0, 0xB0, 0xBD, 0x59, 0xE2, 0xCA, 0x4B, 0xDB, 0x55, 0x6D, 0x61, 0xA5},
Sergunb 0:8918a71cdbe9 497 28,
Sergunb 0:8918a71cdbe9 498 //Base point order q
Sergunb 0:8918a71cdbe9 499 {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xDC,
Sergunb 0:8918a71cdbe9 500 0xE8, 0xD2, 0xEC, 0x61, 0x84, 0xCA, 0xF0, 0xA9, 0x71, 0x76, 0x9F, 0xB1, 0xF7},
Sergunb 0:8918a71cdbe9 501 29,
Sergunb 0:8918a71cdbe9 502 //Cofactor
Sergunb 0:8918a71cdbe9 503 1,
Sergunb 0:8918a71cdbe9 504 //Fast modular reduction
Sergunb 0:8918a71cdbe9 505 secp224k1Mod
Sergunb 0:8918a71cdbe9 506 };
Sergunb 0:8918a71cdbe9 507
Sergunb 0:8918a71cdbe9 508
Sergunb 0:8918a71cdbe9 509 /**
Sergunb 0:8918a71cdbe9 510 * @brief secp224r1 elliptic curve
Sergunb 0:8918a71cdbe9 511 **/
Sergunb 0:8918a71cdbe9 512
Sergunb 0:8918a71cdbe9 513 const EcCurveInfo secp224r1Curve =
Sergunb 0:8918a71cdbe9 514 {
Sergunb 0:8918a71cdbe9 515 //Curve name
Sergunb 0:8918a71cdbe9 516 "secp224r1",
Sergunb 0:8918a71cdbe9 517 //Object identifier
Sergunb 0:8918a71cdbe9 518 SECP224R1_OID,
Sergunb 0:8918a71cdbe9 519 sizeof(SECP224R1_OID),
Sergunb 0:8918a71cdbe9 520 //Curve type
Sergunb 0:8918a71cdbe9 521 EC_CURVE_TYPE_SECP_R1,
Sergunb 0:8918a71cdbe9 522 //Prime modulus p
Sergunb 0:8918a71cdbe9 523 {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
Sergunb 0:8918a71cdbe9 524 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
Sergunb 0:8918a71cdbe9 525 28,
Sergunb 0:8918a71cdbe9 526 //Curve parameter a
Sergunb 0:8918a71cdbe9 527 {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE,
Sergunb 0:8918a71cdbe9 528 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE},
Sergunb 0:8918a71cdbe9 529 28,
Sergunb 0:8918a71cdbe9 530 //Curve parameter b
Sergunb 0:8918a71cdbe9 531 {0xB4, 0x05, 0x0A, 0x85, 0x0C, 0x04, 0xB3, 0xAB, 0xF5, 0x41, 0x32, 0x56, 0x50, 0x44, 0xB0, 0xB7,
Sergunb 0:8918a71cdbe9 532 0xD7, 0xBF, 0xD8, 0xBA, 0x27, 0x0B, 0x39, 0x43, 0x23, 0x55, 0xFF, 0xB4},
Sergunb 0:8918a71cdbe9 533 28,
Sergunb 0:8918a71cdbe9 534 //x-coordinate of the base point G
Sergunb 0:8918a71cdbe9 535 {0xB7, 0x0E, 0x0C, 0xBD, 0x6B, 0xB4, 0xBF, 0x7F, 0x32, 0x13, 0x90, 0xB9, 0x4A, 0x03, 0xC1, 0xD3,
Sergunb 0:8918a71cdbe9 536 0x56, 0xC2, 0x11, 0x22, 0x34, 0x32, 0x80, 0xD6, 0x11, 0x5C, 0x1D, 0x21},
Sergunb 0:8918a71cdbe9 537 28,
Sergunb 0:8918a71cdbe9 538 //y-coordinate of the base point G
Sergunb 0:8918a71cdbe9 539 {0xBD, 0x37, 0x63, 0x88, 0xB5, 0xF7, 0x23, 0xFB, 0x4C, 0x22, 0xDF, 0xE6, 0xCD, 0x43, 0x75, 0xA0,
Sergunb 0:8918a71cdbe9 540 0x5A, 0x07, 0x47, 0x64, 0x44, 0xD5, 0x81, 0x99, 0x85, 0x00, 0x7E, 0x34},
Sergunb 0:8918a71cdbe9 541 28,
Sergunb 0:8918a71cdbe9 542 //Base point order q
Sergunb 0:8918a71cdbe9 543 {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x16, 0xA2,
Sergunb 0:8918a71cdbe9 544 0xE0, 0xB8, 0xF0, 0x3E, 0x13, 0xDD, 0x29, 0x45, 0x5C, 0x5C, 0x2A, 0x3D},
Sergunb 0:8918a71cdbe9 545 28,
Sergunb 0:8918a71cdbe9 546 //Cofactor
Sergunb 0:8918a71cdbe9 547 1,
Sergunb 0:8918a71cdbe9 548 //Fast modular reduction
Sergunb 0:8918a71cdbe9 549 secp224r1Mod
Sergunb 0:8918a71cdbe9 550 };
Sergunb 0:8918a71cdbe9 551
Sergunb 0:8918a71cdbe9 552
Sergunb 0:8918a71cdbe9 553 /**
Sergunb 0:8918a71cdbe9 554 * @brief secp256k1 elliptic curve
Sergunb 0:8918a71cdbe9 555 **/
Sergunb 0:8918a71cdbe9 556
Sergunb 0:8918a71cdbe9 557 const EcCurveInfo secp256k1Curve =
Sergunb 0:8918a71cdbe9 558 {
Sergunb 0:8918a71cdbe9 559 //Curve name
Sergunb 0:8918a71cdbe9 560 "secp256k1",
Sergunb 0:8918a71cdbe9 561 //Object identifier
Sergunb 0:8918a71cdbe9 562 SECP256K1_OID,
Sergunb 0:8918a71cdbe9 563 sizeof(SECP256K1_OID),
Sergunb 0:8918a71cdbe9 564 //Curve type
Sergunb 0:8918a71cdbe9 565 EC_CURVE_TYPE_SECP_K1,
Sergunb 0:8918a71cdbe9 566 //Prime modulus p
Sergunb 0:8918a71cdbe9 567 {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
Sergunb 0:8918a71cdbe9 568 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFC, 0x2F},
Sergunb 0:8918a71cdbe9 569 32,
Sergunb 0:8918a71cdbe9 570 //Curve parameter a
Sergunb 0:8918a71cdbe9 571 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Sergunb 0:8918a71cdbe9 572 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Sergunb 0:8918a71cdbe9 573 32,
Sergunb 0:8918a71cdbe9 574 //Curve parameter b
Sergunb 0:8918a71cdbe9 575 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Sergunb 0:8918a71cdbe9 576 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07},
Sergunb 0:8918a71cdbe9 577 32,
Sergunb 0:8918a71cdbe9 578 //x-coordinate of the base point G
Sergunb 0:8918a71cdbe9 579 {0x79, 0xBE, 0x66, 0x7E, 0xF9, 0xDC, 0xBB, 0xAC, 0x55, 0xA0, 0x62, 0x95, 0xCE, 0x87, 0x0B, 0x07,
Sergunb 0:8918a71cdbe9 580 0x02, 0x9B, 0xFC, 0xDB, 0x2D, 0xCE, 0x28, 0xD9, 0x59, 0xF2, 0x81, 0x5B, 0x16, 0xF8, 0x17, 0x98},
Sergunb 0:8918a71cdbe9 581 32,
Sergunb 0:8918a71cdbe9 582 //y-coordinate of the base point G
Sergunb 0:8918a71cdbe9 583 {0x48, 0x3A, 0xDA, 0x77, 0x26, 0xA3, 0xC4, 0x65, 0x5D, 0xA4, 0xFB, 0xFC, 0x0E, 0x11, 0x08, 0xA8,
Sergunb 0:8918a71cdbe9 584 0xFD, 0x17, 0xB4, 0x48, 0xA6, 0x85, 0x54, 0x19, 0x9C, 0x47, 0xD0, 0x8F, 0xFB, 0x10, 0xD4, 0xB8},
Sergunb 0:8918a71cdbe9 585 32,
Sergunb 0:8918a71cdbe9 586 //Base point order q
Sergunb 0:8918a71cdbe9 587 {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE,
Sergunb 0:8918a71cdbe9 588 0xBA, 0xAE, 0xDC, 0xE6, 0xAF, 0x48, 0xA0, 0x3B, 0xBF, 0xD2, 0x5E, 0x8C, 0xD0, 0x36, 0x41, 0x41},
Sergunb 0:8918a71cdbe9 589 32,
Sergunb 0:8918a71cdbe9 590 //Cofactor
Sergunb 0:8918a71cdbe9 591 1,
Sergunb 0:8918a71cdbe9 592 //Fast modular reduction
Sergunb 0:8918a71cdbe9 593 secp256k1Mod
Sergunb 0:8918a71cdbe9 594 };
Sergunb 0:8918a71cdbe9 595
Sergunb 0:8918a71cdbe9 596
Sergunb 0:8918a71cdbe9 597 /**
Sergunb 0:8918a71cdbe9 598 * @brief secp256r1 elliptic curve
Sergunb 0:8918a71cdbe9 599 **/
Sergunb 0:8918a71cdbe9 600
Sergunb 0:8918a71cdbe9 601 const EcCurveInfo secp256r1Curve =
Sergunb 0:8918a71cdbe9 602 {
Sergunb 0:8918a71cdbe9 603 //Curve name
Sergunb 0:8918a71cdbe9 604 "secp256r1",
Sergunb 0:8918a71cdbe9 605 //Object identifier
Sergunb 0:8918a71cdbe9 606 SECP256R1_OID,
Sergunb 0:8918a71cdbe9 607 sizeof(SECP256R1_OID),
Sergunb 0:8918a71cdbe9 608 //Curve type
Sergunb 0:8918a71cdbe9 609 EC_CURVE_TYPE_SECP_R1,
Sergunb 0:8918a71cdbe9 610 //Prime modulus p
Sergunb 0:8918a71cdbe9 611 {0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Sergunb 0:8918a71cdbe9 612 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
Sergunb 0:8918a71cdbe9 613 32,
Sergunb 0:8918a71cdbe9 614 //Curve parameter a
Sergunb 0:8918a71cdbe9 615 {0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Sergunb 0:8918a71cdbe9 616 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC},
Sergunb 0:8918a71cdbe9 617 32,
Sergunb 0:8918a71cdbe9 618 //Curve parameter b
Sergunb 0:8918a71cdbe9 619 {0x5A, 0xC6, 0x35, 0xD8, 0xAA, 0x3A, 0x93, 0xE7, 0xB3, 0xEB, 0xBD, 0x55, 0x76, 0x98, 0x86, 0xBC,
Sergunb 0:8918a71cdbe9 620 0x65, 0x1D, 0x06, 0xB0, 0xCC, 0x53, 0xB0, 0xF6, 0x3B, 0xCE, 0x3C, 0x3E, 0x27, 0xD2, 0x60, 0x4B},
Sergunb 0:8918a71cdbe9 621 32,
Sergunb 0:8918a71cdbe9 622 //x-coordinate of the base point G
Sergunb 0:8918a71cdbe9 623 {0x6B, 0x17, 0xD1, 0xF2, 0xE1, 0x2C, 0x42, 0x47, 0xF8, 0xBC, 0xE6, 0xE5, 0x63, 0xA4, 0x40, 0xF2,
Sergunb 0:8918a71cdbe9 624 0x77, 0x03, 0x7D, 0x81, 0x2D, 0xEB, 0x33, 0xA0, 0xF4, 0xA1, 0x39, 0x45, 0xD8, 0x98, 0xC2, 0x96},
Sergunb 0:8918a71cdbe9 625 32,
Sergunb 0:8918a71cdbe9 626 //y-coordinate of the base point G
Sergunb 0:8918a71cdbe9 627 {0x4F, 0xE3, 0x42, 0xE2, 0xFE, 0x1A, 0x7F, 0x9B, 0x8E, 0xE7, 0xEB, 0x4A, 0x7C, 0x0F, 0x9E, 0x16,
Sergunb 0:8918a71cdbe9 628 0x2B, 0xCE, 0x33, 0x57, 0x6B, 0x31, 0x5E, 0xCE, 0xCB, 0xB6, 0x40, 0x68, 0x37, 0xBF, 0x51, 0xF5},
Sergunb 0:8918a71cdbe9 629 32,
Sergunb 0:8918a71cdbe9 630 //Base point order q
Sergunb 0:8918a71cdbe9 631 {0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
Sergunb 0:8918a71cdbe9 632 0xBC, 0xE6, 0xFA, 0xAD, 0xA7, 0x17, 0x9E, 0x84, 0xF3, 0xB9, 0xCA, 0xC2, 0xFC, 0x63, 0x25, 0x51},
Sergunb 0:8918a71cdbe9 633 32,
Sergunb 0:8918a71cdbe9 634 //Cofactor
Sergunb 0:8918a71cdbe9 635 1,
Sergunb 0:8918a71cdbe9 636 //Fast modular reduction
Sergunb 0:8918a71cdbe9 637 secp256r1Mod
Sergunb 0:8918a71cdbe9 638 };
Sergunb 0:8918a71cdbe9 639
Sergunb 0:8918a71cdbe9 640
Sergunb 0:8918a71cdbe9 641 /**
Sergunb 0:8918a71cdbe9 642 * @brief secp384r1 elliptic curve
Sergunb 0:8918a71cdbe9 643 **/
Sergunb 0:8918a71cdbe9 644
Sergunb 0:8918a71cdbe9 645 const EcCurveInfo secp384r1Curve =
Sergunb 0:8918a71cdbe9 646 {
Sergunb 0:8918a71cdbe9 647 //Curve name
Sergunb 0:8918a71cdbe9 648 "secp384r1",
Sergunb 0:8918a71cdbe9 649 //Object identifier
Sergunb 0:8918a71cdbe9 650 SECP384R1_OID,
Sergunb 0:8918a71cdbe9 651 sizeof(SECP384R1_OID),
Sergunb 0:8918a71cdbe9 652 //Curve type
Sergunb 0:8918a71cdbe9 653 EC_CURVE_TYPE_SECP_R1,
Sergunb 0:8918a71cdbe9 654 //Prime modulus p
Sergunb 0:8918a71cdbe9 655 {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
Sergunb 0:8918a71cdbe9 656 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE,
Sergunb 0:8918a71cdbe9 657 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF},
Sergunb 0:8918a71cdbe9 658 48,
Sergunb 0:8918a71cdbe9 659 //Curve parameter a
Sergunb 0:8918a71cdbe9 660 {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
Sergunb 0:8918a71cdbe9 661 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE,
Sergunb 0:8918a71cdbe9 662 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFC},
Sergunb 0:8918a71cdbe9 663 48,
Sergunb 0:8918a71cdbe9 664 //Curve parameter b
Sergunb 0:8918a71cdbe9 665 {0xB3, 0x31, 0x2F, 0xA7, 0xE2, 0x3E, 0xE7, 0xE4, 0x98, 0x8E, 0x05, 0x6B, 0xE3, 0xF8, 0x2D, 0x19,
Sergunb 0:8918a71cdbe9 666 0x18, 0x1D, 0x9C, 0x6E, 0xFE, 0x81, 0x41, 0x12, 0x03, 0x14, 0x08, 0x8F, 0x50, 0x13, 0x87, 0x5A,
Sergunb 0:8918a71cdbe9 667 0xC6, 0x56, 0x39, 0x8D, 0x8A, 0x2E, 0xD1, 0x9D, 0x2A, 0x85, 0xC8, 0xED, 0xD3, 0xEC, 0x2A, 0xEF},
Sergunb 0:8918a71cdbe9 668 48,
Sergunb 0:8918a71cdbe9 669 //x-coordinate of the base point G
Sergunb 0:8918a71cdbe9 670 {0xAA, 0x87, 0xCA, 0x22, 0xBE, 0x8B, 0x05, 0x37, 0x8E, 0xB1, 0xC7, 0x1E, 0xF3, 0x20, 0xAD, 0x74,
Sergunb 0:8918a71cdbe9 671 0x6E, 0x1D, 0x3B, 0x62, 0x8B, 0xA7, 0x9B, 0x98, 0x59, 0xF7, 0x41, 0xE0, 0x82, 0x54, 0x2A, 0x38,
Sergunb 0:8918a71cdbe9 672 0x55, 0x02, 0xF2, 0x5D, 0xBF, 0x55, 0x29, 0x6C, 0x3A, 0x54, 0x5E, 0x38, 0x72, 0x76, 0x0A, 0xB7},
Sergunb 0:8918a71cdbe9 673 48,
Sergunb 0:8918a71cdbe9 674 //y-coordinate of the base point G
Sergunb 0:8918a71cdbe9 675 {0x36, 0x17, 0xDE, 0x4A, 0x96, 0x26, 0x2C, 0x6F, 0x5D, 0x9E, 0x98, 0xBF, 0x92, 0x92, 0xDC, 0x29,
Sergunb 0:8918a71cdbe9 676 0xF8, 0xF4, 0x1D, 0xBD, 0x28, 0x9A, 0x14, 0x7C, 0xE9, 0xDA, 0x31, 0x13, 0xB5, 0xF0, 0xB8, 0xC0,
Sergunb 0:8918a71cdbe9 677 0x0A, 0x60, 0xB1, 0xCE, 0x1D, 0x7E, 0x81, 0x9D, 0x7A, 0x43, 0x1D, 0x7C, 0x90, 0xEA, 0x0E, 0x5F},
Sergunb 0:8918a71cdbe9 678 48,
Sergunb 0:8918a71cdbe9 679 //Base point order q
Sergunb 0:8918a71cdbe9 680 {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
Sergunb 0:8918a71cdbe9 681 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC7, 0x63, 0x4D, 0x81, 0xF4, 0x37, 0x2D, 0xDF,
Sergunb 0:8918a71cdbe9 682 0x58, 0x1A, 0x0D, 0xB2, 0x48, 0xB0, 0xA7, 0x7A, 0xEC, 0xEC, 0x19, 0x6A, 0xCC, 0xC5, 0x29, 0x73},
Sergunb 0:8918a71cdbe9 683 48,
Sergunb 0:8918a71cdbe9 684 //Cofactor
Sergunb 0:8918a71cdbe9 685 1,
Sergunb 0:8918a71cdbe9 686 //Fast modular reduction
Sergunb 0:8918a71cdbe9 687 secp384r1Mod
Sergunb 0:8918a71cdbe9 688 };
Sergunb 0:8918a71cdbe9 689
Sergunb 0:8918a71cdbe9 690
Sergunb 0:8918a71cdbe9 691 /**
Sergunb 0:8918a71cdbe9 692 * @brief secp521r1 elliptic curve
Sergunb 0:8918a71cdbe9 693 **/
Sergunb 0:8918a71cdbe9 694
Sergunb 0:8918a71cdbe9 695 const EcCurveInfo secp521r1Curve =
Sergunb 0:8918a71cdbe9 696 {
Sergunb 0:8918a71cdbe9 697 //Curve name
Sergunb 0:8918a71cdbe9 698 "secp521r1",
Sergunb 0:8918a71cdbe9 699 //Object identifier
Sergunb 0:8918a71cdbe9 700 SECP521R1_OID,
Sergunb 0:8918a71cdbe9 701 sizeof(SECP521R1_OID),
Sergunb 0:8918a71cdbe9 702 //Curve type
Sergunb 0:8918a71cdbe9 703 EC_CURVE_TYPE_SECP_R1,
Sergunb 0:8918a71cdbe9 704 //Prime modulus p
Sergunb 0:8918a71cdbe9 705 {0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
Sergunb 0:8918a71cdbe9 706 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
Sergunb 0:8918a71cdbe9 707 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
Sergunb 0:8918a71cdbe9 708 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
Sergunb 0:8918a71cdbe9 709 0xFF, 0xFF},
Sergunb 0:8918a71cdbe9 710 66,
Sergunb 0:8918a71cdbe9 711 //Curve parameter a
Sergunb 0:8918a71cdbe9 712 {0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
Sergunb 0:8918a71cdbe9 713 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
Sergunb 0:8918a71cdbe9 714 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
Sergunb 0:8918a71cdbe9 715 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
Sergunb 0:8918a71cdbe9 716 0xFF, 0xFC},
Sergunb 0:8918a71cdbe9 717 66,
Sergunb 0:8918a71cdbe9 718 //Curve parameter b
Sergunb 0:8918a71cdbe9 719 {0x00, 0x51, 0x95, 0x3E, 0xB9, 0x61, 0x8E, 0x1C, 0x9A, 0x1F, 0x92, 0x9A, 0x21, 0xA0, 0xB6, 0x85,
Sergunb 0:8918a71cdbe9 720 0x40, 0xEE, 0xA2, 0xDA, 0x72, 0x5B, 0x99, 0xB3, 0x15, 0xF3, 0xB8, 0xB4, 0x89, 0x91, 0x8E, 0xF1,
Sergunb 0:8918a71cdbe9 721 0x09, 0xE1, 0x56, 0x19, 0x39, 0x51, 0xEC, 0x7E, 0x93, 0x7B, 0x16, 0x52, 0xC0, 0xBD, 0x3B, 0xB1,
Sergunb 0:8918a71cdbe9 722 0xBF, 0x07, 0x35, 0x73, 0xDF, 0x88, 0x3D, 0x2C, 0x34, 0xF1, 0xEF, 0x45, 0x1F, 0xD4, 0x6B, 0x50,
Sergunb 0:8918a71cdbe9 723 0x3F, 0x00},
Sergunb 0:8918a71cdbe9 724 66,
Sergunb 0:8918a71cdbe9 725 //x-coordinate of the base point G
Sergunb 0:8918a71cdbe9 726 {0x00, 0xC6, 0x85, 0x8E, 0x06, 0xB7, 0x04, 0x04, 0xE9, 0xCD, 0x9E, 0x3E, 0xCB, 0x66, 0x23, 0x95,
Sergunb 0:8918a71cdbe9 727 0xB4, 0x42, 0x9C, 0x64, 0x81, 0x39, 0x05, 0x3F, 0xB5, 0x21, 0xF8, 0x28, 0xAF, 0x60, 0x6B, 0x4D,
Sergunb 0:8918a71cdbe9 728 0x3D, 0xBA, 0xA1, 0x4B, 0x5E, 0x77, 0xEF, 0xE7, 0x59, 0x28, 0xFE, 0x1D, 0xC1, 0x27, 0xA2, 0xFF,
Sergunb 0:8918a71cdbe9 729 0xA8, 0xDE, 0x33, 0x48, 0xB3, 0xC1, 0x85, 0x6A, 0x42, 0x9B, 0xF9, 0x7E, 0x7E, 0x31, 0xC2, 0xE5,
Sergunb 0:8918a71cdbe9 730 0xBD, 0x66},
Sergunb 0:8918a71cdbe9 731 66,
Sergunb 0:8918a71cdbe9 732 //y-coordinate of the base point G
Sergunb 0:8918a71cdbe9 733 {0x01, 0x18, 0x39, 0x29, 0x6A, 0x78, 0x9A, 0x3B, 0xC0, 0x04, 0x5C, 0x8A, 0x5F, 0xB4, 0x2C, 0x7D,
Sergunb 0:8918a71cdbe9 734 0x1B, 0xD9, 0x98, 0xF5, 0x44, 0x49, 0x57, 0x9B, 0x44, 0x68, 0x17, 0xAF, 0xBD, 0x17, 0x27, 0x3E,
Sergunb 0:8918a71cdbe9 735 0x66, 0x2C, 0x97, 0xEE, 0x72, 0x99, 0x5E, 0xF4, 0x26, 0x40, 0xC5, 0x50, 0xB9, 0x01, 0x3F, 0xAD,
Sergunb 0:8918a71cdbe9 736 0x07, 0x61, 0x35, 0x3C, 0x70, 0x86, 0xA2, 0x72, 0xC2, 0x40, 0x88, 0xBE, 0x94, 0x76, 0x9F, 0xD1,
Sergunb 0:8918a71cdbe9 737 0x66, 0x50},
Sergunb 0:8918a71cdbe9 738 66,
Sergunb 0:8918a71cdbe9 739 //Base point order q
Sergunb 0:8918a71cdbe9 740 {0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
Sergunb 0:8918a71cdbe9 741 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
Sergunb 0:8918a71cdbe9 742 0xFF, 0xFA, 0x51, 0x86, 0x87, 0x83, 0xBF, 0x2F, 0x96, 0x6B, 0x7F, 0xCC, 0x01, 0x48, 0xF7, 0x09,
Sergunb 0:8918a71cdbe9 743 0xA5, 0xD0, 0x3B, 0xB5, 0xC9, 0xB8, 0x89, 0x9C, 0x47, 0xAE, 0xBB, 0x6F, 0xB7, 0x1E, 0x91, 0x38,
Sergunb 0:8918a71cdbe9 744 0x64, 0x09},
Sergunb 0:8918a71cdbe9 745 66,
Sergunb 0:8918a71cdbe9 746 //Cofactor
Sergunb 0:8918a71cdbe9 747 1,
Sergunb 0:8918a71cdbe9 748 //Fast modular reduction
Sergunb 0:8918a71cdbe9 749 secp521r1Mod
Sergunb 0:8918a71cdbe9 750 };
Sergunb 0:8918a71cdbe9 751
Sergunb 0:8918a71cdbe9 752
Sergunb 0:8918a71cdbe9 753 /**
Sergunb 0:8918a71cdbe9 754 * @brief brainpoolP160r1 elliptic curve
Sergunb 0:8918a71cdbe9 755 **/
Sergunb 0:8918a71cdbe9 756
Sergunb 0:8918a71cdbe9 757 const EcCurveInfo brainpoolP160r1Curve =
Sergunb 0:8918a71cdbe9 758 {
Sergunb 0:8918a71cdbe9 759 //Curve name
Sergunb 0:8918a71cdbe9 760 "brainpoolP160r1",
Sergunb 0:8918a71cdbe9 761 //Object identifier
Sergunb 0:8918a71cdbe9 762 BRAINPOOLP160R1_OID,
Sergunb 0:8918a71cdbe9 763 sizeof(BRAINPOOLP160R1_OID),
Sergunb 0:8918a71cdbe9 764 //Curve type
Sergunb 0:8918a71cdbe9 765 EC_CURVE_TYPE_BRAINPOOLP_R1,
Sergunb 0:8918a71cdbe9 766 //Prime modulus p
Sergunb 0:8918a71cdbe9 767 {0xE9, 0x5E, 0x4A, 0x5F, 0x73, 0x70, 0x59, 0xDC, 0x60, 0xDF, 0xC7, 0xAD, 0x95, 0xB3, 0xD8, 0x13,
Sergunb 0:8918a71cdbe9 768 0x95, 0x15, 0x62, 0x0F},
Sergunb 0:8918a71cdbe9 769 20,
Sergunb 0:8918a71cdbe9 770 //Curve parameter a
Sergunb 0:8918a71cdbe9 771 {0x34, 0x0E, 0x7B, 0xE2, 0xA2, 0x80, 0xEB, 0x74, 0xE2, 0xBE, 0x61, 0xBA, 0xDA, 0x74, 0x5D, 0x97,
Sergunb 0:8918a71cdbe9 772 0xE8, 0xF7, 0xC3, 0x00},
Sergunb 0:8918a71cdbe9 773 20,
Sergunb 0:8918a71cdbe9 774 //Curve parameter b
Sergunb 0:8918a71cdbe9 775 {0x1E, 0x58, 0x9A, 0x85, 0x95, 0x42, 0x34, 0x12, 0x13, 0x4F, 0xAA, 0x2D, 0xBD, 0xEC, 0x95, 0xC8,
Sergunb 0:8918a71cdbe9 776 0xD8, 0x67, 0x5E, 0x58},
Sergunb 0:8918a71cdbe9 777 20,
Sergunb 0:8918a71cdbe9 778 //x-coordinate of the base point G
Sergunb 0:8918a71cdbe9 779 {0xBE, 0xD5, 0xAF, 0x16, 0xEA, 0x3F, 0x6A, 0x4F, 0x62, 0x93, 0x8C, 0x46, 0x31, 0xEB, 0x5A, 0xF7,
Sergunb 0:8918a71cdbe9 780 0xBD, 0xBC, 0xDB, 0xC3},
Sergunb 0:8918a71cdbe9 781 20,
Sergunb 0:8918a71cdbe9 782 //y-coordinate of the base point G
Sergunb 0:8918a71cdbe9 783 {0x16, 0x67, 0xCB, 0x47, 0x7A, 0x1A, 0x8E, 0xC3, 0x38, 0xF9, 0x47, 0x41, 0x66, 0x9C, 0x97, 0x63,
Sergunb 0:8918a71cdbe9 784 0x16, 0xDA, 0x63, 0x21},
Sergunb 0:8918a71cdbe9 785 20,
Sergunb 0:8918a71cdbe9 786 //Base point order q
Sergunb 0:8918a71cdbe9 787 {0xE9, 0x5E, 0x4A, 0x5F, 0x73, 0x70, 0x59, 0xDC, 0x60, 0xDF, 0x59, 0x91, 0xD4, 0x50, 0x29, 0x40,
Sergunb 0:8918a71cdbe9 788 0x9E, 0x60, 0xFC, 0x09},
Sergunb 0:8918a71cdbe9 789 20,
Sergunb 0:8918a71cdbe9 790 //Cofactor
Sergunb 0:8918a71cdbe9 791 1,
Sergunb 0:8918a71cdbe9 792 //Fast modular reduction
Sergunb 0:8918a71cdbe9 793 NULL
Sergunb 0:8918a71cdbe9 794 };
Sergunb 0:8918a71cdbe9 795
Sergunb 0:8918a71cdbe9 796
Sergunb 0:8918a71cdbe9 797 /**
Sergunb 0:8918a71cdbe9 798 * @brief brainpoolP192r1 elliptic curve
Sergunb 0:8918a71cdbe9 799 **/
Sergunb 0:8918a71cdbe9 800
Sergunb 0:8918a71cdbe9 801 const EcCurveInfo brainpoolP192r1Curve =
Sergunb 0:8918a71cdbe9 802 {
Sergunb 0:8918a71cdbe9 803 //Curve name
Sergunb 0:8918a71cdbe9 804 "brainpoolP192r1",
Sergunb 0:8918a71cdbe9 805 //Object identifier
Sergunb 0:8918a71cdbe9 806 BRAINPOOLP192R1_OID,
Sergunb 0:8918a71cdbe9 807 sizeof(BRAINPOOLP192R1_OID),
Sergunb 0:8918a71cdbe9 808 //Curve type
Sergunb 0:8918a71cdbe9 809 EC_CURVE_TYPE_BRAINPOOLP_R1,
Sergunb 0:8918a71cdbe9 810 //Prime modulus p
Sergunb 0:8918a71cdbe9 811 {0xC3, 0x02, 0xF4, 0x1D, 0x93, 0x2A, 0x36, 0xCD, 0xA7, 0xA3, 0x46, 0x30, 0x93, 0xD1, 0x8D, 0xB7,
Sergunb 0:8918a71cdbe9 812 0x8F, 0xCE, 0x47, 0x6D, 0xE1, 0xA8, 0x62, 0x97},
Sergunb 0:8918a71cdbe9 813 24,
Sergunb 0:8918a71cdbe9 814 //Curve parameter a
Sergunb 0:8918a71cdbe9 815 {0x6A, 0x91, 0x17, 0x40, 0x76, 0xB1, 0xE0, 0xE1, 0x9C, 0x39, 0xC0, 0x31, 0xFE, 0x86, 0x85, 0xC1,
Sergunb 0:8918a71cdbe9 816 0xCA, 0xE0, 0x40, 0xE5, 0xC6, 0x9A, 0x28, 0xEF},
Sergunb 0:8918a71cdbe9 817 24,
Sergunb 0:8918a71cdbe9 818 //Curve parameter b
Sergunb 0:8918a71cdbe9 819 {0x46, 0x9A, 0x28, 0xEF, 0x7C, 0x28, 0xCC, 0xA3, 0xDC, 0x72, 0x1D, 0x04, 0x4F, 0x44, 0x96, 0xBC,
Sergunb 0:8918a71cdbe9 820 0xCA, 0x7E, 0xF4, 0x14, 0x6F, 0xBF, 0x25, 0xC9},
Sergunb 0:8918a71cdbe9 821 24,
Sergunb 0:8918a71cdbe9 822 //x-coordinate of the base point G
Sergunb 0:8918a71cdbe9 823 {0xC0, 0xA0, 0x64, 0x7E, 0xAA, 0xB6, 0xA4, 0x87, 0x53, 0xB0, 0x33, 0xC5, 0x6C, 0xB0, 0xF0, 0x90,
Sergunb 0:8918a71cdbe9 824 0x0A, 0x2F, 0x5C, 0x48, 0x53, 0x37, 0x5F, 0xD6},
Sergunb 0:8918a71cdbe9 825 24,
Sergunb 0:8918a71cdbe9 826 //y-coordinate of the base point G
Sergunb 0:8918a71cdbe9 827 {0x14, 0xB6, 0x90, 0x86, 0x6A, 0xBD, 0x5B, 0xB8, 0x8B, 0x5F, 0x48, 0x28, 0xC1, 0x49, 0x00, 0x02,
Sergunb 0:8918a71cdbe9 828 0xE6, 0x77, 0x3F, 0xA2, 0xFA, 0x29, 0x9B, 0x8F},
Sergunb 0:8918a71cdbe9 829 24,
Sergunb 0:8918a71cdbe9 830 //Base point order q
Sergunb 0:8918a71cdbe9 831 {0xC3, 0x02, 0xF4, 0x1D, 0x93, 0x2A, 0x36, 0xCD, 0xA7, 0xA3, 0x46, 0x2F, 0x9E, 0x9E, 0x91, 0x6B,
Sergunb 0:8918a71cdbe9 832 0x5B, 0xE8, 0xF1, 0x02, 0x9A, 0xC4, 0xAC, 0xC1},
Sergunb 0:8918a71cdbe9 833 24,
Sergunb 0:8918a71cdbe9 834 //Cofactor
Sergunb 0:8918a71cdbe9 835 1,
Sergunb 0:8918a71cdbe9 836 //Fast modular reduction
Sergunb 0:8918a71cdbe9 837 NULL
Sergunb 0:8918a71cdbe9 838 };
Sergunb 0:8918a71cdbe9 839
Sergunb 0:8918a71cdbe9 840
Sergunb 0:8918a71cdbe9 841 /**
Sergunb 0:8918a71cdbe9 842 * @brief brainpoolP224r1 elliptic curve
Sergunb 0:8918a71cdbe9 843 **/
Sergunb 0:8918a71cdbe9 844
Sergunb 0:8918a71cdbe9 845 const EcCurveInfo brainpoolP224r1Curve =
Sergunb 0:8918a71cdbe9 846 {
Sergunb 0:8918a71cdbe9 847 //Curve name
Sergunb 0:8918a71cdbe9 848 "brainpoolP224r1",
Sergunb 0:8918a71cdbe9 849 //Object identifier
Sergunb 0:8918a71cdbe9 850 BRAINPOOLP224R1_OID,
Sergunb 0:8918a71cdbe9 851 sizeof(BRAINPOOLP224R1_OID),
Sergunb 0:8918a71cdbe9 852 //Curve type
Sergunb 0:8918a71cdbe9 853 EC_CURVE_TYPE_BRAINPOOLP_R1,
Sergunb 0:8918a71cdbe9 854 //Prime modulus p
Sergunb 0:8918a71cdbe9 855 {0xD7, 0xC1, 0x34, 0xAA, 0x26, 0x43, 0x66, 0x86, 0x2A, 0x18, 0x30, 0x25, 0x75, 0xD1, 0xD7, 0x87,
Sergunb 0:8918a71cdbe9 856 0xB0, 0x9F, 0x07, 0x57, 0x97, 0xDA, 0x89, 0xF5, 0x7E, 0xC8, 0xC0, 0xFF},
Sergunb 0:8918a71cdbe9 857 28,
Sergunb 0:8918a71cdbe9 858 //Curve parameter a
Sergunb 0:8918a71cdbe9 859 {0x68, 0xA5, 0xE6, 0x2C, 0xA9, 0xCE, 0x6C, 0x1C, 0x29, 0x98, 0x03, 0xA6, 0xC1, 0x53, 0x0B, 0x51,
Sergunb 0:8918a71cdbe9 860 0x4E, 0x18, 0x2A, 0xD8, 0xB0, 0x04, 0x2A, 0x59, 0xCA, 0xD2, 0x9F, 0x43},
Sergunb 0:8918a71cdbe9 861 28,
Sergunb 0:8918a71cdbe9 862 //Curve parameter b
Sergunb 0:8918a71cdbe9 863 {0x25, 0x80, 0xF6, 0x3C, 0xCF, 0xE4, 0x41, 0x38, 0x87, 0x07, 0x13, 0xB1, 0xA9, 0x23, 0x69, 0xE3,
Sergunb 0:8918a71cdbe9 864 0x3E, 0x21, 0x35, 0xD2, 0x66, 0xDB, 0xB3, 0x72, 0x38, 0x6C, 0x40, 0x0B},
Sergunb 0:8918a71cdbe9 865 28,
Sergunb 0:8918a71cdbe9 866 //x-coordinate of the base point G
Sergunb 0:8918a71cdbe9 867 {0x0D, 0x90, 0x29, 0xAD, 0x2C, 0x7E, 0x5C, 0xF4, 0x34, 0x08, 0x23, 0xB2, 0xA8, 0x7D, 0xC6, 0x8C,
Sergunb 0:8918a71cdbe9 868 0x9E, 0x4C, 0xE3, 0x17, 0x4C, 0x1E, 0x6E, 0xFD, 0xEE, 0x12, 0xC0, 0x7D},
Sergunb 0:8918a71cdbe9 869 28,
Sergunb 0:8918a71cdbe9 870 //y-coordinate of the base point G
Sergunb 0:8918a71cdbe9 871 {0x58, 0xAA, 0x56, 0xF7, 0x72, 0xC0, 0x72, 0x6F, 0x24, 0xC6, 0xB8, 0x9E, 0x4E, 0xCD, 0xAC, 0x24,
Sergunb 0:8918a71cdbe9 872 0x35, 0x4B, 0x9E, 0x99, 0xCA, 0xA3, 0xF6, 0xD3, 0x76, 0x14, 0x02, 0xCD},
Sergunb 0:8918a71cdbe9 873 28,
Sergunb 0:8918a71cdbe9 874 //Base point order q
Sergunb 0:8918a71cdbe9 875 {0xD7, 0xC1, 0x34, 0xAA, 0x26, 0x43, 0x66, 0x86, 0x2A, 0x18, 0x30, 0x25, 0x75, 0xD0, 0xFB, 0x98,
Sergunb 0:8918a71cdbe9 876 0xD1, 0x16, 0xBC, 0x4B, 0x6D, 0xDE, 0xBC, 0xA3, 0xA5, 0xA7, 0x93, 0x9F},
Sergunb 0:8918a71cdbe9 877 28,
Sergunb 0:8918a71cdbe9 878 //Cofactor
Sergunb 0:8918a71cdbe9 879 1,
Sergunb 0:8918a71cdbe9 880 //Fast modular reduction
Sergunb 0:8918a71cdbe9 881 NULL
Sergunb 0:8918a71cdbe9 882 };
Sergunb 0:8918a71cdbe9 883
Sergunb 0:8918a71cdbe9 884
Sergunb 0:8918a71cdbe9 885 /**
Sergunb 0:8918a71cdbe9 886 * @brief brainpoolP256r1 elliptic curve
Sergunb 0:8918a71cdbe9 887 **/
Sergunb 0:8918a71cdbe9 888
Sergunb 0:8918a71cdbe9 889 const EcCurveInfo brainpoolP256r1Curve =
Sergunb 0:8918a71cdbe9 890 {
Sergunb 0:8918a71cdbe9 891 //Curve name
Sergunb 0:8918a71cdbe9 892 "brainpoolP256r1",
Sergunb 0:8918a71cdbe9 893 //Object identifier
Sergunb 0:8918a71cdbe9 894 BRAINPOOLP256R1_OID,
Sergunb 0:8918a71cdbe9 895 sizeof(BRAINPOOLP256R1_OID),
Sergunb 0:8918a71cdbe9 896 //Curve type
Sergunb 0:8918a71cdbe9 897 EC_CURVE_TYPE_BRAINPOOLP_R1,
Sergunb 0:8918a71cdbe9 898 //Prime modulus p
Sergunb 0:8918a71cdbe9 899 {0xA9, 0xFB, 0x57, 0xDB, 0xA1, 0xEE, 0xA9, 0xBC, 0x3E, 0x66, 0x0A, 0x90, 0x9D, 0x83, 0x8D, 0x72,
Sergunb 0:8918a71cdbe9 900 0x6E, 0x3B, 0xF6, 0x23, 0xD5, 0x26, 0x20, 0x28, 0x20, 0x13, 0x48, 0x1D, 0x1F, 0x6E, 0x53, 0x77},
Sergunb 0:8918a71cdbe9 901 32,
Sergunb 0:8918a71cdbe9 902 //Curve parameter a
Sergunb 0:8918a71cdbe9 903 {0x7D, 0x5A, 0x09, 0x75, 0xFC, 0x2C, 0x30, 0x57, 0xEE, 0xF6, 0x75, 0x30, 0x41, 0x7A, 0xFF, 0xE7,
Sergunb 0:8918a71cdbe9 904 0xFB, 0x80, 0x55, 0xC1, 0x26, 0xDC, 0x5C, 0x6C, 0xE9, 0x4A, 0x4B, 0x44, 0xF3, 0x30, 0xB5, 0xD9},
Sergunb 0:8918a71cdbe9 905 32,
Sergunb 0:8918a71cdbe9 906 //Curve parameter b
Sergunb 0:8918a71cdbe9 907 {0x26, 0xDC, 0x5C, 0x6C, 0xE9, 0x4A, 0x4B, 0x44, 0xF3, 0x30, 0xB5, 0xD9, 0xBB, 0xD7, 0x7C, 0xBF,
Sergunb 0:8918a71cdbe9 908 0x95, 0x84, 0x16, 0x29, 0x5C, 0xF7, 0xE1, 0xCE, 0x6B, 0xCC, 0xDC, 0x18, 0xFF, 0x8C, 0x07, 0xB6},
Sergunb 0:8918a71cdbe9 909 32,
Sergunb 0:8918a71cdbe9 910 //x-coordinate of the base point G
Sergunb 0:8918a71cdbe9 911 {0x8B, 0xD2, 0xAE, 0xB9, 0xCB, 0x7E, 0x57, 0xCB, 0x2C, 0x4B, 0x48, 0x2F, 0xFC, 0x81, 0xB7, 0xAF,
Sergunb 0:8918a71cdbe9 912 0xB9, 0xDE, 0x27, 0xE1, 0xE3, 0xBD, 0x23, 0xC2, 0x3A, 0x44, 0x53, 0xBD, 0x9A, 0xCE, 0x32, 0x62},
Sergunb 0:8918a71cdbe9 913 32,
Sergunb 0:8918a71cdbe9 914 //y-coordinate of the base point G
Sergunb 0:8918a71cdbe9 915 {0x54, 0x7E, 0xF8, 0x35, 0xC3, 0xDA, 0xC4, 0xFD, 0x97, 0xF8, 0x46, 0x1A, 0x14, 0x61, 0x1D, 0xC9,
Sergunb 0:8918a71cdbe9 916 0xC2, 0x77, 0x45, 0x13, 0x2D, 0xED, 0x8E, 0x54, 0x5C, 0x1D, 0x54, 0xC7, 0x2F, 0x04, 0x69, 0x97},
Sergunb 0:8918a71cdbe9 917 32,
Sergunb 0:8918a71cdbe9 918 //Base point order q
Sergunb 0:8918a71cdbe9 919 {0xA9, 0xFB, 0x57, 0xDB, 0xA1, 0xEE, 0xA9, 0xBC, 0x3E, 0x66, 0x0A, 0x90, 0x9D, 0x83, 0x8D, 0x71,
Sergunb 0:8918a71cdbe9 920 0x8C, 0x39, 0x7A, 0xA3, 0xB5, 0x61, 0xA6, 0xF7, 0x90, 0x1E, 0x0E, 0x82, 0x97, 0x48, 0x56, 0xA7},
Sergunb 0:8918a71cdbe9 921 32,
Sergunb 0:8918a71cdbe9 922 //Cofactor
Sergunb 0:8918a71cdbe9 923 1,
Sergunb 0:8918a71cdbe9 924 //Fast modular reduction
Sergunb 0:8918a71cdbe9 925 NULL
Sergunb 0:8918a71cdbe9 926 };
Sergunb 0:8918a71cdbe9 927
Sergunb 0:8918a71cdbe9 928
Sergunb 0:8918a71cdbe9 929 /**
Sergunb 0:8918a71cdbe9 930 * @brief brainpoolP320r1 elliptic curve
Sergunb 0:8918a71cdbe9 931 **/
Sergunb 0:8918a71cdbe9 932
Sergunb 0:8918a71cdbe9 933 const EcCurveInfo brainpoolP320r1Curve =
Sergunb 0:8918a71cdbe9 934 {
Sergunb 0:8918a71cdbe9 935 //Curve name
Sergunb 0:8918a71cdbe9 936 "brainpoolP320r1",
Sergunb 0:8918a71cdbe9 937 //Object identifier
Sergunb 0:8918a71cdbe9 938 BRAINPOOLP320R1_OID,
Sergunb 0:8918a71cdbe9 939 sizeof(BRAINPOOLP320R1_OID),
Sergunb 0:8918a71cdbe9 940 //Curve type
Sergunb 0:8918a71cdbe9 941 EC_CURVE_TYPE_BRAINPOOLP_R1,
Sergunb 0:8918a71cdbe9 942 //Prime modulus p
Sergunb 0:8918a71cdbe9 943 {0xD3, 0x5E, 0x47, 0x20, 0x36, 0xBC, 0x4F, 0xB7, 0xE1, 0x3C, 0x78, 0x5E, 0xD2, 0x01, 0xE0, 0x65,
Sergunb 0:8918a71cdbe9 944 0xF9, 0x8F, 0xCF, 0xA6, 0xF6, 0xF4, 0x0D, 0xEF, 0x4F, 0x92, 0xB9, 0xEC, 0x78, 0x93, 0xEC, 0x28,
Sergunb 0:8918a71cdbe9 945 0xFC, 0xD4, 0x12, 0xB1, 0xF1, 0xB3, 0x2E, 0x27},
Sergunb 0:8918a71cdbe9 946 40,
Sergunb 0:8918a71cdbe9 947 //Curve parameter a
Sergunb 0:8918a71cdbe9 948 {0x3E, 0xE3, 0x0B, 0x56, 0x8F, 0xBA, 0xB0, 0xF8, 0x83, 0xCC, 0xEB, 0xD4, 0x6D, 0x3F, 0x3B, 0xB8,
Sergunb 0:8918a71cdbe9 949 0xA2, 0xA7, 0x35, 0x13, 0xF5, 0xEB, 0x79, 0xDA, 0x66, 0x19, 0x0E, 0xB0, 0x85, 0xFF, 0xA9, 0xF4,
Sergunb 0:8918a71cdbe9 950 0x92, 0xF3, 0x75, 0xA9, 0x7D, 0x86, 0x0E, 0xB4},
Sergunb 0:8918a71cdbe9 951 40,
Sergunb 0:8918a71cdbe9 952 //Curve parameter b
Sergunb 0:8918a71cdbe9 953 {0x52, 0x08, 0x83, 0x94, 0x9D, 0xFD, 0xBC, 0x42, 0xD3, 0xAD, 0x19, 0x86, 0x40, 0x68, 0x8A, 0x6F,
Sergunb 0:8918a71cdbe9 954 0xE1, 0x3F, 0x41, 0x34, 0x95, 0x54, 0xB4, 0x9A, 0xCC, 0x31, 0xDC, 0xCD, 0x88, 0x45, 0x39, 0x81,
Sergunb 0:8918a71cdbe9 955 0x6F, 0x5E, 0xB4, 0xAC, 0x8F, 0xB1, 0xF1, 0xA6},
Sergunb 0:8918a71cdbe9 956 40,
Sergunb 0:8918a71cdbe9 957 //x-coordinate of the base point G
Sergunb 0:8918a71cdbe9 958 {0x43, 0xBD, 0x7E, 0x9A, 0xFB, 0x53, 0xD8, 0xB8, 0x52, 0x89, 0xBC, 0xC4, 0x8E, 0xE5, 0xBF, 0xE6,
Sergunb 0:8918a71cdbe9 959 0xF2, 0x01, 0x37, 0xD1, 0x0A, 0x08, 0x7E, 0xB6, 0xE7, 0x87, 0x1E, 0x2A, 0x10, 0xA5, 0x99, 0xC7,
Sergunb 0:8918a71cdbe9 960 0x10, 0xAF, 0x8D, 0x0D, 0x39, 0xE2, 0x06, 0x11},
Sergunb 0:8918a71cdbe9 961 40,
Sergunb 0:8918a71cdbe9 962 //y-coordinate of the base point G
Sergunb 0:8918a71cdbe9 963 {0x14, 0xFD, 0xD0, 0x55, 0x45, 0xEC, 0x1C, 0xC8, 0xAB, 0x40, 0x93, 0x24, 0x7F, 0x77, 0x27, 0x5E,
Sergunb 0:8918a71cdbe9 964 0x07, 0x43, 0xFF, 0xED, 0x11, 0x71, 0x82, 0xEA, 0xA9, 0xC7, 0x78, 0x77, 0xAA, 0xAC, 0x6A, 0xC7,
Sergunb 0:8918a71cdbe9 965 0xD3, 0x52, 0x45, 0xD1, 0x69, 0x2E, 0x8E, 0xE1},
Sergunb 0:8918a71cdbe9 966 40,
Sergunb 0:8918a71cdbe9 967 //Base point order q
Sergunb 0:8918a71cdbe9 968 {0xD3, 0x5E, 0x47, 0x20, 0x36, 0xBC, 0x4F, 0xB7, 0xE1, 0x3C, 0x78, 0x5E, 0xD2, 0x01, 0xE0, 0x65,
Sergunb 0:8918a71cdbe9 969 0xF9, 0x8F, 0xCF, 0xA5, 0xB6, 0x8F, 0x12, 0xA3, 0x2D, 0x48, 0x2E, 0xC7, 0xEE, 0x86, 0x58, 0xE9,
Sergunb 0:8918a71cdbe9 970 0x86, 0x91, 0x55, 0x5B, 0x44, 0xC5, 0x93, 0x11},
Sergunb 0:8918a71cdbe9 971 40,
Sergunb 0:8918a71cdbe9 972 //Cofactor
Sergunb 0:8918a71cdbe9 973 1,
Sergunb 0:8918a71cdbe9 974 //Fast modular reduction
Sergunb 0:8918a71cdbe9 975 NULL
Sergunb 0:8918a71cdbe9 976 };
Sergunb 0:8918a71cdbe9 977
Sergunb 0:8918a71cdbe9 978
Sergunb 0:8918a71cdbe9 979 /**
Sergunb 0:8918a71cdbe9 980 * @brief brainpoolP384r1 elliptic curve
Sergunb 0:8918a71cdbe9 981 **/
Sergunb 0:8918a71cdbe9 982
Sergunb 0:8918a71cdbe9 983 const EcCurveInfo brainpoolP384r1Curve =
Sergunb 0:8918a71cdbe9 984 {
Sergunb 0:8918a71cdbe9 985 //Curve name
Sergunb 0:8918a71cdbe9 986 "brainpoolP384r1",
Sergunb 0:8918a71cdbe9 987 //Object identifier
Sergunb 0:8918a71cdbe9 988 BRAINPOOLP384R1_OID,
Sergunb 0:8918a71cdbe9 989 sizeof(BRAINPOOLP384R1_OID),
Sergunb 0:8918a71cdbe9 990 //Curve type
Sergunb 0:8918a71cdbe9 991 EC_CURVE_TYPE_BRAINPOOLP_R1,
Sergunb 0:8918a71cdbe9 992 //Prime modulus p
Sergunb 0:8918a71cdbe9 993 {0x8C, 0xB9, 0x1E, 0x82, 0xA3, 0x38, 0x6D, 0x28, 0x0F, 0x5D, 0x6F, 0x7E, 0x50, 0xE6, 0x41, 0xDF,
Sergunb 0:8918a71cdbe9 994 0x15, 0x2F, 0x71, 0x09, 0xED, 0x54, 0x56, 0xB4, 0x12, 0xB1, 0xDA, 0x19, 0x7F, 0xB7, 0x11, 0x23,
Sergunb 0:8918a71cdbe9 995 0xAC, 0xD3, 0xA7, 0x29, 0x90, 0x1D, 0x1A, 0x71, 0x87, 0x47, 0x00, 0x13, 0x31, 0x07, 0xEC, 0x53},
Sergunb 0:8918a71cdbe9 996 48,
Sergunb 0:8918a71cdbe9 997 //Curve parameter a
Sergunb 0:8918a71cdbe9 998 {0x7B, 0xC3, 0x82, 0xC6, 0x3D, 0x8C, 0x15, 0x0C, 0x3C, 0x72, 0x08, 0x0A, 0xCE, 0x05, 0xAF, 0xA0,
Sergunb 0:8918a71cdbe9 999 0xC2, 0xBE, 0xA2, 0x8E, 0x4F, 0xB2, 0x27, 0x87, 0x13, 0x91, 0x65, 0xEF, 0xBA, 0x91, 0xF9, 0x0F,
Sergunb 0:8918a71cdbe9 1000 0x8A, 0xA5, 0x81, 0x4A, 0x50, 0x3A, 0xD4, 0xEB, 0x04, 0xA8, 0xC7, 0xDD, 0x22, 0xCE, 0x28, 0x26},
Sergunb 0:8918a71cdbe9 1001 48,
Sergunb 0:8918a71cdbe9 1002 //Curve parameter b
Sergunb 0:8918a71cdbe9 1003 {0x04, 0xA8, 0xC7, 0xDD, 0x22, 0xCE, 0x28, 0x26, 0x8B, 0x39, 0xB5, 0x54, 0x16, 0xF0, 0x44, 0x7C,
Sergunb 0:8918a71cdbe9 1004 0x2F, 0xB7, 0x7D, 0xE1, 0x07, 0xDC, 0xD2, 0xA6, 0x2E, 0x88, 0x0E, 0xA5, 0x3E, 0xEB, 0x62, 0xD5,
Sergunb 0:8918a71cdbe9 1005 0x7C, 0xB4, 0x39, 0x02, 0x95, 0xDB, 0xC9, 0x94, 0x3A, 0xB7, 0x86, 0x96, 0xFA, 0x50, 0x4C, 0x11},
Sergunb 0:8918a71cdbe9 1006 48,
Sergunb 0:8918a71cdbe9 1007 //x-coordinate of the base point G
Sergunb 0:8918a71cdbe9 1008 {0x1D, 0x1C, 0x64, 0xF0, 0x68, 0xCF, 0x45, 0xFF, 0xA2, 0xA6, 0x3A, 0x81, 0xB7, 0xC1, 0x3F, 0x6B,
Sergunb 0:8918a71cdbe9 1009 0x88, 0x47, 0xA3, 0xE7, 0x7E, 0xF1, 0x4F, 0xE3, 0xDB, 0x7F, 0xCA, 0xFE, 0x0C, 0xBD, 0x10, 0xE8,
Sergunb 0:8918a71cdbe9 1010 0xE8, 0x26, 0xE0, 0x34, 0x36, 0xD6, 0x46, 0xAA, 0xEF, 0x87, 0xB2, 0xE2, 0x47, 0xD4, 0xAF, 0x1E},
Sergunb 0:8918a71cdbe9 1011 48,
Sergunb 0:8918a71cdbe9 1012 //y-coordinate of the base point G
Sergunb 0:8918a71cdbe9 1013 {0x8A, 0xBE, 0x1D, 0x75, 0x20, 0xF9, 0xC2, 0xA4, 0x5C, 0xB1, 0xEB, 0x8E, 0x95, 0xCF, 0xD5, 0x52,
Sergunb 0:8918a71cdbe9 1014 0x62, 0xB7, 0x0B, 0x29, 0xFE, 0xEC, 0x58, 0x64, 0xE1, 0x9C, 0x05, 0x4F, 0xF9, 0x91, 0x29, 0x28,
Sergunb 0:8918a71cdbe9 1015 0x0E, 0x46, 0x46, 0x21, 0x77, 0x91, 0x81, 0x11, 0x42, 0x82, 0x03, 0x41, 0x26, 0x3C, 0x53, 0x15},
Sergunb 0:8918a71cdbe9 1016 48,
Sergunb 0:8918a71cdbe9 1017 //Base point order q
Sergunb 0:8918a71cdbe9 1018 {0x8C, 0xB9, 0x1E, 0x82, 0xA3, 0x38, 0x6D, 0x28, 0x0F, 0x5D, 0x6F, 0x7E, 0x50, 0xE6, 0x41, 0xDF,
Sergunb 0:8918a71cdbe9 1019 0x15, 0x2F, 0x71, 0x09, 0xED, 0x54, 0x56, 0xB3, 0x1F, 0x16, 0x6E, 0x6C, 0xAC, 0x04, 0x25, 0xA7,
Sergunb 0:8918a71cdbe9 1020 0xCF, 0x3A, 0xB6, 0xAF, 0x6B, 0x7F, 0xC3, 0x10, 0x3B, 0x88, 0x32, 0x02, 0xE9, 0x04, 0x65, 0x65},
Sergunb 0:8918a71cdbe9 1021 48,
Sergunb 0:8918a71cdbe9 1022 //Cofactor
Sergunb 0:8918a71cdbe9 1023 1,
Sergunb 0:8918a71cdbe9 1024 //Fast modular reduction
Sergunb 0:8918a71cdbe9 1025 NULL
Sergunb 0:8918a71cdbe9 1026 };
Sergunb 0:8918a71cdbe9 1027
Sergunb 0:8918a71cdbe9 1028
Sergunb 0:8918a71cdbe9 1029 /**
Sergunb 0:8918a71cdbe9 1030 * @brief brainpoolP512r1 elliptic curve
Sergunb 0:8918a71cdbe9 1031 **/
Sergunb 0:8918a71cdbe9 1032
Sergunb 0:8918a71cdbe9 1033 const EcCurveInfo brainpoolP512r1Curve =
Sergunb 0:8918a71cdbe9 1034 {
Sergunb 0:8918a71cdbe9 1035 //Curve name
Sergunb 0:8918a71cdbe9 1036 "brainpoolP512r1",
Sergunb 0:8918a71cdbe9 1037 //Object identifier
Sergunb 0:8918a71cdbe9 1038 BRAINPOOLP512R1_OID,
Sergunb 0:8918a71cdbe9 1039 sizeof(BRAINPOOLP512R1_OID),
Sergunb 0:8918a71cdbe9 1040 //Curve type
Sergunb 0:8918a71cdbe9 1041 EC_CURVE_TYPE_BRAINPOOLP_R1,
Sergunb 0:8918a71cdbe9 1042 //Prime modulus p
Sergunb 0:8918a71cdbe9 1043 {0xAA, 0xDD, 0x9D, 0xB8, 0xDB, 0xE9, 0xC4, 0x8B, 0x3F, 0xD4, 0xE6, 0xAE, 0x33, 0xC9, 0xFC, 0x07,
Sergunb 0:8918a71cdbe9 1044 0xCB, 0x30, 0x8D, 0xB3, 0xB3, 0xC9, 0xD2, 0x0E, 0xD6, 0x63, 0x9C, 0xCA, 0x70, 0x33, 0x08, 0x71,
Sergunb 0:8918a71cdbe9 1045 0x7D, 0x4D, 0x9B, 0x00, 0x9B, 0xC6, 0x68, 0x42, 0xAE, 0xCD, 0xA1, 0x2A, 0xE6, 0xA3, 0x80, 0xE6,
Sergunb 0:8918a71cdbe9 1046 0x28, 0x81, 0xFF, 0x2F, 0x2D, 0x82, 0xC6, 0x85, 0x28, 0xAA, 0x60, 0x56, 0x58, 0x3A, 0x48, 0xF3},
Sergunb 0:8918a71cdbe9 1047 64,
Sergunb 0:8918a71cdbe9 1048 //Curve parameter a
Sergunb 0:8918a71cdbe9 1049 {0x78, 0x30, 0xA3, 0x31, 0x8B, 0x60, 0x3B, 0x89, 0xE2, 0x32, 0x71, 0x45, 0xAC, 0x23, 0x4C, 0xC5,
Sergunb 0:8918a71cdbe9 1050 0x94, 0xCB, 0xDD, 0x8D, 0x3D, 0xF9, 0x16, 0x10, 0xA8, 0x34, 0x41, 0xCA, 0xEA, 0x98, 0x63, 0xBC,
Sergunb 0:8918a71cdbe9 1051 0x2D, 0xED, 0x5D, 0x5A, 0xA8, 0x25, 0x3A, 0xA1, 0x0A, 0x2E, 0xF1, 0xC9, 0x8B, 0x9A, 0xC8, 0xB5,
Sergunb 0:8918a71cdbe9 1052 0x7F, 0x11, 0x17, 0xA7, 0x2B, 0xF2, 0xC7, 0xB9, 0xE7, 0xC1, 0xAC, 0x4D, 0x77, 0xFC, 0x94, 0xCA},
Sergunb 0:8918a71cdbe9 1053 64,
Sergunb 0:8918a71cdbe9 1054 //Curve parameter b
Sergunb 0:8918a71cdbe9 1055 {0x3D, 0xF9, 0x16, 0x10, 0xA8, 0x34, 0x41, 0xCA, 0xEA, 0x98, 0x63, 0xBC, 0x2D, 0xED, 0x5D, 0x5A,
Sergunb 0:8918a71cdbe9 1056 0xA8, 0x25, 0x3A, 0xA1, 0x0A, 0x2E, 0xF1, 0xC9, 0x8B, 0x9A, 0xC8, 0xB5, 0x7F, 0x11, 0x17, 0xA7,
Sergunb 0:8918a71cdbe9 1057 0x2B, 0xF2, 0xC7, 0xB9, 0xE7, 0xC1, 0xAC, 0x4D, 0x77, 0xFC, 0x94, 0xCA, 0xDC, 0x08, 0x3E, 0x67,
Sergunb 0:8918a71cdbe9 1058 0x98, 0x40, 0x50, 0xB7, 0x5E, 0xBA, 0xE5, 0xDD, 0x28, 0x09, 0xBD, 0x63, 0x80, 0x16, 0xF7, 0x23},
Sergunb 0:8918a71cdbe9 1059 64,
Sergunb 0:8918a71cdbe9 1060 //x-coordinate of the base point G
Sergunb 0:8918a71cdbe9 1061 {0x81, 0xAE, 0xE4, 0xBD, 0xD8, 0x2E, 0xD9, 0x64, 0x5A, 0x21, 0x32, 0x2E, 0x9C, 0x4C, 0x6A, 0x93,
Sergunb 0:8918a71cdbe9 1062 0x85, 0xED, 0x9F, 0x70, 0xB5, 0xD9, 0x16, 0xC1, 0xB4, 0x3B, 0x62, 0xEE, 0xF4, 0xD0, 0x09, 0x8E,
Sergunb 0:8918a71cdbe9 1063 0xFF, 0x3B, 0x1F, 0x78, 0xE2, 0xD0, 0xD4, 0x8D, 0x50, 0xD1, 0x68, 0x7B, 0x93, 0xB9, 0x7D, 0x5F,
Sergunb 0:8918a71cdbe9 1064 0x7C, 0x6D, 0x50, 0x47, 0x40, 0x6A, 0x5E, 0x68, 0x8B, 0x35, 0x22, 0x09, 0xBC, 0xB9, 0xF8, 0x22},
Sergunb 0:8918a71cdbe9 1065 64,
Sergunb 0:8918a71cdbe9 1066 //y-coordinate of the base point G
Sergunb 0:8918a71cdbe9 1067 {0x7D, 0xDE, 0x38, 0x5D, 0x56, 0x63, 0x32, 0xEC, 0xC0, 0xEA, 0xBF, 0xA9, 0xCF, 0x78, 0x22, 0xFD,
Sergunb 0:8918a71cdbe9 1068 0xF2, 0x09, 0xF7, 0x00, 0x24, 0xA5, 0x7B, 0x1A, 0xA0, 0x00, 0xC5, 0x5B, 0x88, 0x1F, 0x81, 0x11,
Sergunb 0:8918a71cdbe9 1069 0xB2, 0xDC, 0xDE, 0x49, 0x4A, 0x5F, 0x48, 0x5E, 0x5B, 0xCA, 0x4B, 0xD8, 0x8A, 0x27, 0x63, 0xAE,
Sergunb 0:8918a71cdbe9 1070 0xD1, 0xCA, 0x2B, 0x2F, 0xA8, 0xF0, 0x54, 0x06, 0x78, 0xCD, 0x1E, 0x0F, 0x3A, 0xD8, 0x08, 0x92},
Sergunb 0:8918a71cdbe9 1071 64,
Sergunb 0:8918a71cdbe9 1072 //Base point order q
Sergunb 0:8918a71cdbe9 1073 {0xAA, 0xDD, 0x9D, 0xB8, 0xDB, 0xE9, 0xC4, 0x8B, 0x3F, 0xD4, 0xE6, 0xAE, 0x33, 0xC9, 0xFC, 0x07,
Sergunb 0:8918a71cdbe9 1074 0xCB, 0x30, 0x8D, 0xB3, 0xB3, 0xC9, 0xD2, 0x0E, 0xD6, 0x63, 0x9C, 0xCA, 0x70, 0x33, 0x08, 0x70,
Sergunb 0:8918a71cdbe9 1075 0x55, 0x3E, 0x5C, 0x41, 0x4C, 0xA9, 0x26, 0x19, 0x41, 0x86, 0x61, 0x19, 0x7F, 0xAC, 0x10, 0x47,
Sergunb 0:8918a71cdbe9 1076 0x1D, 0xB1, 0xD3, 0x81, 0x08, 0x5D, 0xDA, 0xDD, 0xB5, 0x87, 0x96, 0x82, 0x9C, 0xA9, 0x00, 0x69},
Sergunb 0:8918a71cdbe9 1077 64,
Sergunb 0:8918a71cdbe9 1078 //Cofactor
Sergunb 0:8918a71cdbe9 1079 1,
Sergunb 0:8918a71cdbe9 1080 //Fast modular reduction
Sergunb 0:8918a71cdbe9 1081 NULL
Sergunb 0:8918a71cdbe9 1082 };
Sergunb 0:8918a71cdbe9 1083
Sergunb 0:8918a71cdbe9 1084
Sergunb 0:8918a71cdbe9 1085 /**
Sergunb 0:8918a71cdbe9 1086 * @brief Fast modular reduction (secp128r1 curve)
Sergunb 0:8918a71cdbe9 1087 * @param[in,out] a This function accept an integer less than p^2 as
Sergunb 0:8918a71cdbe9 1088 * input and return (a mod p) as output
Sergunb 0:8918a71cdbe9 1089 * @param[in] p Prime modulus
Sergunb 0:8918a71cdbe9 1090 **/
Sergunb 0:8918a71cdbe9 1091
Sergunb 0:8918a71cdbe9 1092 error_t secp128r1Mod(Mpi *a, const Mpi *p)
Sergunb 0:8918a71cdbe9 1093 {
Sergunb 0:8918a71cdbe9 1094 error_t error;
Sergunb 0:8918a71cdbe9 1095 Mpi t;
Sergunb 0:8918a71cdbe9 1096
Sergunb 0:8918a71cdbe9 1097 //Initialize multiple precision integers
Sergunb 0:8918a71cdbe9 1098 mpiInit(&t);
Sergunb 0:8918a71cdbe9 1099
Sergunb 0:8918a71cdbe9 1100 //Ajust the size of the integers
Sergunb 0:8918a71cdbe9 1101 MPI_CHECK(mpiGrow(a, 32 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1102 MPI_CHECK(mpiGrow(&t, 32 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1103
Sergunb 0:8918a71cdbe9 1104 //Perform modular reduction
Sergunb 0:8918a71cdbe9 1105 do
Sergunb 0:8918a71cdbe9 1106 {
Sergunb 0:8918a71cdbe9 1107 //Compute T = 0 | 0 | 0 | 0 | A7 | A6 | A5 | A4
Sergunb 0:8918a71cdbe9 1108 COPY_WORD32(&t, 0, a, 4, 4);
Sergunb 0:8918a71cdbe9 1109 CLEAR_WORD32(&t, 4, 4);
Sergunb 0:8918a71cdbe9 1110
Sergunb 0:8918a71cdbe9 1111 //Clear A7 | A6 | A5 | A4
Sergunb 0:8918a71cdbe9 1112 CLEAR_WORD32(a, 4, 4);
Sergunb 0:8918a71cdbe9 1113
Sergunb 0:8918a71cdbe9 1114 //Compute A = A + T + (T << 97)
Sergunb 0:8918a71cdbe9 1115 MPI_CHECK(mpiAdd(a, a, &t));
Sergunb 0:8918a71cdbe9 1116 MPI_CHECK(mpiShiftLeft(&t, 97));
Sergunb 0:8918a71cdbe9 1117 MPI_CHECK(mpiAdd(a, a, &t));
Sergunb 0:8918a71cdbe9 1118
Sergunb 0:8918a71cdbe9 1119 //Check for end condition
Sergunb 0:8918a71cdbe9 1120 } while(mpiComp(a, p) > 0);
Sergunb 0:8918a71cdbe9 1121
Sergunb 0:8918a71cdbe9 1122 end:
Sergunb 0:8918a71cdbe9 1123 //Release multiple precision integers
Sergunb 0:8918a71cdbe9 1124 mpiFree(&t);
Sergunb 0:8918a71cdbe9 1125
Sergunb 0:8918a71cdbe9 1126 //Return status code
Sergunb 0:8918a71cdbe9 1127 return error;
Sergunb 0:8918a71cdbe9 1128 }
Sergunb 0:8918a71cdbe9 1129
Sergunb 0:8918a71cdbe9 1130
Sergunb 0:8918a71cdbe9 1131 /**
Sergunb 0:8918a71cdbe9 1132 * @brief Fast modular reduction (secp128r2 curve)
Sergunb 0:8918a71cdbe9 1133 * @param[in,out] a This function accept an integer less than p^2 as
Sergunb 0:8918a71cdbe9 1134 * input and return (a mod p) as output
Sergunb 0:8918a71cdbe9 1135 * @param[in] p Prime modulus
Sergunb 0:8918a71cdbe9 1136 **/
Sergunb 0:8918a71cdbe9 1137
Sergunb 0:8918a71cdbe9 1138 error_t secp128r2Mod(Mpi *a, const Mpi *p)
Sergunb 0:8918a71cdbe9 1139 {
Sergunb 0:8918a71cdbe9 1140 error_t error;
Sergunb 0:8918a71cdbe9 1141 Mpi t;
Sergunb 0:8918a71cdbe9 1142
Sergunb 0:8918a71cdbe9 1143 //Initialize multiple precision integers
Sergunb 0:8918a71cdbe9 1144 mpiInit(&t);
Sergunb 0:8918a71cdbe9 1145
Sergunb 0:8918a71cdbe9 1146 //Ajust the size of the integers
Sergunb 0:8918a71cdbe9 1147 MPI_CHECK(mpiGrow(a, 32 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1148 MPI_CHECK(mpiGrow(&t, 32 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1149
Sergunb 0:8918a71cdbe9 1150 //Perform modular reduction
Sergunb 0:8918a71cdbe9 1151 do
Sergunb 0:8918a71cdbe9 1152 {
Sergunb 0:8918a71cdbe9 1153 //Compute T = 0 | 0 | 0 | 0 | A7 | A6 | A5 | A4
Sergunb 0:8918a71cdbe9 1154 COPY_WORD32(&t, 0, a, 4, 4);
Sergunb 0:8918a71cdbe9 1155 CLEAR_WORD32(&t, 4, 4);
Sergunb 0:8918a71cdbe9 1156
Sergunb 0:8918a71cdbe9 1157 //Clear A7 | A6 | A5 | A4
Sergunb 0:8918a71cdbe9 1158 CLEAR_WORD32(a, 4, 4);
Sergunb 0:8918a71cdbe9 1159
Sergunb 0:8918a71cdbe9 1160 //Compute A = A + T + (T << 97)
Sergunb 0:8918a71cdbe9 1161 MPI_CHECK(mpiAdd(a, a, &t));
Sergunb 0:8918a71cdbe9 1162 MPI_CHECK(mpiShiftLeft(&t, 97));
Sergunb 0:8918a71cdbe9 1163 MPI_CHECK(mpiAdd(a, a, &t));
Sergunb 0:8918a71cdbe9 1164
Sergunb 0:8918a71cdbe9 1165 //Check for end condition
Sergunb 0:8918a71cdbe9 1166 } while(mpiComp(a, p) > 0);
Sergunb 0:8918a71cdbe9 1167
Sergunb 0:8918a71cdbe9 1168 end:
Sergunb 0:8918a71cdbe9 1169 //Release multiple precision integers
Sergunb 0:8918a71cdbe9 1170 mpiFree(&t);
Sergunb 0:8918a71cdbe9 1171
Sergunb 0:8918a71cdbe9 1172 //Return status code
Sergunb 0:8918a71cdbe9 1173 return error;
Sergunb 0:8918a71cdbe9 1174 }
Sergunb 0:8918a71cdbe9 1175
Sergunb 0:8918a71cdbe9 1176
Sergunb 0:8918a71cdbe9 1177 /**
Sergunb 0:8918a71cdbe9 1178 * @brief Fast modular reduction (secp160k1 curve)
Sergunb 0:8918a71cdbe9 1179 * @param[in,out] a This function accept an integer less than p^2 as
Sergunb 0:8918a71cdbe9 1180 * input and return (a mod p) as output
Sergunb 0:8918a71cdbe9 1181 * @param[in] p Prime modulus
Sergunb 0:8918a71cdbe9 1182 **/
Sergunb 0:8918a71cdbe9 1183
Sergunb 0:8918a71cdbe9 1184 error_t secp160k1Mod(Mpi *a, const Mpi *p)
Sergunb 0:8918a71cdbe9 1185 {
Sergunb 0:8918a71cdbe9 1186 error_t error;
Sergunb 0:8918a71cdbe9 1187 Mpi t;
Sergunb 0:8918a71cdbe9 1188
Sergunb 0:8918a71cdbe9 1189 //Initialize multiple precision integers
Sergunb 0:8918a71cdbe9 1190 mpiInit(&t);
Sergunb 0:8918a71cdbe9 1191
Sergunb 0:8918a71cdbe9 1192 //Ajust the size of the integers
Sergunb 0:8918a71cdbe9 1193 MPI_CHECK(mpiGrow(a, 40 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1194 MPI_CHECK(mpiGrow(&t, 24 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1195
Sergunb 0:8918a71cdbe9 1196 //Perform modular reduction
Sergunb 0:8918a71cdbe9 1197 do
Sergunb 0:8918a71cdbe9 1198 {
Sergunb 0:8918a71cdbe9 1199 //Compute T = A9 | A8 | A7 | A6 | A5 | 0
Sergunb 0:8918a71cdbe9 1200 CLEAR_WORD32(&t, 0, 1);
Sergunb 0:8918a71cdbe9 1201 COPY_WORD32(&t, 1, a, 5, 5);
Sergunb 0:8918a71cdbe9 1202
Sergunb 0:8918a71cdbe9 1203 //Clear A9 | A8 | A7 | A6 | A5
Sergunb 0:8918a71cdbe9 1204 CLEAR_WORD32(a, 5, 5);
Sergunb 0:8918a71cdbe9 1205
Sergunb 0:8918a71cdbe9 1206 //Compute A = A + T
Sergunb 0:8918a71cdbe9 1207 MPI_CHECK(mpiAdd(a, a, &t));
Sergunb 0:8918a71cdbe9 1208 //Compute T = T >> 32
Sergunb 0:8918a71cdbe9 1209 MPI_CHECK(mpiShiftRight(&t, 32));
Sergunb 0:8918a71cdbe9 1210 //Compute A = A + (21389 * T)
Sergunb 0:8918a71cdbe9 1211 MPI_CHECK(mpiMulInt(&t, &t, 21389));
Sergunb 0:8918a71cdbe9 1212 MPI_CHECK(mpiAdd(a, a, &t));
Sergunb 0:8918a71cdbe9 1213
Sergunb 0:8918a71cdbe9 1214 //Check for end condition
Sergunb 0:8918a71cdbe9 1215 } while(mpiComp(a, p) > 0);
Sergunb 0:8918a71cdbe9 1216
Sergunb 0:8918a71cdbe9 1217 end:
Sergunb 0:8918a71cdbe9 1218 //Release multiple precision integers
Sergunb 0:8918a71cdbe9 1219 mpiFree(&t);
Sergunb 0:8918a71cdbe9 1220
Sergunb 0:8918a71cdbe9 1221 //Return status code
Sergunb 0:8918a71cdbe9 1222 return error;
Sergunb 0:8918a71cdbe9 1223 }
Sergunb 0:8918a71cdbe9 1224
Sergunb 0:8918a71cdbe9 1225
Sergunb 0:8918a71cdbe9 1226 /**
Sergunb 0:8918a71cdbe9 1227 * @brief Fast modular reduction (secp160r1 curve)
Sergunb 0:8918a71cdbe9 1228 * @param[in,out] a This function accept an integer less than p^2 as
Sergunb 0:8918a71cdbe9 1229 * input and return (a mod p) as output
Sergunb 0:8918a71cdbe9 1230 * @param[in] p Prime modulus
Sergunb 0:8918a71cdbe9 1231 **/
Sergunb 0:8918a71cdbe9 1232
Sergunb 0:8918a71cdbe9 1233 error_t secp160r1Mod(Mpi *a, const Mpi *p)
Sergunb 0:8918a71cdbe9 1234 {
Sergunb 0:8918a71cdbe9 1235 error_t error;
Sergunb 0:8918a71cdbe9 1236 Mpi t;
Sergunb 0:8918a71cdbe9 1237
Sergunb 0:8918a71cdbe9 1238 //Initialize multiple precision integers
Sergunb 0:8918a71cdbe9 1239 mpiInit(&t);
Sergunb 0:8918a71cdbe9 1240
Sergunb 0:8918a71cdbe9 1241 //Ajust the size of the integers
Sergunb 0:8918a71cdbe9 1242 MPI_CHECK(mpiGrow(a, 40 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1243 MPI_CHECK(mpiGrow(&t, 24 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1244
Sergunb 0:8918a71cdbe9 1245 //Perform modular reduction
Sergunb 0:8918a71cdbe9 1246 do
Sergunb 0:8918a71cdbe9 1247 {
Sergunb 0:8918a71cdbe9 1248 //Compute T = 0 | A9 | A8 | A7 | A6 | A5
Sergunb 0:8918a71cdbe9 1249 COPY_WORD32(&t, 0, a, 5, 5);
Sergunb 0:8918a71cdbe9 1250 CLEAR_WORD32(&t, 5, 1);
Sergunb 0:8918a71cdbe9 1251
Sergunb 0:8918a71cdbe9 1252 //Clear A9 | A8 | A7 | A6 | A5
Sergunb 0:8918a71cdbe9 1253 CLEAR_WORD32(a, 5, 5);
Sergunb 0:8918a71cdbe9 1254
Sergunb 0:8918a71cdbe9 1255 //Compute A = A + T + (T << 31)
Sergunb 0:8918a71cdbe9 1256 MPI_CHECK(mpiAdd(a, a, &t));
Sergunb 0:8918a71cdbe9 1257 MPI_CHECK(mpiShiftLeft(&t, 31));
Sergunb 0:8918a71cdbe9 1258 MPI_CHECK(mpiAdd(a, a, &t));
Sergunb 0:8918a71cdbe9 1259
Sergunb 0:8918a71cdbe9 1260 //Check for end condition
Sergunb 0:8918a71cdbe9 1261 } while(mpiComp(a, p) > 0);
Sergunb 0:8918a71cdbe9 1262
Sergunb 0:8918a71cdbe9 1263 end:
Sergunb 0:8918a71cdbe9 1264 //Release multiple precision integers
Sergunb 0:8918a71cdbe9 1265 mpiFree(&t);
Sergunb 0:8918a71cdbe9 1266
Sergunb 0:8918a71cdbe9 1267 //Return status code
Sergunb 0:8918a71cdbe9 1268 return error;
Sergunb 0:8918a71cdbe9 1269 }
Sergunb 0:8918a71cdbe9 1270
Sergunb 0:8918a71cdbe9 1271
Sergunb 0:8918a71cdbe9 1272 /**
Sergunb 0:8918a71cdbe9 1273 * @brief Fast modular reduction (secp160r2 curve)
Sergunb 0:8918a71cdbe9 1274 * @param[in,out] a This function accept an integer less than p^2 as
Sergunb 0:8918a71cdbe9 1275 * input and return (a mod p) as output
Sergunb 0:8918a71cdbe9 1276 * @param[in] p Prime modulus
Sergunb 0:8918a71cdbe9 1277 **/
Sergunb 0:8918a71cdbe9 1278
Sergunb 0:8918a71cdbe9 1279 error_t secp160r2Mod(Mpi *a, const Mpi *p)
Sergunb 0:8918a71cdbe9 1280 {
Sergunb 0:8918a71cdbe9 1281 error_t error;
Sergunb 0:8918a71cdbe9 1282 Mpi t;
Sergunb 0:8918a71cdbe9 1283
Sergunb 0:8918a71cdbe9 1284 //Initialize multiple precision integers
Sergunb 0:8918a71cdbe9 1285 mpiInit(&t);
Sergunb 0:8918a71cdbe9 1286
Sergunb 0:8918a71cdbe9 1287 //Ajust the size of the integers
Sergunb 0:8918a71cdbe9 1288 MPI_CHECK(mpiGrow(a, 40 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1289 MPI_CHECK(mpiGrow(&t, 24 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1290
Sergunb 0:8918a71cdbe9 1291 //Perform modular reduction
Sergunb 0:8918a71cdbe9 1292 do
Sergunb 0:8918a71cdbe9 1293 {
Sergunb 0:8918a71cdbe9 1294 //Compute T = A9 | A8 | A7 | A6 | A5 | 0
Sergunb 0:8918a71cdbe9 1295 CLEAR_WORD32(&t, 0, 1);
Sergunb 0:8918a71cdbe9 1296 COPY_WORD32(&t, 1, a, 5, 5);
Sergunb 0:8918a71cdbe9 1297
Sergunb 0:8918a71cdbe9 1298 //Clear A9 | A8 | A7 | A6 | A5
Sergunb 0:8918a71cdbe9 1299 CLEAR_WORD32(a, 5, 5);
Sergunb 0:8918a71cdbe9 1300
Sergunb 0:8918a71cdbe9 1301 //Compute A = A + T
Sergunb 0:8918a71cdbe9 1302 MPI_CHECK(mpiAdd(a, a, &t));
Sergunb 0:8918a71cdbe9 1303 //Compute T = T >> 32
Sergunb 0:8918a71cdbe9 1304 MPI_CHECK(mpiShiftRight(&t, 32));
Sergunb 0:8918a71cdbe9 1305 //Compute A = A + (21389 * T)
Sergunb 0:8918a71cdbe9 1306 MPI_CHECK(mpiMulInt(&t, &t, 21389));
Sergunb 0:8918a71cdbe9 1307 MPI_CHECK(mpiAdd(a, a, &t));
Sergunb 0:8918a71cdbe9 1308
Sergunb 0:8918a71cdbe9 1309 //Check for end condition
Sergunb 0:8918a71cdbe9 1310 } while(mpiComp(a, p) > 0);
Sergunb 0:8918a71cdbe9 1311
Sergunb 0:8918a71cdbe9 1312 end:
Sergunb 0:8918a71cdbe9 1313 //Release multiple precision integers
Sergunb 0:8918a71cdbe9 1314 mpiFree(&t);
Sergunb 0:8918a71cdbe9 1315
Sergunb 0:8918a71cdbe9 1316 //Return status code
Sergunb 0:8918a71cdbe9 1317 return error;
Sergunb 0:8918a71cdbe9 1318 }
Sergunb 0:8918a71cdbe9 1319
Sergunb 0:8918a71cdbe9 1320
Sergunb 0:8918a71cdbe9 1321 /**
Sergunb 0:8918a71cdbe9 1322 * @brief Fast modular reduction (secp192k1 curve)
Sergunb 0:8918a71cdbe9 1323 * @param[in,out] a This function accept an integer less than p^2 as
Sergunb 0:8918a71cdbe9 1324 * input and return (a mod p) as output
Sergunb 0:8918a71cdbe9 1325 * @param[in] p Prime modulus
Sergunb 0:8918a71cdbe9 1326 **/
Sergunb 0:8918a71cdbe9 1327
Sergunb 0:8918a71cdbe9 1328 error_t secp192k1Mod(Mpi *a, const Mpi *p)
Sergunb 0:8918a71cdbe9 1329 {
Sergunb 0:8918a71cdbe9 1330 error_t error;
Sergunb 0:8918a71cdbe9 1331 Mpi t;
Sergunb 0:8918a71cdbe9 1332
Sergunb 0:8918a71cdbe9 1333 //Initialize multiple precision integers
Sergunb 0:8918a71cdbe9 1334 mpiInit(&t);
Sergunb 0:8918a71cdbe9 1335
Sergunb 0:8918a71cdbe9 1336 //Ajust the size of the integers
Sergunb 0:8918a71cdbe9 1337 MPI_CHECK(mpiGrow(a, 48 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1338 MPI_CHECK(mpiGrow(&t, 28 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1339
Sergunb 0:8918a71cdbe9 1340 //Perform modular reduction
Sergunb 0:8918a71cdbe9 1341 do
Sergunb 0:8918a71cdbe9 1342 {
Sergunb 0:8918a71cdbe9 1343 //Compute T = A11 | A10 | A9 | A8 | A7 | A6 | 0
Sergunb 0:8918a71cdbe9 1344 CLEAR_WORD32(&t, 0, 1);
Sergunb 0:8918a71cdbe9 1345 COPY_WORD32(&t, 1, a, 6, 6);
Sergunb 0:8918a71cdbe9 1346
Sergunb 0:8918a71cdbe9 1347 //Clear A11 | A10 | A9 | A8 | A7 | A6
Sergunb 0:8918a71cdbe9 1348 CLEAR_WORD32(a, 6, 6);
Sergunb 0:8918a71cdbe9 1349
Sergunb 0:8918a71cdbe9 1350 //Compute A = A + T
Sergunb 0:8918a71cdbe9 1351 MPI_CHECK(mpiAdd(a, a, &t));
Sergunb 0:8918a71cdbe9 1352 //Compute T = T >> 32
Sergunb 0:8918a71cdbe9 1353 MPI_CHECK(mpiShiftRight(&t, 32));
Sergunb 0:8918a71cdbe9 1354 //Compute A = A + (4553 * T)
Sergunb 0:8918a71cdbe9 1355 MPI_CHECK(mpiMulInt(&t, &t, 4553));
Sergunb 0:8918a71cdbe9 1356 MPI_CHECK(mpiAdd(a, a, &t));
Sergunb 0:8918a71cdbe9 1357
Sergunb 0:8918a71cdbe9 1358 //Check for end condition
Sergunb 0:8918a71cdbe9 1359 } while(mpiComp(a, p) > 0);
Sergunb 0:8918a71cdbe9 1360
Sergunb 0:8918a71cdbe9 1361 end:
Sergunb 0:8918a71cdbe9 1362 //Release multiple precision integers
Sergunb 0:8918a71cdbe9 1363 mpiFree(&t);
Sergunb 0:8918a71cdbe9 1364
Sergunb 0:8918a71cdbe9 1365 //Return status code
Sergunb 0:8918a71cdbe9 1366 return error;
Sergunb 0:8918a71cdbe9 1367 }
Sergunb 0:8918a71cdbe9 1368
Sergunb 0:8918a71cdbe9 1369
Sergunb 0:8918a71cdbe9 1370 /**
Sergunb 0:8918a71cdbe9 1371 * @brief Fast modular reduction (secp192r1 curve)
Sergunb 0:8918a71cdbe9 1372 * @param[in,out] a This function accept an integer less than p^2 as
Sergunb 0:8918a71cdbe9 1373 * input and return (a mod p) as output
Sergunb 0:8918a71cdbe9 1374 * @param[in] p Prime modulus
Sergunb 0:8918a71cdbe9 1375 **/
Sergunb 0:8918a71cdbe9 1376
Sergunb 0:8918a71cdbe9 1377 error_t secp192r1Mod(Mpi *a, const Mpi *p)
Sergunb 0:8918a71cdbe9 1378 {
Sergunb 0:8918a71cdbe9 1379 error_t error;
Sergunb 0:8918a71cdbe9 1380 Mpi s;
Sergunb 0:8918a71cdbe9 1381 Mpi t;
Sergunb 0:8918a71cdbe9 1382
Sergunb 0:8918a71cdbe9 1383 //Initialize multiple precision integers
Sergunb 0:8918a71cdbe9 1384 mpiInit(&s);
Sergunb 0:8918a71cdbe9 1385 mpiInit(&t);
Sergunb 0:8918a71cdbe9 1386
Sergunb 0:8918a71cdbe9 1387 //Ajust the size of the integers
Sergunb 0:8918a71cdbe9 1388 MPI_CHECK(mpiGrow(a, 48 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1389 MPI_CHECK(mpiGrow(&s, 24 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1390 MPI_CHECK(mpiGrow(&t, 24 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1391
Sergunb 0:8918a71cdbe9 1392 //Compute T = A5 | A4 | A3 | A2 | A1 | A0
Sergunb 0:8918a71cdbe9 1393 COPY_WORD32(&t, 0, a, 0, 6);
Sergunb 0:8918a71cdbe9 1394
Sergunb 0:8918a71cdbe9 1395 //Compute S1 = 0 | 0 | A7 | A6 | A7 | A6
Sergunb 0:8918a71cdbe9 1396 COPY_WORD32(&s, 0, a, 6, 2);
Sergunb 0:8918a71cdbe9 1397 COPY_WORD32(&s, 2, a, 6, 2);
Sergunb 0:8918a71cdbe9 1398 CLEAR_WORD32(&s, 4, 2);
Sergunb 0:8918a71cdbe9 1399 //Compute T = T + S1
Sergunb 0:8918a71cdbe9 1400 MPI_CHECK(mpiAdd(&t, &t, &s));
Sergunb 0:8918a71cdbe9 1401
Sergunb 0:8918a71cdbe9 1402 //Compute S2 = A9 | A8 | A9 | A8 | 0 | 0
Sergunb 0:8918a71cdbe9 1403 CLEAR_WORD32(&s, 0, 2);
Sergunb 0:8918a71cdbe9 1404 COPY_WORD32(&s, 2, a, 8, 2);
Sergunb 0:8918a71cdbe9 1405 COPY_WORD32(&s, 4, a, 8, 2);
Sergunb 0:8918a71cdbe9 1406 //Compute T = T + S2
Sergunb 0:8918a71cdbe9 1407 MPI_CHECK(mpiAdd(&t, &t, &s));
Sergunb 0:8918a71cdbe9 1408
Sergunb 0:8918a71cdbe9 1409 //Compute S3 = A11 | A10 | A11 | A10 | A11 | A10
Sergunb 0:8918a71cdbe9 1410 COPY_WORD32(&s, 0, a, 10, 2);
Sergunb 0:8918a71cdbe9 1411 COPY_WORD32(&s, 2, a, 10, 2);
Sergunb 0:8918a71cdbe9 1412 COPY_WORD32(&s, 4, a, 10, 2);
Sergunb 0:8918a71cdbe9 1413 //Compute T = T + S3
Sergunb 0:8918a71cdbe9 1414 MPI_CHECK(mpiAdd(&t, &t, &s));
Sergunb 0:8918a71cdbe9 1415
Sergunb 0:8918a71cdbe9 1416 //Compute (T + S1 + S2 + S3) mod p
Sergunb 0:8918a71cdbe9 1417 while(mpiComp(&t, p) >= 0)
Sergunb 0:8918a71cdbe9 1418 {
Sergunb 0:8918a71cdbe9 1419 MPI_CHECK(mpiSub(&t, &t, p));
Sergunb 0:8918a71cdbe9 1420 }
Sergunb 0:8918a71cdbe9 1421
Sergunb 0:8918a71cdbe9 1422 //Save result
Sergunb 0:8918a71cdbe9 1423 MPI_CHECK(mpiCopy(a, &t));
Sergunb 0:8918a71cdbe9 1424
Sergunb 0:8918a71cdbe9 1425 end:
Sergunb 0:8918a71cdbe9 1426 //Release multiple precision integers
Sergunb 0:8918a71cdbe9 1427 mpiFree(&s);
Sergunb 0:8918a71cdbe9 1428 mpiFree(&t);
Sergunb 0:8918a71cdbe9 1429
Sergunb 0:8918a71cdbe9 1430 //Return status code
Sergunb 0:8918a71cdbe9 1431 return error;
Sergunb 0:8918a71cdbe9 1432 }
Sergunb 0:8918a71cdbe9 1433
Sergunb 0:8918a71cdbe9 1434
Sergunb 0:8918a71cdbe9 1435 /**
Sergunb 0:8918a71cdbe9 1436 * @brief Fast modular reduction (secp224k1 curve)
Sergunb 0:8918a71cdbe9 1437 * @param[in,out] a This function accept an integer less than p^2 as
Sergunb 0:8918a71cdbe9 1438 * input and return (a mod p) as output
Sergunb 0:8918a71cdbe9 1439 * @param[in] p Prime modulus
Sergunb 0:8918a71cdbe9 1440 **/
Sergunb 0:8918a71cdbe9 1441
Sergunb 0:8918a71cdbe9 1442 error_t secp224k1Mod(Mpi *a, const Mpi *p)
Sergunb 0:8918a71cdbe9 1443 {
Sergunb 0:8918a71cdbe9 1444 error_t error;
Sergunb 0:8918a71cdbe9 1445 Mpi t;
Sergunb 0:8918a71cdbe9 1446
Sergunb 0:8918a71cdbe9 1447 //Initialize multiple precision integers
Sergunb 0:8918a71cdbe9 1448 mpiInit(&t);
Sergunb 0:8918a71cdbe9 1449
Sergunb 0:8918a71cdbe9 1450 //Ajust the size of the integers
Sergunb 0:8918a71cdbe9 1451 MPI_CHECK(mpiGrow(a, 56 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1452 MPI_CHECK(mpiGrow(&t, 32 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1453
Sergunb 0:8918a71cdbe9 1454 //Perform modular reduction
Sergunb 0:8918a71cdbe9 1455 do
Sergunb 0:8918a71cdbe9 1456 {
Sergunb 0:8918a71cdbe9 1457 //Compute T = A13 | A12 | A11 | A10 | A9 | A8 | A7 | 0
Sergunb 0:8918a71cdbe9 1458 CLEAR_WORD32(&t, 0, 1);
Sergunb 0:8918a71cdbe9 1459 COPY_WORD32(&t, 1, a, 7, 7);
Sergunb 0:8918a71cdbe9 1460
Sergunb 0:8918a71cdbe9 1461 //Clear A13 | A12 | A11 | A10 | A9 | A8 | A7
Sergunb 0:8918a71cdbe9 1462 CLEAR_WORD32(a, 7, 7);
Sergunb 0:8918a71cdbe9 1463
Sergunb 0:8918a71cdbe9 1464 //Compute A = A + T
Sergunb 0:8918a71cdbe9 1465 MPI_CHECK(mpiAdd(a, a, &t));
Sergunb 0:8918a71cdbe9 1466 //Compute T = T >> 32
Sergunb 0:8918a71cdbe9 1467 MPI_CHECK(mpiShiftRight(&t, 32));
Sergunb 0:8918a71cdbe9 1468 //Compute A = A + (6803 * T)
Sergunb 0:8918a71cdbe9 1469 MPI_CHECK(mpiMulInt(&t, &t, 6803));
Sergunb 0:8918a71cdbe9 1470 MPI_CHECK(mpiAdd(a, a, &t));
Sergunb 0:8918a71cdbe9 1471
Sergunb 0:8918a71cdbe9 1472 //Check for end condition
Sergunb 0:8918a71cdbe9 1473 } while(mpiComp(a, p) > 0);
Sergunb 0:8918a71cdbe9 1474
Sergunb 0:8918a71cdbe9 1475 end:
Sergunb 0:8918a71cdbe9 1476 //Release multiple precision integers
Sergunb 0:8918a71cdbe9 1477 mpiFree(&t);
Sergunb 0:8918a71cdbe9 1478
Sergunb 0:8918a71cdbe9 1479 //Return status code
Sergunb 0:8918a71cdbe9 1480 return error;
Sergunb 0:8918a71cdbe9 1481 }
Sergunb 0:8918a71cdbe9 1482
Sergunb 0:8918a71cdbe9 1483
Sergunb 0:8918a71cdbe9 1484 /**
Sergunb 0:8918a71cdbe9 1485 * @brief Fast modular reduction (secp224r1 curve)
Sergunb 0:8918a71cdbe9 1486 * @param[in,out] a This function accept an integer less than p^2 as
Sergunb 0:8918a71cdbe9 1487 * input and return (a mod p) as output
Sergunb 0:8918a71cdbe9 1488 * @param[in] p Prime modulus
Sergunb 0:8918a71cdbe9 1489 **/
Sergunb 0:8918a71cdbe9 1490
Sergunb 0:8918a71cdbe9 1491 error_t secp224r1Mod(Mpi *a, const Mpi *p)
Sergunb 0:8918a71cdbe9 1492 {
Sergunb 0:8918a71cdbe9 1493 error_t error;
Sergunb 0:8918a71cdbe9 1494 Mpi s;
Sergunb 0:8918a71cdbe9 1495 Mpi t;
Sergunb 0:8918a71cdbe9 1496
Sergunb 0:8918a71cdbe9 1497 //Initialize multiple precision integers
Sergunb 0:8918a71cdbe9 1498 mpiInit(&s);
Sergunb 0:8918a71cdbe9 1499 mpiInit(&t);
Sergunb 0:8918a71cdbe9 1500
Sergunb 0:8918a71cdbe9 1501 //Ajust the size of the integers
Sergunb 0:8918a71cdbe9 1502 MPI_CHECK(mpiGrow(a, 56 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1503 MPI_CHECK(mpiGrow(&s, 28 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1504 MPI_CHECK(mpiGrow(&t, 28 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1505
Sergunb 0:8918a71cdbe9 1506 //Compute T = A6 | A5 | A4 | A3 | A2 | A1 | A0
Sergunb 0:8918a71cdbe9 1507 COPY_WORD32(&t, 0, a, 0, 7);
Sergunb 0:8918a71cdbe9 1508
Sergunb 0:8918a71cdbe9 1509 //Compute S1 = A10 | A9 | A8 | A7 | 0 | 0 | 0
Sergunb 0:8918a71cdbe9 1510 CLEAR_WORD32(&s, 0, 3);
Sergunb 0:8918a71cdbe9 1511 COPY_WORD32(&s, 3, a, 7, 4);
Sergunb 0:8918a71cdbe9 1512 //Compute T = T + S1
Sergunb 0:8918a71cdbe9 1513 MPI_CHECK(mpiAdd(&t, &t, &s));
Sergunb 0:8918a71cdbe9 1514
Sergunb 0:8918a71cdbe9 1515 //Compute S2 = 0 | A13 | A12 | A11 | 0 | 0 | 0
Sergunb 0:8918a71cdbe9 1516 CLEAR_WORD32(&s, 0, 3);
Sergunb 0:8918a71cdbe9 1517 COPY_WORD32(&s, 3, a, 11, 3);
Sergunb 0:8918a71cdbe9 1518 CLEAR_WORD32(&s, 6, 1);
Sergunb 0:8918a71cdbe9 1519 //Compute T = T + S2
Sergunb 0:8918a71cdbe9 1520 MPI_CHECK(mpiAdd(&t, &t, &s));
Sergunb 0:8918a71cdbe9 1521
Sergunb 0:8918a71cdbe9 1522 //Compute D1 = A13 | A12 | A11 | A10 | A9 | A8 | A7
Sergunb 0:8918a71cdbe9 1523 COPY_WORD32(&s, 0, a, 7, 7);
Sergunb 0:8918a71cdbe9 1524 //Compute T = T - D1
Sergunb 0:8918a71cdbe9 1525 MPI_CHECK(mpiSub(&t, &t, &s));
Sergunb 0:8918a71cdbe9 1526
Sergunb 0:8918a71cdbe9 1527 //Compute D2 = 0 | 0 | 0 | 0 | A13 | A12 | A11
Sergunb 0:8918a71cdbe9 1528 COPY_WORD32(&s, 0, a, 11, 3);
Sergunb 0:8918a71cdbe9 1529 CLEAR_WORD32(&s, 3, 4);
Sergunb 0:8918a71cdbe9 1530 //Compute T = T - D2
Sergunb 0:8918a71cdbe9 1531 MPI_CHECK(mpiSub(&t, &t, &s));
Sergunb 0:8918a71cdbe9 1532
Sergunb 0:8918a71cdbe9 1533 //Compute (T + S1 + S2 - D1 - D2) mod p
Sergunb 0:8918a71cdbe9 1534 while(mpiComp(&t, p) >= 0)
Sergunb 0:8918a71cdbe9 1535 {
Sergunb 0:8918a71cdbe9 1536 MPI_CHECK(mpiSub(&t, &t, p));
Sergunb 0:8918a71cdbe9 1537 }
Sergunb 0:8918a71cdbe9 1538
Sergunb 0:8918a71cdbe9 1539 while(mpiCompInt(&t, 0) < 0)
Sergunb 0:8918a71cdbe9 1540 {
Sergunb 0:8918a71cdbe9 1541 MPI_CHECK(mpiAdd(&t, &t, p));
Sergunb 0:8918a71cdbe9 1542 }
Sergunb 0:8918a71cdbe9 1543
Sergunb 0:8918a71cdbe9 1544 //Save result
Sergunb 0:8918a71cdbe9 1545 MPI_CHECK(mpiCopy(a, &t));
Sergunb 0:8918a71cdbe9 1546
Sergunb 0:8918a71cdbe9 1547 end:
Sergunb 0:8918a71cdbe9 1548 //Release multiple precision integers
Sergunb 0:8918a71cdbe9 1549 mpiFree(&s);
Sergunb 0:8918a71cdbe9 1550 mpiFree(&t);
Sergunb 0:8918a71cdbe9 1551
Sergunb 0:8918a71cdbe9 1552 //Return status code
Sergunb 0:8918a71cdbe9 1553 return error;
Sergunb 0:8918a71cdbe9 1554 }
Sergunb 0:8918a71cdbe9 1555
Sergunb 0:8918a71cdbe9 1556
Sergunb 0:8918a71cdbe9 1557 /**
Sergunb 0:8918a71cdbe9 1558 * @brief Fast modular reduction (secp256k1 curve)
Sergunb 0:8918a71cdbe9 1559 * @param[in,out] a This function accept an integer less than p^2 as
Sergunb 0:8918a71cdbe9 1560 * input and return (a mod p) as output
Sergunb 0:8918a71cdbe9 1561 * @param[in] p Prime modulus
Sergunb 0:8918a71cdbe9 1562 **/
Sergunb 0:8918a71cdbe9 1563
Sergunb 0:8918a71cdbe9 1564 error_t secp256k1Mod(Mpi *a, const Mpi *p)
Sergunb 0:8918a71cdbe9 1565 {
Sergunb 0:8918a71cdbe9 1566 error_t error;
Sergunb 0:8918a71cdbe9 1567 Mpi t;
Sergunb 0:8918a71cdbe9 1568
Sergunb 0:8918a71cdbe9 1569 //Initialize multiple precision integers
Sergunb 0:8918a71cdbe9 1570 mpiInit(&t);
Sergunb 0:8918a71cdbe9 1571
Sergunb 0:8918a71cdbe9 1572 //Ajust the size of the integers
Sergunb 0:8918a71cdbe9 1573 MPI_CHECK(mpiGrow(a, 64 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1574 MPI_CHECK(mpiGrow(&t, 36 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1575
Sergunb 0:8918a71cdbe9 1576 //Perform modular reduction
Sergunb 0:8918a71cdbe9 1577 do
Sergunb 0:8918a71cdbe9 1578 {
Sergunb 0:8918a71cdbe9 1579 //Compute T = A15 | A14 | A13 | A12 | A11 | A10 | A9 | A8 | 0
Sergunb 0:8918a71cdbe9 1580 CLEAR_WORD32(&t, 0, 1);
Sergunb 0:8918a71cdbe9 1581 COPY_WORD32(&t, 1, a, 8, 8);
Sergunb 0:8918a71cdbe9 1582
Sergunb 0:8918a71cdbe9 1583 //Clear A15 | A14 | A13 | A12 | A11 | A10 | A9 | A8
Sergunb 0:8918a71cdbe9 1584 CLEAR_WORD32(a, 8, 8);
Sergunb 0:8918a71cdbe9 1585
Sergunb 0:8918a71cdbe9 1586 //Compute A = A + T
Sergunb 0:8918a71cdbe9 1587 MPI_CHECK(mpiAdd(a, a, &t));
Sergunb 0:8918a71cdbe9 1588 //Compute T = T >> 32
Sergunb 0:8918a71cdbe9 1589 MPI_CHECK(mpiShiftRight(&t, 32));
Sergunb 0:8918a71cdbe9 1590 //Compute A = A + (977 * T)
Sergunb 0:8918a71cdbe9 1591 MPI_CHECK(mpiMulInt(&t, &t, 977));
Sergunb 0:8918a71cdbe9 1592 MPI_CHECK(mpiAdd(a, a, &t));
Sergunb 0:8918a71cdbe9 1593
Sergunb 0:8918a71cdbe9 1594 //Check for end condition
Sergunb 0:8918a71cdbe9 1595 } while(mpiComp(a, p) > 0);
Sergunb 0:8918a71cdbe9 1596
Sergunb 0:8918a71cdbe9 1597 end:
Sergunb 0:8918a71cdbe9 1598 //Release multiple precision integers
Sergunb 0:8918a71cdbe9 1599 mpiFree(&t);
Sergunb 0:8918a71cdbe9 1600
Sergunb 0:8918a71cdbe9 1601 //Return status code
Sergunb 0:8918a71cdbe9 1602 return error;
Sergunb 0:8918a71cdbe9 1603 }
Sergunb 0:8918a71cdbe9 1604
Sergunb 0:8918a71cdbe9 1605
Sergunb 0:8918a71cdbe9 1606 /**
Sergunb 0:8918a71cdbe9 1607 * @brief Fast modular reduction (secp256r1 curve)
Sergunb 0:8918a71cdbe9 1608 * @param[in,out] a This function accept an integer less than p^2 as
Sergunb 0:8918a71cdbe9 1609 * input and return (a mod p) as output
Sergunb 0:8918a71cdbe9 1610 * @param[in] p Prime modulus
Sergunb 0:8918a71cdbe9 1611 **/
Sergunb 0:8918a71cdbe9 1612
Sergunb 0:8918a71cdbe9 1613 error_t secp256r1Mod(Mpi *a, const Mpi *p)
Sergunb 0:8918a71cdbe9 1614 {
Sergunb 0:8918a71cdbe9 1615 error_t error;
Sergunb 0:8918a71cdbe9 1616 Mpi s;
Sergunb 0:8918a71cdbe9 1617 Mpi t;
Sergunb 0:8918a71cdbe9 1618 Mpi b;
Sergunb 0:8918a71cdbe9 1619
Sergunb 0:8918a71cdbe9 1620 //Initialize multiple precision integers
Sergunb 0:8918a71cdbe9 1621 mpiInit(&s);
Sergunb 0:8918a71cdbe9 1622 mpiInit(&t);
Sergunb 0:8918a71cdbe9 1623 mpiInit(&b);
Sergunb 0:8918a71cdbe9 1624
Sergunb 0:8918a71cdbe9 1625 //Ajust the size of the integers
Sergunb 0:8918a71cdbe9 1626 MPI_CHECK(mpiGrow(a, 64 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1627 MPI_CHECK(mpiGrow(&s, 32 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1628 MPI_CHECK(mpiGrow(&t, 32 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1629
Sergunb 0:8918a71cdbe9 1630 //Compute T = A7 | A6 | A5 | A4 | A3 | A2 | A1 | A0
Sergunb 0:8918a71cdbe9 1631 COPY_WORD32(&t, 0, a, 0, 8);
Sergunb 0:8918a71cdbe9 1632
Sergunb 0:8918a71cdbe9 1633 //Compute S1 = A15 | A14 | A13 | A12 | A11 | 0 | 0 | 0
Sergunb 0:8918a71cdbe9 1634 CLEAR_WORD32(&s, 0, 3);
Sergunb 0:8918a71cdbe9 1635 COPY_WORD32(&s, 3, a, 11, 5);
Sergunb 0:8918a71cdbe9 1636 //Compute T = T + 2 * S1
Sergunb 0:8918a71cdbe9 1637 MPI_CHECK(mpiAdd(&t, &t, &s));
Sergunb 0:8918a71cdbe9 1638 MPI_CHECK(mpiAdd(&t, &t, &s));
Sergunb 0:8918a71cdbe9 1639
Sergunb 0:8918a71cdbe9 1640 //Compute S2 = 0 | A15 | A14 | A13 | A12 | 0 | 0 | 0
Sergunb 0:8918a71cdbe9 1641 CLEAR_WORD32(&s, 0, 3);
Sergunb 0:8918a71cdbe9 1642 COPY_WORD32(&s, 3, a, 12, 4);
Sergunb 0:8918a71cdbe9 1643 CLEAR_WORD32(&s, 7, 1);
Sergunb 0:8918a71cdbe9 1644 //Compute T = T + 2 * S2
Sergunb 0:8918a71cdbe9 1645 MPI_CHECK(mpiAdd(&t, &t, &s));
Sergunb 0:8918a71cdbe9 1646 MPI_CHECK(mpiAdd(&t, &t, &s));
Sergunb 0:8918a71cdbe9 1647
Sergunb 0:8918a71cdbe9 1648 //Compute S3 = A15 | A14 | 0 | 0 | 0 | A10 | A9 | A8
Sergunb 0:8918a71cdbe9 1649 COPY_WORD32(&s, 0, a, 8, 3);
Sergunb 0:8918a71cdbe9 1650 CLEAR_WORD32(&s, 3, 3);
Sergunb 0:8918a71cdbe9 1651 COPY_WORD32(&s, 6, a, 14, 2);
Sergunb 0:8918a71cdbe9 1652 //Compute T = T + S3
Sergunb 0:8918a71cdbe9 1653 MPI_CHECK(mpiAdd(&t, &t, &s));
Sergunb 0:8918a71cdbe9 1654
Sergunb 0:8918a71cdbe9 1655 //Compute S4 = A8 | A13 | A15 | A14 | A13 | A11 | A10 | A9
Sergunb 0:8918a71cdbe9 1656 COPY_WORD32(&s, 0, a, 9, 3);
Sergunb 0:8918a71cdbe9 1657 COPY_WORD32(&s, 3, a, 13, 3);
Sergunb 0:8918a71cdbe9 1658 COPY_WORD32(&s, 6, a, 13, 1);
Sergunb 0:8918a71cdbe9 1659 COPY_WORD32(&s, 7, a, 8, 1);
Sergunb 0:8918a71cdbe9 1660 //Compute T = T + S4
Sergunb 0:8918a71cdbe9 1661 MPI_CHECK(mpiAdd(&t, &t, &s));
Sergunb 0:8918a71cdbe9 1662
Sergunb 0:8918a71cdbe9 1663 //Compute D1 = A10 | A8 | 0 | 0 | 0 | A13 | A12 | A11
Sergunb 0:8918a71cdbe9 1664 COPY_WORD32(&s, 0, a, 11, 3);
Sergunb 0:8918a71cdbe9 1665 CLEAR_WORD32(&s, 3, 3);
Sergunb 0:8918a71cdbe9 1666 COPY_WORD32(&s, 6, a, 8, 1);
Sergunb 0:8918a71cdbe9 1667 COPY_WORD32(&s, 7, a, 10, 1);
Sergunb 0:8918a71cdbe9 1668 //Compute T = T - D1
Sergunb 0:8918a71cdbe9 1669 MPI_CHECK(mpiSub(&t, &t, &s));
Sergunb 0:8918a71cdbe9 1670
Sergunb 0:8918a71cdbe9 1671 //Compute D2 = A11 | A9 | 0 | 0 | A15 | A14 | A13 | A12
Sergunb 0:8918a71cdbe9 1672 COPY_WORD32(&s, 0, a, 12, 4);
Sergunb 0:8918a71cdbe9 1673 CLEAR_WORD32(&s, 4, 2);
Sergunb 0:8918a71cdbe9 1674 COPY_WORD32(&s, 6, a, 9, 1);
Sergunb 0:8918a71cdbe9 1675 COPY_WORD32(&s, 7, a, 11, 1);
Sergunb 0:8918a71cdbe9 1676 //Compute T = T - D2
Sergunb 0:8918a71cdbe9 1677 MPI_CHECK(mpiSub(&t, &t, &s));
Sergunb 0:8918a71cdbe9 1678
Sergunb 0:8918a71cdbe9 1679 //Compute D3 = A12 | 0 | A10 | A9 | A8 | A15 | A14 | A13
Sergunb 0:8918a71cdbe9 1680 COPY_WORD32(&s, 0, a, 13, 3);
Sergunb 0:8918a71cdbe9 1681 COPY_WORD32(&s, 3, a, 8, 3);
Sergunb 0:8918a71cdbe9 1682 CLEAR_WORD32(&s, 6, 1);
Sergunb 0:8918a71cdbe9 1683 COPY_WORD32(&s, 7, a, 12, 1);
Sergunb 0:8918a71cdbe9 1684 //Compute T = T - D3
Sergunb 0:8918a71cdbe9 1685 MPI_CHECK(mpiSub(&t, &t, &s));
Sergunb 0:8918a71cdbe9 1686
Sergunb 0:8918a71cdbe9 1687 //Compute D4 = A13 | 0 | A11 | A10 | A9 | 0 | A15 | A14
Sergunb 0:8918a71cdbe9 1688 COPY_WORD32(&s, 0, a, 14, 2);
Sergunb 0:8918a71cdbe9 1689 CLEAR_WORD32(&s, 2, 1);
Sergunb 0:8918a71cdbe9 1690 COPY_WORD32(&s, 3, a, 9, 3);
Sergunb 0:8918a71cdbe9 1691 CLEAR_WORD32(&s, 6, 1);
Sergunb 0:8918a71cdbe9 1692 COPY_WORD32(&s, 7, a, 13, 1);
Sergunb 0:8918a71cdbe9 1693 //Compute T = T - D4
Sergunb 0:8918a71cdbe9 1694 MPI_CHECK(mpiSub(&t, &t, &s));
Sergunb 0:8918a71cdbe9 1695
Sergunb 0:8918a71cdbe9 1696 //Compute (T + 2 * S1 + 2 * S2 + S3 + S4 - D1 - D2 - D3 - D4) mod p
Sergunb 0:8918a71cdbe9 1697 while(mpiComp(&t, p) >= 0)
Sergunb 0:8918a71cdbe9 1698 {
Sergunb 0:8918a71cdbe9 1699 MPI_CHECK(mpiSub(&t, &t, p));
Sergunb 0:8918a71cdbe9 1700 }
Sergunb 0:8918a71cdbe9 1701
Sergunb 0:8918a71cdbe9 1702 while(mpiCompInt(&t, 0) < 0)
Sergunb 0:8918a71cdbe9 1703 {
Sergunb 0:8918a71cdbe9 1704 MPI_CHECK(mpiAdd(&t, &t, p));
Sergunb 0:8918a71cdbe9 1705 }
Sergunb 0:8918a71cdbe9 1706
Sergunb 0:8918a71cdbe9 1707 //Save result
Sergunb 0:8918a71cdbe9 1708 MPI_CHECK(mpiCopy(a, &t));
Sergunb 0:8918a71cdbe9 1709
Sergunb 0:8918a71cdbe9 1710 end:
Sergunb 0:8918a71cdbe9 1711 //Release multiple precision integers
Sergunb 0:8918a71cdbe9 1712 mpiFree(&s);
Sergunb 0:8918a71cdbe9 1713 mpiFree(&t);
Sergunb 0:8918a71cdbe9 1714
Sergunb 0:8918a71cdbe9 1715 //Return status code
Sergunb 0:8918a71cdbe9 1716 return error;
Sergunb 0:8918a71cdbe9 1717 }
Sergunb 0:8918a71cdbe9 1718
Sergunb 0:8918a71cdbe9 1719
Sergunb 0:8918a71cdbe9 1720 /**
Sergunb 0:8918a71cdbe9 1721 * @brief Fast modular reduction (secp384r1 curve)
Sergunb 0:8918a71cdbe9 1722 * @param[in,out] a This function accept an integer less than p^2 as
Sergunb 0:8918a71cdbe9 1723 * input and return (a mod p) as output
Sergunb 0:8918a71cdbe9 1724 * @param[in] p Prime modulus
Sergunb 0:8918a71cdbe9 1725 **/
Sergunb 0:8918a71cdbe9 1726
Sergunb 0:8918a71cdbe9 1727 error_t secp384r1Mod(Mpi *a, const Mpi *p)
Sergunb 0:8918a71cdbe9 1728 {
Sergunb 0:8918a71cdbe9 1729 error_t error;
Sergunb 0:8918a71cdbe9 1730 Mpi s;
Sergunb 0:8918a71cdbe9 1731 Mpi t;
Sergunb 0:8918a71cdbe9 1732
Sergunb 0:8918a71cdbe9 1733 //Initialize multiple precision integers
Sergunb 0:8918a71cdbe9 1734 mpiInit(&s);
Sergunb 0:8918a71cdbe9 1735 mpiInit(&t);
Sergunb 0:8918a71cdbe9 1736
Sergunb 0:8918a71cdbe9 1737 //Ajust the size of the integers
Sergunb 0:8918a71cdbe9 1738 MPI_CHECK(mpiGrow(a, 96 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1739 MPI_CHECK(mpiGrow(&s, 48 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1740 MPI_CHECK(mpiGrow(&t, 48 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1741
Sergunb 0:8918a71cdbe9 1742 //Compute T = A11 | A10 | A9 | A8 | A7 | A6 | A5 | A4 | A3 | A2 | A1 | A0
Sergunb 0:8918a71cdbe9 1743 COPY_WORD32(&t, 0, a, 0, 12);
Sergunb 0:8918a71cdbe9 1744
Sergunb 0:8918a71cdbe9 1745 //Compute S1 = 0 | 0 | 0 | 0 | 0 | A23 | A22 | A21 | 0 | 0 | 0 | 0
Sergunb 0:8918a71cdbe9 1746 CLEAR_WORD32(&s, 0, 4);
Sergunb 0:8918a71cdbe9 1747 COPY_WORD32(&s, 4, a, 21, 3);
Sergunb 0:8918a71cdbe9 1748 CLEAR_WORD32(&s, 7, 5);
Sergunb 0:8918a71cdbe9 1749 //Compute T = T + 2 * S1
Sergunb 0:8918a71cdbe9 1750 MPI_CHECK(mpiAdd(&t, &t, &s));
Sergunb 0:8918a71cdbe9 1751 MPI_CHECK(mpiAdd(&t, &t, &s));
Sergunb 0:8918a71cdbe9 1752
Sergunb 0:8918a71cdbe9 1753 //Compute S2 = A23 | A22 | A21 | A20 | A19 | A18 | A17 | A16 | A15 | A14 | A13 | A12
Sergunb 0:8918a71cdbe9 1754 COPY_WORD32(&s, 0, a, 12, 12);
Sergunb 0:8918a71cdbe9 1755 //Compute T = T + S2
Sergunb 0:8918a71cdbe9 1756 MPI_CHECK(mpiAdd(&t, &t, &s));
Sergunb 0:8918a71cdbe9 1757
Sergunb 0:8918a71cdbe9 1758 //Compute S3 = A20 | A19 | A18 | A17 | A16 | A15 | A14 | A13 | A12 | A23| A22 | A21
Sergunb 0:8918a71cdbe9 1759 COPY_WORD32(&s, 0, a, 21, 3);
Sergunb 0:8918a71cdbe9 1760 COPY_WORD32(&s, 3, a, 12, 9);
Sergunb 0:8918a71cdbe9 1761 //Compute T = T + S3
Sergunb 0:8918a71cdbe9 1762 MPI_CHECK(mpiAdd(&t, &t, &s));
Sergunb 0:8918a71cdbe9 1763
Sergunb 0:8918a71cdbe9 1764 //Compute S4 = A19 | A18 | A17 | A16 | A15 | A14 | A13 | A12 | A20 | 0 | A23 | 0
Sergunb 0:8918a71cdbe9 1765 CLEAR_WORD32(&s, 0, 1);
Sergunb 0:8918a71cdbe9 1766 COPY_WORD32(&s, 1, a, 23, 1);
Sergunb 0:8918a71cdbe9 1767 CLEAR_WORD32(&s, 2, 1);
Sergunb 0:8918a71cdbe9 1768 COPY_WORD32(&s, 3, a, 20, 1);
Sergunb 0:8918a71cdbe9 1769 COPY_WORD32(&s, 4, a, 12, 8);
Sergunb 0:8918a71cdbe9 1770 //Compute T = T + S4
Sergunb 0:8918a71cdbe9 1771 MPI_CHECK(mpiAdd(&t, &t, &s));
Sergunb 0:8918a71cdbe9 1772
Sergunb 0:8918a71cdbe9 1773 //Compute S5 = 0 | 0 | 0 | 0 | A23 | A22 | A21 | A20 | 0 | 0 | 0 | 0
Sergunb 0:8918a71cdbe9 1774 CLEAR_WORD32(&s, 0, 4);
Sergunb 0:8918a71cdbe9 1775 COPY_WORD32(&s, 4, a, 20, 4);
Sergunb 0:8918a71cdbe9 1776 CLEAR_WORD32(&s, 8, 4);
Sergunb 0:8918a71cdbe9 1777 //Compute T = T + S5
Sergunb 0:8918a71cdbe9 1778 MPI_CHECK(mpiAdd(&t, &t, &s));
Sergunb 0:8918a71cdbe9 1779
Sergunb 0:8918a71cdbe9 1780 //Compute S6 = 0 | 0 | 0 | 0 | 0 | 0 | A23 | A22 | A21 | 0 | 0 | A20
Sergunb 0:8918a71cdbe9 1781 COPY_WORD32(&s, 0, a, 20, 1);
Sergunb 0:8918a71cdbe9 1782 CLEAR_WORD32(&s, 1, 2);
Sergunb 0:8918a71cdbe9 1783 COPY_WORD32(&s, 3, a, 21, 3);
Sergunb 0:8918a71cdbe9 1784 CLEAR_WORD32(&s, 6, 6);
Sergunb 0:8918a71cdbe9 1785 //Compute T = T + S6
Sergunb 0:8918a71cdbe9 1786 MPI_CHECK(mpiAdd(&t, &t, &s));
Sergunb 0:8918a71cdbe9 1787
Sergunb 0:8918a71cdbe9 1788 //Compute D1 = A22 | A21 | A20 | A19 | A18 | A17 | A16 | A15 | A14 | A13 | A12 | A23
Sergunb 0:8918a71cdbe9 1789 COPY_WORD32(&s, 0, a, 23, 1);
Sergunb 0:8918a71cdbe9 1790 COPY_WORD32(&s, 1, a, 12, 11);
Sergunb 0:8918a71cdbe9 1791 //Compute T = T - D1
Sergunb 0:8918a71cdbe9 1792 MPI_CHECK(mpiSub(&t, &t, &s));
Sergunb 0:8918a71cdbe9 1793
Sergunb 0:8918a71cdbe9 1794 //Compute D2 = 0 | 0 | 0 | 0 | 0 | 0 | 0 | A23 | A22 | A21 | A20 | 0
Sergunb 0:8918a71cdbe9 1795 CLEAR_WORD32(&s, 0, 1);
Sergunb 0:8918a71cdbe9 1796 COPY_WORD32(&s, 1, a, 20, 4);
Sergunb 0:8918a71cdbe9 1797 CLEAR_WORD32(&s, 5, 7);
Sergunb 0:8918a71cdbe9 1798 //Compute T = T - D2
Sergunb 0:8918a71cdbe9 1799 MPI_CHECK(mpiSub(&t, &t, &s));
Sergunb 0:8918a71cdbe9 1800
Sergunb 0:8918a71cdbe9 1801 //Compute D3 = 0 | 0 | 0 | 0 | 0 | 0 | 0 | A23 | A23 | 0 | 0 | 0
Sergunb 0:8918a71cdbe9 1802 CLEAR_WORD32(&s, 0, 3);
Sergunb 0:8918a71cdbe9 1803 COPY_WORD32(&s, 3, a, 23, 1);
Sergunb 0:8918a71cdbe9 1804 COPY_WORD32(&s, 4, a, 23, 1);
Sergunb 0:8918a71cdbe9 1805 CLEAR_WORD32(&s, 5, 7);
Sergunb 0:8918a71cdbe9 1806 //Compute T = T - D3
Sergunb 0:8918a71cdbe9 1807 MPI_CHECK(mpiSub(&t, &t, &s));
Sergunb 0:8918a71cdbe9 1808
Sergunb 0:8918a71cdbe9 1809 //Compute (T + 2 * S1 + S2 + S3 + S4 + S5 + S6 - D1 - D2 - D3) mod p
Sergunb 0:8918a71cdbe9 1810 while(mpiComp(&t, p) >= 0)
Sergunb 0:8918a71cdbe9 1811 {
Sergunb 0:8918a71cdbe9 1812 MPI_CHECK(mpiSub(&t, &t, p));
Sergunb 0:8918a71cdbe9 1813 }
Sergunb 0:8918a71cdbe9 1814
Sergunb 0:8918a71cdbe9 1815 while(mpiCompInt(&t, 0) < 0)
Sergunb 0:8918a71cdbe9 1816 {
Sergunb 0:8918a71cdbe9 1817 MPI_CHECK(mpiAdd(&t, &t, p));
Sergunb 0:8918a71cdbe9 1818 }
Sergunb 0:8918a71cdbe9 1819
Sergunb 0:8918a71cdbe9 1820 //Save result
Sergunb 0:8918a71cdbe9 1821 MPI_CHECK(mpiCopy(a, &t));
Sergunb 0:8918a71cdbe9 1822
Sergunb 0:8918a71cdbe9 1823 end:
Sergunb 0:8918a71cdbe9 1824 //Release multiple precision integers
Sergunb 0:8918a71cdbe9 1825 mpiFree(&s);
Sergunb 0:8918a71cdbe9 1826 mpiFree(&t);
Sergunb 0:8918a71cdbe9 1827
Sergunb 0:8918a71cdbe9 1828 //Return status code
Sergunb 0:8918a71cdbe9 1829 return error;
Sergunb 0:8918a71cdbe9 1830 }
Sergunb 0:8918a71cdbe9 1831
Sergunb 0:8918a71cdbe9 1832
Sergunb 0:8918a71cdbe9 1833 /**
Sergunb 0:8918a71cdbe9 1834 * @brief Fast modular reduction (secp521r1 curve)
Sergunb 0:8918a71cdbe9 1835 * @param[in,out] a This function accept an integer less than p^2 as
Sergunb 0:8918a71cdbe9 1836 * input and return (a mod p) as output
Sergunb 0:8918a71cdbe9 1837 * @param[in] p Prime modulus
Sergunb 0:8918a71cdbe9 1838 **/
Sergunb 0:8918a71cdbe9 1839
Sergunb 0:8918a71cdbe9 1840 error_t secp521r1Mod(Mpi *a, const Mpi *p)
Sergunb 0:8918a71cdbe9 1841 {
Sergunb 0:8918a71cdbe9 1842 error_t error;
Sergunb 0:8918a71cdbe9 1843 Mpi t;
Sergunb 0:8918a71cdbe9 1844
Sergunb 0:8918a71cdbe9 1845 //Initialize multiple precision integer
Sergunb 0:8918a71cdbe9 1846 mpiInit(&t);
Sergunb 0:8918a71cdbe9 1847
Sergunb 0:8918a71cdbe9 1848 //Ajust the size of the integers
Sergunb 0:8918a71cdbe9 1849 MPI_CHECK(mpiGrow(a, 132 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1850 MPI_CHECK(mpiGrow(&t, 68 / MPI_INT_SIZE));
Sergunb 0:8918a71cdbe9 1851
Sergunb 0:8918a71cdbe9 1852 //Compute A0
Sergunb 0:8918a71cdbe9 1853 COPY_WORD32(&t, 0, a, 0, 17);
Sergunb 0:8918a71cdbe9 1854 t.data[16] &= 0x000001FF;
Sergunb 0:8918a71cdbe9 1855
Sergunb 0:8918a71cdbe9 1856 //Compute A1
Sergunb 0:8918a71cdbe9 1857 MPI_CHECK(mpiShiftRight(a, 521));
Sergunb 0:8918a71cdbe9 1858
Sergunb 0:8918a71cdbe9 1859 //Compute A0 + A1
Sergunb 0:8918a71cdbe9 1860 MPI_CHECK(mpiAdd(a, a, &t));
Sergunb 0:8918a71cdbe9 1861
Sergunb 0:8918a71cdbe9 1862 //Compute (A0 + A1) mod p
Sergunb 0:8918a71cdbe9 1863 while(mpiComp(a, p) >= 0)
Sergunb 0:8918a71cdbe9 1864 {
Sergunb 0:8918a71cdbe9 1865 MPI_CHECK(mpiSub(a, a, p));
Sergunb 0:8918a71cdbe9 1866 }
Sergunb 0:8918a71cdbe9 1867
Sergunb 0:8918a71cdbe9 1868 end:
Sergunb 0:8918a71cdbe9 1869 //Release multiple precision integer
Sergunb 0:8918a71cdbe9 1870 mpiFree(&t);
Sergunb 0:8918a71cdbe9 1871
Sergunb 0:8918a71cdbe9 1872 //Return status code
Sergunb 0:8918a71cdbe9 1873 return error;
Sergunb 0:8918a71cdbe9 1874 }
Sergunb 0:8918a71cdbe9 1875
Sergunb 0:8918a71cdbe9 1876
Sergunb 0:8918a71cdbe9 1877 /**
Sergunb 0:8918a71cdbe9 1878 * @brief Get the elliptic curve that matches the specified OID
Sergunb 0:8918a71cdbe9 1879 * @param[in] oid Object identifier
Sergunb 0:8918a71cdbe9 1880 * @param[in] length OID length
Sergunb 0:8918a71cdbe9 1881 * @return Elliptic curve domain parameters
Sergunb 0:8918a71cdbe9 1882 **/
Sergunb 0:8918a71cdbe9 1883
Sergunb 0:8918a71cdbe9 1884 const EcCurveInfo *ecGetCurveInfo(const uint8_t *oid, size_t length)
Sergunb 0:8918a71cdbe9 1885 {
Sergunb 0:8918a71cdbe9 1886 //secp112r1 elliptic curve?
Sergunb 0:8918a71cdbe9 1887 if(!oidComp(oid, length, SECP112R1_OID, sizeof(SECP112R1_OID)))
Sergunb 0:8918a71cdbe9 1888 return SECP112R1_CURVE;
Sergunb 0:8918a71cdbe9 1889 //secp112r2 elliptic curve?
Sergunb 0:8918a71cdbe9 1890 if(!oidComp(oid, length, SECP112R2_OID, sizeof(SECP112R2_OID)))
Sergunb 0:8918a71cdbe9 1891 return SECP112R2_CURVE;
Sergunb 0:8918a71cdbe9 1892 //secp128r1 elliptic curve?
Sergunb 0:8918a71cdbe9 1893 if(!oidComp(oid, length, SECP128R1_OID, sizeof(SECP128R1_OID)))
Sergunb 0:8918a71cdbe9 1894 return SECP128R1_CURVE;
Sergunb 0:8918a71cdbe9 1895 //secp128r2 elliptic curve?
Sergunb 0:8918a71cdbe9 1896 if(!oidComp(oid, length, SECP128R2_OID, sizeof(SECP128R2_OID)))
Sergunb 0:8918a71cdbe9 1897 return SECP128R2_CURVE;
Sergunb 0:8918a71cdbe9 1898 //secp160k1 elliptic curve?
Sergunb 0:8918a71cdbe9 1899 if(!oidComp(oid, length, SECP160K1_OID, sizeof(SECP160K1_OID)))
Sergunb 0:8918a71cdbe9 1900 return SECP160K1_CURVE;
Sergunb 0:8918a71cdbe9 1901 //secp160r1 elliptic curve?
Sergunb 0:8918a71cdbe9 1902 else if(!oidComp(oid, length, SECP160R1_OID, sizeof(SECP160R1_OID)))
Sergunb 0:8918a71cdbe9 1903 return SECP160R1_CURVE;
Sergunb 0:8918a71cdbe9 1904 //secp160r2 elliptic curve?
Sergunb 0:8918a71cdbe9 1905 else if(!oidComp(oid, length, SECP160R2_OID, sizeof(SECP160R2_OID)))
Sergunb 0:8918a71cdbe9 1906 return SECP160R2_CURVE;
Sergunb 0:8918a71cdbe9 1907 //secp192k1 elliptic curve?
Sergunb 0:8918a71cdbe9 1908 else if(!oidComp(oid, length, SECP192K1_OID, sizeof(SECP192K1_OID)))
Sergunb 0:8918a71cdbe9 1909 return SECP192K1_CURVE;
Sergunb 0:8918a71cdbe9 1910 //secp192r1 elliptic curve?
Sergunb 0:8918a71cdbe9 1911 else if(!oidComp(oid, length, SECP192R1_OID, sizeof(SECP192R1_OID)))
Sergunb 0:8918a71cdbe9 1912 return SECP192R1_CURVE;
Sergunb 0:8918a71cdbe9 1913 //secp224k1 elliptic curve?
Sergunb 0:8918a71cdbe9 1914 else if(!oidComp(oid, length, SECP224K1_OID, sizeof(SECP224K1_OID)))
Sergunb 0:8918a71cdbe9 1915 return SECP224K1_CURVE;
Sergunb 0:8918a71cdbe9 1916 //secp224r1 elliptic curve?
Sergunb 0:8918a71cdbe9 1917 else if(!oidComp(oid, length, SECP224R1_OID, sizeof(SECP224R1_OID)))
Sergunb 0:8918a71cdbe9 1918 return SECP224R1_CURVE;
Sergunb 0:8918a71cdbe9 1919 //secp256k1 elliptic curve?
Sergunb 0:8918a71cdbe9 1920 else if(!oidComp(oid, length, SECP256K1_OID, sizeof(SECP256K1_OID)))
Sergunb 0:8918a71cdbe9 1921 return SECP256K1_CURVE;
Sergunb 0:8918a71cdbe9 1922 //secp256r1 elliptic curve?
Sergunb 0:8918a71cdbe9 1923 else if(!oidComp(oid, length, SECP256R1_OID, sizeof(SECP256R1_OID)))
Sergunb 0:8918a71cdbe9 1924 return SECP256R1_CURVE;
Sergunb 0:8918a71cdbe9 1925 //secp384r1 elliptic curve?
Sergunb 0:8918a71cdbe9 1926 else if(!oidComp(oid, length, SECP384R1_OID, sizeof(SECP384R1_OID)))
Sergunb 0:8918a71cdbe9 1927 return SECP384R1_CURVE;
Sergunb 0:8918a71cdbe9 1928 //secp521r1 elliptic curve?
Sergunb 0:8918a71cdbe9 1929 else if(!oidComp(oid, length, SECP521R1_OID, sizeof(SECP521R1_OID)))
Sergunb 0:8918a71cdbe9 1930 return SECP521R1_CURVE;
Sergunb 0:8918a71cdbe9 1931 //brainpoolP160r1 elliptic curve?
Sergunb 0:8918a71cdbe9 1932 else if(!oidComp(oid, length, BRAINPOOLP160R1_OID, sizeof(BRAINPOOLP160R1_OID)))
Sergunb 0:8918a71cdbe9 1933 return BRAINPOOLP160R1_CURVE;
Sergunb 0:8918a71cdbe9 1934 //brainpoolP192r1 elliptic curve?
Sergunb 0:8918a71cdbe9 1935 else if(!oidComp(oid, length, BRAINPOOLP192R1_OID, sizeof(BRAINPOOLP192R1_OID)))
Sergunb 0:8918a71cdbe9 1936 return BRAINPOOLP192R1_CURVE;
Sergunb 0:8918a71cdbe9 1937 //brainpoolP224r1 elliptic curve?
Sergunb 0:8918a71cdbe9 1938 else if(!oidComp(oid, length, BRAINPOOLP224R1_OID, sizeof(BRAINPOOLP224R1_OID)))
Sergunb 0:8918a71cdbe9 1939 return BRAINPOOLP224R1_CURVE;
Sergunb 0:8918a71cdbe9 1940 //brainpoolP256r1 elliptic curve?
Sergunb 0:8918a71cdbe9 1941 else if(!oidComp(oid, length, BRAINPOOLP256R1_OID, sizeof(BRAINPOOLP256R1_OID)))
Sergunb 0:8918a71cdbe9 1942 return BRAINPOOLP256R1_CURVE;
Sergunb 0:8918a71cdbe9 1943 //brainpoolP320r1 elliptic curve?
Sergunb 0:8918a71cdbe9 1944 else if(!oidComp(oid, length, BRAINPOOLP320R1_OID, sizeof(BRAINPOOLP320R1_OID)))
Sergunb 0:8918a71cdbe9 1945 return BRAINPOOLP320R1_CURVE;
Sergunb 0:8918a71cdbe9 1946 //brainpoolP384r1 elliptic curve?
Sergunb 0:8918a71cdbe9 1947 else if(!oidComp(oid, length, BRAINPOOLP384R1_OID, sizeof(BRAINPOOLP384R1_OID)))
Sergunb 0:8918a71cdbe9 1948 return BRAINPOOLP384R1_CURVE;
Sergunb 0:8918a71cdbe9 1949 //brainpoolP512r1 elliptic curve?
Sergunb 0:8918a71cdbe9 1950 else if(!oidComp(oid, length, BRAINPOOLP512R1_OID, sizeof(BRAINPOOLP512R1_OID)))
Sergunb 0:8918a71cdbe9 1951 return BRAINPOOLP512R1_CURVE;
Sergunb 0:8918a71cdbe9 1952 //Unknown identifier?
Sergunb 0:8918a71cdbe9 1953 else
Sergunb 0:8918a71cdbe9 1954 return NULL;
Sergunb 0:8918a71cdbe9 1955 }
Sergunb 0:8918a71cdbe9 1956
Sergunb 0:8918a71cdbe9 1957 #endif
Sergunb 0:8918a71cdbe9 1958