putc('\n', stdout) or putchar('\n') - pick one
And remove duplicate putchar('\n') to improve code clarity
This commit is contained in:
parent
071c467ff3
commit
b1bcecf086
@ -76,7 +76,6 @@ box(void)
|
||||
fputs("Secret key: ", stdout);
|
||||
print_hex(bob_sk, sizeof bob_sk);
|
||||
putchar('\n');
|
||||
putchar('\n');
|
||||
|
||||
puts("Alice");
|
||||
fputs("Public key: ", stdout);
|
||||
@ -85,7 +84,6 @@ box(void)
|
||||
fputs("Secret key: ", stdout);
|
||||
print_hex(alice_sk, sizeof alice_sk);
|
||||
putchar('\n');
|
||||
putchar('\n');
|
||||
|
||||
/* nonce must be unique per (key, message) - it can be public and deterministic */
|
||||
puts("Generating nonce...");
|
||||
@ -93,14 +91,12 @@ box(void)
|
||||
fputs("Nonce: ", stdout);
|
||||
print_hex(nonce, sizeof nonce);
|
||||
putchar('\n');
|
||||
putchar('\n');
|
||||
|
||||
/* read input */
|
||||
message_len = prompt_input("a message", (char*)message, sizeof message, 1);
|
||||
|
||||
print_hex(message, message_len);
|
||||
putchar('\n');
|
||||
putchar('\n');
|
||||
|
||||
/* encrypt and authenticate the message */
|
||||
printf("Encrypting and authenticating with %s\n\n", crypto_box_primitive());
|
||||
@ -118,7 +114,6 @@ box(void)
|
||||
fputs("Ciphertext: ", stdout);
|
||||
print_hex(ciphertext, ciphertext_len);
|
||||
putchar('\n');
|
||||
putchar('\n');
|
||||
|
||||
/* decrypt the message */
|
||||
puts("Alice verifies and decrypts the ciphertext...");
|
||||
|
@ -76,7 +76,6 @@ box_detached(void)
|
||||
fputs("Secret key: ", stdout);
|
||||
print_hex(bob_sk, sizeof bob_sk);
|
||||
putchar('\n');
|
||||
putchar('\n');
|
||||
|
||||
puts("Alice");
|
||||
fputs("Public key: ", stdout);
|
||||
@ -85,7 +84,6 @@ box_detached(void)
|
||||
fputs("Secret key: ", stdout);
|
||||
print_hex(alice_sk, sizeof alice_sk);
|
||||
putchar('\n');
|
||||
putchar('\n');
|
||||
|
||||
/* nonce must be unique per (key, message) - it can be public and deterministic */
|
||||
puts("Generating nonce...");
|
||||
@ -93,14 +91,12 @@ box_detached(void)
|
||||
fputs("Nonce: ", stdout);
|
||||
print_hex(nonce, sizeof nonce);
|
||||
putchar('\n');
|
||||
putchar('\n');
|
||||
|
||||
/* read input */
|
||||
message_len = prompt_input("a message", (char*)message, sizeof message, 1);
|
||||
|
||||
print_hex(message, message_len);
|
||||
putchar('\n');
|
||||
putchar('\n');
|
||||
|
||||
/* encrypt and authenticate the message */
|
||||
printf("Encrypting and authenticating with %s\n\n", crypto_box_primitive());
|
||||
@ -118,7 +114,6 @@ box_detached(void)
|
||||
fputs("Ciphertext: ", stdout);
|
||||
print_hex(ciphertext, message_len);
|
||||
putchar('\n');
|
||||
putchar('\n');
|
||||
|
||||
/* decrypt the message */
|
||||
puts("Alice verifies the MAC and decrypts the ciphertext...");
|
||||
|
10
demos/sign.c
10
demos/sign.c
@ -37,19 +37,17 @@ sign(void)
|
||||
|
||||
fputs("Public: ", stdout);
|
||||
print_hex(pk, sizeof pk);
|
||||
putc('\n', stdout);
|
||||
putchar('\n');
|
||||
fputs("Secret: ", stdout);
|
||||
print_hex(sk, sizeof sk);
|
||||
puts("\n");
|
||||
putchar('\n');
|
||||
|
||||
/* read input */
|
||||
mlen = prompt_input("a message", (char*)m, sizeof m, 1);
|
||||
putchar('\n');
|
||||
|
||||
puts("Notice the message has no prepended padding");
|
||||
print_hex(m, mlen);
|
||||
putchar('\n');
|
||||
putchar('\n');
|
||||
|
||||
printf("Signing message with %s...\n", crypto_sign_primitive());
|
||||
crypto_sign(sm, &smlen, m, mlen, sk);
|
||||
@ -57,7 +55,6 @@ sign(void)
|
||||
puts("Notice the signed message has prepended signature");
|
||||
print_hex(sm, smlen);
|
||||
putchar('\n');
|
||||
putchar('\n');
|
||||
|
||||
fputs("Signature: ", stdout);
|
||||
print_hex(sm, crypto_sign_BYTES);
|
||||
@ -71,11 +68,12 @@ sign(void)
|
||||
|
||||
print_verification(r);
|
||||
if (r == 0)
|
||||
printf("Message: %s\n\n", m);
|
||||
printf("Message: %s\n", m);
|
||||
|
||||
sodium_memzero(sk, sizeof sk); /* wipe sensitive data */
|
||||
sodium_memzero(m, sizeof m);
|
||||
sodium_memzero(sm, sizeof sm);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user