tabs begone

This commit is contained in:
Orson Peters 2013-04-11 20:20:20 +02:00
parent 4147206bca
commit 35f4cd8431
2 changed files with 27 additions and 27 deletions

View File

@ -9,7 +9,7 @@ void ed25519_add_scalar(unsigned char *public_key, unsigned char *private_key, c
const unsigned char SC_1[32] = {1}; /* scalar with value 1 */
unsigned char n[32];
unsigned char salt[64];
unsigned char salt[64];
ge_p3 nB;
ge_p1p1 A_p1p1;
ge_p3 A;

52
test.c
View File

@ -14,13 +14,13 @@ const char message[] = "Hello, world!";
int main(int argc, char *argv[]) {
unsigned char public_key[32], private_key[64], seed[32], scalar[32];
unsigned char other_public_key[32], other_private_key[64];
unsigned char shared_secret[32], other_shared_secret[32];
unsigned char other_public_key[32], other_private_key[64];
unsigned char shared_secret[32], other_shared_secret[32];
unsigned char signature[64];
clock_t start;
clock_t end;
int i;
clock_t start;
clock_t end;
int i;
/* create a random seed, and a keypair out of that seed */
ed25519_create_seed(seed);
@ -58,32 +58,32 @@ int main(int argc, char *argv[]) {
printf("correctly detected signature change\n");
}
/* generate two keypairs for testing key exchange */
ed25519_create_seed(seed);
ed25519_create_keypair(public_key, private_key, seed);
ed25519_create_seed(seed);
ed25519_create_keypair(other_public_key, other_private_key, seed);
/* generate two keypairs for testing key exchange */
ed25519_create_seed(seed);
ed25519_create_keypair(public_key, private_key, seed);
ed25519_create_seed(seed);
ed25519_create_keypair(other_public_key, other_private_key, seed);
/* create two shared secrets - from both perspectives - and check if they're equal */
ed25519_key_exchange(shared_secret, other_public_key, private_key);
ed25519_key_exchange(other_shared_secret, public_key, other_private_key);
/* create two shared secrets - from both perspectives - and check if they're equal */
ed25519_key_exchange(shared_secret, other_public_key, private_key);
ed25519_key_exchange(other_shared_secret, public_key, other_private_key);
for (i = 0; i < 32; ++i) {
if (shared_secret[i] != other_shared_secret[i]) {
printf("key exchange was incorrect\n");
break;
}
}
for (i = 0; i < 32; ++i) {
if (shared_secret[i] != other_shared_secret[i]) {
printf("key exchange was incorrect\n");
break;
}
}
if (i == 32) {
printf("key exchange was correct\n");
}
if (i == 32) {
printf("key exchange was correct\n");
}
/* test performance */
printf("testing seed generation performance: ");
printf("testing seed generation performance: ");
start = clock();
for (i = 0; i < 10000; ++i) {
ed25519_create_seed(seed);
ed25519_create_seed(seed);
}
end = clock();
@ -127,7 +127,7 @@ int main(int argc, char *argv[]) {
printf("%fus per keypair\n", ((double) ((end - start) * 1000)) / CLOCKS_PER_SEC / i * 1000);
printf("testing public key scalar addition performance: ");
printf("testing public key scalar addition performance: ");
start = clock();
for (i = 0; i < 10000; ++i) {
ed25519_add_scalar(public_key, NULL, scalar);
@ -136,7 +136,7 @@ int main(int argc, char *argv[]) {
printf("%fus per key\n", ((double) ((end - start) * 1000)) / CLOCKS_PER_SEC / i * 1000);
printf("testing key exchange performance: ");
printf("testing key exchange performance: ");
start = clock();
for (i = 0; i < 10000; ++i) {
ed25519_key_exchange(shared_secret, other_public_key, private_key);