52 lines
2.1 KiB
C
52 lines
2.1 KiB
C
|
/*
|
||
|
* Copyright (c) 2009 Chris K Cockrum <ckc@cockrum.net>
|
||
|
*
|
||
|
* Copyright (c) 2013 Jens Trillmann <jtrillma@tzi.de>
|
||
|
* Copyright (c) 2013 Marc Müller-Weinhardt <muewei@tzi.de>
|
||
|
* Copyright (c) 2013 Lars Schmertmann <lars@tzi.de>
|
||
|
* Copyright (c) 2013 Hauke Mehrtens <hauke@hauke-m.de>
|
||
|
*
|
||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||
|
* of this software and associated documentation files (the "Software"), to deal
|
||
|
* in the Software without restriction, including without limitation the rights
|
||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||
|
* copies of the Software, and to permit persons to whom the Software is
|
||
|
* furnished to do so, subject to the following conditions:
|
||
|
*
|
||
|
* The above copyright notice and this permission notice shall be included in
|
||
|
* all copies or substantial portions of the Software.
|
||
|
*
|
||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||
|
* THE SOFTWARE.
|
||
|
*
|
||
|
*
|
||
|
* This implementation is based in part on the paper Implementation of an
|
||
|
* Elliptic Curve Cryptosystem on an 8-bit Microcontroller [0] by
|
||
|
* Chris K Cockrum <ckc@cockrum.net>.
|
||
|
*
|
||
|
* [0]: http://cockrum.net/Implementation_of_ECC_on_an_8-bit_microcontroller.pdf
|
||
|
*
|
||
|
* This is a efficient ECC implementation on the secp256r1 curve for 32 Bit CPU
|
||
|
* architectures. It provides basic operations on the secp256r1 curve and support
|
||
|
* for ECDH and ECDSA.
|
||
|
*/
|
||
|
#include <inttypes.h>
|
||
|
|
||
|
extern const uint32_t ecc_prime_m[8];
|
||
|
extern const uint32_t ecc_prime_r[8];
|
||
|
|
||
|
//debug function to print long numbers
|
||
|
void ecc_printNumber(const uint32_t *x, int numberLength);
|
||
|
void ecc_setRandom(uint32_t *secret);
|
||
|
|
||
|
#ifdef CONTIKI
|
||
|
#undef assert
|
||
|
#define assert(e) ((e) ? (void)0 : test_assert(__FILE__, __LINE__))
|
||
|
void test_assert(const char *, int);
|
||
|
#endif
|