ECCParams.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2019, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
39 #ifndef ti_drivers_cryptoutils_ecc_ECCParams__include
40 #define ti_drivers_cryptoutils_ecc_ECCParams__include
41 
42 #include <stdint.h>
43 #include <stddef.h>
44 #include <stdbool.h>
45 
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 /* Error status codes for the utility functions */
53 
60 #define ECCParams_STATUS_SUCCESS (0)
61 
68 #define ECCParams_STATUS_ERROR (-1)
69 
96 typedef uint32_t ECCParams_CurveType;
97 
98 #define ECCParams_CURVE_TYPE_NONE 0U
99 #define ECCParams_CURVE_TYPE_SHORT_WEIERSTRASS_AN3 1U
100 #define ECCParams_CURVE_TYPE_SHORT_WEIERSTRASS_GEN 2U
101 #define ECCParams_CURVE_TYPE_MONTGOMERY 3U
102 #define ECCParams_CURVE_TYPE_EDWARDS 4U
103 
104 typedef struct ECCParams_ECCPoint {
105  const uint8_t *x;
106  const uint8_t *y;
108 
120 typedef struct ECCParams_CurveParams {
121  const ECCParams_CurveType curveType;
122  const uint8_t *prime;
123  const uint8_t *a;
124  const uint8_t *b;
125  const uint8_t *order;
128  uint16_t primeBitLength;
129  uint16_t orderBitLength;
130  uint8_t cofactor;
131  uint8_t curveID;
132  uint16_t reserved;
133 
134  /* Below: differences between implementations that need to be aligned */
135  const size_t length;
136  const uint8_t *generatorX;
137  const uint8_t *generatorY;
141 
142 
143 
144 /* Short Weierstrass curves */
145 
152 
159 
166 
173 
180 
187 
194 
195 
196 
197 /* Montgomery curves */
198 
205 
206 
207 
208 /* Edwards curves */
209 
210 /* Utility functions */
211 
227 int_fast16_t ECCParams_FormatCurve25519PrivateKey(CryptoKey *myPrivateKey);
228 
229 #ifdef __cplusplus
230 }
231 #endif
232 
233 #endif /* ti_drivers_cryptoutils_ecc_ECCParams__include */
uint32_t ECCParams_CurveType
Enumeration of curve equations supported.
Definition: ECCParams.h:96
The CryptoKey type is an opaque representation of a cryptographic key.
const uint8_t * prime
Definition: ECCParams.h:122
const uint8_t * x
Definition: ECCParams.h:105
const ECCParams_CurveType curveType
Definition: ECCParams.h:121
const uint8_t * y
Definition: ECCParams.h:106
uint16_t orderBitLength
Definition: ECCParams.h:129
ECCParams_ECCPoint generator
Definition: ECCParams.h:138
const ECCParams_CurveParams ECCParams_BrainpoolP512R1
The BrainpoolP512R1 curve in short Weierstrass form.
const ECCParams_ECCPoint * t
Definition: ECCParams.h:127
const ECCParams_CurveParams ECCParams_NISTP384
The NISTP384 curve in short Weierstrass form.
CryptoKey datastructure.
Definition: CryptoKey.h:209
const uint8_t * order
Definition: ECCParams.h:125
Definition: ECCParams.h:104
const ECCParams_CurveParams ECCParams_BrainpoolP256R1
The BrainpoolP256R1 curve in short Weierstrass form.
uint8_t curveID
Definition: ECCParams.h:131
const uint8_t * b
Definition: ECCParams.h:124
const ECCParams_CurveParams ECCParams_NISTP256
The NISTP256 curve in short Weierstrass form.
const uint8_t * generatorX
Definition: ECCParams.h:136
struct ECCParams_ECCPoint ECCParams_ECCPoint
uint16_t primeBitLength
Definition: ECCParams.h:128
uint8_t cofactor
Definition: ECCParams.h:130
const uint8_t * a
Definition: ECCParams.h:123
ECCParams_ECCPoint precomputed
Definition: ECCParams.h:139
const ECCParams_CurveParams ECCParams_Curve25519
The Curve25519 curve in Montgomery form.
const ECCParams_ECCPoint * g
Definition: ECCParams.h:126
const size_t length
Definition: ECCParams.h:135
A structure containing the parameters of an elliptic curve in short Weierstrass form.
Definition: ECCParams.h:120
const ECCParams_CurveParams ECCParams_BrainpoolP384R1
The BrainpoolP384R1 curve in short Weierstrass form.
uint16_t reserved
Definition: ECCParams.h:132
const ECCParams_CurveParams ECCParams_NISTP224
The NISTP224 curve in short Weierstrass form.
struct ECCParams_CurveParams ECCParams_CurveParams
A structure containing the parameters of an elliptic curve in short Weierstrass form.
int_fast16_t ECCParams_FormatCurve25519PrivateKey(CryptoKey *myPrivateKey)
Formats a CryptoKey to conform to Curve25519 private key requirements.
const uint8_t * generatorY
Definition: ECCParams.h:137
const ECCParams_CurveParams ECCParams_NISTP521
The NISTP521 curve in short Weierstrass form.
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale