Check if requested hash is supported before writing LUKS header.
[platform/upstream/cryptsetup.git] / tests / api-test.c
index a888090..3063dce 100644 (file)
@@ -293,7 +293,7 @@ static void LuksOpen(void)
 
 static void query_device(void)
 {
-       struct crypt_options co = {. icb = &cmd_icb };
+       struct crypt_options co = {.icb = &cmd_icb };
 
        co.name = CDEVICE_WRONG;
        EQ_(crypt_query_device(&co), 0);
@@ -313,7 +313,7 @@ static void query_device(void)
 static void remove_device(void)
 {
        int fd;
-       struct crypt_options co = {. icb = &cmd_icb };
+       struct crypt_options co = {.icb = &cmd_icb };
 
        co.name = CDEVICE_WRONG;
        EQ_(crypt_remove_device(&co), -ENODEV);
@@ -761,6 +761,10 @@ static void NonFIPSAlg(void)
        }
        OK_(crypt_init(&cd, DEVICE_2));
        OK_(crypt_format(cd, CRYPT_LUKS1, cipher, cipher_mode, NULL, key, key_size, &params));
+
+       params.hash = "md5";
+       FAIL_(crypt_format(cd, CRYPT_LUKS1, cipher, cipher_mode, NULL, key, key_size, &params),
+             "MD5 unsupported, too short");
        crypt_free(cd);
 }