ssh lib

Dependents:   OS

Committer:
sPymbed
Date:
Mon Nov 25 14:23:49 2019 +0000
Revision:
1:e4ea39eba2fb
Parent:
0:1387ff3eed4a
improved

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sPymbed 0:1387ff3eed4a 1 /* ge_operations.h
sPymbed 0:1387ff3eed4a 2 *
sPymbed 0:1387ff3eed4a 3 * Copyright (C) 2006-2017 wolfSSL Inc.
sPymbed 0:1387ff3eed4a 4 *
sPymbed 0:1387ff3eed4a 5 * This file is part of wolfSSL.
sPymbed 0:1387ff3eed4a 6 *
sPymbed 0:1387ff3eed4a 7 * wolfSSL is free software; you can redistribute it and/or modify
sPymbed 0:1387ff3eed4a 8 * it under the terms of the GNU General Public License as published by
sPymbed 0:1387ff3eed4a 9 * the Free Software Foundation; either version 2 of the License, or
sPymbed 0:1387ff3eed4a 10 * (at your option) any later version.
sPymbed 0:1387ff3eed4a 11 *
sPymbed 0:1387ff3eed4a 12 * wolfSSL is distributed in the hope that it will be useful,
sPymbed 0:1387ff3eed4a 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
sPymbed 0:1387ff3eed4a 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
sPymbed 0:1387ff3eed4a 15 * GNU General Public License for more details.
sPymbed 0:1387ff3eed4a 16 *
sPymbed 0:1387ff3eed4a 17 * You should have received a copy of the GNU General Public License
sPymbed 0:1387ff3eed4a 18 * along with this program; if not, write to the Free Software
sPymbed 0:1387ff3eed4a 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
sPymbed 0:1387ff3eed4a 20 */
sPymbed 0:1387ff3eed4a 21
sPymbed 0:1387ff3eed4a 22
sPymbed 0:1387ff3eed4a 23 /* Based On Daniel J Bernstein's ed25519 Public Domain ref10 work. */
sPymbed 0:1387ff3eed4a 24
sPymbed 0:1387ff3eed4a 25 #ifndef WOLF_CRYPT_GE_OPERATIONS_H
sPymbed 0:1387ff3eed4a 26 #define WOLF_CRYPT_GE_OPERATIONS_H
sPymbed 0:1387ff3eed4a 27
sPymbed 0:1387ff3eed4a 28 #include <wolfcrypt/settings.h>
sPymbed 0:1387ff3eed4a 29
sPymbed 0:1387ff3eed4a 30 #ifdef HAVE_ED25519
sPymbed 0:1387ff3eed4a 31
sPymbed 0:1387ff3eed4a 32 #include <wolfcrypt/fe_operations.h>
sPymbed 0:1387ff3eed4a 33
sPymbed 0:1387ff3eed4a 34 /*
sPymbed 0:1387ff3eed4a 35 ge means group element.
sPymbed 0:1387ff3eed4a 36
sPymbed 0:1387ff3eed4a 37 Here the group is the set of pairs (x,y) of field elements (see fe.h)
sPymbed 0:1387ff3eed4a 38 satisfying -x^2 + y^2 = 1 + d x^2y^2
sPymbed 0:1387ff3eed4a 39 where d = -121665/121666.
sPymbed 0:1387ff3eed4a 40
sPymbed 0:1387ff3eed4a 41 Representations:
sPymbed 0:1387ff3eed4a 42 ge_p2 (projective): (X:Y:Z) satisfying x=X/Z, y=Y/Z
sPymbed 0:1387ff3eed4a 43 ge_p3 (extended): (X:Y:Z:T) satisfying x=X/Z, y=Y/Z, XY=ZT
sPymbed 0:1387ff3eed4a 44 ge_p1p1 (completed): ((X:Z),(Y:T)) satisfying x=X/Z, y=Y/T
sPymbed 0:1387ff3eed4a 45 ge_precomp (Duif): (y+x,y-x,2dxy)
sPymbed 0:1387ff3eed4a 46 */
sPymbed 0:1387ff3eed4a 47
sPymbed 0:1387ff3eed4a 48 #ifdef ED25519_SMALL
sPymbed 0:1387ff3eed4a 49 typedef byte ge[F25519_SIZE];
sPymbed 0:1387ff3eed4a 50 #elif defined(CURVED25519_X64)
sPymbed 0:1387ff3eed4a 51 typedef int64_t ge[4];
sPymbed 0:1387ff3eed4a 52 #elif defined(CURVED25519_128BIT)
sPymbed 0:1387ff3eed4a 53 typedef int64_t ge[5];
sPymbed 0:1387ff3eed4a 54 #else
sPymbed 0:1387ff3eed4a 55 typedef int32_t ge[10];
sPymbed 0:1387ff3eed4a 56 #endif
sPymbed 0:1387ff3eed4a 57
sPymbed 0:1387ff3eed4a 58 typedef struct {
sPymbed 0:1387ff3eed4a 59 ge X;
sPymbed 0:1387ff3eed4a 60 ge Y;
sPymbed 0:1387ff3eed4a 61 ge Z;
sPymbed 0:1387ff3eed4a 62 } ge_p2;
sPymbed 0:1387ff3eed4a 63
sPymbed 0:1387ff3eed4a 64 typedef struct {
sPymbed 0:1387ff3eed4a 65 ge X;
sPymbed 0:1387ff3eed4a 66 ge Y;
sPymbed 0:1387ff3eed4a 67 ge Z;
sPymbed 0:1387ff3eed4a 68 ge T;
sPymbed 0:1387ff3eed4a 69 } ge_p3;
sPymbed 0:1387ff3eed4a 70
sPymbed 0:1387ff3eed4a 71
sPymbed 0:1387ff3eed4a 72 WOLFSSL_LOCAL int ge_compress_key(byte* out, const byte* xIn, const byte* yIn,
sPymbed 0:1387ff3eed4a 73 word32 keySz);
sPymbed 0:1387ff3eed4a 74 WOLFSSL_LOCAL int ge_frombytes_negate_vartime(ge_p3 *,const unsigned char *);
sPymbed 0:1387ff3eed4a 75
sPymbed 0:1387ff3eed4a 76 WOLFSSL_LOCAL int ge_double_scalarmult_vartime(ge_p2 *,const unsigned char *,
sPymbed 0:1387ff3eed4a 77 const ge_p3 *,const unsigned char *);
sPymbed 0:1387ff3eed4a 78 WOLFSSL_LOCAL void ge_scalarmult_base(ge_p3 *,const unsigned char *);
sPymbed 0:1387ff3eed4a 79 WOLFSSL_LOCAL void sc_reduce(byte* s);
sPymbed 0:1387ff3eed4a 80 WOLFSSL_LOCAL void sc_muladd(byte* s, const byte* a, const byte* b,
sPymbed 0:1387ff3eed4a 81 const byte* c);
sPymbed 0:1387ff3eed4a 82 WOLFSSL_LOCAL void ge_tobytes(unsigned char *,const ge_p2 *);
sPymbed 0:1387ff3eed4a 83 WOLFSSL_LOCAL void ge_p3_tobytes(unsigned char *,const ge_p3 *);
sPymbed 0:1387ff3eed4a 84
sPymbed 0:1387ff3eed4a 85
sPymbed 0:1387ff3eed4a 86 #ifndef ED25519_SMALL
sPymbed 0:1387ff3eed4a 87 typedef struct {
sPymbed 0:1387ff3eed4a 88 ge X;
sPymbed 0:1387ff3eed4a 89 ge Y;
sPymbed 0:1387ff3eed4a 90 ge Z;
sPymbed 0:1387ff3eed4a 91 ge T;
sPymbed 0:1387ff3eed4a 92 } ge_p1p1;
sPymbed 0:1387ff3eed4a 93
sPymbed 0:1387ff3eed4a 94 typedef struct {
sPymbed 0:1387ff3eed4a 95 ge yplusx;
sPymbed 0:1387ff3eed4a 96 ge yminusx;
sPymbed 0:1387ff3eed4a 97 ge xy2d;
sPymbed 0:1387ff3eed4a 98 } ge_precomp;
sPymbed 0:1387ff3eed4a 99
sPymbed 0:1387ff3eed4a 100 typedef struct {
sPymbed 0:1387ff3eed4a 101 ge YplusX;
sPymbed 0:1387ff3eed4a 102 ge YminusX;
sPymbed 0:1387ff3eed4a 103 ge Z;
sPymbed 0:1387ff3eed4a 104 ge T2d;
sPymbed 0:1387ff3eed4a 105 } ge_cached;
sPymbed 0:1387ff3eed4a 106
sPymbed 0:1387ff3eed4a 107 #endif /* !ED25519_SMALL */
sPymbed 0:1387ff3eed4a 108
sPymbed 0:1387ff3eed4a 109 #endif /* HAVE_ED25519 */
sPymbed 0:1387ff3eed4a 110
sPymbed 0:1387ff3eed4a 111 #endif /* WOLF_CRYPT_GE_OPERATIONS_H */
sPymbed 0:1387ff3eed4a 112