2 * Copyright (c) 2009 Chris K Cockrum <ckc@cockrum.net>
4 * Copyright (c) 2013 Jens Trillmann <jtrillma@tzi.de>
5 * Copyright (c) 2013 Marc Müller-Weinhardt <muewei@tzi.de>
6 * Copyright (c) 2013 Lars Schmertmann <lars@tzi.de>
7 * Copyright (c) 2013 Hauke Mehrtens <hauke@hauke-m.de>
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to deal
11 * in the Software without restriction, including without limitation the rights
12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28 * This implementation is based in part on the paper Implementation of an
29 * Elliptic Curve Cryptosystem on an 8-bit Microcontroller [0] by
30 * Chris K Cockrum <ckc@cockrum.net>.
32 * [0]: http://cockrum.net/Implementation_of_ECC_on_an_8-bit_microcontroller.pdf
34 * This is a efficient ECC implementation on the secp256r1 curve for 32 Bit CPU
35 * architectures. It provides basic operations on the secp256r1 curve and support
38 #include "test_helper.h"
44 void ecc_printNumber(const uint32_t *x, int numberLength){ //here the values are turned to MSB!
47 for(n = numberLength - 1; n >= 0; n--){
53 void ecc_setRandom(uint32_t *secret){
56 for (i = 0; i < arrayLength; ++i)
61 const uint32_t ecc_prime_m[8] = {0xffffffff, 0xffffffff, 0xffffffff, 0x00000000,
62 0x00000000, 0x00000000, 0x00000001, 0xffffffff};
65 /* This is added after an static byte addition if the answer has a carry in MSB*/
66 const uint32_t ecc_prime_r[8] = {0x00000001, 0x00000000, 0x00000000, 0xffffffff,
67 0xffffffff, 0xffffffff, 0xfffffffe, 0x00000000};
71 test_assert(const char *file, int lineno)
73 printf("Assertion failed: file %s, line %d.\n", file, lineno);
76 * call _reset_vector__();