Add the order of the base point to the public API

This commit is contained in:
Matthias Schiffer 2012-12-08 12:15:49 +01:00
parent 5dff3b368f
commit d072ec9de1
2 changed files with 4 additions and 2 deletions

View file

@ -56,6 +56,7 @@ void ecc_25519_scalarmult(ecc_25519_work *out, const ecc_int_256 *n, const ecc_2
void ecc_25519_scalarmult_base(ecc_25519_work *out, const ecc_int_256 *n); void ecc_25519_scalarmult_base(ecc_25519_work *out, const ecc_int_256 *n);
/* operations on elements of the prime field F_q for q = 2^252 + 27742317777372353535851937790883648493 */ /* operations on elements of the prime field F_q for q = 2^252 + 27742317777372353535851937790883648493 */
extern const ecc_int_256 ecc_25519_gf_order;
int ecc_25519_gf_is_zero(const ecc_int_256 *in); int ecc_25519_gf_is_zero(const ecc_int_256 *in);
void ecc_25519_gf_add(ecc_int_256 *out, const ecc_int_256 *in1, const ecc_int_256 *in2); void ecc_25519_gf_add(ecc_int_256 *out, const ecc_int_256 *in1, const ecc_int_256 *in2);
void ecc_25519_gf_sub(ecc_int_256 *out, const ecc_int_256 *in1, const ecc_int_256 *in2); void ecc_25519_gf_sub(ecc_int_256 *out, const ecc_int_256 *in1, const ecc_int_256 *in2);

View file

@ -37,13 +37,14 @@
#define ASR(n,s) (((n) >> s)|(IS_NEGATIVE(n)*((unsigned)-1) << (8*sizeof(n)-s))) #define ASR(n,s) (((n) >> s)|(IS_NEGATIVE(n)*((unsigned)-1) << (8*sizeof(n)-s)))
static const unsigned char q[32] = { const ecc_int_256 ecc_25519_gf_order = {{
0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58,
0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10
}; }};
static const unsigned char *q = ecc_25519_gf_order.p;
static void select(unsigned char out[32], const unsigned char r[32], const unsigned char s[32], unsigned int b) { static void select(unsigned char out[32], const unsigned char r[32], const unsigned char s[32], unsigned int b) {
unsigned int j; unsigned int j;