Hello,

I'm seeing a different behavior between two architectures when using gnutls_cipher_init with incorrect key size.

If I use gnutls_cipher_init with the gnutls_cipher_algorithm_t GNUTLS_CIPHER_AES_128_GCM and a key of 24 bits, I have a different result value if I execute the same code on an AMD64 or an ARMV7 architecture.

On a AMD64 CPU, using the attached sample program, I have the following output: $ gcc -o gnutls-cipher-init gnutls-cipher-init.c -lgnutls && ./gnutls-cipher-init
gnutls_cipher_init OK

On an ARMV7 CPU (Odroid C2 or Raspberry Pi), gnutls_cipher_init returns an error: $ gcc -o gnutls-cipher-init gnutls-cipher-init.c -lgnutls && ./gnutls-cipher-init
gnutls_cipher_init Error: The request is invalid.

Is it a bug? If so, which architecture has the correct answer?

/Nicolas
#include <stdio.h>
#include <gnutls/gnutls.h>
#include <gnutls/crypto.h>
#include <gnutls/abstract.h>
#include <gnutls/x509.h>

int main(void) {
  gnutls_datum_t key, iv;
  gnutls_cipher_hd_t handle = NULL;
  unsigned char key_data[] = {0xcb, 0xfc, 0x7c, 0x78, 0x15, 0x27, 0x99, 0xaf, 0xc8, 0x82, 0xa1, 0x44, 0xa2, 0xb2, 0x1a, 0x27, 0x00, 0xac, 0x09, 0xd9, 0xe1, 0x43, 0x1d, 0x59},
                iv_data[] = {0x74, 0x98, 0x05, 0x8f, 0xf1, 0x02, 0x03, 0x17, 0x33, 0x49, 0x70, 0x78};
  int res;
  
  key.data = key_data;
  key.size = sizeof(key_data);
  iv.data = iv_data;
  iv.size = sizeof(iv_data);
  
  res = gnutls_cipher_init(&handle, GNUTLS_CIPHER_AES_128_GCM, &key, &iv);
  
  if (res < 0) {
    printf("gnutls_cipher_init Error: %s\n", gnutls_strerror(res));
  } else {
    printf("gnutls_cipher_init OK\n");
  }
}
_______________________________________________
Gnutls-help mailing list
Gnutls-help@lists.gnutls.org
http://lists.gnupg.org/mailman/listinfo/gnutls-help

Reply via email to