Fix random data offset bug

It seems on previous version (when using malloc instead of
gcry_malloc_secure) calling malloc(0) returns a pointer but
gcry_malloc_secure(0) returns NULL. So... only abort decryption if the
length is set and the pointer is NULL, otherwise if the length == 0,
just carry on. Also: when encrypting, force the length to be > 0.