My Project
Loading...
Searching...
No Matches
fe_448.h
1/* fe448_448.h
2 *
3 * Copyright (C) 2006-2020 wolfSSL Inc.
4 *
5 * This file is part of wolfSSL.
6 *
7 * wolfSSL is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * wolfSSL is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 */
21
22
23#ifndef WOLF_CRYPT_FE_448_H
24#define WOLF_CRYPT_FE_448_H
25
26#include <wolfssl/wolfcrypt/settings.h>
27
28#if defined(HAVE_CURVE448) || defined(HAVE_ED448)
29
30#include <stdint.h>
31
33
34#if defined(HAVE___UINT128_T) && !defined(NO_CURVED448_128BIT)
35 #define CURVED448_128BIT
36#endif
37
38#ifdef __cplusplus
39 extern "C" {
40#endif
41
42/* default to be faster but take more memory */
43#if !defined(CURVE448_SMALL) || !defined(ED448_SMALL)
44
45#if defined(CURVED448_128BIT)
46 typedef int64_t fe448;
47 #ifdef __SIZEOF_INT128__
48 typedef __uint128_t uint128_t;
49 typedef __int128_t int128_t;
50 #else
51 typedef unsigned long uint128_t __attribute__ ((mode(TI)));
52 typedef long int128_t __attribute__ ((mode(TI)));
53 #endif
54#else
55 typedef int32_t fe448;
56#endif
57
58WOLFSSL_LOCAL void fe448_init(void);
59WOLFSSL_LOCAL int curve448(byte* r, const byte* n, const byte* a);
60
61#if !defined(CURVED448_128BIT)
62WOLFSSL_LOCAL void fe448_reduce(fe448*);
63#else
64#define fe448_reduce(a)
65#endif
66WOLFSSL_LOCAL void fe448_neg(fe448*,const fe448*);
67WOLFSSL_LOCAL void fe448_add(fe448*, const fe448*, const fe448*);
68WOLFSSL_LOCAL void fe448_sub(fe448*, const fe448*, const fe448*);
69WOLFSSL_LOCAL void fe448_mul(fe448*,const fe448*,const fe448*);
70WOLFSSL_LOCAL void fe448_sqr(fe448*, const fe448*);
71WOLFSSL_LOCAL void fe448_mul39081(fe448*, const fe448*);
72WOLFSSL_LOCAL void fe448_invert(fe448*, const fe448*);
73
74WOLFSSL_LOCAL void fe448_0(fe448*);
75WOLFSSL_LOCAL void fe448_1(fe448*);
76WOLFSSL_LOCAL void fe448_copy(fe448*, const fe448*);
77WOLFSSL_LOCAL int fe448_isnonzero(const fe448*);
78WOLFSSL_LOCAL int fe448_isnegative(const fe448*);
79
80WOLFSSL_LOCAL void fe448_from_bytes(fe448*,const unsigned char *);
81WOLFSSL_LOCAL void fe448_to_bytes(unsigned char *, const fe448*);
82
83WOLFSSL_LOCAL void fe448_cmov(fe448*,const fe448*, int);
84WOLFSSL_LOCAL void fe448_pow_2_446_222_1(fe448*,const fe448*);
85
86#else
87
88WOLFSSL_LOCAL void fe448_init(void);
89WOLFSSL_LOCAL int curve448(byte* r, const byte* n, const byte* a);
90
91#define fe448_reduce(a)
92WOLFSSL_LOCAL void fe448_neg(uint8_t*,const uint8_t*);
93WOLFSSL_LOCAL void fe448_add(uint8_t*, const uint8_t*, const uint8_t*);
94WOLFSSL_LOCAL void fe448_sub(uint8_t*, const uint8_t*, const uint8_t*);
95WOLFSSL_LOCAL void fe448_mul(uint8_t*,const uint8_t*,const uint8_t*);
96WOLFSSL_LOCAL void fe448_sqr(uint8_t*, const uint8_t*);
97WOLFSSL_LOCAL void fe448_mul39081(uint8_t*, const uint8_t*);
98WOLFSSL_LOCAL void fe448_invert(uint8_t*, const uint8_t*);
99
100WOLFSSL_LOCAL void fe448_copy(uint8_t*, const uint8_t*);
101WOLFSSL_LOCAL int fe448_isnonzero(const uint8_t*);
102
103WOLFSSL_LOCAL void fe448_norm(byte *a);
104
105WOLFSSL_LOCAL void fe448_cmov(uint8_t*,const uint8_t*, int);
106WOLFSSL_LOCAL void fe448_pow_2_446_222_1(uint8_t*,const uint8_t*);
107
108#endif /* !CURVE448_SMALL || !ED448_SMALL */
109
110#ifdef __cplusplus
111 } /* extern "C" */
112#endif
113
114#endif /* HAVE_CURVE448 || HAVE_ED448 */
115
116#endif /* WOLF_CRYPT_FE_448_H */