1 /* 2 * Copyright (c) 2009 Chris K Cockrum <ckc@cockrum.net> 3 * 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> 8 * 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: 15 * 16 * The above copyright notice and this permission notice shall be included in 17 * all copies or substantial portions of the Software. 18 * 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 25 * THE SOFTWARE. 26 * 27 * 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>. 31 * 32 * [0]: http://cockrum.net/Implementation_of_ECC_on_an_8-bit_microcontroller.pdf 33 * 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 36 * for ECDH and ECDSA. 37 */ 38 #include <inttypes.h> 39 40 extern const uint32_t ecc_prime_m[8]; 41 extern const uint32_t ecc_prime_r[8]; 42 43 //debug function to print long numbers 44 void ecc_printNumber(const uint32_t *x, int numberLength); 45 void ecc_setRandom(uint32_t *secret); 46 47 #ifdef CONTIKI 48 #undef assert 49 #define assert(e) ((e) ? (void)0 : test_assert(__FILE__, __LINE__)) 50 void test_assert(const char *, int); 51 #endif 52