mirror of
https://github.com/kmackay/micro-ecc.git
synced 2026-08-19 00:10:01 +00:00
Stray tabs to spaces.
This commit is contained in:
+7
-7
@@ -41,13 +41,13 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
randfd = open("/dev/urandom", O_RDONLY);
|
||||
if(randfd == -1)
|
||||
{
|
||||
if(randfd == -1)
|
||||
{
|
||||
printf("No access to urandom\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint32_t l_private[NUM_ECC_DIGITS];
|
||||
}
|
||||
|
||||
uint32_t l_private[NUM_ECC_DIGITS];
|
||||
EccPoint l_public;
|
||||
|
||||
for(i=0; i<l_num; ++i)
|
||||
@@ -67,8 +67,8 @@ int main(int argc, char **argv)
|
||||
vli_print(l_public.y);
|
||||
printf("}};\n\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* !TARGET_LPC11XX */
|
||||
|
||||
+7
-7
@@ -29,9 +29,9 @@ void vli_print(uint32_t *p_vli)
|
||||
{
|
||||
unsigned i;
|
||||
for(i=0; i<NUM_ECC_DIGITS; ++i)
|
||||
{
|
||||
printf("%08X ", (unsigned)p_vli[i]);
|
||||
}
|
||||
{
|
||||
printf("%08X ", (unsigned)p_vli[i]);
|
||||
}
|
||||
}
|
||||
|
||||
#if (ECC_CURVE == secp128r1)
|
||||
@@ -439,8 +439,8 @@ uint32_t g_dsa_s[10][NUM_ECC_DIGITS] = {
|
||||
int main()
|
||||
{
|
||||
uartInit(BAUD_115200);
|
||||
initTime();
|
||||
|
||||
initTime();
|
||||
|
||||
uint32_t l_shared[NUM_ECC_DIGITS];
|
||||
uint64_t l_total = 0;
|
||||
|
||||
@@ -472,6 +472,6 @@ int main()
|
||||
}
|
||||
|
||||
printf("Total ECDSA time: %llu\n", l_total);
|
||||
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+63
-63
@@ -9,11 +9,11 @@
|
||||
|
||||
void vli_print(uint32_t *p_vli, unsigned int p_size)
|
||||
{
|
||||
while(p_size)
|
||||
{
|
||||
printf("%08X ", (unsigned)p_vli[p_size - 1]);
|
||||
--p_size;
|
||||
}
|
||||
while(p_size)
|
||||
{
|
||||
printf("%08X ", (unsigned)p_vli[p_size - 1]);
|
||||
--p_size;
|
||||
}
|
||||
}
|
||||
|
||||
int randfd;
|
||||
@@ -29,72 +29,72 @@ void getRandomBytes(void *p_dest, unsigned p_size)
|
||||
int main()
|
||||
{
|
||||
EccPoint l_Q1, l_Q2; /* public keys */
|
||||
uint32_t l_secret1[NUM_ECC_DIGITS];
|
||||
uint32_t l_secret2[NUM_ECC_DIGITS];
|
||||
uint64_t l_total;
|
||||
int i;
|
||||
|
||||
uint32_t l_shared1[NUM_ECC_DIGITS];
|
||||
uint32_t l_shared2[NUM_ECC_DIGITS];
|
||||
|
||||
uint32_t l_random1[NUM_ECC_DIGITS];
|
||||
uint32_t l_random2[NUM_ECC_DIGITS];
|
||||
|
||||
uint32_t l_secret1[NUM_ECC_DIGITS];
|
||||
uint32_t l_secret2[NUM_ECC_DIGITS];
|
||||
uint64_t l_total;
|
||||
int i;
|
||||
|
||||
uint32_t l_shared1[NUM_ECC_DIGITS];
|
||||
uint32_t l_shared2[NUM_ECC_DIGITS];
|
||||
|
||||
uint32_t l_random1[NUM_ECC_DIGITS];
|
||||
uint32_t l_random2[NUM_ECC_DIGITS];
|
||||
|
||||
randfd = open("/dev/urandom", O_RDONLY);
|
||||
if(randfd == -1)
|
||||
{
|
||||
if(randfd == -1)
|
||||
{
|
||||
printf("No access to urandom\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("Testing 256 random private key pairs\n");
|
||||
|
||||
}
|
||||
|
||||
printf("Testing 256 random private key pairs\n");
|
||||
|
||||
l_total = 0;
|
||||
for(i=0; i<256; ++i)
|
||||
{
|
||||
printf(".");
|
||||
fflush(stdout);
|
||||
getRandomBytes((char *)l_secret1, NUM_ECC_DIGITS * sizeof(uint32_t));
|
||||
getRandomBytes((char *)l_secret2, NUM_ECC_DIGITS * sizeof(uint32_t));
|
||||
|
||||
getRandomBytes((char *)l_random1, NUM_ECC_DIGITS * sizeof(uint32_t));
|
||||
getRandomBytes((char *)l_random2, NUM_ECC_DIGITS * sizeof(uint32_t));
|
||||
|
||||
for(i=0; i<256; ++i)
|
||||
{
|
||||
printf(".");
|
||||
fflush(stdout);
|
||||
getRandomBytes((char *)l_secret1, NUM_ECC_DIGITS * sizeof(uint32_t));
|
||||
getRandomBytes((char *)l_secret2, NUM_ECC_DIGITS * sizeof(uint32_t));
|
||||
|
||||
getRandomBytes((char *)l_random1, NUM_ECC_DIGITS * sizeof(uint32_t));
|
||||
getRandomBytes((char *)l_random2, NUM_ECC_DIGITS * sizeof(uint32_t));
|
||||
|
||||
ecc_make_key(&l_Q1, l_secret1, l_secret1);
|
||||
ecc_make_key(&l_Q2, l_secret2, l_secret2);
|
||||
|
||||
if(!ecdh_shared_secret(l_shared1, &l_Q1, l_secret2, l_random1))
|
||||
{
|
||||
printf("shared_secret() failed (1)\n");
|
||||
return 1;
|
||||
}
|
||||
if(!ecdh_shared_secret(l_shared1, &l_Q1, l_secret2, l_random1))
|
||||
{
|
||||
printf("shared_secret() failed (1)\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(!ecdh_shared_secret(l_shared2, &l_Q2, l_secret1, l_random2))
|
||||
{
|
||||
printf("shared_secret() failed (2)\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(memcmp(l_shared1, l_shared2, sizeof(l_shared1)) != 0)
|
||||
{
|
||||
printf("Shared secrets are not identical!\n");
|
||||
printf("Shared secret 1 = ");
|
||||
vli_print(l_shared1, NUM_ECC_DIGITS);
|
||||
printf("\n");
|
||||
printf("Shared secret 2 = ");
|
||||
vli_print(l_shared2, NUM_ECC_DIGITS);
|
||||
printf("\n");
|
||||
printf("Private key 1 = ");
|
||||
vli_print(l_secret1, NUM_ECC_DIGITS);
|
||||
printf("\n");
|
||||
printf("Private key 2 = ");
|
||||
vli_print(l_secret2, NUM_ECC_DIGITS);
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
return 0;
|
||||
if(!ecdh_shared_secret(l_shared2, &l_Q2, l_secret1, l_random2))
|
||||
{
|
||||
printf("shared_secret() failed (2)\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(memcmp(l_shared1, l_shared2, sizeof(l_shared1)) != 0)
|
||||
{
|
||||
printf("Shared secrets are not identical!\n");
|
||||
printf("Shared secret 1 = ");
|
||||
vli_print(l_shared1, NUM_ECC_DIGITS);
|
||||
printf("\n");
|
||||
printf("Shared secret 2 = ");
|
||||
vli_print(l_shared2, NUM_ECC_DIGITS);
|
||||
printf("\n");
|
||||
printf("Private key 1 = ");
|
||||
vli_print(l_secret1, NUM_ECC_DIGITS);
|
||||
printf("\n");
|
||||
printf("Private key 2 = ");
|
||||
vli_print(l_secret2, NUM_ECC_DIGITS);
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* !TARGET_LPC11XX */
|
||||
|
||||
+26
-26
@@ -20,31 +20,31 @@ void getRandomBytes(void *p_dest, unsigned p_size)
|
||||
int main()
|
||||
{
|
||||
EccPoint l_public;
|
||||
uint32_t l_private[NUM_ECC_DIGITS];
|
||||
uint32_t l_private[NUM_ECC_DIGITS];
|
||||
|
||||
uint32_t l_hash[NUM_ECC_DIGITS];
|
||||
uint32_t l_random[NUM_ECC_DIGITS];
|
||||
|
||||
uint32_t r[NUM_ECC_DIGITS];
|
||||
uint32_t s[NUM_ECC_DIGITS];
|
||||
|
||||
int i;
|
||||
|
||||
uint32_t l_hash[NUM_ECC_DIGITS];
|
||||
uint32_t l_random[NUM_ECC_DIGITS];
|
||||
|
||||
uint32_t r[NUM_ECC_DIGITS];
|
||||
uint32_t s[NUM_ECC_DIGITS];
|
||||
|
||||
int i;
|
||||
|
||||
randfd = open("/dev/urandom", O_RDONLY);
|
||||
if(randfd == -1)
|
||||
{
|
||||
if(randfd == -1)
|
||||
{
|
||||
printf("No access to urandom\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("Testing 256 signatures\n");
|
||||
|
||||
for(i=0; i<256; ++i)
|
||||
{
|
||||
printf(".");
|
||||
fflush(stdout);
|
||||
getRandomBytes((char *)l_private, NUM_ECC_DIGITS * sizeof(uint32_t));
|
||||
|
||||
}
|
||||
|
||||
printf("Testing 256 signatures\n");
|
||||
|
||||
for(i=0; i<256; ++i)
|
||||
{
|
||||
printf(".");
|
||||
fflush(stdout);
|
||||
getRandomBytes((char *)l_private, NUM_ECC_DIGITS * sizeof(uint32_t));
|
||||
|
||||
ecc_make_key(&l_public, l_private, l_private);
|
||||
|
||||
getRandomBytes((char *)l_hash, NUM_ECC_DIGITS * sizeof(uint32_t));
|
||||
@@ -59,17 +59,17 @@ int main()
|
||||
if(!ecc_valid_public_key(&l_public))
|
||||
{
|
||||
printf("Not a valid public key!\n");
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!ecdsa_verify(&l_public, l_hash, r, s))
|
||||
{
|
||||
printf("ecdsa_verify() failed\n");
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* !TARGET_LPC11XX */
|
||||
|
||||
Reference in New Issue
Block a user