Contiki-NG
Loading...
Searching...
No Matches
ecc-curve.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014, Institute for Pervasive Computing, ETH Zurich.
3 * All rights reserved.
4 *
5 * Author: Andreas Dröscher <contiki@anticat.ch>
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. 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 * 3. Neither the name of the Institute nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS "AS IS" AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32/**
33 * \addtogroup crypto
34 * @{
35 *
36 * \file
37 * NIST curves for various key sizes.
38 * \author
39 * Konrad Krentz <konrad.krentz@gmail.com>
40 */
41
42#include "lib/ecc-curve.h"
43
44/* [NIST P-256, X9.62 prime256v1, secp256r1] */
45static const uint32_t nist_p_256_p[] = {
46 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
47 0x00000000, 0x00000000, 0x00000001, 0xFFFFFFFF
48};
49static const uint32_t nist_p_256_p_plus_one[] = {
50 0x00000000, 0x00000000, 0x00000000, 0x00000001,
51 0x00000000, 0x00000000, 0x00000001, 0xFFFFFFFF
52};
53static const uint32_t nist_p_256_n[] = {
54 0xFC632551, 0xF3B9CAC2, 0xA7179E84, 0xBCE6FAAD,
55 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF
56};
57static const uint32_t nist_p_256_a[] = {
58 0xFFFFFFFC, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
59 0x00000000, 0x00000000, 0x00000001, 0xFFFFFFFF
60};
61static const uint32_t nist_p_256_b[] = {
62 0x27D2604B, 0x3BCE3C3E, 0xCC53B0F6, 0x651D06B0,
63 0x769886BC, 0xB3EBBD55, 0xAA3A93E7, 0x5AC635D8
64};
65static const uint32_t nist_p_256_x[] = {
66 0xD898C296, 0xF4A13945, 0x2DEB33A0, 0x77037D81,
67 0x63A440F2, 0xF8BCE6E5, 0xE12C4247, 0x6B17D1F2
68};
69static const uint32_t nist_p_256_y[] = {
70 0x37BF51F5, 0xCBB64068, 0x6B315ECE, 0x2BCE3357,
71 0x7C0F9E16, 0x8EE7EB4A, 0xFE1A7F9B, 0x4FE342E2
72};
73
74ecc_curve_t ecc_curve_p_256 = {
75 .name = "NIST P-256",
76 .words = 8,
77 .bytes = 32,
78 .p = nist_p_256_p,
79 .p_plus_one = nist_p_256_p_plus_one,
80 .binary_length_of_p_plus_one = 256,
81 .n = nist_p_256_n,
82 .binary_length_of_n = 256,
83 .a = nist_p_256_a,
84 .b = nist_p_256_b,
85 .x = nist_p_256_x,
86 .y = nist_p_256_y
87};
88
89/* [NIST P-192, X9.62 prime192v1] */
90static const uint32_t nist_p_192_p[] = {
91 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF
92};
93static const uint32_t nist_p_192_p_plus_one[] = {
94 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
95};
96static const uint32_t nist_p_192_a[] = {
97 0xFFFFFFFC, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF
98};
99static const uint32_t nist_p_192_b[] = {
100 0xC146B9B1, 0xFEB8DEEC, 0x72243049, 0x0FA7E9AB, 0xE59C80E7, 0x64210519
101};
102static const uint32_t nist_p_192_x[] = {
103 0x82FF1012, 0xF4FF0AFD, 0x43A18800, 0x7CBF20EB, 0xB03090F6, 0x188DA80E
104};
105static const uint32_t nist_p_192_y[] = {
106 0x1E794811, 0x73F977A1, 0x6B24CDD5, 0x631011ED, 0xFFC8DA78, 0x07192B95
107};
108static const uint32_t nist_p_192_n[] = {
109 0xB4D22831, 0x146BC9B1, 0x99DEF836, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF
110};
111
112ecc_curve_t ecc_curve_p_192 = {
113 .name = "NIST P-192",
114 .words = 6,
115 .bytes = 24,
116 .p = nist_p_192_p,
117 .p_plus_one = nist_p_192_p_plus_one,
118 .binary_length_of_p_plus_one = 192,
119 .n = nist_p_192_n,
120 .binary_length_of_n = 192,
121 .a = nist_p_192_a,
122 .b = nist_p_192_b,
123 .x = nist_p_192_x,
124 .y = nist_p_192_y
125};
126
127/**
128 * @}
129 */
NIST curves for various key sizes.
Parameters of an ECC curve in little-endian word order.
Definition ecc-curve.h:53
const char * name
Name of the curve.
Definition ecc-curve.h:55