wolfSSL SSL/TLS library, support up to TLS1.3

Dependents:   CyaSSL-Twitter-OAuth4Tw Example-client-tls-cert TwitterReader TweetTest ... more

Committer:
wolfSSL
Date:
Tue May 02 08:44:47 2017 +0000
Revision:
7:481bce714567
wolfSSL3.10.2

Who changed what in which revision?

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