1 /* ge_448.h 2 * 3 * Copyright (C) 2006-2021 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_GE_448_H 24 #define WOLF_CRYPT_GE_448_H 25 26 #include <wolfssl/wolfcrypt/settings.h> 27 28 #ifdef HAVE_ED448 29 30 #include <wolfssl/wolfcrypt/fe_448.h> 31 32 /* 33 ge448 means group element. 34 35 Here the group is the set of pairs (x,y) of field elements (see fe.h) 36 satisfying -x^2 + y^2 = 1 + d x^2y^2 37 where d = -39081. 38 39 Representations: 40 ge448_p2 (projective) : (X:Y:Z) satisfying x=X/Z, y=Y/Z 41 ge448_precomp (affine): (x,y) 42 */ 43 44 #ifdef ED448_SMALL 45 typedef byte ge448; 46 #define GE448_WORDS 56 47 #elif defined(CURVED448_128BIT) 48 typedef sword64 ge448; 49 #define GE448_WORDS 8 50 #else 51 typedef sword32 ge448; 52 #define GE448_WORDS 16 53 #endif 54 55 typedef struct { 56 ge448 X[GE448_WORDS]; 57 ge448 Y[GE448_WORDS]; 58 ge448 Z[GE448_WORDS]; 59 } ge448_p2; 60 61 62 WOLFSSL_LOCAL int ge448_compress_key(byte*, const byte*, const byte*); 63 WOLFSSL_LOCAL int ge448_from_bytes_negate_vartime(ge448_p2 *, 64 const unsigned char *); 65 66 WOLFSSL_LOCAL int ge448_double_scalarmult_vartime(ge448_p2 *, 67 const unsigned char *, 68 const ge448_p2 *, 69 const unsigned char *); 70 WOLFSSL_LOCAL void ge448_scalarmult_base(ge448_p2 *, const unsigned char *); 71 WOLFSSL_LOCAL void sc448_reduce(byte*); 72 WOLFSSL_LOCAL void sc448_muladd(byte*, const byte*, const byte*, const byte*); 73 WOLFSSL_LOCAL void ge448_to_bytes(unsigned char *, const ge448_p2 *); 74 75 76 #ifndef ED448_SMALL 77 typedef struct { 78 ge448 x[GE448_WORDS]; 79 ge448 y[GE448_WORDS]; 80 } ge448_precomp; 81 82 #endif /* !ED448_SMALL */ 83 84 #endif /* HAVE_ED448 */ 85 86 #endif /* WOLF_CRYPT_GE_448_H */ 87