curve448.h
Go to the documentation of this file.
1 /**
2  * @file curve448.h
3  * @brief Curve448 elliptic curve (constant-time implementation)
4  *
5  * @section License
6  *
7  * Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.
8  *
9  * This file is part of CycloneCrypto Open.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24  *
25  * @author Oryx Embedded SARL (www.oryx-embedded.com)
26  * @version 1.9.0
27  **/
28 
29 #ifndef _CURVE448_H
30 #define _CURVE448_H
31 
32 //Dependencies
33 #include "core/crypto.h"
34 
35 //Length of the elliptic curve
36 #define CURVE448_BIT_LEN 448
37 #define CURVE448_BYTE_LEN 56
38 #define CURVE448_WORD_LEN 14
39 
40 //A24 constant
41 #define CURVE448_A24 39082
42 
43 //C++ guard
44 #ifdef __cplusplus
45  extern "C" {
46 #endif
47 
48 //Curve448 related functions
49 void curve448SetInt(uint32_t *a, uint32_t b);
50 void curve448Add(uint32_t *r, const uint32_t *a, const uint32_t *b);
51 void curve448AddInt(uint32_t *r, const uint32_t *a, uint32_t b);
52 void curve448Sub(uint32_t *r, const uint32_t *a, const uint32_t *b);
53 void curve448SubInt(uint32_t *r, const uint32_t *a, uint32_t b);
54 void curve448Mul(uint32_t *r, const uint32_t *a, const uint32_t *b);
55 void curve448MulInt(uint32_t *r, const uint32_t *a, uint32_t b);
56 void curve448Red(uint32_t *r, const uint32_t *a, uint32_t h);
57 void curve448Sqr(uint32_t *r, const uint32_t *a);
58 void curve448Pwr2(uint32_t *r, const uint32_t *a, uint_t n);
59 void curve448Inv(uint32_t *r, const uint32_t *a);
60 
61 uint32_t curve448Sqrt(uint32_t *r, const uint32_t *a, const uint32_t *b);
62 
63 void curve448Copy(uint32_t *a, const uint32_t *b);
64 void curve448Swap(uint32_t *a, uint32_t *b, uint32_t c);
65 
66 void curve448Select(uint32_t *r, const uint32_t *a, const uint32_t *b,
67  uint32_t c);
68 
69 uint32_t curve448Comp(const uint32_t *a, const uint32_t *b);
70 
71 void curve448Import(uint32_t *a, const uint8_t *data);
72 void curve448Export(uint32_t *a, uint8_t *data);
73 
74 //C++ guard
75 #ifdef __cplusplus
76  }
77 #endif
78 
79 #endif
void curve448Pwr2(uint32_t *r, const uint32_t *a, uint_t n)
Raise an integer to power 2^n.
Definition: curve448.c:344
void curve448Swap(uint32_t *a, uint32_t *b, uint32_t c)
Conditional swap.
Definition: curve448.c:545
uint8_t c
Definition: ndp.h:510
void curve448SetInt(uint32_t *a, uint32_t b)
Set integer value.
Definition: curve448.c:48
uint32_t curve448Sqrt(uint32_t *r, const uint32_t *a, const uint32_t *b)
Compute the square root of (A / B) modulo p.
Definition: curve448.c:450
General definitions for cryptographic algorithms.
void curve448Sub(uint32_t *r, const uint32_t *a, const uint32_t *b)
Modular subtraction.
Definition: curve448.c:121
void curve448Red(uint32_t *r, const uint32_t *a, uint32_t h)
Modular reduction.
Definition: curve448.c:366
void curve448AddInt(uint32_t *r, const uint32_t *a, uint32_t b)
Modular addition.
Definition: curve448.c:96
uint8_t a
Definition: ndp.h:407
void curve448Add(uint32_t *r, const uint32_t *a, const uint32_t *b)
Modular addition.
Definition: curve448.c:70
uint32_t curve448Comp(const uint32_t *a, const uint32_t *b)
Compare integers.
Definition: curve448.c:598
void curve448Mul(uint32_t *r, const uint32_t *a, const uint32_t *b)
Modular multiplication.
Definition: curve448.c:197
void curve448Copy(uint32_t *a, const uint32_t *b)
Copy an integer.
Definition: curve448.c:526
void curve448Select(uint32_t *r, const uint32_t *a, const uint32_t *b, uint32_t c)
Select an integer.
Definition: curve448.c:573
unsigned int uint_t
Definition: compiler_port.h:43
uint8_t data[]
Definition: dtls_misc.h:167
void curve448Export(uint32_t *a, uint8_t *data)
Export an octet string.
Definition: curve448.c:645
uint32_t r
Definition: ndp.h:342
void curve448MulInt(uint32_t *r, const uint32_t *a, uint32_t b)
Modular multiplication.
Definition: curve448.c:289
void curve448SubInt(uint32_t *r, const uint32_t *a, uint32_t b)
Modular subtraction.
Definition: curve448.c:158
void curve448Inv(uint32_t *r, const uint32_t *a)
Modular multiplicative inverse.
Definition: curve448.c:401
uint8_t n
uint8_t h
Definition: ndp.h:297
void curve448Sqr(uint32_t *r, const uint32_t *a)
Modular squaring.
Definition: curve448.c:330
uint8_t b[6]
Definition: dtls_misc.h:130
void curve448Import(uint32_t *a, const uint8_t *data)
Import an octet string.
Definition: curve448.c:624