|
Contiki 3.x
|
Calculations on elliptic curve secp256r1More...
#include <stdint.h>Go to the source code of this file.
Macros | |
| #define | ecc_is_valid_key(key, order) (ecc_compare(order, key) == 1) |
| Checks if a (random) number is valid as scalar on elliptic curve secp256r1. More... | |
Functions | |
| int32_t | ecc_compare (const uint32_t *a, const uint32_t *b) |
| Compares the value of a with the value of b. More... | |
| void | ecc_ec_mult (uint32_t *resultx, uint32_t *resulty, const uint32_t *px, const uint32_t *py, const uint32_t *secret) |
| ECC scalar multiplication on elliptic curve secp256r1. More... | |
Calculations on elliptic curve secp256r1
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.
Definition in file ecc.h.
| #define ecc_is_valid_key | ( | key, | |
| order | |||
| ) | (ecc_compare(order, key) == 1) |
Checks if a (random) number is valid as scalar on elliptic curve secp256r1.
A (random) number is only usable as scalar on elliptic curve secp256r1 if it is lower than the order of the curve. For the check, you need to provide the order of elliptic curve secp256r1.
uint32_t order[8] = {0xFC632551, 0xF3B9CAC2, 0xA7179E84, 0xBCE6FAAD, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF};
| key | The (random) number to check for usability |
| order | The order of elliptic curve secp256r1 |
| int32_t ecc_compare | ( | const uint32_t * | a, |
| const uint32_t * | b | ||
| ) |
Compares the value of a with the value of b.
This function is only public because its needed for the macro ecc_is_valid_key. It does a comparison of two 256 bit numbers. The return values are 1, 0 or -1.
| a | First number |
| b | Second number |
| void ecc_ec_mult | ( | uint32_t * | resultx, |
| uint32_t * | resulty, | ||
| const uint32_t * | px, | ||
| const uint32_t * | py, | ||
| const uint32_t * | secret | ||
| ) |
ECC scalar multiplication on elliptic curve secp256r1.
This function does a scalar multiplication on elliptic curve secp256r1. For an Elliptic curve Diffie–Hellman you need two multiplications. First one with the base point of elliptic curve secp256r1 you need to provide.
uint32_t base_x[8] = {0xd898c296, 0xf4a13945, 0x2deb33a0, 0x77037d81, 0x63a440f2, 0xf8bce6e5, 0xe12c4247, 0x6b17d1f2}; uint32_t base_y[8] = {0x37bf51f5, 0xcbb64068, 0x6b315ece, 0x2bce3357, 0x7c0f9e16, 0x8ee7eb4a, 0xfe1a7f9b, 0x4fe342e2};
| resultx | Pointer to memory to store the x-coordinate of the result |
| resulty | Pointer to memory to store the y-coordinate of the result |
| px | x-coordinate of the point to multiply with scalar |
| py | y-coordinate of the point to multiply with scalar |
| secret | Scalar for multiplication with elliptic curve point |
1.8.6