| 1 |
/* |
| 2 |
* (C) 2004- TeraTerm Project |
| 3 |
* All rights reserved. |
| 4 |
* |
| 5 |
* Redistribution and use in source and binary forms, with or without |
| 6 |
* modification, are permitted provided that the following conditions |
| 7 |
* are met: |
| 8 |
* |
| 9 |
* 1. Redistributions of source code must retain the above copyright |
| 10 |
* notice, this list of conditions and the following disclaimer. |
| 11 |
* 2. Redistributions in binary form must reproduce the above copyright |
| 12 |
* notice, this list of conditions and the following disclaimer in the |
| 13 |
* documentation and/or other materials provided with the distribution. |
| 14 |
* 3. The name of the author may not be used to endorse or promote products |
| 15 |
* derived from this software without specific prior written permission. |
| 16 |
* |
| 17 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR |
| 18 |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 19 |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 20 |
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 21 |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 22 |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 |
*/ |
| 28 |
|
| 29 |
#ifndef __ED25519_SC25519_H |
| 30 |
#define __ED25519_SC25519_H |
| 31 |
|
| 32 |
#include "ed25519_crypto_api.h" |
| 33 |
|
| 34 |
#define sc25519 crypto_sign_ed25519_ref_sc25519 |
| 35 |
#define shortsc25519 crypto_sign_ed25519_ref_shortsc25519 |
| 36 |
#define sc25519_from32bytes crypto_sign_ed25519_ref_sc25519_from32bytes |
| 37 |
#define shortsc25519_from16bytes crypto_sign_ed25519_ref_shortsc25519_from16bytes |
| 38 |
#define sc25519_from64bytes crypto_sign_ed25519_ref_sc25519_from64bytes |
| 39 |
#define sc25519_from_shortsc crypto_sign_ed25519_ref_sc25519_from_shortsc |
| 40 |
#define sc25519_to32bytes crypto_sign_ed25519_ref_sc25519_to32bytes |
| 41 |
#define sc25519_iszero_vartime crypto_sign_ed25519_ref_sc25519_iszero_vartime |
| 42 |
#define sc25519_isshort_vartime crypto_sign_ed25519_ref_sc25519_isshort_vartime |
| 43 |
#define sc25519_lt_vartime crypto_sign_ed25519_ref_sc25519_lt_vartime |
| 44 |
#define sc25519_add crypto_sign_ed25519_ref_sc25519_add |
| 45 |
#define sc25519_sub_nored crypto_sign_ed25519_ref_sc25519_sub_nored |
| 46 |
#define sc25519_mul crypto_sign_ed25519_ref_sc25519_mul |
| 47 |
#define sc25519_mul_shortsc crypto_sign_ed25519_ref_sc25519_mul_shortsc |
| 48 |
#define sc25519_window3 crypto_sign_ed25519_ref_sc25519_window3 |
| 49 |
#define sc25519_window5 crypto_sign_ed25519_ref_sc25519_window5 |
| 50 |
#define sc25519_2interleave2 crypto_sign_ed25519_ref_sc25519_2interleave2 |
| 51 |
|
| 52 |
typedef struct |
| 53 |
{ |
| 54 |
crypto_uint32 v[32]; |
| 55 |
} |
| 56 |
sc25519; |
| 57 |
|
| 58 |
typedef struct |
| 59 |
{ |
| 60 |
crypto_uint32 v[16]; |
| 61 |
} |
| 62 |
shortsc25519; |
| 63 |
|
| 64 |
void sc25519_from32bytes(sc25519 *r, const unsigned char x[32]); |
| 65 |
|
| 66 |
void shortsc25519_from16bytes(shortsc25519 *r, const unsigned char x[16]); |
| 67 |
|
| 68 |
void sc25519_from64bytes(sc25519 *r, const unsigned char x[64]); |
| 69 |
|
| 70 |
void sc25519_from_shortsc(sc25519 *r, const shortsc25519 *x); |
| 71 |
|
| 72 |
void sc25519_to32bytes(unsigned char r[32], const sc25519 *x); |
| 73 |
|
| 74 |
int sc25519_iszero_vartime(const sc25519 *x); |
| 75 |
|
| 76 |
int sc25519_isshort_vartime(const sc25519 *x); |
| 77 |
|
| 78 |
int sc25519_lt_vartime(const sc25519 *x, const sc25519 *y); |
| 79 |
|
| 80 |
void sc25519_add(sc25519 *r, const sc25519 *x, const sc25519 *y); |
| 81 |
|
| 82 |
void sc25519_sub_nored(sc25519 *r, const sc25519 *x, const sc25519 *y); |
| 83 |
|
| 84 |
void sc25519_mul(sc25519 *r, const sc25519 *x, const sc25519 *y); |
| 85 |
|
| 86 |
void sc25519_mul_shortsc(sc25519 *r, const sc25519 *x, const shortsc25519 *y); |
| 87 |
|
| 88 |
/* Convert s into a representation of the form \sum_{i=0}^{84}r[i]2^3 |
| 89 |
* with r[i] in {-4,...,3} |
| 90 |
*/ |
| 91 |
void sc25519_window3(signed char r[85], const sc25519 *s); |
| 92 |
|
| 93 |
/* Convert s into a representation of the form \sum_{i=0}^{50}r[i]2^5 |
| 94 |
* with r[i] in {-16,...,15} |
| 95 |
*/ |
| 96 |
void sc25519_window5(signed char r[51], const sc25519 *s); |
| 97 |
|
| 98 |
void sc25519_2interleave2(unsigned char r[127], const sc25519 *s1, const sc25519 *s2); |
| 99 |
|
| 100 |
#endif |