1
0
mirror of https://github.com/taigrr/arduinolibs synced 2025-01-18 04:33:12 -08:00

Update reference links for Curve25519 and Ed25519

This commit is contained in:
Rhys Weatherley 2016-03-27 09:45:39 +10:00
parent 5c4d7ce69a
commit e1bf1808c1
4 changed files with 11 additions and 68 deletions

View File

@ -35,8 +35,8 @@
* stack space to store intermediate results while the curve function is
* being evaluated. About 1k of free stack space is recommended for safety.
*
* References: http://cr.yp.to/ecdh.html
* https://tools.ietf.org/html/draft-irtf-cfrg-curves-02
* References: http://cr.yp.to/ecdh.html,
* <a href="http://tools.ietf.org/html/rfc7748">RFC 7748</a>
*
* \sa Ed25519
*/
@ -72,7 +72,7 @@
* \return Returns true if the function was evaluated; false if \a x is
* not a proper member of the field modulo (2^255 - 19).
*
* Reference: https://tools.ietf.org/html/draft-irtf-cfrg-curves-02
* Reference: <a href="http://tools.ietf.org/html/rfc7748">RFC 7748</a>
*
* \sa dh1(), dh2()
*/
@ -237,7 +237,7 @@ bool Curve25519::eval(uint8_t result[32], const uint8_t s[32], const uint8_t x[3
* ...
* \endcode
*
* Reference: https://tools.ietf.org/html/draft-irtf-cfrg-curves-02
* Reference: <a href="http://tools.ietf.org/html/rfc7748">RFC 7748</a>
*
* \sa dh2()
*/
@ -275,7 +275,7 @@ void Curve25519::dh1(uint8_t k[32], uint8_t f[32])
* \return Returns true if the key exchange was successful, or false if
* the \a k value is invalid.
*
* Reference: https://tools.ietf.org/html/draft-irtf-cfrg-curves-02
* Reference: <a href="http://tools.ietf.org/html/rfc7748">RFC 7748</a>
*
* \sa dh1()
*/
@ -1319,7 +1319,7 @@ void Curve25519::cswap(limb_t select, limb_t *x, limb_t *y)
--sel;
// Swap the two values based on "select". Algorithm from:
// https://tools.ietf.org/html/draft-irtf-cfrg-curves-02
// http://tools.ietf.org/html/rfc7748
for (posn = 0; posn < NUM_LIMBS_256BIT; ++posn) {
dummy = sel & (x[posn] ^ y[posn]);
x[posn] ^= dummy;
@ -1577,8 +1577,7 @@ bool Curve25519::sqrt(limb_t *result, const limb_t *x)
};
limb_t y[NUM_LIMBS_256BIT];
// Algorithm from:
// https://tools.ietf.org/id/draft-josefsson-eddsa-ed25519-02.txt
// Algorithm from: http://tools.ietf.org/html/rfc7748
// Compute a candidate root: result = x^((p + 3) / 8) mod p.
// (p + 3) / 8 = (2^252 - 2) which is 251 one bits followed by a zero:

View File

@ -68,7 +68,7 @@
* stack space to store intermediate results while the curve function is
* being evaluated. About 1.5k of free stack space is recommended for safety.
*
* References: https://tools.ietf.org/id/draft-josefsson-eddsa-ed25519-02.txt
* References: https://tools.ietf.org/html/draft-irtf-cfrg-eddsa-05
*
* \sa Curve25519
*/

View File

@ -41,8 +41,8 @@ void printNumber(const char *name, const uint8_t *x)
Serial.println();
}
// Check the eval() function using the test vectors from:
// https://tools.ietf.org/html/draft-turner-thecurve25519function-01
// Check the eval() function using the test vectors from
// section 6.1 of RFC 7748.
void testEval()
{
static uint8_t alice_private[32] = {

View File

@ -41,7 +41,7 @@ struct TestVector
};
// Test vectors for Ed25519 from:
// https://tools.ietf.org/id/draft-josefsson-eddsa-ed25519-02.txt
// https://tools.ietf.org/html/draft-irtf-cfrg-eddsa-05
static TestVector const testVectorEd25519_1 PROGMEM = {
.name = "Ed25519 #1",
.privateKey = {0x9d, 0x61, 0xb1, 0x9d, 0xef, 0xfd, 0x5a, 0x60,
@ -162,64 +162,10 @@ void testFixedVectors(const struct TestVector *test)
void testFixedVectors()
{
//Serial.println("Fixed test vectors:");
testFixedVectors(&testVectorEd25519_1);
testFixedVectors(&testVectorEd25519_2);
}
/*
void testDH()
{
static uint8_t alice_k[32];
static uint8_t alice_f[32];
static uint8_t bob_k[32];
static uint8_t bob_f[32];
Serial.println("Diffie-Hellman key exchange:");
Serial.print("Generate random k/f for Alice ... ");
Serial.flush();
unsigned long start = micros();
Curve25519::dh1(alice_k, alice_f);
unsigned long elapsed = micros() - start;
Serial.print("elapsed ");
Serial.print(elapsed);
Serial.println(" us");
Serial.print("Generate random k/f for Bob ... ");
Serial.flush();
start = micros();
Curve25519::dh1(bob_k, bob_f);
elapsed = micros() - start;
Serial.print("elapsed ");
Serial.print(elapsed);
Serial.println(" us");
Serial.print("Generate shared secret for Alice ... ");
Serial.flush();
start = micros();
Curve25519::dh2(bob_k, alice_f);
elapsed = micros() - start;
Serial.print("elapsed ");
Serial.print(elapsed);
Serial.println(" us");
Serial.print("Generate shared secret for Bob ... ");
Serial.flush();
start = micros();
Curve25519::dh2(alice_k, bob_f);
elapsed = micros() - start;
Serial.print("elapsed ");
Serial.print(elapsed);
Serial.println(" us");
Serial.print("Check that the shared secrets match ... ");
if (memcmp(alice_k, bob_k, 32) == 0)
Serial.println("ok");
else
Serial.println("failed");
}
*/
void setup()
{
Serial.begin(9600);
@ -232,8 +178,6 @@ void setup()
// Perform the tests.
testFixedVectors();
Serial.println();
//testDH();
//Serial.println();
}
void loop()