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  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneCRYPTO Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.4
29  **/
30 
31 #ifndef _CURVE448_H
32 #define _CURVE448_H
33 
34 //Dependencies
35 #include "core/crypto.h"
36 
37 //Length of the elliptic curve
38 #define CURVE448_BIT_LEN 448
39 #define CURVE448_BYTE_LEN 56
40 #define CURVE448_WORD_LEN 14
41 
42 //A24 constant
43 #define CURVE448_A24 39082
44 
45 //C++ guard
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 //Curve448 related functions
51 void curve448SetInt(uint32_t *a, uint32_t b);
52 void curve448Add(uint32_t *r, const uint32_t *a, const uint32_t *b);
53 void curve448AddInt(uint32_t *r, const uint32_t *a, uint32_t b);
54 void curve448Sub(uint32_t *r, const uint32_t *a, const uint32_t *b);
55 void curve448SubInt(uint32_t *r, const uint32_t *a, uint32_t b);
56 void curve448Mul(uint32_t *r, const uint32_t *a, const uint32_t *b);
57 void curve448MulInt(uint32_t *r, const uint32_t *a, uint32_t b);
58 void curve448Red(uint32_t *r, const uint32_t *a, uint32_t h);
59 void curve448Sqr(uint32_t *r, const uint32_t *a);
60 void curve448Pwr2(uint32_t *r, const uint32_t *a, uint_t n);
61 void curve448Inv(uint32_t *r, const uint32_t *a);
62 
63 uint32_t curve448Sqrt(uint32_t *r, const uint32_t *a, const uint32_t *b);
64 
65 void curve448Copy(uint32_t *a, const uint32_t *b);
66 void curve448Swap(uint32_t *a, uint32_t *b, uint32_t c);
67 
68 void curve448Select(uint32_t *r, const uint32_t *a, const uint32_t *b,
69  uint32_t c);
70 
71 uint32_t curve448Comp(const uint32_t *a, const uint32_t *b);
72 
73 void curve448Import(uint32_t *a, const uint8_t *data);
74 void curve448Export(uint32_t *a, uint8_t *data);
75 
76 //C++ guard
77 #ifdef __cplusplus
78 }
79 #endif
80 
81 #endif
uint8_t b
Definition: nbns_common.h:104
void curve448Sqr(uint32_t *r, const uint32_t *a)
Modular squaring.
Definition: curve448.c:331
uint8_t a
Definition: ndp.h:411
void curve448Red(uint32_t *r, const uint32_t *a, uint32_t h)
Modular reduction.
Definition: curve448.c:367
void curve448AddInt(uint32_t *r, const uint32_t *a, uint32_t b)
Modular addition.
Definition: curve448.c:98
uint8_t data[]
Definition: ethernet.h:222
uint32_t curve448Comp(const uint32_t *a, const uint32_t *b)
Compare integers.
Definition: curve448.c:599
uint8_t r
Definition: ndp.h:346
uint8_t h
Definition: ndp.h:302
void curve448Sub(uint32_t *r, const uint32_t *a, const uint32_t *b)
Modular subtraction.
Definition: curve448.c:123
General definitions for cryptographic algorithms.
void curve448Add(uint32_t *r, const uint32_t *a, const uint32_t *b)
Modular addition.
Definition: curve448.c:72
void curve448Mul(uint32_t *r, const uint32_t *a, const uint32_t *b)
Modular multiplication.
Definition: curve448.c:199
void curve448SubInt(uint32_t *r, const uint32_t *a, uint32_t b)
Modular subtraction.
Definition: curve448.c:160
void curve448Inv(uint32_t *r, const uint32_t *a)
Modular multiplicative inverse.
Definition: curve448.c:402
uint8_t n
void curve448Copy(uint32_t *a, const uint32_t *b)
Copy an integer.
Definition: curve448.c:527
void curve448Import(uint32_t *a, const uint8_t *data)
Import an octet string.
Definition: curve448.c:625
void curve448Swap(uint32_t *a, uint32_t *b, uint32_t c)
Conditional swap.
Definition: curve448.c:546
void curve448Pwr2(uint32_t *r, const uint32_t *a, uint_t n)
Raise an integer to power 2^n.
Definition: curve448.c:345
void curve448Select(uint32_t *r, const uint32_t *a, const uint32_t *b, uint32_t c)
Select an integer.
Definition: curve448.c:574
unsigned int uint_t
Definition: compiler_port.h:50
void curve448Export(uint32_t *a, uint8_t *data)
Export an octet string.
Definition: curve448.c:646
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:451
void curve448SetInt(uint32_t *a, uint32_t b)
Set integer value.
Definition: curve448.c:50
uint8_t c
Definition: ndp.h:514
void curve448MulInt(uint32_t *r, const uint32_t *a, uint32_t b)
Modular multiplication.
Definition: curve448.c:290