[gnutls-help] GnuTLS on ARMv7 and HardFP
Nikos Mavrogiannopoulos
n.mavrogiannopoulos at gmail.com
Fri Jun 9 08:40:35 CEST 2017
On Thu, Jun 8, 2017 at 4:16 PM, Mandar Joshi <emailmandar at gmail.com> wrote:
> On Sun, May 28, 2017 at 4:43 PM, Nikos Mavrogiannopoulos
> <n.mavrogiannopoulos at gmail.com> wrote:
>> Could you catch this fpe using gdb and send if along with the contents of
>> /proc/cpuinfo?
>>
> Here's the code again. Seems like it was scrubbed from the archives
>
> --------------------------
> #include <glib.h>
> #include <string.h>
> #include <gnutls/gnutls.h>
> #include <gnutls/crypto.h>
> int main (int argc, char *argv[]) {
> gchar *input = argv[1];
> gchar encrypted[1024];
> memset (encrypted, 0, 1024);
> gsize size;
> gnutls_cipher_hd_t handle;
> gnutls_datum_t key;
> gsize length;
> key.data = "abcdabcdabcdabcdabcdabcdabcdabcd";
> key.size = 32;
> g_message ("Init: %d", gnutls_cipher_init (&handle,
> GNUTLS_CIPHER_AES_256_CBC, &key, NULL));
> g_message ("Encrypt: %d", gnutls_cipher_encrypt2 (handle, (void *)
> input, strlen(input), encrypted, strlen(input)));
> g_message ("%s", g_base64_encode (encrypted, strlen(input)));
> return 0;
> }
I see that you are using strlen() on the input data. CBC mode is a
block mode, which means you cannot encrypt data of arbitrary size. Any
data you encrypt must be a multiple of the block size. I'd recommend
to switch to the authenticated encryption API and use that, due to its
simplicity.
regards,
Nikos
More information about the Gnutls-help
mailing list