[gnutls-devel] Guile-GnuTLS | aead.scm fails on Mac OS (#13)

Read-only notification of GnuTLS library development activities gnutls-devel at lists.gnutls.org
Tue Jul 18 20:33:20 CEST 2023




Vivien Kraus Would Rather Not Be On Gitlab_com commented on a discussion: https://gitlab.com/gnutls/guile/-/issues/13#note_1475344062

I’m not sure how it works, I tried to concatenate the "digest" with the "encrypt" result (after an "update") but it does not give the correct result. I must be missing something. I guess the nonce value should not be used as an initialization vector…

```c
#include <nettle/gcm.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

int
main ()
{
  static const char *key = "the secret key is 32 bytes long.";
  static const char *auth = "Additional secret data";
  static const char *nonce = "Never encrypt more data with this nonce";
  static const char *data = "Confidential data.";
  struct gcm_aes256_ctx context;
  gcm_aes256_set_key (&context, key);
  gcm_aes256_set_iv (&context, strlen (nonce), nonce);
  static const size_t tag_size = 16;
  size_t used_size = tag_size + strlen (data);
  char output[used_size];
  gcm_aes256_update (&context, strlen (auth), auth);
  gcm_aes256_encrypt (&context, strlen (data), & (output[tag_size]), data);
  gcm_aes256_digest (&context, tag_size, output);
  for (int i= 0; i < used_size; i++)
    fprintf (stderr, "%x ", 0xFF & output[i]);
  if (output[0] != (char) 165)
    {
      return EXIT_FAILURE;
    }
  fprintf (stderr, "OK\n");
  return EXIT_SUCCESS;
}
```

-- 
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/guile/-/issues/13#note_1475344062
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20230718/3d6dada0/attachment-0001.html>


More information about the Gnutls-devel mailing list