Renaming ambiguous names
This commit is contained in:
parent
94c4bbd6cf
commit
2134acdc09
1 changed files with 11 additions and 11 deletions
22
main.c
22
main.c
|
|
@ -27,15 +27,15 @@ int main(void) {
|
|||
// uint8_t seed[32];
|
||||
// arc4random_buf(seed, 32);
|
||||
|
||||
uint8_t sk[64]; /* secret key */
|
||||
uint8_t pk[32]; /* Matching public key */
|
||||
uint8_t seckey[64]; /* secret key */
|
||||
uint8_t pubkey[32]; /* Matching public key */
|
||||
PRINT_HEX(seed, seed_len);
|
||||
|
||||
/* The seed is wiped automatically here */
|
||||
crypto_eddsa_key_pair(sk, pk, seed);
|
||||
crypto_eddsa_key_pair(seckey, pubkey, seed);
|
||||
|
||||
print_hex("PubKey", pk, 32);
|
||||
print_hex("SecKey", sk, 64);
|
||||
PRINT_HEX(pubkey, 32);
|
||||
PRINT_HEX(seckey, 64);
|
||||
|
||||
uint8_t message[4];
|
||||
|
||||
|
|
@ -43,24 +43,24 @@ int main(void) {
|
|||
arc4random_buf(message, 4);
|
||||
PRINT_HEX(message, sizeof(message));
|
||||
|
||||
uint8_t sig[64];
|
||||
uint8_t signature[64];
|
||||
|
||||
/* Sign it and store the signature in sig[] */
|
||||
crypto_eddsa_sign(sig, sk, (const uint8_t *)message, sizeof(message));
|
||||
print_hex("Signature:", sig, 64);
|
||||
crypto_eddsa_sign(signature, seckey, (const uint8_t *)message, sizeof(message));
|
||||
PRINT_HEX(signature, 64);
|
||||
|
||||
/* Assert valid */
|
||||
assert(!crypto_eddsa_check(sig, pk, (const uint8_t *)message, sizeof(message)));
|
||||
assert(!crypto_eddsa_check(signature, pubkey, (const uint8_t *)message, sizeof(message)));
|
||||
|
||||
/* Tamper with payload to invalidate the signature */
|
||||
arc4random_buf(message, 4);
|
||||
PRINT_HEX(message, sizeof(message));
|
||||
|
||||
/* Assert invalid */
|
||||
assert(crypto_eddsa_check(sig, pk, (const uint8_t *)message, sizeof(message)));
|
||||
assert(crypto_eddsa_check(signature, pubkey, (const uint8_t *)message, sizeof(message)));
|
||||
|
||||
/* Wipe the secret key if it is no longer needed */
|
||||
crypto_wipe(sk, 32);
|
||||
crypto_wipe(seckey, 32);
|
||||
|
||||
printf("Program finished: Ok!\n");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue