Browse Source

Remove usage of VLAs

master
Ron Nazarov 1 year ago
parent
commit
6746f4b4f6
Signed by: noisytoot
GPG Key ID: 1D43EF4F4492268B
  1. 1
      common.h
  2. 10
      sign.c

1
common.h

@ -16,5 +16,6 @@
#define base64_variant sodium_base64_VARIANT_ORIGINAL
#define base64_pk_len sodium_base64_ENCODED_LEN(crypto_sign_PUBLICKEYBYTES, base64_variant)
#define base64_sk_len sodium_base64_ENCODED_LEN(crypto_sign_SECRETKEYBYTES, base64_variant)
#define base64_signature_len sodium_base64_ENCODED_LEN(crypto_sign_BYTES, base64_variant)
#define base64_ignore " \t\r\n" /* whitespace */
#define max_message_len 512 /* to fit into an IRC message */

10
sign.c

@ -59,12 +59,10 @@ int main(int argc, char *argv[]) {
return 1;
}
unsigned char signature[crypto_sign_BYTES];
unsigned long long signature_len;
crypto_sign_detached(signature, &signature_len, message, message_len, sk);
char base64_signature[sodium_base64_ENCODED_LEN(signature_len, base64_variant)];
sodium_bin2base64(base64_signature,
sodium_base64_ENCODED_LEN(signature_len, base64_variant),
signature, signature_len, base64_variant);
crypto_sign_detached(signature, NULL, message, message_len, sk);
char base64_signature[base64_signature_len];
sodium_bin2base64(base64_signature, base64_signature_len,
signature, crypto_sign_BYTES, base64_variant);
printf("%s %s\n", base64_signature, message);
return 0;
}

Loading…
Cancel
Save