#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include <fcntl.h>
#include <linux/fs.h>
#include <errno.h>
#include <sys/stat.h>
+#include <sys/ioctl.h>
#include "libcryptsetup.h"
}
// Decode key from its hex representation
-static int crypt_decode_key(unsigned char *key, const char *hex, unsigned int size)
+static int crypt_decode_key(char *key, char *hex, unsigned int size)
{
char buffer[3];
char *endp;
.offset = 0,
};
int fd;
- unsigned char key[128], key2[128], path[128];
+ char key[128], key2[128], path[128];
char *passphrase = "blabla";
char *mk_hex = "bb21158c733229347bd4e681891e213d94c685be6a5b84818afe7a78a6de7a1a";
struct crypt_device *cd;
char key[128];
size_t key_size;
- int fd;
OK_(crypt_init(&cd, DEVICE_1));
OK_(crypt_load(cd, CRYPT_LUKS1, NULL));
static void SuspendDevice(void)
{
struct crypt_device *cd;
- char key[128];
- size_t key_size;
- int fd;
OK_(crypt_init(&cd, DEVICE_1));
OK_(crypt_load(cd, CRYPT_LUKS1, NULL));
.hash = "sha512",
.data_alignment = 2048, // 4M, data offset will be 4096
};
- int fd;
- unsigned char key[128], key2[128], path[128];
+ char key[128], key2[128];
char *passphrase = "blabla";
char *mk_hex = "bb21158c733229347bd4e681891e213d94c685be6a5b84818afe7a78a6de7a1a";
crypt_free(cd);
}
+// Check that gcrypt is properly initialised in format
+static void NonFIPSAlg(void)
+{
+ struct crypt_device *cd;
+ struct crypt_params_luks1 params = {
+ .hash = "whirlpool",
+ };
+ char key[128] = "";
+ size_t key_size = 128;
+ char *cipher = "aes";
+ char *cipher_mode = "cbc-essiv:sha256";
+
+ OK_(crypt_init(&cd, DEVICE_2));
+ OK_(crypt_format(cd, CRYPT_LUKS1, cipher, cipher_mode, NULL, key, key_size, ¶ms));
+ crypt_free(cd);
+}
+
int main (int argc, char *argv[])
{
int i;
crypt_set_debug_level(_debug ? CRYPT_DEBUG_ALL : CRYPT_DEBUG_NONE);
+ RUN_(NonFIPSAlg, "Crypto is properly initialised in format"); //must be the first!
RUN_(LuksUUID, "luksUUID API call");
RUN_(IsLuks, "isLuks API call");
RUN_(LuksOpen, "luksOpen API call");