mirror of
https://github.com/jedisct1/libsodium.git
synced 2026-08-26 19:57:13 +09:00
"buffer" and "buffer size" are way too generic to be useful
This commit is contained in:
+1
-1
@@ -20,7 +20,7 @@ auth(void)
|
||||
{
|
||||
unsigned char k[crypto_auth_KEYBYTES]; /* key */
|
||||
unsigned char a[crypto_auth_BYTES]; /* authentication token */
|
||||
unsigned char m[BUFFER_SIZE]; /* message */
|
||||
unsigned char m[MAX_INPUT_SIZE]; /* message */
|
||||
size_t mlen; /* message length */
|
||||
int r;
|
||||
|
||||
|
||||
+4
-4
@@ -30,10 +30,10 @@ box(void)
|
||||
unsigned char alice_pk[crypto_box_PUBLICKEYBYTES]; /* Alice public */
|
||||
unsigned char alice_sk[crypto_box_SECRETKEYBYTES]; /* Alice secret */
|
||||
|
||||
unsigned char n[crypto_box_NONCEBYTES]; /* message nonce */
|
||||
unsigned char m[BUFFER_SIZE]; /* plaintext */
|
||||
unsigned char c[BUFFER_SIZE + crypto_box_MACBYTES]; /* ciphertext */
|
||||
size_t mlen; /* length */
|
||||
unsigned char n[crypto_box_NONCEBYTES]; /* message nonce */
|
||||
unsigned char m[MAX_INPUT_SIZE]; /* plaintext */
|
||||
unsigned char c[MAX_INPUT_SIZE + crypto_box_MACBYTES]; /* ciphertext */
|
||||
size_t mlen; /* length */
|
||||
int r;
|
||||
|
||||
puts("Example: crypto_box_easy\n");
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@
|
||||
* ================================================================== */
|
||||
|
||||
/*
|
||||
* Print hex is a wrapper around sodium_bin2hex which allocates
|
||||
* print_hex() is a wrapper around sodium_bin2hex() which allocates
|
||||
* temporary memory then immediately prints the result.
|
||||
*/
|
||||
void
|
||||
@@ -64,7 +64,7 @@ prompt_input(char *prompt, char *input, const size_t max_input_len)
|
||||
}
|
||||
|
||||
/*
|
||||
* Print a message if the function was sucessful or failed.
|
||||
* Display whether the function was sucessful or failed.
|
||||
*/
|
||||
void
|
||||
print_verification(int r)
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define BUFFER_SIZE 128 /* size of all input buffers in the demo */
|
||||
#define MAX_INPUT_SIZE 128 /* size of all input buffers in the demo */
|
||||
|
||||
void print_hex(const void *bin, const size_t bin_len);
|
||||
size_t prompt_input(char *prompt, char *input, const size_t max_input_len);
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ generichash(void)
|
||||
{
|
||||
unsigned char k[crypto_generichash_KEYBYTES_MAX]; /* key */
|
||||
unsigned char h[crypto_generichash_BYTES_MIN]; /* hash output */
|
||||
unsigned char m[BUFFER_SIZE]; /* message */
|
||||
unsigned char m[MAX_INPUT_SIZE]; /* message */
|
||||
size_t mlen; /* length */
|
||||
|
||||
puts("Example: crypto_generichash\n");
|
||||
|
||||
@@ -21,7 +21,7 @@ generichashstream(void)
|
||||
unsigned char k[crypto_generichash_KEYBYTES_MAX]; /* key */
|
||||
unsigned char h[crypto_generichash_BYTES_MIN]; /* hash output */
|
||||
crypto_generichash_state state; /* hash stream */
|
||||
unsigned char m[BUFFER_SIZE]; /* input buffer */
|
||||
unsigned char m[MAX_INPUT_SIZE]; /* input buffer */
|
||||
size_t mlen; /* input length */
|
||||
|
||||
puts("Example: crypto_generichashstream\n");
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ static void
|
||||
hash(void)
|
||||
{
|
||||
unsigned char h[crypto_hash_BYTES]; /* hash output */
|
||||
unsigned char m[BUFFER_SIZE]; /* message */
|
||||
unsigned char m[MAX_INPUT_SIZE]; /* message */
|
||||
size_t mlen; /* length */
|
||||
|
||||
puts("Example: crypto_hash\n");
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ onetimeauth(void)
|
||||
{
|
||||
unsigned char k[crypto_onetimeauth_KEYBYTES]; /* key */
|
||||
unsigned char a[crypto_onetimeauth_BYTES]; /* authentication */
|
||||
unsigned char m[BUFFER_SIZE]; /* message */
|
||||
unsigned char m[MAX_INPUT_SIZE]; /* message */
|
||||
size_t mlen; /* message length */
|
||||
int r;
|
||||
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ shorthash(void)
|
||||
{
|
||||
unsigned char k[crypto_shorthash_KEYBYTES]; /* key */
|
||||
unsigned char h[crypto_shorthash_BYTES]; /* hash output */
|
||||
unsigned char m[BUFFER_SIZE]; /* message */
|
||||
unsigned char m[MAX_INPUT_SIZE]; /* message */
|
||||
size_t mlen; /* length */
|
||||
|
||||
puts("Example: crypto_shorthash\n");
|
||||
|
||||
+6
-6
@@ -22,12 +22,12 @@
|
||||
static int
|
||||
sign(void)
|
||||
{
|
||||
unsigned char pk[crypto_sign_PUBLICKEYBYTES]; /* Bob public */
|
||||
unsigned char sk[crypto_sign_SECRETKEYBYTES]; /* Bob secret */
|
||||
unsigned char m[BUFFER_SIZE]; /* message */
|
||||
unsigned char sm[BUFFER_SIZE + crypto_sign_BYTES]; /* signed message */
|
||||
unsigned long long int mlen; /* message length */
|
||||
unsigned long long int smlen; /* signed length */
|
||||
unsigned char pk[crypto_sign_PUBLICKEYBYTES]; /* Bob public */
|
||||
unsigned char sk[crypto_sign_SECRETKEYBYTES]; /* Bob secret */
|
||||
unsigned char m[MAX_INPUT_SIZE]; /* message */
|
||||
unsigned char sm[MAX_INPUT_SIZE + crypto_sign_BYTES]; /* signed message */
|
||||
unsigned long long int mlen; /* message length */
|
||||
unsigned long long int smlen; /* signed length */
|
||||
int r;
|
||||
|
||||
puts("Example: crypto_sign\n");
|
||||
|
||||
+2
-2
@@ -25,8 +25,8 @@ stream(void)
|
||||
{
|
||||
unsigned char k[crypto_stream_KEYBYTES]; /* secret key */
|
||||
unsigned char n[crypto_stream_NONCEBYTES]; /* message nonce */
|
||||
unsigned char m[BUFFER_SIZE]; /* plain-text */
|
||||
unsigned char c[BUFFER_SIZE]; /* cipher-text */
|
||||
unsigned char m[MAX_INPUT_SIZE]; /* plain-text */
|
||||
unsigned char c[MAX_INPUT_SIZE]; /* cipher-text */
|
||||
size_t mlen; /* length */
|
||||
int r;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user