/*
* Nettle crypto backend implementation
*
- * Copyright (C) 2011-2020 Red Hat, Inc. All rights reserved.
- * Copyright (C) 2011-2020 Milan Broz
+ * Copyright (C) 2011-2023 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2011-2023 Milan Broz
*
* This file is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#include <nettle/sha3.h>
#include <nettle/hmac.h>
#include <nettle/pbkdf2.h>
+#include <nettle/memops.h>
#include "crypto_backend_internal.h"
#if HAVE_NETTLE_VERSION_H
return NULL;
}
-int crypt_backend_init(void)
+int crypt_backend_init(bool fips __attribute__((unused)))
{
return 0;
}
h->hash = _get_alg(name);
- if (!h->hash)
- goto bad;
+ if (!h->hash) {
+ free(h);
+ return -EINVAL;
+ }
h->key = malloc(key_length);
- if (!h->key)
- goto bad;
+ if (!h->key) {
+ free(h);
+ return -ENOMEM;
+ }
memcpy(h->key, key, key_length);
h->key_length = key_length;
*ctx = h;
return 0;
-bad:
- free(h);
- return -EINVAL;
}
static void crypt_hmac_restart(struct crypt_hmac *ctx)
}
/* RNG - N/A */
-int crypt_backend_rng(char *buffer, size_t length, int quality, int fips)
+int crypt_backend_rng(char *buffer __attribute__((unused)),
+ size_t length __attribute__((unused)),
+ int quality __attribute__((unused)),
+ int fips __attribute__((unused)))
{
return -EINVAL;
}
return crypt_cipher_decrypt_kernel(&ctx->ck, in, out, length, iv, iv_length);
}
-bool crypt_cipher_kernel_only(struct crypt_cipher *ctx)
+bool crypt_cipher_kernel_only(struct crypt_cipher *ctx __attribute__((unused)))
{
return true;
}
return crypt_bitlk_decrypt_key_kernel(key, key_length, in, out, length,
iv, iv_length, tag, tag_length);
}
+
+int crypt_backend_memeq(const void *m1, const void *m2, size_t n)
+{
+ /* The logic is inverse to memcmp... */
+ return !memeql_sec(m1, m2, n);
+}
+
+bool crypt_fips_mode(void)
+{
+ return false;
+}