summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2026-11-13 16:01:07 +0000
committerMark Brown <broonie@kernel.org>2026-11-13 16:01:07 +0000
commitbb02ec4537b93865cbdb343cb385f613dc27fd48 (patch)
treeaff5ef867ae0dc7283a9c91e975e6163ef42f63b /include
parenta1905b52db599318f6803f181fda5dda4086337a (diff)
parentfd29be9b992511ff68d8a9c6f8a505d801e9f775 (diff)
downloadlinux-next-bb02ec4537b93865cbdb343cb385f613dc27fd48.tar.gz
linux-next-bb02ec4537b93865cbdb343cb385f613dc27fd48.zip
Merge branch 'master' of https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
Diffstat (limited to 'include')
-rw-r--r--include/crypto/arc4.h3
-rw-r--r--include/crypto/internal/rng.h40
-rw-r--r--include/crypto/rng.h194
-rw-r--r--include/linux/crypto.h3
-rw-r--r--include/uapi/linux/cryptouser.h3
5 files changed, 14 insertions, 229 deletions
diff --git a/include/crypto/arc4.h b/include/crypto/arc4.h
index f3c22fe01704..f88a5fb85c9a 100644
--- a/include/crypto/arc4.h
+++ b/include/crypto/arc4.h
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
- * Common values for ARC4 Cipher Algorithm
+ * ARC4 Cipher Algorithm
*/
#ifndef _CRYPTO_ARC4_H
@@ -10,7 +10,6 @@
#define ARC4_MIN_KEY_SIZE 1
#define ARC4_MAX_KEY_SIZE 256
-#define ARC4_BLOCK_SIZE 1
struct arc4_ctx {
u32 S[256];
diff --git a/include/crypto/internal/rng.h b/include/crypto/internal/rng.h
deleted file mode 100644
index e0711b6a597f..000000000000
--- a/include/crypto/internal/rng.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * RNG: Random Number Generator algorithms under the crypto API
- *
- * Copyright (c) 2008 Neil Horman <nhorman@tuxdriver.com>
- * Copyright (c) 2015 Herbert Xu <herbert@gondor.apana.org.au>
- */
-
-#ifndef _CRYPTO_INTERNAL_RNG_H
-#define _CRYPTO_INTERNAL_RNG_H
-
-#include <crypto/algapi.h>
-#include <crypto/rng.h>
-
-int crypto_register_rng(struct rng_alg *alg);
-void crypto_unregister_rng(struct rng_alg *alg);
-int crypto_register_rngs(struct rng_alg *algs, int count);
-void crypto_unregister_rngs(struct rng_alg *algs, int count);
-
-#if defined(CONFIG_CRYPTO_RNG) || defined(CONFIG_CRYPTO_RNG_MODULE)
-int crypto_del_default_rng(void);
-#else
-static inline int crypto_del_default_rng(void)
-{
- return 0;
-}
-#endif
-
-static inline void *crypto_rng_ctx(struct crypto_rng *tfm)
-{
- return crypto_tfm_ctx(&tfm->base);
-}
-
-static inline void crypto_rng_set_entropy(struct crypto_rng *tfm,
- const u8 *data, unsigned int len)
-{
- crypto_rng_alg(tfm)->set_ent(tfm, data, len);
-}
-
-#endif
diff --git a/include/crypto/rng.h b/include/crypto/rng.h
index 07f494b2c881..719401225f92 100644
--- a/include/crypto/rng.h
+++ b/include/crypto/rng.h
@@ -9,71 +9,23 @@
#ifndef _CRYPTO_RNG_H
#define _CRYPTO_RNG_H
-#include <linux/atomic.h>
-#include <linux/container_of.h>
-#include <linux/crypto.h>
#include <linux/fips.h>
#include <linux/random.h>
-struct crypto_rng;
-
-/**
- * struct rng_alg - random number generator definition
- *
- * @generate: The function defined by this variable obtains a
- * random number. The random number generator transform
- * must generate the random number out of the context
- * provided with this call, plus any additional data
- * if provided to the call.
- * @seed: Seed or reseed the random number generator. With the
- * invocation of this function call, the random number
- * generator shall become ready for generation. If the
- * random number generator requires a seed for setting
- * up a new state, the seed must be provided by the
- * consumer while invoking this function. The required
- * size of the seed is defined with @seedsize .
- * @set_ent: Set entropy that would otherwise be obtained from
- * entropy source. Internal use only.
- * @seedsize: The seed size required for a random number generator
- * initialization defined with this variable. Some
- * random number generators does not require a seed
- * as the seeding is implemented internally without
- * the need of support by the consumer. In this case,
- * the seed size is set to zero.
- * @base: Common crypto API algorithm data structure.
- */
-struct rng_alg {
- int (*generate)(struct crypto_rng *tfm,
- const u8 *src, unsigned int slen,
- u8 *dst, unsigned int dlen);
- int (*seed)(struct crypto_rng *tfm, const u8 *seed, unsigned int slen);
- void (*set_ent)(struct crypto_rng *tfm, const u8 *data,
- unsigned int len);
-
- unsigned int seedsize;
-
- struct crypto_alg base;
-};
-
-struct crypto_rng {
- struct crypto_tfm base;
-};
-
-int __crypto_stdrng_get_bytes(void *buf, unsigned int len);
+int __crypto_stdrng_get_bytes(void *buf, size_t len);
/**
* crypto_stdrng_get_bytes() - get cryptographically secure random bytes
* @buf: output buffer holding the random numbers
* @len: length of the output buffer
*
- * This function fills the caller-allocated buffer with random numbers using the
- * normal Linux RNG if fips_enabled=0, or the highest-priority "stdrng"
- * algorithm in the crypto_rng subsystem if fips_enabled=1.
+ * This function fills the given buffer with random numbers using the normal
+ * Linux RNG if fips_enabled=0, or a NIST SP800-90A DRBG if fips_enabled=1.
*
* Context: May sleep
* Return: 0 function was successful; < 0 if an error occurred
*/
-static inline int crypto_stdrng_get_bytes(void *buf, unsigned int len)
+static inline int crypto_stdrng_get_bytes(void *buf, size_t len)
{
might_sleep();
if (fips_enabled)
@@ -81,139 +33,13 @@ static inline int crypto_stdrng_get_bytes(void *buf, unsigned int len)
return get_random_bytes_wait(buf, len);
}
-/**
- * DOC: Random number generator API
- *
- * The random number generator API is used with the ciphers of type
- * CRYPTO_ALG_TYPE_RNG (listed as type "rng" in /proc/crypto)
- */
-
-/**
- * crypto_alloc_rng() -- allocate RNG handle
- * @alg_name: is the cra_name / name or cra_driver_name / driver name of the
- * message digest cipher
- * @type: specifies the type of the cipher
- * @mask: specifies the mask for the cipher
- *
- * Allocate a cipher handle for a random number generator. The returned struct
- * crypto_rng is the cipher handle that is required for any subsequent
- * API invocation for that random number generator.
- *
- * For all random number generators, this call creates a new private copy of
- * the random number generator that does not share a state with other
- * instances. The only exception is the "krng" random number generator which
- * is a kernel crypto API use case for the get_random_bytes() function of the
- * /dev/random driver.
- *
- * Return: allocated cipher handle in case of success; IS_ERR() is true in case
- * of an error, PTR_ERR() returns the error code.
- */
-struct crypto_rng *crypto_alloc_rng(const char *alg_name, u32 type, u32 mask);
-
-static inline struct crypto_tfm *crypto_rng_tfm(struct crypto_rng *tfm)
-{
- return &tfm->base;
-}
-
-static inline struct rng_alg *__crypto_rng_alg(struct crypto_alg *alg)
-{
- return container_of(alg, struct rng_alg, base);
-}
-
-/**
- * crypto_rng_alg() - obtain 'struct rng_alg' pointer from RNG handle
- * @tfm: RNG handle
- *
- * Return: Pointer to 'struct rng_alg', derived from @tfm RNG handle
- */
-static inline struct rng_alg *crypto_rng_alg(struct crypto_rng *tfm)
-{
- return __crypto_rng_alg(crypto_rng_tfm(tfm)->__crt_alg);
-}
-
-/**
- * crypto_free_rng() - zeroize and free RNG handle
- * @tfm: cipher handle to be freed
- *
- * If @tfm is a NULL or error pointer, this function does nothing.
- */
-static inline void crypto_free_rng(struct crypto_rng *tfm)
-{
- crypto_destroy_tfm(tfm, crypto_rng_tfm(tfm));
-}
-
-/**
- * crypto_rng_generate() - get random number
- * @tfm: cipher handle
- * @src: Input buffer holding additional data, may be NULL
- * @slen: Length of additional data
- * @dst: output buffer holding the random numbers
- * @dlen: length of the output buffer
- *
- * This function fills the caller-allocated buffer with random
- * numbers using the random number generator referenced by the
- * cipher handle.
- *
- * Return: 0 function was successful; < 0 if an error occurred
- */
-static inline int crypto_rng_generate(struct crypto_rng *tfm,
- const u8 *src, unsigned int slen,
- u8 *dst, unsigned int dlen)
+#ifdef CONFIG_CRYPTO_FIPS
+int crypto_del_default_rng(void);
+#else
+static inline int crypto_del_default_rng(void)
{
- return crypto_rng_alg(tfm)->generate(tfm, src, slen, dst, dlen);
-}
-
-/**
- * crypto_rng_get_bytes() - get random number
- * @tfm: cipher handle
- * @rdata: output buffer holding the random numbers
- * @dlen: length of the output buffer
- *
- * This function fills the caller-allocated buffer with random numbers using the
- * random number generator referenced by the cipher handle.
- *
- * Return: 0 function was successful; < 0 if an error occurred
- */
-static inline int crypto_rng_get_bytes(struct crypto_rng *tfm,
- u8 *rdata, unsigned int dlen)
-{
- return crypto_rng_generate(tfm, NULL, 0, rdata, dlen);
-}
-
-/**
- * crypto_rng_reset() - re-initialize the RNG
- * @tfm: cipher handle
- * @seed: seed input data
- * @slen: length of the seed input data
- *
- * The reset function completely re-initializes the random number generator
- * referenced by the cipher handle by clearing the current state. The new state
- * is initialized with the caller provided seed or automatically, depending on
- * the random number generator type. (The SP800-90A DRBGs perform an automatic
- * seeding.) The seed is provided as a parameter to this function call. The
- * provided seed should have the length of the seed size defined for the random
- * number generator as defined by crypto_rng_seedsize.
- *
- * Return: 0 if the setting of the key was successful; < 0 if an error occurred
- */
-int crypto_rng_reset(struct crypto_rng *tfm, const u8 *seed,
- unsigned int slen);
-
-/**
- * crypto_rng_seedsize() - obtain seed size of RNG
- * @tfm: cipher handle
- *
- * The function returns the seed size for the random number generator
- * referenced by the cipher handle. This value may be zero if the random
- * number generator does not implement or require a reseeding. For example,
- * the SP800-90A DRBGs implement an automated reseeding after reaching a
- * pre-defined threshold.
- *
- * Return: seed size for the random number generator
- */
-static inline int crypto_rng_seedsize(struct crypto_rng *tfm)
-{
- return crypto_rng_alg(tfm)->seedsize;
+ return 0;
}
+#endif
#endif
diff --git a/include/linux/crypto.h b/include/linux/crypto.h
index b7c97f1c47c9..bfad00a1339c 100644
--- a/include/linux/crypto.h
+++ b/include/linux/crypto.h
@@ -31,7 +31,6 @@
#define CRYPTO_ALG_TYPE_KPP 0x00000008
#define CRYPTO_ALG_TYPE_ACOMPRESS 0x0000000a
#define CRYPTO_ALG_TYPE_SCOMPRESS 0x0000000b
-#define CRYPTO_ALG_TYPE_RNG 0x0000000c
#define CRYPTO_ALG_TYPE_HASH 0x0000000e
#define CRYPTO_ALG_TYPE_SHASH 0x0000000e
#define CRYPTO_ALG_TYPE_AHASH 0x0000000f
@@ -307,7 +306,7 @@ struct cipher_alg {
* @cra_type: Type of the cryptographic transformation. This is a pointer to
* struct crypto_type, which implements callbacks common for all
* transformation types. There are multiple options, such as
- * &crypto_skcipher_type, &crypto_ahash_type, &crypto_rng_type.
+ * &crypto_skcipher_type, &crypto_ahash_type.
* This field might be empty. In that case, there are no common
* callbacks. This is the case for: cipher.
* @cra_u: Callbacks implementing the transformation. This is a union of
diff --git a/include/uapi/linux/cryptouser.h b/include/uapi/linux/cryptouser.h
index db05e0419972..29f9c6c4290b 100644
--- a/include/uapi/linux/cryptouser.h
+++ b/include/uapi/linux/cryptouser.h
@@ -49,7 +49,7 @@ enum crypto_attr_type_t {
CRYPTOCFGA_REPORT_BLKCIPHER, /* struct crypto_report_blkcipher */
CRYPTOCFGA_REPORT_AEAD, /* struct crypto_report_aead */
CRYPTOCFGA_REPORT_COMPRESS, /* struct crypto_report_comp */
- CRYPTOCFGA_REPORT_RNG, /* struct crypto_report_rng */
+ CRYPTOCFGA_REPORT_RNG, /* No longer supported, do not use. */
CRYPTOCFGA_REPORT_CIPHER, /* struct crypto_report_cipher */
CRYPTOCFGA_REPORT_AKCIPHER, /* struct crypto_report_akcipher */
CRYPTOCFGA_REPORT_KPP, /* struct crypto_report_kpp */
@@ -191,6 +191,7 @@ struct crypto_report_comp {
char type[CRYPTO_MAX_NAME];
};
+/* No longer supported, do not use. */
struct crypto_report_rng {
char type[CRYPTO_MAX_NAME];
unsigned int seedsize;