public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto
@ 2026-02-12  2:45 Jay Wang
  2026-02-12  2:45 ` [PATCH 001/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO and CONFIG_CRYPTO_ALGAPI2 crypto Jay Wang
                   ` (105 more replies)
  0 siblings, 106 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:45 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

This patch series is a follow up of Series 1/4:
https://lore.kernel.org/all/20260212024228.6267-1-wanjay@amazon.com/

This feature is organized into four patch series for submission to the mainline (up to the "Merge tag 'landlock-7.0-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/mic/linux"):
- Patch Series 1/4: "[PATCH v1 0...17] crypto: Standalone crypto module (Series 1/4): Core implementation"
- Patch Series 2/4: "[PATCH v1 0...106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto"
- Patch Series 3/4: "[PATCH v1 0...21] crypto: Standalone crypto module (Series 3/4): x86_64 crypto"
- Patch Series 4/4: "[PATCH v1 0...12] crypto: Standalone crypto module (Series 4/4): arm64 crypto"

The full source code is available at https://github.com/amazonlinux/linux/tree/fips-kernel-module.
Details on this feature and what each patch series covers can be found below.

## 1. Introduction

Amazon Linux is releasing a new kernel feature that converts the previously built-in kernel crypto subsystem into a standalone kernel module. This module becomes the carrier of the kernel crypto subsystem and can be loaded at early boot to provide the same functionality as the original built-in crypto. The primary motivation for this modularization is to streamline Federal Information Processing Standards (FIPS) validation, a critical cryptographic certification for cloud computing users doing business with the U.S. government.
 
In a bit more detail, previously, FIPS certification was tied to the entire kernel image, meaning non-crypto updates could potentially invalidate certification. With this feature, FIPS certification is tied only to the crypto module. Therefore, once the module is certified, loading this certified module on newer kernels automatically makes those kernels FIPS-certified. As a result, this approach can save re-certification costs and 12-18 months of waiting time by reducing the need for repeated FIPS re-certification cycles.

This feature is organized into four patch series:
- Patch Series 1 - Core feature implementation
- Patch Series 2 - Architecture-independent crypto: Modularize built-in crypto under `crypto/`
- Patch Series 3 - x86_64 crypto: Modularize built-in crypto under `arch/x86/crypto/`
- Patch Series 4 - arm64 crypto: Modularize built-in crypto under `arch/arm64/crypto/`

This document provides technical details on how this feature is designed and implemented for users or developers who are interested in developing upon it, and is organized as follows:
- Section 2 - Getting Started: Quick start on how to enable the feature
- Section 3 - Workflow Overview: Changes this feature brings to build and runtime
- Section 4 - Design Implementation Details: Technical deep-dive into each component
- Section 5 - Customizing and Extending Crypto Module: How to select crypto to be included and extend to new crypto/architectures
- Section 6 - Related Work and Comparison
- Section 7 - Summary

## 2. Getting Started

This section provides a quick start guide for developers on how to enable, compile and use the standalone cryptography module feature.

### 2.1 Basic Configuration

The feature is controlled by a single configuration option:
```
CONFIG_CRYPTO_FIPS140_EXTMOD=y
```
What it does: When enabled, automatically redirects a set of cryptographic algorithms from the main kernel into a standalone module `crypto/fips140/fips140.ko`. The cryptographic algorithms that are redirected need to satisfy all the following conditions, otherwise the cryptography will remain in its original form:
1. Must be configured as built-in (i.e., `CONFIG_CRYPTO_*=y`). This means cryptography already configured as modular (i.e., `CONFIG_CRYPTO_*=m`) are not redirected as they are already modularized.
2. Must be among a list, which can be customized by developers as described in Section 5.

When disabled, the kernel behaves as before.

### 2.2 Build Process

Once `CONFIG_CRYPTO_FIPS140_EXTMOD=y` is set, no additional steps are required. The standalone module will be built automatically as part of the standard kernel build process:
```
make -j$(nproc)
# or
make vmlinux
```
**What happens automatically (No user action required):**
1. Build the module as `crypto/fips140/fips140.ko`
2. The cryptography module will be loaded at boot time
3. All kernel cryptographic services will provide the same functionality as before (i.e., prior to introducing this new feature) once boot completes.

### 2.3 Advanced Configuration Options

**Using External Cryptography Module:**
```
CONFIG_CRYPTO_FIPS140_EXTMOD_SOURCE=y
```
By default, `CONFIG_CRYPTO_FIPS140_EXTMOD_SOURCE` is not set, meaning the freshly built cryptography module is used. Otherwise, the pre-built standalone cryptography module from `fips140_build/crypto/fips140/fips140.ko` and modular cryptography such as `fips140_build/crypto/aes.ko` (need to manually place pre-built modules in these locations before the build) are included in kernel packaging (e.g., during `make modules_install`) and are used at later boot time.

**Dual Version Support:**
```
CONFIG_CRYPTO_FIPS140_DUAL_VERSION=y
```
Encapsulate two versions of `fips140.ko` into kernel: one is freshly built for non-FIPS mode usage, another is pre-built specified by `fips140_build/crypto/fips140/fips140.ko` for FIPS mode usage. The appropriate version is selected and loaded at boot time based on boot time FIPS mode status.

### 2.4 Verification

To verify the feature is working, after install and boot with the new kernel:
```
# Check if fips140.ko module is loaded
lsmod | grep fips140
```

## 3. Workflow Overview

This section provides an overview without delving into deep technical details of the changes the standalone cryptography module feature introduces. When this feature is enabled, it introduces changes to both the kernel build and booting process. 

3.1 Build-Time Changes

Kernel cryptography subsystem consists of both cryptography management infrastructure (e.g., `crypto/api.c`, `crypto/algapi.c`, etc), along with hundreds of different cryptography algorithms (e.g., `crypto/arc4.c`).

**Traditional Build Process:**
Traditionally, cryptography management infrastructure are always built-in to the kernel, while cryptographic algorithms can be configured to be built either as built-in (`CONFIG_CRYPTO_*=y`) or as separate modular (`CONFIG_CRYPTO_*=m`) `.ko` file depending on kernel configuration:
As a result, the builtin cryptography management infrastructure and cryptographic algorithms are statically linked into the kernel binary:
```
cryptographic algorithms source files → compiled as .o objfiles →  linked into vmlinux → single kernel binary
```
**With Standalone Cryptography Module:**
This feature automatically transforms the builtin cryptographic components into a standalone cryptography module, `fips140.ko`. To do so, it develops a new kernel build rule `crypto-objs-$(CONFIG_CRYPTO_*)` such that, once this build rule is applied to a cryptographic algorithm, such cryptographic algorithm will be automatically collected into the cryptography module if it is configured as built-in (i.e, `CONFIG_CRYPTO_*=y`), for example:
```
// in crypto/asymmetric_keys/Makefile
- obj-$(CONFIG_ASYMMETRIC_KEY_TYPE) += asymmetric_keys.o
+ crypto-objs-$(CONFIG_ASYMMETRIC_KEY_TYPE) += asymmetric_keys.o
```
Such build change allows the modularization transformation to only affect selected cryptographic algorithms (i.e, where the `crypto-objs-$(CONFIG_CRYPTO_*`) is applied).

Then, after the `fips140.ko` is generated, it will be embedded back into main kernel vmlinux as a replacement part. The purpose of this embedding, instead of traditionally putting the `fips140.ko` into filesystem, is a preparation to allow the module to be loaded early enough even before the filesystem is ready.

The new build process is illustrated below.
```
cryptographic algorithms source files → compiled as .o objfiles → automatically collected and linked into fips140.ko → embedded fips140.ko into vmlinux as a replaceable binary
```

### 3.2 Runtime Changes

**Traditional Boot Process:**
The kernel initializes the cryptographic subsystem early during boot, executing each cryptographic initialization routine accordingly. These initialization routines may depend on other cryptographic components or other kernel subsystems, so their invocation follows a well-defined execution order to ensure they are initialized before their first use.
```
kernel starts → cryptography subsystem initialization → cryptography subsystem available → other components use cryptography
```
**With Standalone Cryptography Module:**
At the start of kernel boot, compared to a regular kernel, the first major change introduced by this feature is that no cryptography services are initially available — since the entire cryptography subsystem has been decoupled from the main kernel.
To ensure that the cryptography subsystem becomes available early enough (before the first kernel component that requires cryptography services), the standalone cryptography kernel module must be loaded at a very early stage, even before the filesystem becomes available.

However, the regular module loading mechanism relies on placing kernel modules in the filesystem and loading them from there, which creates a chicken-and-egg problem — the cryptography module cannot be loaded until the filesystem is ready, yet some kernel components may require cryptography services even before that point.

To address this, the second change introduced by this feature is that the cryptography kernel module is loaded directly from memory, leveraging the earlier compilation changes that embed the module binary into the main kernel image. Afterward, the feature includes a “plug-in” mechanism that connects the decoupled cryptography subsystem back to the main kernel, ensuring that kernel cryptography users can correctly locate and invoke the cryptography routine entry points.

Finally, to ensure proper initialization, the feature guarantees that all cryptography algorithms and the cryptography management infra execute their initialization routines in the exact same order as they would if they were built-in.

The process described above is illustrated below.
```
kernel starts → no cryptography available → load fips140.ko from memory → plug cryptography back to kernel → module initialization → cryptographic services available → other components use cryptography
```

## 4. Design Implementation Details

While the earlier sections provide a holistic view of how this feature shapes the kernel, this section provides deeper design details on how these functionalities are realized. There are three key design components:
1. A specialized compile rule that automatically compiles and collects all built-in cryptographic algorithm object files to generate the final module binary under arbitrary kernel configurations, and then embeds the generated binary into the main kernel image for early loading.
2. A mechanism to convert interactions between the cryptography subsystem and the main kernel into a pluggable interface.
3. A module loading and initialization process that ensures the cryptography subsystem is properly initialized as if it were built-in.

### 4.1. Specialized Compilation System

**Automatic Collection and Linking of Built-in Cryptographic Algorithm Objects:**
The first step in generating the `fips140.ko` module is to compile and collect built-in cryptographic components (i.e., those specified by `CONFIG_CRYPTO_*=y`).
Traditionally, the existing module build process requires all module components (e.g., source files) to reside in a single directory. However, this approach is not suitable for our case, where hundreds of cryptographic algorithm source files are scattered across multiple directories.

A naïve approach would be to create a separate Makefile that duplicates the original build rules with adjusted paths.
However, this method is not scalable due to the large number of cryptographic build rules, many of which are highly customized and can vary under different Kconfig settings, making such a separate Makefile even more complex.
Moreover, this approach cannot ensure that built-in cryptographic algorithms are completely removed from the main kernel, which would result in redundant cryptographic code being included in both the kernel and the module.

To tackle this challenge, we automated the object collection and linking process by introducing special build logic for the kernel cryptography subsystem.
Specifically, to automatically collect cryptography object files while preserving their original compilation settings (such as flags, headers, and paths), we introduced a new compilation rule:
```
crypto-objs-y += *.o
```
This replaces the original `obj-y += *.o` rule in cryptography Makefiles later, for example:
```
// in crypto/asymmetric_keys/Makefile
- obj-$(CONFIG_ASYMMETRIC_KEY_TYPE) += asymmetric_keys.o
+ crypto-objs-$(CONFIG_ASYMMETRIC_KEY_TYPE) += asymmetric_keys.o
asymmetric_keys-y := \    asymmetric_type.o \    restrict.o \    signature.o
```
in the cryptography subsystem Makefiles, allowing most of the existing Makefile logic to be reused.
As a result, when the standalone cryptography module feature is enabled, any cryptographic algorithm configured as built-in (for example, `crypto-objs-$(CONFIG_ASYMMETRIC_KEY_TYPE) += asymmetric_keys.o` where `CONFIG_ASYMMETRIC_KEY_TYPE=y`) will be automatically collected and linked into a single final object binary, `fips140.o`.
During this process, a special compilation flag (`-DFIPS_MODULE=1`) is applied to instruct each object file to be compiled in a module-specific manner. This flag will later be used to generate the pluggable interface on both the main kernel side and the module side from the same source code.

The implementation details are as follows: it follows a similar methodology used by the `obj-y` collection process for building `vmlinux.o`. The `crypto-objs-y` rule is placed in `scripts/Makefile.build`, which is executed by each directory Makefile to collect the corresponding crypto object files. Each directory then creates a `crypto-module.a` archive that contains all `crypto-objs-y += <object>.o` files under that directory. In the parent directories, these `crypto-module.a` archives are recursively included into the parent’s own `crypto-module.a`, and this process continues upward until the final `fips140.o` is generated.

**A Separate Module Generation Pipeline for Building the Final Kernel Module from Linked Cryptographic Algorithm Object:**
With the linked cryptographic algorithm object (i.e., `fips140.o`), the next step is to generate the final kernel module, `fips140.ko`.

A direct approach would be to inject the `fips140.ko` module build into the existing modules generation pipeline (i.e., `make modules`) by providing our pre-generated `fips140.o`. However, we choose not to do this because it would create a circular make rule dependency (which is invalid in Makefiles and causes build failures), resulting in mutual dependencies between the modules and vmlinux targets (i.e., `modules:vmlinux` and `vmlinux:modules` at the same time).
This happens for the following reasons:
1. Since we will later embed `fips140.ko` into the final kernel image (as described in the next section), we must make vmlinux depend on `fips140.ko`. In other words: `vmlinux: fips140.ko`.
2. When the kernel is built with `CONFIG_DEBUG_INFO_BTF_MODULES=y`, it requires: modules: vmlinux. This is because `CONFIG_DEBUG_INFO_BTF_MODULES=y` takes vmlinux as input to generate BTF info for the module, and inserts such info into the `.ko` module by default.
3. If we choose to inject `fips140.ko` into make modules, this would create a make rule dependency: `fips140.ko: modules`. Combined with items 1 and 2, this eventually creates an invalid circular dependency between vmlinux and modules.

Due to these reasons, the design choice is to use a separate make pipeline (defined as `fips140-ready` in the Makefile). This new pipeline reuses the same module generation scripts used by make modules but adds additional logic in `scripts/Makefile.{modfinal|modinst|modpost}` and `scripts/mod/modpost.c` to handle module symbol generation and verification correctly. 

**A Seamless Process That Embeds the Generated Binary Into the Main Kernel Image for Early Loading:**
As mentioned earlier, in order to load the standalone cryptography module early in the boot process—before the filesystem is ready—the module binary must be embedded into the final kernel image (i.e., vmlinux) so that it can be loaded directly from memory.
We intend for this embedding process to be completely seamless and automatically triggered whenever vmlinux is built (i.e., during `make vmlinux`).

To achieve this, the feature adds a Make dependency rule so that vmlinux depends on `fips140.ko`.
It also modifies the vmlinux link rules (i.e., `arch/<arch>/kernel/vmlinux.lds.S`, `scripts/Makefile.vmlinux`, and `scripts/link-vmlinux.sh`) so that the generated module binary is finally combined with `vmlinux.o`.

In addition, we allow multiple cryptography module binary versions (for example, a certified cryptography binary and a latest, up-to-date but uncertified one) to be embedded into the main kernel image to serve different user needs. This design allows regular (non-FIPS) users to benefit from the latest cryptographic updates, while FIPS-mode users continue to use the certified cryptography module.

To support this, we introduce an optional configuration, `CONFIG_CRYPTO_FIPS140_DUAL_VERSION`. When enabled, this option allows two cryptography module versions to be embedded within a single kernel build and ensures that the appropriate module is selected and loaded at boot time based on the system’s FIPS mode status.

### 4.2. Pluggable Interface Between the Built-in Cryptography Subsystem and the Main Kernel

Although the module binary (`fips140.ko`) has been embedded into the final kernel image (`vmlinux`) as described in the previous section, it is not linked to the kernel in any way. This is because `fips140.ko` is embedded in a data-only manner, so the main kernel cannot directly call any functions or access any data defined in the module binary.

Even worse, simply removing the built-in cryptographic algorithms without additional handling would cause the kernel to fail to compile, because traditionally, built-in cryptographic algorithms and the main kernel can interact only through functions and variables whose addresses they assume to know. As a result, even if they have been removed, kernel cryptography users still expect the symbol addresses of cryptographic routines and data to be available at compile time.

To address this, we introduce a pluggable interface between built-in cryptographic functions and variables by placing **address placeholders**. During runtime, once the cryptography kernel module is loaded, these placeholders are updated to the correct addresses. In the rest of this section, we first introduce this pluggable interface mechanism, and then explain how to apply it to the built-in cryptographic algorithms.

**The Pluggable Interface Mechanism:**
There are two types of address holders used to achieve this pluggable interface:
- Function addresses:  We use the “static call” mechanism. Static calls are a Linux mechanism that converts an “indirect call” into something with performance equivalent to a “direct call,” while avoiding the introduction of additional security concerns, such as control-flow–hijacking attack gadgets. We implement this function-address placeholder as the `DECLARE_STATIC_CALL()` and `DEFINE_CRYPTO_API_STUB()` wrappers.
- Variable addresses (the remaining smaller portion): For these, we use a pointer of the corresponding data type. We implement this address placeholder as the `DECLARE_CRYPTO_VAR()` and `DEFINE_CRYPTO_API_STUB()` wrappers:

These wrappers are applied to each symbol-exported (i.e., `EXPORT_SYMBOL()`) cryptographic function and variable (details on how to apply them are described later). Once applied, the wrappers are compiled differently for the main kernel and for the built-in cryptographic algorithm source code—acting as the “outlet” and the “plug,” respectively—using different compilation flags (`-DFIPS_MODULE`) introduced by our customized build rules described earlier.

As a result, the kernel can successfully compile even when the built-in cryptographic algorithms are removed, thanks to these address placeholders. At boot time, the placeholders initially hold NULL, but since no cryptography users exist at that stage, the kernel can still start booting correctly. After the cryptography module is loaded, the placeholders are dynamically updated to the correct addresses later (by `do_crypto_api()` and `do_crypto_var()`, described in later section).

In addition to these address placeholders, there is another important interaction point between the cryptography subsystem and the main kernel—the cryptographic initialization routines. Therefore, we also add a mechanism to collect all cryptographic initialization functions (e.g., those defined using `module_init()`) into a dedicated ELF section. This serves as preparation for the later module and cryptography-subsystem initialization steps described in subsequent sections.

**Applying the Pluggable Interface Mechanism to Cryptographic Algorithms:**

To apply these pluggable interface wrappers to a cryptographic algorithm and make them take effect, we follow the steps below (using `crypto/asymmetric_keys/asymmetric_type.c` as an example):
1. **Apply `crypto-objs-y` compile rule to the cryptographic algorithm:**
```
// in crypto/asymmetric_keys/Makefile
- obj-$(CONFIG_ASYMMETRIC_KEY_TYPE) += asymmetric_keys.o
+ crypto-objs-$(CONFIG_ASYMMETRIC_KEY_TYPE) += asymmetric_keys.o
asymmetric_keys-y := \    asymmetric_type.o \    restrict.o \    signature.o
```
2. **Locate the communication point between the cryptographic algorithm and the main kernel:**

The cryptography subsystem is designed such that most interactions between the main kernel and cryptographic algorithms occur through exported symbols using `EXPORT_SYMBOL()` wrappers.
This kernel design exists because most cryptographic algorithm implementations must support both built-in and modular modes. 

Consequently, the cryptographic functions and variables exported by `EXPORT_SYMBOL()` are a well-defined and identifiable interface between the cryptography subsystem and the main kernel: 
```
// in crypto/asymmetric_keys/asymmetric_type.c 
//Exported cryptographic function:
bool asymmetric_key_id_same(const struct asymmetric_key_id *kid1,
                const struct asymmetric_key_id *kid2) {...}
EXPORT_SYMBOL_GPL(asymmetric_key_id_same); 
//Exported cryptographic variable:
struct key_type key_type_asymmetric = {...};
EXPORT_SYMBOL_GPL(key_type_asymmetric); 
```
3. **Replace their declarations in the header file with the address-placeholder declaration wrappers:**
```
// in include/keys/asymmetric-type.h
// for exported cryptographic function:
- bool asymmetric_key_id_same const struct asymmetric_key_id *kid1, const struct asymmetric_key_id *kid2);
+ DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, asymmetric_key_id_same, bool,
    (const struct asymmetric_key_id *kid1, const struct asymmetric_key_id *kid2),
    (kid1, kid2)); 
// for exported cryptographic variables:
- struct key_type key_type_asymmetric;
+ DECLARE_CRYPTO_VAR(CONFIG_ASYMMETRIC_KEY_TYPE, key_type_asymmetric, struct key_type, );
+ #if defined(CONFIG_CRYPTO_FIPS140_EXTMOD) && !defined(FIPS_MODULE) && IS_BUILTIN(CONFIG_ASYMMETRIC_KEY_TYPE)
+ #define key_type_asymmetric (*((struct key_type*)CRYPTO_VAR_NAME(key_type_asymmetric)))
+ #endif 
```
By replacing the original declarations with the address-placeholder declaration wrappers, we can automatically force all cryptography users to go through the placeholders, because those users already include the same header file.
The wrapper also takes the cryptographic algorithm Kconfig symbol as a parameter, so that when a cryptographic algorithm is built as a module (for example, `CONFIG_ASYMMETRIC_KEY_TYPE=m`), the original function declarations remain unchanged and are not affected.

4. **Add the address-placeholder definition wrappers into a dedicated file `fips140-api.c`:**

This file will be compiled separately and acts as both the “outlet” and the “plug” for the main kernel and the cryptography module, respectively:
```
// in crypto/fips140/fips140-api.c
+ #if IS_BUILTIN(CONFIG_ASYMMETRIC_KEY_TYPE)
+ #include <keys/asymmetric-type.h>
// for exported cryptographic function:
+ DEFINE_CRYPTO_API_STUB(asymmetric_key_id_same);
// for exported cryptographic variables:
+ #undef key_type_asymmetric
+ DEFINE_CRYPTO_VAR_STUB(key_type_asymmetric);
+ #endif
```

5. **Lastly, collect the cryptographic initialization routines for later module and cryptography-subsystem initialization by wrapping the original cryptographic initialization functions:**
```
// in crypto/asymmetric_keys/asymmetric_type.c 
- module_init(asymmetric_key_init);
- module_exit(asymmetric_key_cleanup); 
+ crypto_module_init(asymmetric_key_init);
+ crypto_module_exit(asymmetric_key_cleanup); 
```
We apply the above steps to both architecture-independent and architecture-specific cryptographic algorithms.

### 4.3. Initialization Synchronization

To ensure the embedded `fips140.ko` module binary provides the same cryptography functionality as the regular kernel, the kernel needs:
1. A module loader to load the module binary directly from memory,
2. A mechanism to plug the module back into the kernel by updating the address placeholders, and
3. Correct cryptography subsystem initialization, as if the cryptographic algorithms were still built-in.

**Directly Load Module Binary from Memory:**
Regular modules are loaded from the filesystem and undergo signature verification on the module binary, which relies on cryptographic operations. However, since we have already fully decoupled the cryptography subsystem, we must skip this step for this `fips140.ko` module.
To achieve this, we add a new loader function `load_crypto_module_mem()` that can load the module binary directly from memory at the designed address without checking the signature. Since the module binary is embedded into main kernel in an ELF section, as specified in the linker script:
```
// in arch/<arch>/kernel/vmlinux.lds.S
    .fips140_embedded : AT(ADDR(.fips140_embedded) - LOAD_OFFSET) {
        . = ALIGN(8);
        _binary_fips140_ko_start = .;
        KEEP(*(.fips140_module_data))
        _binary_fips140_ko_end = .;
    }
```
Therefore, the runtime memory address of the module can be accessed directly by the module loader to invoke the new loader function `load_crypto_module_mem()`.

**Plug Back the Module by Updating Address Placeholder Values:**
To update the address placeholders in the main kernel to the correct addresses matching the loaded module, after compilation the placeholders are placed into dedicated ELF sections `_crypto_api_keys` and `_crypto_var_keys`.
This can be seen from the definition of the placeholder-declaration wrappers:
```
#define DEFINE_CRYPTO_API_STUB(name) \    static struct crypto_api_key __##name##_key \        __used \        __section("__crypto_api_keys")  // Place in a dedicated ELF Section
        __aligned(__alignof__(struct crypto_api_key)) = \    { \        .key = &STATIC_CALL_KEY(crypto_##name##_key), \        .tramp = STATIC_CALL_TRAMP_ADDR(crypto_##name##_key), \        .func = &name, \    };

#define DEFINE_CRYPTO_VAR_STUB(name) \    static struct crypto_var_key __crypto_##name##_var_key \        __used \        __section("__crypto_var_keys")  // Place in a dedicated ELF Section
        __aligned(__alignof__(struct crypto_var_key)) = \    { \        .ptr = &CRYPTO_VAR_NAME(name), \        .var = (void*)&name, \    };
```
The purpose of doing this is to allow the main kernel to quickly locate the placeholders and update them to the correct addresses. The update functions are defined as `do_crypto_var()` and `do_crypto_api()`, which are executed at module load.

As a result, all cryptography users in the main kernel can now call the cryptographic functions as if they were built-in.

**Initialize Cryptography Subsystem as if it Were Built-in:**
Cryptographic components must be properly initialized before use, and this initialization is typically achieved through dedicated initialization functions (e.g., `module_init(crypto_init_func)` or `late_initcall(crypto_init_func)`). These functions often have strict execution order requirements and must run during the appropriate boot phase.

Therefore, for our standalone cryptography module feature, we must ensure that these decoupled “built-in” cryptographic algorithms are properly initialized and that their initialization order is preserved as before because failure to follow the correct order can result in kernel panic.

To address this, we introduce a synchronization mechanism between the main kernel and the module to ensure all cryptographic algorithms are executed in the correct kernel boot phase. In more details, we spawn the module initialization process `fips_loader_init()` as an async thread `fips140_sync_thread()`, in which we call `run_initcalls()` to execute the initialization calls of each cryptographic algorithm.
Then, we introduce synchronization helpers such as `wait_until_fips140_level_sync(int level)` to ensure the initialization order of all cryptographic algorithms is synchronized with the main kernel.

## 5. Customization and Extension of Cryptography Module

This section describes how developers can customize which cryptographic algorithms are included in the standalone cryptography module, as well as extend this feature to other cryptographic algorithms or hardware architectures.

### 5.1. Cryptography Selection Mechanism

The feature automatically includes cryptographic algorithms that meet specific criteria:
1. **Built-in Configuration**: Only cryptographic algorithms configured as `CONFIG_CRYPTO_*=y` are candidates for inclusion
2. **Explicit Inclusion**: Cryptographic algorithms must be explicitly converted using the `crypto-objs-$(CONFIG__CRYPTO_*`) build rule

### 5.2. Extend Support to New Cryptographic Algorithms

To extend support to a new cryptographic algorithm in the standalone module, follow these steps:

**Step 1: Update the Makefile**
```
# in crypto/[algorithm]/Makefile
- obj-$(CONFIG_CRYPTO_ALGORITHM) += algorithm.o
+ crypto-objs-$(CONFIG_CRYPTO_ALGORITHM) += algorithm.o
```
For Architecture-Specific Cryptographic Algorithms:
- Apply the `crypto-objs-` rule in the appropriate `arch/*/crypto/Makefile`

**Step 2: Add Pluggable Interface Support**
If the cryptographic algorithm exports symbols via `EXPORT_SYMBOL()`, add the pluggable interface wrappers:
```
# Example: in include/crypto/algorithm.h
- extern int crypto_algorithm_transform(struct crypto_tfm *tfm, const u8 *src, 
                                       u8 *dst, unsigned int len, u32 flags);
+ DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGORITHM, crypto_algorithm_transform, int,
    (struct crypto_tfm *tfm, const u8 *src, u8 *dst, unsigned int len, u32 flags),
    (tfm, src, dst, len, flags));
```
Then, add the corresponding stubs in `crypto/fips140/fips140-api.c`:
```
#if IS_BUILTIN(CONFIG_CRYPTO_ALGORITHM)
#include <crypto/algorithm.h>
DEFINE_CRYPTO_API_STUB(crypto_algorithm_transform);
#endif
```
For Architecture-Specific Cryptographic Algorithms:
- Include architecture-specific stubs in `arch/*/crypto/fips140/fips140-api.c`:
```
# Example: in arch/arm64/crypto/fips140/fips140-api.c
#if IS_BUILTIN(CONFIG_CRYPTO_AES_ARM64_CE)
#include <arch/arm64/crypto/aes-ce-setkey.h>
DEFINE_CRYPTO_API_STUB(ce_aes_setkey);
DEFINE_CRYPTO_API_STUB(ce_aes_expandkey);
#endif
```
**Step 3: Update Initialization**
Replace module initialization calls:
```
# in crypto/algorithm/algorithm.c
- module_init(algorithm_init);
- module_exit(algorithm_exit);
+ crypto_module_init(algorithm_init);
+ crypto_module_exit(algorithm_exit);
```

### 5.3. Architecture-Specific Extensions

**Extending to New Architectures:**
Currently supported architectures are x86_64 and ARM64. To extend this feature to additional architectures:
1. **Update Linker Scripts**: Add ELF sections in `arch/[new-arch]/kernel/vmlinux.lds.S`:
```
.fips140_embedded : AT(ADDR(.fips140_embedded) - LOAD_OFFSET) {
    . = ALIGN(8);
    _binary_fips140_ko_start = .;
    KEEP(*(.fips140_module_data))
    _binary_fips140_ko_end = .;
}
```
2. **Create Architecture-Specific Files**: Set up `arch/[new-arch]/crypto/fips140/` directory with Makefile and `fips140-api.c` following the pattern used in x86_64 and ARM64.

## 6. Related Work and Comparison

The idea of modularizing kernel cryptographic functionality has also attracted attention from other Linux distributions as well as Linux-kernel-based platforms that are not traditional distributions. Specifically, there are two related efforts: one from [Android's GKI kernel](https://source.android.com/docs/core/architecture/kernel/gki-fips140-module) and another from [Oracle Linux](https://git.kernel.org/pub/scm/linux/kernel/git/vegard/linux-fips140.git/log/?h=fips140). While Amazon Linux incorporated several valuable ideas from these efforts (and have acknowledged them in the patch commits—thank you again!), this section highlights the key differences between those approaches and this approach. The goal is to describe the trade-offs and design choices objectively, rather than to criticize other implementations.

### 6.1. Comparison with Android's GKI

Android's work is the earliest one on modularizing kernel cryptographic code, and it targets a non-intrusive approach to the core GKI kernel, with the goal of minimizing modifications to the kernel source. To achieve this, the crypto module relies on several interception or "hijacking" techniques that intervene in the core kernel execution path.

While this approach minimizes kernel code changes, we don't adopt such an approach for several reasons. First, these interception mechanisms tightly depend on internal kernel crypto subsystem behavior, making them fragile across major kernel updates thus less suitable to reuse the same module on newer major kernel versions. Second, this design requires substantial additional cryptographic code duplication, which impacts maintainability. Finally, the solution only supports a fixed set of cryptographic algorithms, making it non-general and difficult to extend.

In contrast, our design integrates directly into the Linux kernel source tree, avoids duplicated cryptographic implementations, supports arbitrary kernel configuration settings, and works with any chosen set of cryptographic algorithms.

### 6.2. Comparison with Oracle Linux

Oracle’s work was developed concurrently with this approach. The primary differences between Oracle’s approach and Amazon's lie in build integration, pluggable interface design, and module initialization.

**Build Integration:**
Oracle's module is implemented as an out-of-tree module with a separate Makefile. This introduces three major reasons we don't adopt such an approach: 

*First*, the separate Makefile duplicates many kernel build rules, which increases maintenance cost, as upstream kernel build changes must be tracked and replicated. One concrete example can be seen below:

in Oracle's module makefile
```
fips140-y += crypto/skcipher.o
fips140-y += crypto/lskcipher.o
```
However, in upstream, the corresponding build logic is more complex and configuration-dependent:
```
crypto_skcipher-y += lskcipher.o
crypto_skcipher-y += skcipher.o
obj-$(CONFIG_CRYPTO_SKCIPHER2) += crypto_skcipher.o
ifeq ($(CONFIG_BPF_SYSCALL),y)
obj-$(CONFIG_CRYPTO_SKCIPHER2) += bpf_crypto_skcipher.o
endif
```
As shown above, when `CONFIG_BPF_SYSCALL` is enabled, `bpf_crypto_skcipher.o` must also be included. Tracking such dependencies is hard in the duplicated Makefile approach. In contrast, our approach integrates seamlessly into the kernel build system by introducing a customized build rule (`crypto-objs-*`) rather than relying on a duplicated Makefile, such that this is handled correctly by reusing the existing kernel build logic:
```
crypto_skcipher-y += lskcipher.o
crypto_skcipher-y += skcipher.o
- obj-$(CONFIG_CRYPTO_SKCIPHER2) += crypto_skcipher.o
+ crypto-objs-$(CONFIG_CRYPTO_SKCIPHER2) += crypto_skcipher.o
ifeq ($(CONFIG_BPF_SYSCALL),y)
- obj-$(CONFIG_CRYPTO_SKCIPHER2) += bpf_crypto_skcipher.o
+ crypto-objs-$(CONFIG_CRYPTO_SKCIPHER2) += bpf_crypto_skcipher.o
endif
```
As a result, such a Makefile-duplication approach does not scale well across all kernel configurations and does not easily support arbitrary sets of cryptographic algorithms.

*Second*, since the module is to be embedded as part of the kernel image (i.e., `vmlinux`) as described earlier, the module build must be triggered automatically as part of the `vmlinux` build process to achieve a seamless build workflow. However, Oracle's module build is not tightly integrated into the kernel build framework and requires special build commands (e.g., first do `make M=fips140/` specifically, then do some shell command and finally `make`). 

In contrast, our approach improves this aspect by integrating the module build tightly into the regular kernel build, so the build process is seamless and automatic with regular build and packaging processes such as `make` or `make vmlinux` or `make install`.

**Pluggable Interface:**
There are several differences in the pluggable interface design.

*First*, we avoid duplicate crypto code so only keep one crypto code in kernel memory, while existing work keeps two crypto code even if these crypto code are from the same source code. This is due to the way Oracle defines pluggable interface macros in `crypto/api`, where its design requires some cryptographic code to remain compiled into the main kernel image in addition to the code inside the standalone cryptography module. Keeping two crypto code is ok if these code are different and designed to be used for different runtime modes (i.e., FIPS/non-FIPS mode), but will be unnecessary if both crypto code are the same.

In contrast, the approach we use can flexibly support both choices: keep one cryptography subsystem, or two different crypto subsystems. To do so, we introduce an option `CRYPTO_FIPS140_DUAL_VERSION` such that when it is disabled, we only keep one cryptographic subsystem in the cryptography module while completely removing it from the main kernel; and when it is enabled, we allow having two different modules carrying different cryptography for different kernel runtime modes (i.e., FIPS and non-FIPS mode).

*Second*, existing approach requires modifications to both the cryptographic implementation (.c) files and the declaration (.h) header files while our approach only requires modifying the header file, making the change less intrusive to the kernel codebase.

*Third*, prior approaches mainly support making cryptographic function calls pluggable, while our approach extends pluggability to cryptographic variables as well.

*Fourth*, prior approach requires all cryptographics that we care (for any purpose such as those within FIPS boundary) to be included within a single kernel module `fips140.ko` (e.g., when `CONFIG_CRYPTO_AES=m`, it cannot be `aes.ko` but must be within fips140.ko). However, this requirement limits the inherent benefit of a kernel module (i.e., on-demand loading for memory efficiency). In contrast, our approach allows the cryptographic we care remain its original modular if it is configured as being so (i.e., if `CONFIG_CRYPTO_AES=m`, the aes will still be as `aes.ko` but not forced to `fips140.ko`) up to the `.config` setting. One benefit of this design is that it does not impose strict requirements on `.config` setting (i.e., a cryptography `.config` can be set to both `=y|m` while existing work must be set as `=y`), preserving configuration flexibility.

To support so, for any cryptography within the interest (i.e., whose makerule has been replaced with `crypto-objs-*`) but configured as build-as-module (i.e., `CONFIG_CRYPTO_*=m`), its compiled `.ko` binary will be marked automatically, such that the loader will have a way to recognize to perform some interest-specific processing (e.g., registered as FIPS-required flag) if needed. And the pluggable interface can also adjust its coverage automatically based on different `CONFIG_CRYPTO_*=y|=m` settings. This is achieved by letting the pluggable interface macro to take `CONFIG_CRYPTO_*` option as a parameter to recognize the `.config` setting.

**Module Initialization:**
Oracle's initialization routine does not guarantee preservation of the original crypto initialization order (i.e., the order they should follow if they were originally built-in in the main kernel), which limits its ability to support arbitrary combinations of cryptographic algorithms. This is because the crypto initialization routine in the module is executed too early, such that all module crypto is initialized before the cryptography init in the main kernel. So if there is a crypto in the module (e.g., a crypto init defined as `late_init()`) that depends on a cryptography (whose init is defined as `module_init()`) in the main kernel, since the one in the main kernel should be executed earlier (but because the module init is too early, it makes the crypto in the main kernel executed too late), such a case will break the kernel boot process.

Our design, on the other hand, introduces explicit initialization synchronization mechanisms between cryptography's init routine in the module and in the main kernel that can preserve the original built-in initialization order. As a result, our module supports any chosen crypto set to be included in the module.

### 6.3. Comparison Summary

Overall, combined with differences in coding style and integration strategy, the proposed approach is more seamlessly integrated with the upstream Linux kernel, making it more generalizable across different kernel configuration settings, and the changed behavior more invisible to kernel users.

## 7. Summary
In this patch series, Amazon Linux proposes a new kernel feature that decouples the built-in crypto subsystem into a dedicated kernel module. To achieve this, several key mechanisms are designed, including specialized compile rules, a novel pluggable interface mechanism, and a module-loading initialization process. This feature is designed in an upstream-friendly manner so that it can support arbitrary kernel configuration settings and arbitrary chosen sets of cryptographic algorithms. It is planned to be officially launched with the Amazon Linux Kernel 6.18 and future kernels.

---
Written by Jay Wang <wanjay@amazon.com>, Amazon Linux


Jay Wang (91):
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO and CONFIG_CRYPTO_ALGAPI2 crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_AES crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_AEAD2 crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_GENIV crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_SKCIPHER2 crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_HASH2 crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_AKCIPHER2 crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_SIG2 crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_KPP2 crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_RSA crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_ACOMP2 crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_MANAGER2 crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_MD5 crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_SHA3 crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_AUTHENC crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_LZO crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_RNG2 crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_ASYMMETRIC_KEY_TYPE crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_X509_CERTIFICATE_PARSER crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_PKCS7_MESSAGE_PARSER crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_ENGINE crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_HKDF crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_DH crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_ECDSA and CONFIG_CRYPTO_ECC crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_USER crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_XCBC crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_NULL crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_MD4 crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_RMD160 crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_SHA1 crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_SM3_GENERIC crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_STREEBOG crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_WP512 crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_BLAKE2B crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_PCBC crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_CTS crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_LRW crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_XTS crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_XCTR and CONFIG_CRYPTO_HCTR2 crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_ADIANTUM crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_CHACHA20 crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_CHACHA20POLY1305 crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_AEGIS128 crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_CRYPTD crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_DES crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_FCRYPT crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_BLOWFISH and CONFIG_CRYPTO_BLOWFISH_COMMON crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_SM4 and CONFIG_CRYPTO_SM4_GENERIC crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_TWOFISH and CONFIG_CRYPTO_TWOFISH_COMMON crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_SERPENT crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_CAMELLIA crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_CAST_COMMON, CONFIG_CRYPTO_CAST5, CONFIG_CRYPTO_CAST6
    crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_ARC4 crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_USER_API crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_USER_API_SKCIPHER crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_TEA crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_KHAZAD crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_ANUBIS crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_SEED crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_ARIA crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_DEFLATE crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_MICHAEL_MIC crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_CRC32C and CONFIG_CRYPTO_CRC32 crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_KRB5ENC crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_LZ4 and CONFIG_CRYPTO_LZ4HC crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_XXHASH crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_842 crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_JITTERENTROPY_TESTINTERFACE crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_BENCHMARK crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_USER_API_HASH crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_USER_API_RNG crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_USER_API_AEAD crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_ZSTD crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_ESSIV crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_ECDH crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_ECRDSA crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_XOR_BLOCKS crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_ASYNC_CORE crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_ASYNC_MEMCPY crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_ASYNC_XOR crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_ASYNC_PQ crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_ASYNC_RAID6_RECOV crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_KDF800108_CTR crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_KRB5 crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_FIPS_SIGNATURE_SELFTEST crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_PKCS8_PRIVATE_KEY_PARSER crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_PKCS7_TEST_KEY crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_SIGNED_PE_FILE_VERIFICATION crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_SIMD crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_ASYNC_RAID6_TEST crypto

Vegard Nossum (15):
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_SEQIV crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_ECHAINIV crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_CMAC crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_HMAC crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_SHA256 crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_SHA512 crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_ECB crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_CBC crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_CTR crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_GCM crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_CCM crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_DRBG crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_JITTERENTROPY crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_GHASH crypto
  crypto: convert exported crypto symbol into pluggable interface for
    CONFIG_CRYPTO_PCRYPT crypto

 certs/system_keyring.c                   |   1 +
 crypto/842.c                             |   4 +-
 crypto/Makefile                          | 204 ++---
 crypto/adiantum.c                        |   4 +-
 crypto/aegis128-core.c                   |   4 +-
 crypto/aes.c                             |   4 +-
 crypto/af_alg.c                          |   4 +-
 crypto/algapi.c                          |   4 +-
 crypto/algboss.c                         |   4 +-
 crypto/algif_aead.c                      |   4 +-
 crypto/algif_hash.c                      |   4 +-
 crypto/algif_rng.c                       |   4 +-
 crypto/algif_skcipher.c                  |   4 +-
 crypto/anubis.c                          |   4 +-
 crypto/arc4.c                            |   4 +-
 crypto/aria_generic.c                    |   4 +-
 crypto/asymmetric_keys/Makefile          |  16 +-
 crypto/asymmetric_keys/asymmetric_type.c |   4 +-
 crypto/asymmetric_keys/pkcs7_key_type.c  |   6 +-
 crypto/asymmetric_keys/pkcs8_parser.c    |   4 +-
 crypto/asymmetric_keys/restrict.c        |   3 +-
 crypto/asymmetric_keys/selftest.c        |   2 +-
 crypto/asymmetric_keys/verify_pefile.c   |   1 +
 crypto/asymmetric_keys/x509_parser.h     |  15 +-
 crypto/asymmetric_keys/x509_public_key.c |   4 +-
 crypto/async_tx/Makefile                 |  12 +-
 crypto/async_tx/async_pq.c               |   4 +-
 crypto/async_tx/async_tx.c               |   4 +-
 crypto/async_tx/raid6test.c              |   4 +-
 crypto/authenc.c                         |   4 +-
 crypto/authencesn.c                      |   4 +-
 crypto/blake2b.c                         |   4 +-
 crypto/blowfish_generic.c                |   4 +-
 crypto/bpf_crypto_skcipher.c             |   4 +-
 crypto/camellia_generic.c                |   4 +-
 crypto/cast5_generic.c                   |   4 +-
 crypto/cast6_generic.c                   |   4 +-
 crypto/cbc.c                             |   4 +-
 crypto/ccm.c                             |   4 +-
 crypto/chacha.c                          |   4 +-
 crypto/chacha20poly1305.c                |   4 +-
 crypto/cmac.c                            |   4 +-
 crypto/crc32.c                           |   4 +-
 crypto/crc32c.c                          |   4 +-
 crypto/cryptd.c                          |   4 +-
 crypto/crypto_null.c                     |   4 +-
 crypto/crypto_user.c                     |   4 +-
 crypto/ctr.c                             |   4 +-
 crypto/cts.c                             |   4 +-
 crypto/deflate.c                         |   4 +-
 crypto/des_generic.c                     |   4 +-
 crypto/dh.c                              |   4 +-
 crypto/drbg.c                            |   4 +-
 crypto/ecb.c                             |   4 +-
 crypto/ecdh.c                            |   4 +-
 crypto/ecdsa.c                           |   4 +-
 crypto/echainiv.c                        |   4 +-
 crypto/ecrdsa.c                          |   4 +-
 crypto/essiv.c                           |   4 +-
 crypto/fcrypt.c                          |   4 +-
 crypto/fips140/fips140-api.c             | 934 ++++++++++++++++++++++-
 crypto/gcm.c                             |   4 +-
 crypto/ghash-generic.c                   |   4 +-
 crypto/hctr2.c                           |   4 +-
 crypto/hkdf.c                            |   4 +-
 crypto/hmac.c                            |   4 +-
 crypto/internal.h                        |  89 ++-
 crypto/jitterentropy-kcapi.c             |   4 +-
 crypto/kdf_sp800108.c                    |   4 +-
 crypto/khazad.c                          |   4 +-
 crypto/krb5/Makefile                     |   2 +-
 crypto/krb5/krb5_api.c                   |   4 +-
 crypto/krb5enc.c                         |   4 +-
 crypto/lrw.c                             |   4 +-
 crypto/lz4.c                             |   4 +-
 crypto/lz4hc.c                           |   4 +-
 crypto/lzo-rle.c                         |   4 +-
 crypto/lzo.c                             |   4 +-
 crypto/md4.c                             |   4 +-
 crypto/md5.c                             |   4 +-
 crypto/michael_mic.c                     |   4 +-
 crypto/pcbc.c                            |   4 +-
 crypto/pcrypt.c                          |   4 +-
 crypto/rmd160.c                          |   4 +-
 crypto/rsa.c                             |   4 +-
 crypto/seed.c                            |   4 +-
 crypto/seqiv.c                           |   4 +-
 crypto/serpent_generic.c                 |   4 +-
 crypto/sha1.c                            |   4 +-
 crypto/sha256.c                          |   4 +-
 crypto/sha3.c                            |   4 +-
 crypto/sha512.c                          |   4 +-
 crypto/sm3_generic.c                     |   4 +-
 crypto/sm4_generic.c                     |   4 +-
 crypto/streebog_generic.c                |   4 +-
 crypto/tcrypt.c                          |   4 +-
 crypto/tea.c                             |   4 +-
 crypto/twofish_generic.c                 |   4 +-
 crypto/wp512.c                           |   4 +-
 crypto/xcbc.c                            |   4 +-
 crypto/xctr.c                            |   4 +-
 crypto/xor.c                             |   4 +-
 crypto/xts.c                             |   4 +-
 crypto/xxhash_generic.c                  |   4 +-
 crypto/zstd.c                            |   4 +-
 include/crypto/acompress.h               |  14 +-
 include/crypto/aead.h                    |  30 +-
 include/crypto/akcipher.h                |  12 +-
 include/crypto/algapi.h                  | 125 ++-
 include/crypto/aria.h                    |  16 +-
 include/crypto/authenc.h                 |  12 +-
 include/crypto/blowfish.h                |   6 +-
 include/crypto/cast5.h                   |  14 +-
 include/crypto/cast6.h                   |  19 +-
 include/crypto/cast_common.h             |  17 +-
 include/crypto/cryptd.h                  |  56 +-
 include/crypto/dh.h                      |  14 +-
 include/crypto/ecc_curve.h               |   9 +-
 include/crypto/ecdh.h                    |  14 +-
 include/crypto/engine.h                  | 140 ++--
 include/crypto/hash.h                    |  53 +-
 include/crypto/hkdf.h                    |  13 +-
 include/crypto/if_alg.h                  |  84 +-
 include/crypto/internal/acompress.h      |  27 +-
 include/crypto/internal/aead.h           |  28 +-
 include/crypto/internal/akcipher.h       |  12 +-
 include/crypto/internal/cipher.h         |  20 +-
 include/crypto/internal/ecc.h            |  91 ++-
 include/crypto/internal/geniv.h          |  14 +-
 include/crypto/internal/hash.h           |  59 +-
 include/crypto/internal/kpp.h            |  12 +-
 include/crypto/internal/rng.h            |  21 +-
 include/crypto/internal/rsa.h            |   7 +-
 include/crypto/internal/scompress.h      |   9 +-
 include/crypto/internal/sig.h            |  12 +-
 include/crypto/internal/simd.h           |  33 +-
 include/crypto/internal/skcipher.h       |  91 ++-
 include/crypto/kdf_sp800108.h            |  14 +-
 include/crypto/kpp.h                     |   5 +-
 include/crypto/krb5.h                    |  78 +-
 include/crypto/md5.h                     |   8 +-
 include/crypto/pkcs7.h                   |  31 +-
 include/crypto/public_key.h              |  44 +-
 include/crypto/rng.h                     |  18 +-
 include/crypto/scatterwalk.h             |  36 +-
 include/crypto/serpent.h                 |  20 +-
 include/crypto/sig.h                     |   3 +-
 include/crypto/skcipher.h                |  56 +-
 include/crypto/sm4.h                     |  22 +-
 include/crypto/twofish.h                 |  11 +-
 include/keys/asymmetric-parser.h         |   8 +-
 include/keys/asymmetric-type.h           |  37 +-
 include/linux/async_tx.h                 |  76 +-
 include/linux/crypto.h                   |  22 +-
 include/linux/raid/xor.h                 |   7 +-
 include/linux/verification.h             |   8 +-
 156 files changed, 2302 insertions(+), 943 deletions(-)

-- 
2.47.3


^ permalink raw reply	[flat|nested] 107+ messages in thread

* [PATCH 001/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO and CONFIG_CRYPTO_ALGAPI2 crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
@ 2026-02-12  2:45 ` Jay Wang
  2026-02-12  2:45 ` [PATCH 002/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_AES crypto Jay Wang
                   ` (104 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:45 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO- and CONFIG_CRYPTO_ALGAPI2-related crypto to convert them
into pluggable interface.

This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.

Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile                  |   4 +-
 crypto/algapi.c                  |   4 +-
 crypto/fips140/fips140-api.c     | 109 +++++++++++++++++++++++++--
 crypto/internal.h                |  86 +++++++++++++--------
 include/crypto/algapi.h          | 125 +++++++++++++++++++++----------
 include/crypto/internal/cipher.h |  20 +++--
 include/crypto/scatterwalk.h     |  36 +++++----
 include/linux/crypto.h           |  22 ++++--
 8 files changed, 302 insertions(+), 104 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 5129be5e7208..88de6dcbd7c4 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -5,7 +5,7 @@
 
 CONTEXT_ANALYSIS := y
 
-obj-$(CONFIG_CRYPTO) += crypto.o
+crypto-objs-$(CONFIG_CRYPTO) += crypto.o
 crypto-y := api.o cipher.o
 
 obj-$(CONFIG_CRYPTO_ENGINE) += crypto_engine.o
@@ -13,7 +13,7 @@ obj-$(CONFIG_CRYPTO_FIPS) += fips.o
 
 crypto_algapi-$(CONFIG_PROC_FS) += proc.o
 crypto_algapi-y := algapi.o scatterwalk.o $(crypto_algapi-y)
-obj-$(CONFIG_CRYPTO_ALGAPI2) += crypto_algapi.o
+crypto-objs-$(CONFIG_CRYPTO_ALGAPI2) += crypto_algapi.o
 
 obj-$(CONFIG_CRYPTO_AEAD2) += aead.o
 obj-$(CONFIG_CRYPTO_GENIV) += geniv.o
diff --git a/crypto/algapi.c b/crypto/algapi.c
index 663698e0cd65..0a041a6f6668 100644
--- a/crypto/algapi.c
+++ b/crypto/algapi.c
@@ -1123,8 +1123,8 @@ static void __exit crypto_algapi_exit(void)
  * We run this at late_initcall so that all the built-in algorithms
  * have had a chance to register themselves first.
  */
-late_initcall(crypto_algapi_init);
-module_exit(crypto_algapi_exit);
+crypto_late_initcall(crypto_algapi_init);
+crypto_module_exit(crypto_algapi_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Cryptographic algorithms API");
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index a11e898ff4bc..8a0e1d28615c 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -1,7 +1,106 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * crypto/api.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO)
+
+#include <linux/crypto.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_req_done);
+DEFINE_CRYPTO_API_STUB(crypto_has_alg);
+DEFINE_CRYPTO_API_STUB(crypto_alloc_base);
+DEFINE_CRYPTO_API_STUB(crypto_destroy_tfm);
+DEFINE_CRYPTO_API_STUB(crypto_request_clone);
+
+#include <crypto/algapi.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_mod_put);
+
+#include <crypto/internal.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_mod_get);
+DEFINE_CRYPTO_API_STUB(crypto_alg_mod_lookup);
+DEFINE_CRYPTO_API_STUB(crypto_larval_alloc);
+DEFINE_CRYPTO_API_STUB(crypto_schedule_test);
+DEFINE_CRYPTO_API_STUB(crypto_shoot_alg);
+DEFINE_CRYPTO_API_STUB(__crypto_alloc_tfmgfp);
+DEFINE_CRYPTO_API_STUB(__crypto_alloc_tfm);
+DEFINE_CRYPTO_API_STUB(crypto_create_tfm_node);
+DEFINE_CRYPTO_API_STUB(crypto_clone_tfm);
+DEFINE_CRYPTO_API_STUB(crypto_find_alg);
+DEFINE_CRYPTO_API_STUB(crypto_alloc_tfm_node);
+DEFINE_CRYPTO_API_STUB(crypto_probing_notify);
+DEFINE_CRYPTO_API_STUB(crypto_destroy_alg);
+
+#endif
+/*
+ * crypto/cipher.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO)
+
+#include <crypto/internal/cipher.h>
 
+DEFINE_CRYPTO_API_STUB(crypto_cipher_setkey);
+DEFINE_CRYPTO_API_STUB(crypto_cipher_encrypt_one);
+DEFINE_CRYPTO_API_STUB(crypto_cipher_decrypt_one);
+DEFINE_CRYPTO_API_STUB(crypto_clone_cipher);
+
+#endif
+/*
+ * crypto/scatterwalk.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_ALGAPI2)
+
+#include <crypto/scatterwalk.h>
+
+DEFINE_CRYPTO_API_STUB(scatterwalk_skip);
+DEFINE_CRYPTO_API_STUB(memcpy_from_scatterwalk);
+DEFINE_CRYPTO_API_STUB(memcpy_to_scatterwalk);
+DEFINE_CRYPTO_API_STUB(memcpy_from_sglist);
+DEFINE_CRYPTO_API_STUB(memcpy_to_sglist);
+DEFINE_CRYPTO_API_STUB(memcpy_sglist);
+DEFINE_CRYPTO_API_STUB(scatterwalk_ffwd);
+
+#endif
 /*
- * Define static call keys for any functions which are part of the crypto
- * API and used by the standalone FIPS module but which are not built into
- * vmlinux.
- */
\ No newline at end of file
+ * crypto/algapi.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_ALGAPI2)
+
+#include <crypto/algapi.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_register_alg);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_alg);
+DEFINE_CRYPTO_API_STUB(crypto_register_algs);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_algs);
+DEFINE_CRYPTO_API_STUB(crypto_register_template);
+DEFINE_CRYPTO_API_STUB(crypto_register_templates);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_template);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_templates);
+DEFINE_CRYPTO_API_STUB(crypto_lookup_template);
+DEFINE_CRYPTO_API_STUB(crypto_register_instance);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_instance);
+DEFINE_CRYPTO_API_STUB(crypto_grab_spawn);
+DEFINE_CRYPTO_API_STUB(crypto_drop_spawn);
+DEFINE_CRYPTO_API_STUB(crypto_spawn_tfm);
+DEFINE_CRYPTO_API_STUB(crypto_spawn_tfm2);
+DEFINE_CRYPTO_API_STUB(crypto_get_attr_type);
+DEFINE_CRYPTO_API_STUB(crypto_check_attr_type);
+DEFINE_CRYPTO_API_STUB(crypto_attr_alg_name);
+DEFINE_CRYPTO_API_STUB(__crypto_inst_setname);
+DEFINE_CRYPTO_API_STUB(crypto_init_queue);
+DEFINE_CRYPTO_API_STUB(crypto_enqueue_request);
+DEFINE_CRYPTO_API_STUB(crypto_enqueue_request_head);
+DEFINE_CRYPTO_API_STUB(crypto_dequeue_request);
+DEFINE_CRYPTO_API_STUB(crypto_inc);
+DEFINE_CRYPTO_API_STUB(crypto_register_notifier);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_notifier);
+
+#include <crypto/internal.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_alg_tested);
+DEFINE_CRYPTO_API_STUB(crypto_remove_spawns);
+DEFINE_CRYPTO_API_STUB(crypto_remove_final);
+DEFINE_CRYPTO_API_STUB(crypto_alg_extsize);
+DEFINE_CRYPTO_API_STUB(crypto_type_has_alg);
+
+#endif
\ No newline at end of file
diff --git a/crypto/internal.h b/crypto/internal.h
index 8fbe0226d48e..8ebe4dc336bc 100644
--- a/crypto/internal.h
+++ b/crypto/internal.h
@@ -109,25 +109,44 @@ static inline unsigned int crypto_compress_ctxsize(struct crypto_alg *alg)
 	return alg->cra_ctxsize;
 }
 
-struct crypto_alg *crypto_mod_get(struct crypto_alg *alg);
-struct crypto_alg *crypto_alg_mod_lookup(const char *name, u32 type, u32 mask);
-
-struct crypto_larval *crypto_larval_alloc(const char *name, u32 type, u32 mask);
-void crypto_schedule_test(struct crypto_larval *larval);
-void crypto_alg_tested(const char *name, int err);
-
-void crypto_remove_spawns(struct crypto_alg *alg, struct list_head *list,
-			  struct crypto_alg *nalg);
-void crypto_remove_final(struct list_head *list);
-void crypto_shoot_alg(struct crypto_alg *alg);
-struct crypto_tfm *__crypto_alloc_tfmgfp(struct crypto_alg *alg, u32 type,
-					 u32 mask, gfp_t gfp);
-struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type,
-				      u32 mask);
-void *crypto_create_tfm_node(struct crypto_alg *alg,
-			const struct crypto_type *frontend, int node);
-void *crypto_clone_tfm(const struct crypto_type *frontend,
-		       struct crypto_tfm *otfm);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO, crypto_mod_get, struct crypto_alg *,
+	(struct crypto_alg *alg),
+	(alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO, crypto_alg_mod_lookup, struct crypto_alg *,
+	(const char *name, u32 type, u32 mask),
+	(name, type, mask));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO, crypto_larval_alloc, struct crypto_larval *,
+	(const char *name, u32 type, u32 mask),
+	(name, type, mask));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO, crypto_schedule_test, void,
+	(struct crypto_larval *larval),
+	(larval));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_alg_tested, void,
+	(const char *name, int err),
+	(name, err));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_remove_spawns, void,
+	(struct crypto_alg *alg, struct list_head *list, struct crypto_alg *nalg),
+	(alg, list, nalg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_remove_final, void,
+	(struct list_head *list),
+	(list));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO, crypto_shoot_alg, void,
+	(struct crypto_alg *alg),
+	(alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO, __crypto_alloc_tfmgfp, struct crypto_tfm *,
+	(struct crypto_alg *alg, u32 type, u32 mask, gfp_t gfp),
+	(alg, type, mask, gfp));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO, __crypto_alloc_tfm, struct crypto_tfm *,
+	(struct crypto_alg *alg, u32 type, u32 mask),
+	(alg, type, mask));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO, crypto_create_tfm_node, void *,
+	(struct crypto_alg *alg, const struct crypto_type *frontend, int node),
+	(alg, frontend, node));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO, crypto_clone_tfm, void *,
+	(const struct crypto_type *frontend, struct crypto_tfm *otfm),
+	(frontend, otfm));
 
 static inline void *crypto_create_tfm(struct crypto_alg *alg,
 			const struct crypto_type *frontend)
@@ -135,13 +154,13 @@ static inline void *crypto_create_tfm(struct crypto_alg *alg,
 	return crypto_create_tfm_node(alg, frontend, NUMA_NO_NODE);
 }
 
-struct crypto_alg *crypto_find_alg(const char *alg_name,
-				   const struct crypto_type *frontend,
-				   u32 type, u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO, crypto_find_alg, struct crypto_alg *,
+	(const char *alg_name, const struct crypto_type *frontend, u32 type, u32 mask),
+	(alg_name, frontend, type, mask));
 
-void *crypto_alloc_tfm_node(const char *alg_name,
-		       const struct crypto_type *frontend, u32 type, u32 mask,
-		       int node);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO, crypto_alloc_tfm_node, void *,
+	(const char *alg_name, const struct crypto_type *frontend, u32 type, u32 mask, int node),
+	(alg_name, frontend, type, mask, node));
 
 static inline void *crypto_alloc_tfm(const char *alg_name,
 		       const struct crypto_type *frontend, u32 type, u32 mask)
@@ -149,12 +168,17 @@ static inline void *crypto_alloc_tfm(const char *alg_name,
 	return crypto_alloc_tfm_node(alg_name, frontend, type, mask, NUMA_NO_NODE);
 }
 
-int crypto_probing_notify(unsigned long val, void *v);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO, crypto_probing_notify, int,
+	(unsigned long val, void *v),
+	(val, v));
 
-unsigned int crypto_alg_extsize(struct crypto_alg *alg);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_alg_extsize, unsigned int,
+	(struct crypto_alg *alg),
+	(alg));
 
-int crypto_type_has_alg(const char *name, const struct crypto_type *frontend,
-			u32 type, u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_type_has_alg, int,
+	(const char *name, const struct crypto_type *frontend, u32 type, u32 mask),
+	(name, frontend, type, mask));
 
 static inline struct crypto_alg *crypto_alg_get(struct crypto_alg *alg)
 {
@@ -162,7 +186,9 @@ static inline struct crypto_alg *crypto_alg_get(struct crypto_alg *alg)
 	return alg;
 }
 
-void crypto_destroy_alg(struct crypto_alg *alg);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO, crypto_destroy_alg, void,
+	(struct crypto_alg *alg),
+	(alg));
 
 static inline void crypto_alg_put(struct crypto_alg *alg)
 {
diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
index 05deea9dac5e..455b7c190936 100644
--- a/include/crypto/algapi.h
+++ b/include/crypto/algapi.h
@@ -7,6 +7,7 @@
 #ifndef _CRYPTO_ALGAPI_H
 #define _CRYPTO_ALGAPI_H
 
+#include <crypto/api.h>
 #include <crypto/utils.h>
 #include <linux/align.h>
 #include <linux/cache.h>
@@ -131,35 +132,71 @@ struct crypto_attr_type {
 /*
  * Algorithm registration interface.
  */
-int crypto_register_alg(struct crypto_alg *alg);
-void crypto_unregister_alg(struct crypto_alg *alg);
-int crypto_register_algs(struct crypto_alg *algs, int count);
-void crypto_unregister_algs(struct crypto_alg *algs, int count);
-
-void crypto_mod_put(struct crypto_alg *alg);
-
-int crypto_register_template(struct crypto_template *tmpl);
-int crypto_register_templates(struct crypto_template *tmpls, int count);
-void crypto_unregister_template(struct crypto_template *tmpl);
-void crypto_unregister_templates(struct crypto_template *tmpls, int count);
-struct crypto_template *crypto_lookup_template(const char *name);
-
-int crypto_register_instance(struct crypto_template *tmpl,
-			     struct crypto_instance *inst);
-void crypto_unregister_instance(struct crypto_instance *inst);
-
-int crypto_grab_spawn(struct crypto_spawn *spawn, struct crypto_instance *inst,
-		      const char *name, u32 type, u32 mask);
-void crypto_drop_spawn(struct crypto_spawn *spawn);
-struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type,
-				    u32 mask);
-void *crypto_spawn_tfm2(struct crypto_spawn *spawn);
-
-struct crypto_attr_type *crypto_get_attr_type(struct rtattr **tb);
-int crypto_check_attr_type(struct rtattr **tb, u32 type, u32 *mask_ret);
-const char *crypto_attr_alg_name(struct rtattr *rta);
-int __crypto_inst_setname(struct crypto_instance *inst, const char *name,
-			  const char *driver, struct crypto_alg *alg);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_register_alg, int,
+	(struct crypto_alg *alg),
+	(alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_unregister_alg, void,
+	(struct crypto_alg *alg),
+	(alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_register_algs, int,
+	(struct crypto_alg *algs, int count),
+	(algs, count));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_unregister_algs, void,
+	(struct crypto_alg *algs, int count),
+	(algs, count));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO, crypto_mod_put, void,
+	(struct crypto_alg *alg),
+	(alg));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_register_template, int,
+	(struct crypto_template *tmpl),
+	(tmpl));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_register_templates, int,
+	(struct crypto_template *tmpls, int count),
+	(tmpls, count));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_unregister_template, void,
+	(struct crypto_template *tmpl),
+	(tmpl));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_unregister_templates, void,
+	(struct crypto_template *tmpls, int count),
+	(tmpls, count));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_lookup_template, struct crypto_template *,
+	(const char *name),
+	(name));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_register_instance, int,
+	(struct crypto_template *tmpl, struct crypto_instance *inst),
+	(tmpl, inst));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_unregister_instance, void,
+	(struct crypto_instance *inst),
+	(inst));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_grab_spawn, int,
+	(struct crypto_spawn *spawn, struct crypto_instance *inst, const char *name, u32 type, u32 mask),
+	(spawn, inst, name, type, mask));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_drop_spawn, void,
+	(struct crypto_spawn *spawn),
+	(spawn));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_spawn_tfm, struct crypto_tfm *,
+	(struct crypto_spawn *spawn, u32 type, u32 mask),
+	(spawn, type, mask));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_spawn_tfm2, void *,
+	(struct crypto_spawn *spawn),
+	(spawn));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_get_attr_type, struct crypto_attr_type *,
+	(struct rtattr **tb),
+	(tb));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_check_attr_type, int,
+	(struct rtattr **tb, u32 type, u32 *mask_ret),
+	(tb, type, mask_ret));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_attr_alg_name, const char *,
+	(struct rtattr *rta),
+	(rta));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, __crypto_inst_setname, int,
+	(struct crypto_instance *inst, const char *name, const char *driver, struct crypto_alg *alg),
+	(inst, name, driver, alg));
 
 #define crypto_inst_setname(inst, name, ...) \
 	CONCATENATE(crypto_inst_setname_, COUNT_ARGS(__VA_ARGS__))( \
@@ -169,18 +206,26 @@ int __crypto_inst_setname(struct crypto_instance *inst, const char *name,
 #define crypto_inst_setname_2(inst, name, driver, alg) \
 	__crypto_inst_setname(inst, name, driver, alg)
 
-void crypto_init_queue(struct crypto_queue *queue, unsigned int max_qlen);
-int crypto_enqueue_request(struct crypto_queue *queue,
-			   struct crypto_async_request *request);
-void crypto_enqueue_request_head(struct crypto_queue *queue,
-				 struct crypto_async_request *request);
-struct crypto_async_request *crypto_dequeue_request(struct crypto_queue *queue);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_init_queue, void,
+	(struct crypto_queue *queue, unsigned int max_qlen),
+	(queue, max_qlen));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_enqueue_request, int,
+	(struct crypto_queue *queue, struct crypto_async_request *request),
+	(queue, request));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_enqueue_request_head, void,
+	(struct crypto_queue *queue, struct crypto_async_request *request),
+	(queue, request));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_dequeue_request, struct crypto_async_request *,
+	(struct crypto_queue *queue),
+	(queue));
 static inline unsigned int crypto_queue_len(struct crypto_queue *queue)
 {
 	return queue->qlen;
 }
 
-void crypto_inc(u8 *a, unsigned int size);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_inc, void,
+	(u8 *a, unsigned int size),
+	(a, size));
 
 static inline void *crypto_tfm_ctx(struct crypto_tfm *tfm)
 {
@@ -254,8 +299,12 @@ static inline u32 crypto_algt_inherited_mask(struct crypto_attr_type *algt)
 	return crypto_requires_off(algt, CRYPTO_ALG_INHERITED_FLAGS);
 }
 
-int crypto_register_notifier(struct notifier_block *nb);
-int crypto_unregister_notifier(struct notifier_block *nb);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_register_notifier, int,
+	(struct notifier_block *nb),
+	(nb));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, crypto_unregister_notifier, int,
+	(struct notifier_block *nb),
+	(nb));
 
 /* Crypto notification events. */
 enum {
diff --git a/include/crypto/internal/cipher.h b/include/crypto/internal/cipher.h
index 5030f6d2df31..62d18c0f5c11 100644
--- a/include/crypto/internal/cipher.h
+++ b/include/crypto/internal/cipher.h
@@ -11,6 +11,7 @@
 #ifndef _CRYPTO_INTERNAL_CIPHER_H
 #define _CRYPTO_INTERNAL_CIPHER_H
 
+#include <crypto/api.h>
 #include <crypto/algapi.h>
 
 struct crypto_cipher {
@@ -149,8 +150,9 @@ static inline void crypto_cipher_clear_flags(struct crypto_cipher *tfm,
  *
  * Return: 0 if the setting of the key was successful; < 0 if an error occurred
  */
-int crypto_cipher_setkey(struct crypto_cipher *tfm,
-			 const u8 *key, unsigned int keylen);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO, crypto_cipher_setkey, int,
+	(struct crypto_cipher *tfm, const u8 *key, unsigned int keylen),
+	(tfm, key, keylen));
 
 /**
  * crypto_cipher_encrypt_one() - encrypt one block of plaintext
@@ -161,8 +163,9 @@ int crypto_cipher_setkey(struct crypto_cipher *tfm,
  * Invoke the encryption operation of one block. The caller must ensure that
  * the plaintext and ciphertext buffers are at least one block in size.
  */
-void crypto_cipher_encrypt_one(struct crypto_cipher *tfm,
-			       u8 *dst, const u8 *src);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO, crypto_cipher_encrypt_one, void,
+	(struct crypto_cipher *tfm, u8 *dst, const u8 *src),
+	(tfm, dst, src));
 
 /**
  * crypto_cipher_decrypt_one() - decrypt one block of ciphertext
@@ -173,10 +176,13 @@ void crypto_cipher_encrypt_one(struct crypto_cipher *tfm,
  * Invoke the decryption operation of one block. The caller must ensure that
  * the plaintext and ciphertext buffers are at least one block in size.
  */
-void crypto_cipher_decrypt_one(struct crypto_cipher *tfm,
-			       u8 *dst, const u8 *src);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO, crypto_cipher_decrypt_one, void,
+	(struct crypto_cipher *tfm, u8 *dst, const u8 *src),
+	(tfm, dst, src));
 
-struct crypto_cipher *crypto_clone_cipher(struct crypto_cipher *cipher);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO, crypto_clone_cipher, struct crypto_cipher *,
+	(struct crypto_cipher *cipher),
+	(cipher));
 
 struct crypto_cipher_spawn {
 	struct crypto_spawn base;
diff --git a/include/crypto/scatterwalk.h b/include/crypto/scatterwalk.h
index 624fab589c2c..4b7daf05719c 100644
--- a/include/crypto/scatterwalk.h
+++ b/include/crypto/scatterwalk.h
@@ -11,6 +11,7 @@
 #ifndef _CRYPTO_SCATTERWALK_H
 #define _CRYPTO_SCATTERWALK_H
 
+#include <crypto/api.h>
 #include <crypto/algapi.h>
 
 #include <linux/highmem.h>
@@ -221,22 +222,29 @@ static inline void scatterwalk_done_dst(struct scatter_walk *walk,
 	scatterwalk_advance(walk, nbytes);
 }
 
-void scatterwalk_skip(struct scatter_walk *walk, unsigned int nbytes);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, scatterwalk_skip, void,
+	(struct scatter_walk *walk, unsigned int nbytes),
+	(walk, nbytes));
 
-void memcpy_from_scatterwalk(void *buf, struct scatter_walk *walk,
-			     unsigned int nbytes);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, memcpy_from_scatterwalk, void,
+	(void *buf, struct scatter_walk *walk, unsigned int nbytes),
+	(buf, walk, nbytes));
 
-void memcpy_to_scatterwalk(struct scatter_walk *walk, const void *buf,
-			   unsigned int nbytes);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, memcpy_to_scatterwalk, void,
+	(struct scatter_walk *walk, const void *buf, unsigned int nbytes),
+	(walk, buf, nbytes));
 
-void memcpy_from_sglist(void *buf, struct scatterlist *sg,
-			unsigned int start, unsigned int nbytes);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, memcpy_from_sglist, void,
+	(void *buf, struct scatterlist *sg, unsigned int start, unsigned int nbytes),
+	(buf, sg, start, nbytes));
 
-void memcpy_to_sglist(struct scatterlist *sg, unsigned int start,
-		      const void *buf, unsigned int nbytes);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, memcpy_to_sglist, void,
+	(struct scatterlist *sg, unsigned int start, const void *buf, unsigned int nbytes),
+	(sg, start, buf, nbytes));
 
-void memcpy_sglist(struct scatterlist *dst, struct scatterlist *src,
-		   unsigned int nbytes);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, memcpy_sglist, void,
+	(struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes),
+	(dst, src, nbytes));
 
 /* In new code, please use memcpy_{from,to}_sglist() directly instead. */
 static inline void scatterwalk_map_and_copy(void *buf, struct scatterlist *sg,
@@ -249,8 +257,8 @@ static inline void scatterwalk_map_and_copy(void *buf, struct scatterlist *sg,
 		memcpy_from_sglist(buf, sg, start, nbytes);
 }
 
-struct scatterlist *scatterwalk_ffwd(struct scatterlist dst[2],
-				     struct scatterlist *src,
-				     unsigned int len);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ALGAPI2, scatterwalk_ffwd, struct scatterlist *,
+	(struct scatterlist dst[2], struct scatterlist *src, unsigned int len),
+	(dst, src, len));
 
 #endif  /* _CRYPTO_SCATTERWALK_H */
diff --git a/include/linux/crypto.h b/include/linux/crypto.h
index a2137e19be7d..20eecf13d0e5 100644
--- a/include/linux/crypto.h
+++ b/include/linux/crypto.h
@@ -12,6 +12,7 @@
 #ifndef _LINUX_CRYPTO_H
 #define _LINUX_CRYPTO_H
 
+#include <crypto/api.h>
 #include <linux/completion.h>
 #include <linux/errno.h>
 #include <linux/refcount_types.h>
@@ -376,7 +377,9 @@ struct crypto_wait {
 /*
  * Async ops completion helper functioons
  */
-void crypto_req_done(void *req, int err);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO, crypto_req_done, void,
+	(void *req, int err),
+	(req, err));
 
 static inline int crypto_wait_req(int err, struct crypto_wait *wait)
 {
@@ -400,7 +403,9 @@ static inline void crypto_init_wait(struct crypto_wait *wait)
 /*
  * Algorithm query interface.
  */
-int crypto_has_alg(const char *name, u32 type, u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO, crypto_has_alg, int,
+	(const char *name, u32 type, u32 mask),
+	(name, type, mask));
 
 /*
  * Transforms: user-instantiated objects which encapsulate algorithms
@@ -428,8 +433,12 @@ struct crypto_tfm {
  * Transform user interface.
  */
  
-struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask);
-void crypto_destroy_tfm(void *mem, struct crypto_tfm *tfm);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO, crypto_alloc_base, struct crypto_tfm *,
+	(const char *alg_name, u32 type, u32 mask),
+	(alg_name, type, mask));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO, crypto_destroy_tfm, void,
+	(void *mem, struct crypto_tfm *tfm),
+	(mem, tfm));
 
 static inline void crypto_free_tfm(struct crypto_tfm *tfm)
 {
@@ -514,8 +523,9 @@ static inline void crypto_request_set_tfm(struct crypto_async_request *req,
 	req->flags &= ~CRYPTO_TFM_REQ_ON_STACK;
 }
 
-struct crypto_async_request *crypto_request_clone(
-	struct crypto_async_request *req, size_t total, gfp_t gfp);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO, crypto_request_clone, struct crypto_async_request *,
+	(struct crypto_async_request *req, size_t total, gfp_t gfp),
+	(req, total, gfp));
 
 static inline void crypto_stack_request_init(struct crypto_async_request *req,
 					     struct crypto_tfm *tfm)
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 002/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_AES crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
  2026-02-12  2:45 ` [PATCH 001/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO and CONFIG_CRYPTO_ALGAPI2 crypto Jay Wang
@ 2026-02-12  2:45 ` Jay Wang
  2026-02-12  2:45 ` [PATCH 003/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_AEAD2 crypto Jay Wang
                   ` (103 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:45 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_AES-related crypto to convert them into pluggable
interface.

This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.

Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/aes.c    | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 88de6dcbd7c4..da5a7a4aa59b 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -134,7 +134,7 @@ obj-$(CONFIG_CRYPTO_TWOFISH) += twofish_generic.o
 obj-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o
 obj-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o
 CFLAGS_serpent_generic.o := $(call cc-option,-fsched-pressure)  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149
-obj-$(CONFIG_CRYPTO_AES) += aes.o
+crypto-objs-$(CONFIG_CRYPTO_AES) += aes.o
 obj-$(CONFIG_CRYPTO_SM4) += sm4.o
 obj-$(CONFIG_CRYPTO_SM4_GENERIC) += sm4_generic.o
 obj-$(CONFIG_CRYPTO_CAMELLIA) += camellia_generic.o
diff --git a/crypto/aes.c b/crypto/aes.c
index ae8385df0ce5..bda6a1cba552 100644
--- a/crypto/aes.c
+++ b/crypto/aes.c
@@ -52,13 +52,13 @@ static int __init crypto_aes_mod_init(void)
 {
 	return crypto_register_alg(&alg);
 }
-module_init(crypto_aes_mod_init);
+crypto_module_init(crypto_aes_mod_init);
 
 static void __exit crypto_aes_mod_exit(void)
 {
 	crypto_unregister_alg(&alg);
 }
-module_exit(crypto_aes_mod_exit);
+crypto_module_exit(crypto_aes_mod_exit);
 
 MODULE_DESCRIPTION("Crypto API support for AES block cipher");
 MODULE_LICENSE("GPL");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 003/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_AEAD2 crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
  2026-02-12  2:45 ` [PATCH 001/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO and CONFIG_CRYPTO_ALGAPI2 crypto Jay Wang
  2026-02-12  2:45 ` [PATCH 002/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_AES crypto Jay Wang
@ 2026-02-12  2:45 ` Jay Wang
  2026-02-12  2:45 ` [PATCH 004/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_GENIV crypto Jay Wang
                   ` (102 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:45 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_AEAD2-related crypto to convert them into pluggable
interface.

This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.

Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile                |  2 +-
 crypto/fips140/fips140-api.c   | 26 ++++++++++++++++++++++++++
 include/crypto/aead.h          | 30 ++++++++++++++++++++++--------
 include/crypto/internal/aead.h | 28 +++++++++++++++++++---------
 4 files changed, 68 insertions(+), 18 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index da5a7a4aa59b..9aa52ddebb05 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -15,7 +15,7 @@ crypto_algapi-$(CONFIG_PROC_FS) += proc.o
 crypto_algapi-y := algapi.o scatterwalk.o $(crypto_algapi-y)
 crypto-objs-$(CONFIG_CRYPTO_ALGAPI2) += crypto_algapi.o
 
-obj-$(CONFIG_CRYPTO_AEAD2) += aead.o
+crypto-objs-$(CONFIG_CRYPTO_AEAD2) += aead.o
 obj-$(CONFIG_CRYPTO_GENIV) += geniv.o
 
 crypto_skcipher-y += lskcipher.o
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 8a0e1d28615c..eb02a56cb8b3 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -103,4 +103,30 @@ DEFINE_CRYPTO_API_STUB(crypto_remove_final);
 DEFINE_CRYPTO_API_STUB(crypto_alg_extsize);
 DEFINE_CRYPTO_API_STUB(crypto_type_has_alg);
 
+#endif
+
+/*
+ * crypto/aead.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_AEAD2)
+
+#include <crypto/aead.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_alloc_aead);
+DEFINE_CRYPTO_API_STUB(crypto_alloc_sync_aead);
+DEFINE_CRYPTO_API_STUB(crypto_has_aead);
+DEFINE_CRYPTO_API_STUB(crypto_aead_setkey);
+DEFINE_CRYPTO_API_STUB(crypto_aead_setauthsize);
+DEFINE_CRYPTO_API_STUB(crypto_aead_encrypt);
+DEFINE_CRYPTO_API_STUB(crypto_aead_decrypt);
+
+#include <crypto/internal/aead.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_grab_aead);
+DEFINE_CRYPTO_API_STUB(crypto_register_aead);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_aead);
+DEFINE_CRYPTO_API_STUB(crypto_register_aeads);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_aeads);
+DEFINE_CRYPTO_API_STUB(aead_register_instance);
+
 #endif
\ No newline at end of file
diff --git a/include/crypto/aead.h b/include/crypto/aead.h
index 8e66a1fa9c78..2d3e2bde5c1d 100644
--- a/include/crypto/aead.h
+++ b/include/crypto/aead.h
@@ -8,6 +8,7 @@
 #ifndef _CRYPTO_AEAD_H
 #define _CRYPTO_AEAD_H
 
+#include <crypto/api.h>
 #include <linux/atomic.h>
 #include <linux/container_of.h>
 #include <linux/crypto.h>
@@ -193,9 +194,13 @@ static inline struct crypto_aead *__crypto_aead_cast(struct crypto_tfm *tfm)
  * 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_aead *crypto_alloc_aead(const char *alg_name, u32 type, u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_AEAD2, crypto_alloc_aead, struct crypto_aead *,
+	(const char *alg_name, u32 type, u32 mask),
+	(alg_name, type, mask));
 
-struct crypto_sync_aead *crypto_alloc_sync_aead(const char *alg_name, u32 type, u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_AEAD2, crypto_alloc_sync_aead, struct crypto_sync_aead *,
+	(const char *alg_name, u32 type, u32 mask),
+	(alg_name, type, mask));
 
 static inline struct crypto_tfm *crypto_aead_tfm(struct crypto_aead *tfm)
 {
@@ -233,7 +238,9 @@ static inline void crypto_free_sync_aead(struct crypto_sync_aead *tfm)
  * Return: true when the aead is known to the kernel crypto API; false
  *	   otherwise
  */
-int crypto_has_aead(const char *alg_name, u32 type, u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_AEAD2, crypto_has_aead, int,
+	(const char *alg_name, u32 type, u32 mask),
+	(alg_name, type, mask));
 
 static inline const char *crypto_aead_driver_name(struct crypto_aead *tfm)
 {
@@ -378,8 +385,9 @@ static inline void crypto_sync_aead_clear_flags(struct crypto_sync_aead *tfm, u3
  *
  * Return: 0 if the setting of the key was successful; < 0 if an error occurred
  */
-int crypto_aead_setkey(struct crypto_aead *tfm,
-		       const u8 *key, unsigned int keylen);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_AEAD2, crypto_aead_setkey, int,
+	(struct crypto_aead *tfm, const u8 *key, unsigned int keylen),
+	(tfm, key, keylen));
 
 static inline int crypto_sync_aead_setkey(struct crypto_sync_aead *tfm,
 					 const u8 *key, unsigned int keylen)
@@ -397,7 +405,9 @@ static inline int crypto_sync_aead_setkey(struct crypto_sync_aead *tfm,
  *
  * Return: 0 if the setting of the key was successful; < 0 if an error occurred
  */
-int crypto_aead_setauthsize(struct crypto_aead *tfm, unsigned int authsize);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_AEAD2, crypto_aead_setauthsize, int,
+	(struct crypto_aead *tfm, unsigned int authsize),
+	(tfm, authsize));
 
 static inline int crypto_sync_aead_setauthsize(struct crypto_sync_aead *tfm,
 					       unsigned int authsize)
@@ -436,7 +446,9 @@ static inline struct crypto_sync_aead *crypto_sync_aead_reqtfm(struct aead_reque
  *
  * Return: 0 if the cipher operation was successful; < 0 if an error occurred
  */
-int crypto_aead_encrypt(struct aead_request *req);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_AEAD2, crypto_aead_encrypt, int,
+	(struct aead_request *req),
+	(req));
 
 /**
  * crypto_aead_decrypt() - decrypt ciphertext
@@ -460,7 +472,9 @@ int crypto_aead_encrypt(struct aead_request *req);
  *	   integrity of the ciphertext or the associated data was violated);
  *	   < 0 if an error occurred.
  */
-int crypto_aead_decrypt(struct aead_request *req);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_AEAD2, crypto_aead_decrypt, int,
+	(struct aead_request *req),
+	(req));
 
 /**
  * DOC: Asynchronous AEAD Request Handle
diff --git a/include/crypto/internal/aead.h b/include/crypto/internal/aead.h
index 28a95eb3182d..773e6dbb34d6 100644
--- a/include/crypto/internal/aead.h
+++ b/include/crypto/internal/aead.h
@@ -8,6 +8,7 @@
 #ifndef _CRYPTO_INTERNAL_AEAD_H
 #define _CRYPTO_INTERNAL_AEAD_H
 
+#include <crypto/api.h>
 #include <crypto/aead.h>
 #include <crypto/algapi.h>
 #include <linux/stddef.h>
@@ -96,9 +97,9 @@ static inline struct aead_request *aead_request_cast(
 	return container_of(req, struct aead_request, base);
 }
 
-int crypto_grab_aead(struct crypto_aead_spawn *spawn,
-		     struct crypto_instance *inst,
-		     const char *name, u32 type, u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_AEAD2, crypto_grab_aead, int,
+	(struct crypto_aead_spawn *spawn, struct crypto_instance *inst, const char *name, u32 type, u32 mask),
+	(spawn, inst, name, type, mask));
 
 static inline void crypto_drop_aead(struct crypto_aead_spawn *spawn)
 {
@@ -157,12 +158,21 @@ static inline unsigned int crypto_aead_chunksize(struct crypto_aead *tfm)
 	return crypto_aead_alg_chunksize(crypto_aead_alg(tfm));
 }
 
-int crypto_register_aead(struct aead_alg *alg);
-void crypto_unregister_aead(struct aead_alg *alg);
-int crypto_register_aeads(struct aead_alg *algs, int count);
-void crypto_unregister_aeads(struct aead_alg *algs, int count);
-int aead_register_instance(struct crypto_template *tmpl,
-			   struct aead_instance *inst);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_AEAD2, crypto_register_aead, int,
+	(struct aead_alg *alg),
+	(alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_AEAD2, crypto_unregister_aead, void,
+	(struct aead_alg *alg),
+	(alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_AEAD2, crypto_register_aeads, int,
+	(struct aead_alg *algs, int count),
+	(algs, count));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_AEAD2, crypto_unregister_aeads, void,
+	(struct aead_alg *algs, int count),
+	(algs, count));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_AEAD2, aead_register_instance, int,
+	(struct crypto_template *tmpl, struct aead_instance *inst),
+	(tmpl, inst));
 
 #endif	/* _CRYPTO_INTERNAL_AEAD_H */
 
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 004/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_GENIV crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (2 preceding siblings ...)
  2026-02-12  2:45 ` [PATCH 003/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_AEAD2 crypto Jay Wang
@ 2026-02-12  2:45 ` Jay Wang
  2026-02-12  2:45 ` [PATCH 005/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SKCIPHER2 crypto Jay Wang
                   ` (101 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:45 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_GENIV-related crypto to convert them into pluggable
interface.

This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.

Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile                 |  2 +-
 crypto/fips140/fips140-api.c    | 13 +++++++++++++
 include/crypto/internal/geniv.h | 14 ++++++++++----
 3 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 9aa52ddebb05..b05fdfacf170 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -16,7 +16,7 @@ crypto_algapi-y := algapi.o scatterwalk.o $(crypto_algapi-y)
 crypto-objs-$(CONFIG_CRYPTO_ALGAPI2) += crypto_algapi.o
 
 crypto-objs-$(CONFIG_CRYPTO_AEAD2) += aead.o
-obj-$(CONFIG_CRYPTO_GENIV) += geniv.o
+crypto-objs-$(CONFIG_CRYPTO_GENIV) += geniv.o
 
 crypto_skcipher-y += lskcipher.o
 crypto_skcipher-y += skcipher.o
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index eb02a56cb8b3..55129c62d813 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -129,4 +129,17 @@ DEFINE_CRYPTO_API_STUB(crypto_register_aeads);
 DEFINE_CRYPTO_API_STUB(crypto_unregister_aeads);
 DEFINE_CRYPTO_API_STUB(aead_register_instance);
 
+#endif
+
+/*
+ * crypto/geniv.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_GENIV)
+
+#include <crypto/internal/geniv.h>
+
+DEFINE_CRYPTO_API_STUB(aead_geniv_alloc);
+DEFINE_CRYPTO_API_STUB(aead_init_geniv);
+DEFINE_CRYPTO_API_STUB(aead_exit_geniv);
+
 #endif
\ No newline at end of file
diff --git a/include/crypto/internal/geniv.h b/include/crypto/internal/geniv.h
index 012f5fb22d43..f6dfe3292b3c 100644
--- a/include/crypto/internal/geniv.h
+++ b/include/crypto/internal/geniv.h
@@ -8,6 +8,7 @@
 #ifndef _CRYPTO_INTERNAL_GENIV_H
 #define _CRYPTO_INTERNAL_GENIV_H
 
+#include <crypto/api.h>
 #include <crypto/internal/aead.h>
 #include <linux/spinlock.h>
 #include <linux/types.h>
@@ -18,9 +19,14 @@ struct aead_geniv_ctx {
 	u8 salt[] __attribute__ ((aligned(__alignof__(u32))));
 };
 
-struct aead_instance *aead_geniv_alloc(struct crypto_template *tmpl,
-				       struct rtattr **tb);
-int aead_init_geniv(struct crypto_aead *tfm);
-void aead_exit_geniv(struct crypto_aead *tfm);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_GENIV, aead_geniv_alloc, struct aead_instance *,
+	(struct crypto_template *tmpl, struct rtattr **tb),
+	(tmpl, tb));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_GENIV, aead_init_geniv, int,
+	(struct crypto_aead *tfm),
+	(tfm));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_GENIV, aead_exit_geniv, void,
+	(struct crypto_aead *tfm),
+	(tfm));
 
 #endif	/* _CRYPTO_INTERNAL_GENIV_H */
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 005/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SKCIPHER2 crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (3 preceding siblings ...)
  2026-02-12  2:45 ` [PATCH 004/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_GENIV crypto Jay Wang
@ 2026-02-12  2:45 ` Jay Wang
  2026-02-12  2:45 ` [PATCH 006/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SEQIV crypto Jay Wang
                   ` (100 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:45 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_SKCIPHER2-related crypto to convert them into pluggable
interface.

This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.

Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile                    |  4 +-
 crypto/bpf_crypto_skcipher.c       |  4 +-
 crypto/fips140/fips140-api.c       | 47 +++++++++++++++
 include/crypto/internal/skcipher.h | 91 +++++++++++++++++++-----------
 include/crypto/skcipher.h          | 56 +++++++++++-------
 5 files changed, 145 insertions(+), 57 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index b05fdfacf170..546f80e014e1 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -21,9 +21,9 @@ crypto-objs-$(CONFIG_CRYPTO_GENIV) += geniv.o
 crypto_skcipher-y += lskcipher.o
 crypto_skcipher-y += skcipher.o
 
-obj-$(CONFIG_CRYPTO_SKCIPHER2) += crypto_skcipher.o
+crypto-objs-$(CONFIG_CRYPTO_SKCIPHER2) += crypto_skcipher.o
 ifeq ($(CONFIG_BPF_SYSCALL),y)
-obj-$(CONFIG_CRYPTO_SKCIPHER2) += bpf_crypto_skcipher.o
+crypto-objs-$(CONFIG_CRYPTO_SKCIPHER2) += bpf_crypto_skcipher.o
 endif
 
 obj-$(CONFIG_CRYPTO_SEQIV) += seqiv.o
diff --git a/crypto/bpf_crypto_skcipher.c b/crypto/bpf_crypto_skcipher.c
index a88798d3e8c8..764bfc27e477 100644
--- a/crypto/bpf_crypto_skcipher.c
+++ b/crypto/bpf_crypto_skcipher.c
@@ -77,7 +77,7 @@ static void __exit bpf_crypto_skcipher_exit(void)
 	WARN_ON_ONCE(err);
 }
 
-module_init(bpf_crypto_skcipher_init);
-module_exit(bpf_crypto_skcipher_exit);
+crypto_module_init(bpf_crypto_skcipher_init);
+crypto_module_exit(bpf_crypto_skcipher_exit);
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Symmetric key cipher support for BPF");
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 55129c62d813..e256b0f3e4a6 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -142,4 +142,51 @@ DEFINE_CRYPTO_API_STUB(aead_geniv_alloc);
 DEFINE_CRYPTO_API_STUB(aead_init_geniv);
 DEFINE_CRYPTO_API_STUB(aead_exit_geniv);
 
+#endif
+
+/*
+ * crypto/lskcipher.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_SKCIPHER2)
+
+#include <crypto/skcipher.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_alloc_lskcipher);
+DEFINE_CRYPTO_API_STUB(crypto_lskcipher_setkey);
+DEFINE_CRYPTO_API_STUB(crypto_lskcipher_encrypt);
+DEFINE_CRYPTO_API_STUB(crypto_lskcipher_decrypt);
+
+#include <crypto/internal/skcipher.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_grab_lskcipher);
+DEFINE_CRYPTO_API_STUB(crypto_register_lskcipher);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_lskcipher);
+DEFINE_CRYPTO_API_STUB(crypto_register_lskciphers);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_lskciphers);
+DEFINE_CRYPTO_API_STUB(lskcipher_register_instance);
+DEFINE_CRYPTO_API_STUB(lskcipher_alloc_instance_simple);
+
+/*
+ * crypto/skcipher.c
+ */
+DEFINE_CRYPTO_API_STUB(crypto_alloc_skcipher);
+DEFINE_CRYPTO_API_STUB(crypto_alloc_sync_skcipher);
+DEFINE_CRYPTO_API_STUB(crypto_has_skcipher);
+DEFINE_CRYPTO_API_STUB(crypto_skcipher_setkey);
+DEFINE_CRYPTO_API_STUB(crypto_skcipher_encrypt);
+DEFINE_CRYPTO_API_STUB(crypto_skcipher_decrypt);
+DEFINE_CRYPTO_API_STUB(crypto_skcipher_export);
+DEFINE_CRYPTO_API_STUB(crypto_skcipher_import);
+DEFINE_CRYPTO_API_STUB(crypto_grab_skcipher);
+DEFINE_CRYPTO_API_STUB(crypto_register_skcipher);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_skcipher);
+DEFINE_CRYPTO_API_STUB(crypto_register_skciphers);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_skciphers);
+DEFINE_CRYPTO_API_STUB(skcipher_register_instance);
+DEFINE_CRYPTO_API_STUB(skcipher_walk_done);
+DEFINE_CRYPTO_API_STUB(skcipher_walk_virt);
+DEFINE_CRYPTO_API_STUB(skcipher_walk_aead_encrypt);
+DEFINE_CRYPTO_API_STUB(skcipher_walk_aead_decrypt);
+DEFINE_CRYPTO_API_STUB(skcipher_alloc_instance_simple);
+
 #endif
\ No newline at end of file
diff --git a/include/crypto/internal/skcipher.h b/include/crypto/internal/skcipher.h
index a965b6aabf61..b571c58269bc 100644
--- a/include/crypto/internal/skcipher.h
+++ b/include/crypto/internal/skcipher.h
@@ -8,6 +8,7 @@
 #ifndef _CRYPTO_INTERNAL_SKCIPHER_H
 #define _CRYPTO_INTERNAL_SKCIPHER_H
 
+#include <crypto/api.h>
 #include <crypto/algapi.h>
 #include <crypto/internal/cipher.h>
 #include <crypto/skcipher.h>
@@ -136,13 +137,13 @@ static inline void skcipher_request_complete(struct skcipher_request *req, int e
 	crypto_request_complete(&req->base, err);
 }
 
-int crypto_grab_skcipher(struct crypto_skcipher_spawn *spawn,
-			 struct crypto_instance *inst,
-			 const char *name, u32 type, u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, crypto_grab_skcipher, int,
+	(struct crypto_skcipher_spawn *spawn, struct crypto_instance *inst, const char *name, u32 type, u32 mask),
+	(spawn, inst, name, type, mask));
 
-int crypto_grab_lskcipher(struct crypto_lskcipher_spawn *spawn,
-			  struct crypto_instance *inst,
-			  const char *name, u32 type, u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, crypto_grab_lskcipher, int,
+	(struct crypto_lskcipher_spawn *spawn, struct crypto_instance *inst, const char *name, u32 type, u32 mask),
+	(spawn, inst, name, type, mask));
 
 static inline void crypto_drop_skcipher(struct crypto_skcipher_spawn *spawn)
 {
@@ -197,30 +198,50 @@ static inline void crypto_skcipher_set_reqsize_dma(
 	skcipher->reqsize = reqsize;
 }
 
-int crypto_register_skcipher(struct skcipher_alg *alg);
-void crypto_unregister_skcipher(struct skcipher_alg *alg);
-int crypto_register_skciphers(struct skcipher_alg *algs, int count);
-void crypto_unregister_skciphers(struct skcipher_alg *algs, int count);
-int skcipher_register_instance(struct crypto_template *tmpl,
-			       struct skcipher_instance *inst);
-
-int crypto_register_lskcipher(struct lskcipher_alg *alg);
-void crypto_unregister_lskcipher(struct lskcipher_alg *alg);
-int crypto_register_lskciphers(struct lskcipher_alg *algs, int count);
-void crypto_unregister_lskciphers(struct lskcipher_alg *algs, int count);
-int lskcipher_register_instance(struct crypto_template *tmpl,
-				struct lskcipher_instance *inst);
-
-int skcipher_walk_done(struct skcipher_walk *walk, int res);
-int skcipher_walk_virt(struct skcipher_walk *__restrict walk,
-		       struct skcipher_request *__restrict req,
-		       bool atomic);
-int skcipher_walk_aead_encrypt(struct skcipher_walk *__restrict walk,
-			       struct aead_request *__restrict req,
-			       bool atomic);
-int skcipher_walk_aead_decrypt(struct skcipher_walk *__restrict walk,
-			       struct aead_request *__restrict req,
-			       bool atomic);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, crypto_register_skcipher, int,
+	(struct skcipher_alg *alg),
+	(alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, crypto_unregister_skcipher, void,
+	(struct skcipher_alg *alg),
+	(alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, crypto_register_skciphers, int,
+	(struct skcipher_alg *algs, int count),
+	(algs, count));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, crypto_unregister_skciphers, void,
+	(struct skcipher_alg *algs, int count),
+	(algs, count));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, skcipher_register_instance, int,
+	(struct crypto_template *tmpl, struct skcipher_instance *inst),
+	(tmpl, inst));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, crypto_register_lskcipher, int,
+	(struct lskcipher_alg *alg),
+	(alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, crypto_unregister_lskcipher, void,
+	(struct lskcipher_alg *alg),
+	(alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, crypto_register_lskciphers, int,
+	(struct lskcipher_alg *algs, int count),
+	(algs, count));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, crypto_unregister_lskciphers, void,
+	(struct lskcipher_alg *algs, int count),
+	(algs, count));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, lskcipher_register_instance, int,
+	(struct crypto_template *tmpl, struct lskcipher_instance *inst),
+	(tmpl, inst));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, skcipher_walk_done, int,
+	(struct skcipher_walk *walk, int res),
+	(walk, res));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, skcipher_walk_virt, int,
+	(struct skcipher_walk *__restrict walk, struct skcipher_request *__restrict req, bool atomic),
+	(walk, req, atomic));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, skcipher_walk_aead_encrypt, int,
+	(struct skcipher_walk *__restrict walk, struct aead_request *__restrict req, bool atomic),
+	(walk, req, atomic));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, skcipher_walk_aead_decrypt, int,
+	(struct skcipher_walk *__restrict walk, struct aead_request *__restrict req, bool atomic),
+	(walk, req, atomic));
 
 static inline void skcipher_walk_abort(struct skcipher_walk *walk)
 {
@@ -281,8 +302,9 @@ skcipher_cipher_simple(struct crypto_skcipher *tfm)
 	return ctx->cipher;
 }
 
-struct skcipher_instance *skcipher_alloc_instance_simple(
-	struct crypto_template *tmpl, struct rtattr **tb);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, skcipher_alloc_instance_simple, struct skcipher_instance *,
+	(struct crypto_template *tmpl, struct rtattr **tb),
+	(tmpl, tb));
 
 static inline struct crypto_alg *skcipher_ialg_simple(
 	struct skcipher_instance *inst)
@@ -300,8 +322,9 @@ static inline struct crypto_lskcipher *lskcipher_cipher_simple(
 	return *ctx;
 }
 
-struct lskcipher_instance *lskcipher_alloc_instance_simple(
-	struct crypto_template *tmpl, struct rtattr **tb);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, lskcipher_alloc_instance_simple, struct lskcipher_instance *,
+	(struct crypto_template *tmpl, struct rtattr **tb),
+	(tmpl, tb));
 
 static inline struct lskcipher_alg *lskcipher_ialg_simple(
 	struct lskcipher_instance *inst)
diff --git a/include/crypto/skcipher.h b/include/crypto/skcipher.h
index 9e5853464345..39282b83a280 100644
--- a/include/crypto/skcipher.h
+++ b/include/crypto/skcipher.h
@@ -8,6 +8,7 @@
 #ifndef _CRYPTO_SKCIPHER_H
 #define _CRYPTO_SKCIPHER_H
 
+#include <crypto/api.h>
 #include <linux/atomic.h>
 #include <linux/container_of.h>
 #include <linux/crypto.h>
@@ -276,11 +277,13 @@ static inline struct crypto_skcipher *__crypto_skcipher_cast(
  * 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_skcipher *crypto_alloc_skcipher(const char *alg_name,
-					      u32 type, u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, crypto_alloc_skcipher, struct crypto_skcipher *,
+	(const char *alg_name, u32 type, u32 mask),
+	(alg_name, type, mask));
 
-struct crypto_sync_skcipher *crypto_alloc_sync_skcipher(const char *alg_name,
-					      u32 type, u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, crypto_alloc_sync_skcipher, struct crypto_sync_skcipher *,
+	(const char *alg_name, u32 type, u32 mask),
+	(alg_name, type, mask));
 
 
 /**
@@ -297,8 +300,9 @@ struct crypto_sync_skcipher *crypto_alloc_sync_skcipher(const char *alg_name,
  * 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_lskcipher *crypto_alloc_lskcipher(const char *alg_name,
-						u32 type, u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, crypto_alloc_lskcipher, struct crypto_lskcipher *,
+	(const char *alg_name, u32 type, u32 mask),
+	(alg_name, type, mask));
 
 static inline struct crypto_tfm *crypto_skcipher_tfm(
 	struct crypto_skcipher *tfm)
@@ -355,7 +359,9 @@ static inline void crypto_free_lskcipher(struct crypto_lskcipher *tfm)
  * Return: true when the skcipher is known to the kernel crypto API; false
  *	   otherwise
  */
-int crypto_has_skcipher(const char *alg_name, u32 type, u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, crypto_has_skcipher, int,
+	(const char *alg_name, u32 type, u32 mask),
+	(alg_name, type, mask));
 
 static inline const char *crypto_skcipher_driver_name(
 	struct crypto_skcipher *tfm)
@@ -611,8 +617,9 @@ static inline void crypto_lskcipher_clear_flags(struct crypto_lskcipher *tfm,
  *
  * Return: 0 if the setting of the key was successful; < 0 if an error occurred
  */
-int crypto_skcipher_setkey(struct crypto_skcipher *tfm,
-			   const u8 *key, unsigned int keylen);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, crypto_skcipher_setkey, int,
+	(struct crypto_skcipher *tfm, const u8 *key, unsigned int keylen),
+	(tfm, key, keylen));
 
 static inline int crypto_sync_skcipher_setkey(struct crypto_sync_skcipher *tfm,
 					 const u8 *key, unsigned int keylen)
@@ -636,8 +643,9 @@ static inline int crypto_sync_skcipher_setkey(struct crypto_sync_skcipher *tfm,
  *
  * Return: 0 if the setting of the key was successful; < 0 if an error occurred
  */
-int crypto_lskcipher_setkey(struct crypto_lskcipher *tfm,
-			    const u8 *key, unsigned int keylen);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, crypto_lskcipher_setkey, int,
+	(struct crypto_lskcipher *tfm, const u8 *key, unsigned int keylen),
+	(tfm, key, keylen));
 
 static inline unsigned int crypto_skcipher_min_keysize(
 	struct crypto_skcipher *tfm)
@@ -697,7 +705,9 @@ static inline struct crypto_sync_skcipher *crypto_sync_skcipher_reqtfm(
  *
  * Return: 0 if the cipher operation was successful; < 0 if an error occurred
  */
-int crypto_skcipher_encrypt(struct skcipher_request *req);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, crypto_skcipher_encrypt, int,
+	(struct skcipher_request *req),
+	(req));
 
 /**
  * crypto_skcipher_decrypt() - decrypt ciphertext
@@ -710,7 +720,9 @@ int crypto_skcipher_encrypt(struct skcipher_request *req);
  *
  * Return: 0 if the cipher operation was successful; < 0 if an error occurred
  */
-int crypto_skcipher_decrypt(struct skcipher_request *req);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, crypto_skcipher_decrypt, int,
+	(struct skcipher_request *req),
+	(req));
 
 /**
  * crypto_skcipher_export() - export partial state
@@ -728,7 +740,9 @@ int crypto_skcipher_decrypt(struct skcipher_request *req);
  *
  * Return: 0 if the cipher operation was successful; < 0 if an error occurred
  */
-int crypto_skcipher_export(struct skcipher_request *req, void *out);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, crypto_skcipher_export, int,
+	(struct skcipher_request *req, void *out),
+	(req, out));
 
 /**
  * crypto_skcipher_import() - import partial state
@@ -743,7 +757,9 @@ int crypto_skcipher_export(struct skcipher_request *req, void *out);
  *
  * Return: 0 if the cipher operation was successful; < 0 if an error occurred
  */
-int crypto_skcipher_import(struct skcipher_request *req, const void *in);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, crypto_skcipher_import, int,
+	(struct skcipher_request *req, const void *in),
+	(req, in));
 
 /**
  * crypto_lskcipher_encrypt() - encrypt plaintext
@@ -761,8 +777,9 @@ int crypto_skcipher_import(struct skcipher_request *req, const void *in);
  *	   then this many bytes have been left unprocessed;
  *	   < 0 if an error occurred
  */
-int crypto_lskcipher_encrypt(struct crypto_lskcipher *tfm, const u8 *src,
-			     u8 *dst, unsigned len, u8 *siv);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, crypto_lskcipher_encrypt, int,
+	(struct crypto_lskcipher *tfm, const u8 *src, u8 *dst, unsigned len, u8 *siv),
+	(tfm, src, dst, len, siv));
 
 /**
  * crypto_lskcipher_decrypt() - decrypt ciphertext
@@ -781,8 +798,9 @@ int crypto_lskcipher_encrypt(struct crypto_lskcipher *tfm, const u8 *src,
  *	   then this many bytes have been left unprocessed;
  *	   < 0 if an error occurred
  */
-int crypto_lskcipher_decrypt(struct crypto_lskcipher *tfm, const u8 *src,
-			     u8 *dst, unsigned len, u8 *siv);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SKCIPHER2, crypto_lskcipher_decrypt, int,
+	(struct crypto_lskcipher *tfm, const u8 *src, u8 *dst, unsigned len, u8 *siv),
+	(tfm, src, dst, len, siv));
 
 /**
  * DOC: Symmetric Key Cipher Request Handle
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 006/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SEQIV crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (4 preceding siblings ...)
  2026-02-12  2:45 ` [PATCH 005/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SKCIPHER2 crypto Jay Wang
@ 2026-02-12  2:45 ` Jay Wang
  2026-02-12  2:45 ` [PATCH 007/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ECHAINIV crypto Jay Wang
                   ` (99 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:45 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

From: Vegard Nossum <vegard.nossum@oracle.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_SEQIV-related crypto to convert them into pluggable
interface.

Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[add seqiv.o into crypto-objs-y; revise commit message]
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/seqiv.c  | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 546f80e014e1..4d6f1c927db4 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -26,7 +26,7 @@ ifeq ($(CONFIG_BPF_SYSCALL),y)
 crypto-objs-$(CONFIG_CRYPTO_SKCIPHER2) += bpf_crypto_skcipher.o
 endif
 
-obj-$(CONFIG_CRYPTO_SEQIV) += seqiv.o
+crypto-objs-$(CONFIG_CRYPTO_SEQIV) += seqiv.o
 obj-$(CONFIG_CRYPTO_ECHAINIV) += echainiv.o
 
 crypto_hash-y += ahash.o
diff --git a/crypto/seqiv.c b/crypto/seqiv.c
index 678bb4145d78..5db32c596c40 100644
--- a/crypto/seqiv.c
+++ b/crypto/seqiv.c
@@ -170,8 +170,8 @@ static void __exit seqiv_module_exit(void)
 	crypto_unregister_template(&seqiv_tmpl);
 }
 
-module_init(seqiv_module_init);
-module_exit(seqiv_module_exit);
+crypto_module_init(seqiv_module_init);
+crypto_module_exit(seqiv_module_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Sequence Number IV Generator");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 007/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ECHAINIV crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (5 preceding siblings ...)
  2026-02-12  2:45 ` [PATCH 006/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SEQIV crypto Jay Wang
@ 2026-02-12  2:45 ` Jay Wang
  2026-02-12  2:45 ` [PATCH 008/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_HASH2 crypto Jay Wang
                   ` (98 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:45 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

From: Vegard Nossum <vegard.nossum@oracle.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_ECHAINIV-related crypto to convert them into pluggable
interface.

Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[add echainiv.o into crypto-objs-y; revise commit message]
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile   | 2 +-
 crypto/echainiv.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 4d6f1c927db4..f14758177ee3 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -27,7 +27,7 @@ crypto-objs-$(CONFIG_CRYPTO_SKCIPHER2) += bpf_crypto_skcipher.o
 endif
 
 crypto-objs-$(CONFIG_CRYPTO_SEQIV) += seqiv.o
-obj-$(CONFIG_CRYPTO_ECHAINIV) += echainiv.o
+crypto-objs-$(CONFIG_CRYPTO_ECHAINIV) += echainiv.o
 
 crypto_hash-y += ahash.o
 crypto_hash-y += shash.o
diff --git a/crypto/echainiv.c b/crypto/echainiv.c
index e0a2d3209938..d409b4169e83 100644
--- a/crypto/echainiv.c
+++ b/crypto/echainiv.c
@@ -145,8 +145,8 @@ static void __exit echainiv_module_exit(void)
 	crypto_unregister_template(&echainiv_tmpl);
 }
 
-module_init(echainiv_module_init);
-module_exit(echainiv_module_exit);
+crypto_module_init(echainiv_module_init);
+crypto_module_exit(echainiv_module_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Encrypted Chain IV Generator");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 008/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_HASH2 crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (6 preceding siblings ...)
  2026-02-12  2:45 ` [PATCH 007/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ECHAINIV crypto Jay Wang
@ 2026-02-12  2:45 ` Jay Wang
  2026-02-12  2:45 ` [PATCH 009/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_AKCIPHER2 crypto Jay Wang
                   ` (97 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:45 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_HASH2-related crypto to convert them into pluggable
interface.

This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.

Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile                |  2 +-
 crypto/fips140/fips140-api.c   | 63 ++++++++++++++++++++++++++++++++++
 include/crypto/hash.h          | 53 +++++++++++++---------------
 include/crypto/internal/hash.h | 59 ++++++++++++++-----------------
 4 files changed, 113 insertions(+), 64 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index f14758177ee3..210e4aa3dbac 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -31,7 +31,7 @@ crypto-objs-$(CONFIG_CRYPTO_ECHAINIV) += echainiv.o
 
 crypto_hash-y += ahash.o
 crypto_hash-y += shash.o
-obj-$(CONFIG_CRYPTO_HASH2) += crypto_hash.o
+crypto-objs-$(CONFIG_CRYPTO_HASH2) += crypto_hash.o
 
 obj-$(CONFIG_CRYPTO_AKCIPHER2) += akcipher.o
 obj-$(CONFIG_CRYPTO_SIG2) += sig.o
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index e256b0f3e4a6..e1c2f709ad3b 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -189,4 +189,67 @@ DEFINE_CRYPTO_API_STUB(skcipher_walk_aead_encrypt);
 DEFINE_CRYPTO_API_STUB(skcipher_walk_aead_decrypt);
 DEFINE_CRYPTO_API_STUB(skcipher_alloc_instance_simple);
 
+#endif
+
+/*
+ * crypto/ahash.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_HASH2)
+
+#include <crypto/hash.h>
+#include <crypto/internal/hash.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_hash_walk_first);
+DEFINE_CRYPTO_API_STUB(crypto_hash_walk_done);
+DEFINE_CRYPTO_API_STUB(shash_ahash_update);
+DEFINE_CRYPTO_API_STUB(shash_ahash_finup);
+DEFINE_CRYPTO_API_STUB(shash_ahash_digest);
+DEFINE_CRYPTO_API_STUB(crypto_ahash_setkey);
+DEFINE_CRYPTO_API_STUB(crypto_ahash_init);
+DEFINE_CRYPTO_API_STUB(crypto_ahash_update);
+DEFINE_CRYPTO_API_STUB(crypto_ahash_finup);
+DEFINE_CRYPTO_API_STUB(crypto_ahash_digest);
+DEFINE_CRYPTO_API_STUB(crypto_ahash_export_core);
+DEFINE_CRYPTO_API_STUB(crypto_ahash_export);
+DEFINE_CRYPTO_API_STUB(crypto_ahash_import_core);
+DEFINE_CRYPTO_API_STUB(crypto_ahash_import);
+DEFINE_CRYPTO_API_STUB(crypto_grab_ahash);
+DEFINE_CRYPTO_API_STUB(crypto_alloc_ahash);
+DEFINE_CRYPTO_API_STUB(crypto_has_ahash);
+DEFINE_CRYPTO_API_STUB(crypto_hash_alg_has_setkey);
+DEFINE_CRYPTO_API_STUB(crypto_clone_ahash);
+DEFINE_CRYPTO_API_STUB(crypto_register_ahash);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_ahash);
+DEFINE_CRYPTO_API_STUB(crypto_register_ahashes);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_ahashes);
+DEFINE_CRYPTO_API_STUB(ahash_register_instance);
+DEFINE_CRYPTO_API_STUB(ahash_request_free);
+DEFINE_CRYPTO_API_STUB(crypto_hash_digest);
+DEFINE_CRYPTO_API_STUB(ahash_free_singlespawn_instance);
+
+/*
+ * crypto/shash.c
+ */
+
+DEFINE_CRYPTO_API_STUB(shash_no_setkey);
+DEFINE_CRYPTO_API_STUB(crypto_shash_setkey);
+DEFINE_CRYPTO_API_STUB(crypto_shash_init);
+DEFINE_CRYPTO_API_STUB(crypto_shash_finup);
+DEFINE_CRYPTO_API_STUB(crypto_shash_digest);
+DEFINE_CRYPTO_API_STUB(crypto_shash_tfm_digest);
+DEFINE_CRYPTO_API_STUB(crypto_shash_export_core);
+DEFINE_CRYPTO_API_STUB(crypto_shash_export);
+DEFINE_CRYPTO_API_STUB(crypto_shash_import_core);
+DEFINE_CRYPTO_API_STUB(crypto_shash_import);
+DEFINE_CRYPTO_API_STUB(crypto_grab_shash);
+DEFINE_CRYPTO_API_STUB(crypto_alloc_shash);
+DEFINE_CRYPTO_API_STUB(crypto_has_shash);
+DEFINE_CRYPTO_API_STUB(crypto_clone_shash);
+DEFINE_CRYPTO_API_STUB(crypto_register_shash);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_shash);
+DEFINE_CRYPTO_API_STUB(crypto_register_shashes);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_shashes);
+DEFINE_CRYPTO_API_STUB(shash_register_instance);
+DEFINE_CRYPTO_API_STUB(shash_free_singlespawn_instance);
+
 #endif
\ No newline at end of file
diff --git a/include/crypto/hash.h b/include/crypto/hash.h
index 586700332c73..10325879514a 100644
--- a/include/crypto/hash.h
+++ b/include/crypto/hash.h
@@ -8,6 +8,7 @@
 #ifndef _CRYPTO_HASH_H
 #define _CRYPTO_HASH_H
 
+#include <crypto/api.h>
 #include <linux/crypto.h>
 #include <linux/scatterlist.h>
 #include <linux/slab.h>
@@ -319,10 +320,9 @@ static inline struct crypto_ahash *__crypto_ahash_cast(struct crypto_tfm *tfm)
  * 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_ahash *crypto_alloc_ahash(const char *alg_name, u32 type,
-					u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_alloc_ahash, struct crypto_ahash *, (const char *alg_name, u32 type, u32 mask), (alg_name, type, mask));
 
-struct crypto_ahash *crypto_clone_ahash(struct crypto_ahash *tfm);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_clone_ahash, struct crypto_ahash *, (struct crypto_ahash *tfm), (tfm));
 
 static inline struct crypto_tfm *crypto_ahash_tfm(struct crypto_ahash *tfm)
 {
@@ -350,7 +350,7 @@ static inline void crypto_free_ahash(struct crypto_ahash *tfm)
  * Return: true when the ahash is known to the kernel crypto API; false
  *	   otherwise
  */
-int crypto_has_ahash(const char *alg_name, u32 type, u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_has_ahash, int, (const char *alg_name, u32 type, u32 mask), (alg_name, type, mask));
 
 static inline const char *crypto_ahash_alg_name(struct crypto_ahash *tfm)
 {
@@ -476,8 +476,7 @@ static inline void *ahash_request_ctx(struct ahash_request *req)
  *
  * Return: 0 if the setting of the key was successful; < 0 if an error occurred
  */
-int crypto_ahash_setkey(struct crypto_ahash *tfm, const u8 *key,
-			unsigned int keylen);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_ahash_setkey, int, (struct crypto_ahash *tfm, const u8 *key, unsigned int keylen), (tfm, key, keylen));
 
 /**
  * crypto_ahash_finup() - update and finalize message digest
@@ -490,7 +489,7 @@ int crypto_ahash_setkey(struct crypto_ahash *tfm, const u8 *key,
  *
  * Return: see crypto_ahash_final()
  */
-int crypto_ahash_finup(struct ahash_request *req);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_ahash_finup, int, (struct ahash_request *req), (req));
 
 /**
  * crypto_ahash_final() - calculate message digest
@@ -524,7 +523,7 @@ static inline int crypto_ahash_final(struct ahash_request *req)
  *
  * Return: see crypto_ahash_final()
  */
-int crypto_ahash_digest(struct ahash_request *req);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_ahash_digest, int, (struct ahash_request *req), (req));
 
 /**
  * crypto_ahash_export() - extract current message digest state
@@ -537,7 +536,7 @@ int crypto_ahash_digest(struct ahash_request *req);
  *
  * Return: 0 if the export was successful; < 0 if an error occurred
  */
-int crypto_ahash_export(struct ahash_request *req, void *out);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_ahash_export, int, (struct ahash_request *req, void *out), (req, out));
 
 /**
  * crypto_ahash_import() - import message digest state
@@ -550,7 +549,7 @@ int crypto_ahash_export(struct ahash_request *req, void *out);
  *
  * Return: 0 if the import was successful; < 0 if an error occurred
  */
-int crypto_ahash_import(struct ahash_request *req, const void *in);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_ahash_import, int, (struct ahash_request *req, const void *in), (req, in));
 
 /**
  * crypto_ahash_init() - (re)initialize message digest handle
@@ -563,7 +562,7 @@ int crypto_ahash_import(struct ahash_request *req, const void *in);
  *
  * Return: see crypto_ahash_final()
  */
-int crypto_ahash_init(struct ahash_request *req);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_ahash_init, int, (struct ahash_request *req), (req));
 
 /**
  * crypto_ahash_update() - add data to message digest for processing
@@ -576,7 +575,7 @@ int crypto_ahash_init(struct ahash_request *req);
  *
  * Return: see crypto_ahash_final()
  */
-int crypto_ahash_update(struct ahash_request *req);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_ahash_update, int, (struct ahash_request *req), (req));
 
 /**
  * DOC: Asynchronous Hash Request Handle
@@ -634,7 +633,7 @@ static inline struct ahash_request *ahash_request_alloc_noprof(
  * ahash_request_free() - zeroize and free the request data structure
  * @req: request data structure cipher handle to be freed
  */
-void ahash_request_free(struct ahash_request *req);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, ahash_request_free, void, (struct ahash_request *req), (req));
 
 static inline void ahash_request_zero(struct ahash_request *req)
 {
@@ -756,12 +755,11 @@ static inline void ahash_request_set_virt(struct ahash_request *req,
  * 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_shash *crypto_alloc_shash(const char *alg_name, u32 type,
-					u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_alloc_shash, struct crypto_shash *, (const char *alg_name, u32 type, u32 mask), (alg_name, type, mask));
 
-struct crypto_shash *crypto_clone_shash(struct crypto_shash *tfm);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_clone_shash, struct crypto_shash *, (struct crypto_shash *tfm), (tfm));
 
-int crypto_has_shash(const char *alg_name, u32 type, u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_has_shash, int, (const char *alg_name, u32 type, u32 mask), (alg_name, type, mask));
 
 static inline struct crypto_tfm *crypto_shash_tfm(struct crypto_shash *tfm)
 {
@@ -885,8 +883,7 @@ static inline void *shash_desc_ctx(struct shash_desc *desc)
  * Context: Softirq or process context.
  * Return: 0 if the setting of the key was successful; < 0 if an error occurred
  */
-int crypto_shash_setkey(struct crypto_shash *tfm, const u8 *key,
-			unsigned int keylen);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_shash_setkey, int, (struct crypto_shash *tfm, const u8 *key, unsigned int keylen), (tfm, key, keylen));
 
 /**
  * crypto_shash_digest() - calculate message digest for buffer
@@ -903,8 +900,7 @@ int crypto_shash_setkey(struct crypto_shash *tfm, const u8 *key,
  * Return: 0 if the message digest creation was successful; < 0 if an error
  *	   occurred
  */
-int crypto_shash_digest(struct shash_desc *desc, const u8 *data,
-			unsigned int len, u8 *out);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_shash_digest, int, (struct shash_desc *desc, const u8 *data, unsigned int len, u8 *out), (desc, data, len, out));
 
 /**
  * crypto_shash_tfm_digest() - calculate message digest for buffer
@@ -922,11 +918,9 @@ int crypto_shash_digest(struct shash_desc *desc, const u8 *data,
  * Context: Softirq or process context.
  * Return: 0 on success; < 0 if an error occurred.
  */
-int crypto_shash_tfm_digest(struct crypto_shash *tfm, const u8 *data,
-			    unsigned int len, u8 *out);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_shash_tfm_digest, int, (struct crypto_shash *tfm, const u8 *data, unsigned int len, u8 *out), (tfm, data, len, out));
 
-int crypto_hash_digest(struct crypto_ahash *tfm, const u8 *data,
-		       unsigned int len, u8 *out);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_hash_digest, int, (struct crypto_ahash *tfm, const u8 *data, unsigned int len, u8 *out), (tfm, data, len, out));
 
 /**
  * crypto_shash_export() - extract operational state for message digest
@@ -940,7 +934,7 @@ int crypto_hash_digest(struct crypto_ahash *tfm, const u8 *data,
  * Context: Softirq or process context.
  * Return: 0 if the export creation was successful; < 0 if an error occurred
  */
-int crypto_shash_export(struct shash_desc *desc, void *out);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_shash_export, int, (struct shash_desc *desc, void *out), (desc, out));
 
 /**
  * crypto_shash_import() - import operational state
@@ -954,7 +948,7 @@ int crypto_shash_export(struct shash_desc *desc, void *out);
  * Context: Softirq or process context.
  * Return: 0 if the import was successful; < 0 if an error occurred
  */
-int crypto_shash_import(struct shash_desc *desc, const void *in);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_shash_import, int, (struct shash_desc *desc, const void *in), (desc, in));
 
 /**
  * crypto_shash_init() - (re)initialize message digest
@@ -968,7 +962,7 @@ int crypto_shash_import(struct shash_desc *desc, const void *in);
  * Return: 0 if the message digest initialization was successful; < 0 if an
  *	   error occurred
  */
-int crypto_shash_init(struct shash_desc *desc);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_shash_init, int, (struct shash_desc *desc), (desc));
 
 /**
  * crypto_shash_finup() - calculate message digest of buffer
@@ -985,8 +979,7 @@ int crypto_shash_init(struct shash_desc *desc);
  * Return: 0 if the message digest creation was successful; < 0 if an error
  *	   occurred
  */
-int crypto_shash_finup(struct shash_desc *desc, const u8 *data,
-		       unsigned int len, u8 *out);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_shash_finup, int, (struct shash_desc *desc, const u8 *data, unsigned int len, u8 *out), (desc, data, len, out));
 
 /**
  * crypto_shash_update() - add data to message digest for processing
diff --git a/include/crypto/internal/hash.h b/include/crypto/internal/hash.h
index 6ec5f2f37ccb..7ab717d1fd9c 100644
--- a/include/crypto/internal/hash.h
+++ b/include/crypto/internal/hash.h
@@ -8,6 +8,7 @@
 #ifndef _CRYPTO_INTERNAL_HASH_H
 #define _CRYPTO_INTERNAL_HASH_H
 
+#include <crypto/api.h>
 #include <crypto/algapi.h>
 #include <crypto/hash.h>
 
@@ -75,32 +76,29 @@ struct crypto_shash_spawn {
 	struct crypto_spawn base;
 };
 
-int crypto_hash_walk_done(struct crypto_hash_walk *walk, int err);
-int crypto_hash_walk_first(struct ahash_request *req,
-			   struct crypto_hash_walk *walk);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_hash_walk_done, int, (struct crypto_hash_walk *walk, int err), (walk, err));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_hash_walk_first, int, (struct ahash_request *req, struct crypto_hash_walk *walk), (req, walk));
 
 static inline int crypto_hash_walk_last(struct crypto_hash_walk *walk)
 {
 	return !(walk->entrylen | walk->total);
 }
 
-int crypto_register_ahash(struct ahash_alg *alg);
-void crypto_unregister_ahash(struct ahash_alg *alg);
-int crypto_register_ahashes(struct ahash_alg *algs, int count);
-void crypto_unregister_ahashes(struct ahash_alg *algs, int count);
-int ahash_register_instance(struct crypto_template *tmpl,
-			    struct ahash_instance *inst);
-void ahash_free_singlespawn_instance(struct ahash_instance *inst);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_register_ahash, int, (struct ahash_alg *alg), (alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_unregister_ahash, void, (struct ahash_alg *alg), (alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_register_ahashes, int, (struct ahash_alg *algs, int count), (algs, count));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_unregister_ahashes, void, (struct ahash_alg *algs, int count), (algs, count));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, ahash_register_instance, int, (struct crypto_template *tmpl, struct ahash_instance *inst), (tmpl, inst));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, ahash_free_singlespawn_instance, void, (struct ahash_instance *inst), (inst));
 
-int shash_no_setkey(struct crypto_shash *tfm, const u8 *key,
-		    unsigned int keylen);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, shash_no_setkey, int, (struct crypto_shash *tfm, const u8 *key, unsigned int keylen), (tfm, key, keylen));
 
 static inline bool crypto_shash_alg_has_setkey(struct shash_alg *alg)
 {
 	return alg->setkey != shash_no_setkey;
 }
 
-bool crypto_hash_alg_has_setkey(struct hash_alg_common *halg);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_hash_alg_has_setkey, bool, (struct hash_alg_common *halg), (halg));
 
 static inline bool crypto_shash_alg_needs_key(struct shash_alg *alg)
 {
@@ -120,9 +118,7 @@ static inline bool crypto_hash_no_export_core(struct crypto_ahash *tfm)
 	       CRYPTO_AHASH_ALG_NO_EXPORT_CORE;
 }
 
-int crypto_grab_ahash(struct crypto_ahash_spawn *spawn,
-		      struct crypto_instance *inst,
-		      const char *name, u32 type, u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_grab_ahash, int, (struct crypto_ahash_spawn *spawn, struct crypto_instance *inst, const char *name, u32 type, u32 mask), (spawn, inst, name, type, mask));
 
 static inline void crypto_drop_ahash(struct crypto_ahash_spawn *spawn)
 {
@@ -135,17 +131,14 @@ static inline struct hash_alg_common *crypto_spawn_ahash_alg(
 	return __crypto_hash_alg_common(spawn->base.alg);
 }
 
-int crypto_register_shash(struct shash_alg *alg);
-void crypto_unregister_shash(struct shash_alg *alg);
-int crypto_register_shashes(struct shash_alg *algs, int count);
-void crypto_unregister_shashes(struct shash_alg *algs, int count);
-int shash_register_instance(struct crypto_template *tmpl,
-			    struct shash_instance *inst);
-void shash_free_singlespawn_instance(struct shash_instance *inst);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_register_shash, int, (struct shash_alg *alg), (alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_unregister_shash, void, (struct shash_alg *alg), (alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_register_shashes, int, (struct shash_alg *algs, int count), (algs, count));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_unregister_shashes, void, (struct shash_alg *algs, int count), (algs, count));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, shash_register_instance, int, (struct crypto_template *tmpl, struct shash_instance *inst), (tmpl, inst));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, shash_free_singlespawn_instance, void, (struct shash_instance *inst), (inst));
 
-int crypto_grab_shash(struct crypto_shash_spawn *spawn,
-		      struct crypto_instance *inst,
-		      const char *name, u32 type, u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_grab_shash, int, (struct crypto_shash_spawn *spawn, struct crypto_instance *inst, const char *name, u32 type, u32 mask), (spawn, inst, name, type, mask));
 
 static inline void crypto_drop_shash(struct crypto_shash_spawn *spawn)
 {
@@ -158,9 +151,9 @@ static inline struct shash_alg *crypto_spawn_shash_alg(
 	return __crypto_shash_alg(spawn->base.alg);
 }
 
-int shash_ahash_update(struct ahash_request *req, struct shash_desc *desc);
-int shash_ahash_finup(struct ahash_request *req, struct shash_desc *desc);
-int shash_ahash_digest(struct ahash_request *req, struct shash_desc *desc);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, shash_ahash_update, int, (struct ahash_request *req, struct shash_desc *desc), (req, desc));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, shash_ahash_finup, int, (struct ahash_request *req, struct shash_desc *desc), (req, desc));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, shash_ahash_digest, int, (struct ahash_request *req, struct shash_desc *desc), (req, desc));
 
 static inline void *crypto_ahash_ctx(struct crypto_ahash *tfm)
 {
@@ -363,7 +356,7 @@ static inline unsigned int crypto_shash_coresize(struct crypto_shash *tfm)
  * Context: Softirq or process context.
  * Return: 0 if the export creation was successful; < 0 if an error occurred
  */
-int crypto_ahash_export_core(struct ahash_request *req, void *out);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_ahash_export_core, int, (struct ahash_request *req, void *out), (req, out));
 
 /**
  * crypto_ahash_import_core() - import core state
@@ -375,7 +368,7 @@ int crypto_ahash_export_core(struct ahash_request *req, void *out);
  * Context: Softirq or process context.
  * Return: 0 if the import was successful; < 0 if an error occurred
  */
-int crypto_ahash_import_core(struct ahash_request *req, const void *in);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_ahash_import_core, int, (struct ahash_request *req, const void *in), (req, in));
 
 /**
  * crypto_shash_export_core() - extract core state for message digest
@@ -387,7 +380,7 @@ int crypto_ahash_import_core(struct ahash_request *req, const void *in);
  * Context: Softirq or process context.
  * Return: 0 if the export creation was successful; < 0 if an error occurred
  */
-int crypto_shash_export_core(struct shash_desc *desc, void *out);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_shash_export_core, int, (struct shash_desc *desc, void *out), (desc, out));
 
 /**
  * crypto_shash_import_core() - import core state
@@ -399,7 +392,7 @@ int crypto_shash_export_core(struct shash_desc *desc, void *out);
  * Context: Softirq or process context.
  * Return: 0 if the import was successful; < 0 if an error occurred
  */
-int crypto_shash_import_core(struct shash_desc *desc, const void *in);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HASH2, crypto_shash_import_core, int, (struct shash_desc *desc, const void *in), (desc, in));
 
 #endif	/* _CRYPTO_INTERNAL_HASH_H */
 
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 009/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_AKCIPHER2 crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (7 preceding siblings ...)
  2026-02-12  2:45 ` [PATCH 008/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_HASH2 crypto Jay Wang
@ 2026-02-12  2:45 ` Jay Wang
  2026-02-12  2:45 ` [PATCH 010/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SIG2 crypto Jay Wang
                   ` (96 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:45 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_AKCIPHER2-related crypto to convert them into pluggable
interface.

This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.

Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile                    |  2 +-
 crypto/fips140/fips140-api.c       | 18 ++++++++++++++++++
 include/crypto/akcipher.h          | 12 ++++--------
 include/crypto/internal/akcipher.h | 12 +++++-------
 4 files changed, 28 insertions(+), 16 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 210e4aa3dbac..7d55be467108 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -33,7 +33,7 @@ crypto_hash-y += ahash.o
 crypto_hash-y += shash.o
 crypto-objs-$(CONFIG_CRYPTO_HASH2) += crypto_hash.o
 
-obj-$(CONFIG_CRYPTO_AKCIPHER2) += akcipher.o
+crypto-objs-$(CONFIG_CRYPTO_AKCIPHER2) += akcipher.o
 obj-$(CONFIG_CRYPTO_SIG2) += sig.o
 obj-$(CONFIG_CRYPTO_KPP2) += kpp.o
 obj-$(CONFIG_CRYPTO_HKDF) += hkdf.o
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index e1c2f709ad3b..8d4d07060d86 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -252,4 +252,22 @@ DEFINE_CRYPTO_API_STUB(crypto_unregister_shashes);
 DEFINE_CRYPTO_API_STUB(shash_register_instance);
 DEFINE_CRYPTO_API_STUB(shash_free_singlespawn_instance);
 
+#endif
+
+/*
+ * crypto/akcipher.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_AKCIPHER2)
+
+#include <crypto/akcipher.h>
+#include <crypto/internal/akcipher.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_grab_akcipher);
+DEFINE_CRYPTO_API_STUB(crypto_alloc_akcipher);
+DEFINE_CRYPTO_API_STUB(crypto_register_akcipher);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_akcipher);
+DEFINE_CRYPTO_API_STUB(akcipher_register_instance);
+DEFINE_CRYPTO_API_STUB(crypto_akcipher_sync_encrypt);
+DEFINE_CRYPTO_API_STUB(crypto_akcipher_sync_decrypt);
+
 #endif
\ No newline at end of file
diff --git a/include/crypto/akcipher.h b/include/crypto/akcipher.h
index cdf7da74bf2f..a48cf468521e 100644
--- a/include/crypto/akcipher.h
+++ b/include/crypto/akcipher.h
@@ -8,6 +8,7 @@
 #ifndef _CRYPTO_AKCIPHER_H
 #define _CRYPTO_AKCIPHER_H
 
+#include <crypto/api.h>
 #include <linux/atomic.h>
 #include <linux/crypto.h>
 
@@ -116,8 +117,7 @@ struct akcipher_alg {
  * Return: allocated handle in case of success; IS_ERR() is true in case
  *	   of an error, PTR_ERR() returns the error code.
  */
-struct crypto_akcipher *crypto_alloc_akcipher(const char *alg_name, u32 type,
-					      u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_AKCIPHER2, crypto_alloc_akcipher, struct crypto_akcipher *, (const char *alg_name, u32 type, u32 mask), (alg_name, type, mask));
 
 static inline struct crypto_tfm *crypto_akcipher_tfm(
 	struct crypto_akcipher *tfm)
@@ -310,9 +310,7 @@ static inline int crypto_akcipher_decrypt(struct akcipher_request *req)
  *
  * Return: zero on success; error code in case of error
  */
-int crypto_akcipher_sync_encrypt(struct crypto_akcipher *tfm,
-				 const void *src, unsigned int slen,
-				 void *dst, unsigned int dlen);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_AKCIPHER2, crypto_akcipher_sync_encrypt, int, (struct crypto_akcipher *tfm, const void *src, unsigned int slen, void *dst, unsigned int dlen), (tfm, src, slen, dst, dlen));
 
 /**
  * crypto_akcipher_sync_decrypt() - Invoke public key decrypt operation
@@ -328,9 +326,7 @@ int crypto_akcipher_sync_encrypt(struct crypto_akcipher *tfm,
  *
  * Return: Output length on success; error code in case of error
  */
-int crypto_akcipher_sync_decrypt(struct crypto_akcipher *tfm,
-				 const void *src, unsigned int slen,
-				 void *dst, unsigned int dlen);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_AKCIPHER2, crypto_akcipher_sync_decrypt, int, (struct crypto_akcipher *tfm, const void *src, unsigned int slen, void *dst, unsigned int dlen), (tfm, src, slen, dst, dlen));
 
 /**
  * crypto_akcipher_set_pub_key() - Invoke set public key operation
diff --git a/include/crypto/internal/akcipher.h b/include/crypto/internal/akcipher.h
index 14ee62bc52b6..5b690a82d58e 100644
--- a/include/crypto/internal/akcipher.h
+++ b/include/crypto/internal/akcipher.h
@@ -7,6 +7,7 @@
  */
 #ifndef _CRYPTO_AKCIPHER_INT_H
 #define _CRYPTO_AKCIPHER_INT_H
+#include <crypto/api.h>
 #include <crypto/akcipher.h>
 #include <crypto/algapi.h>
 
@@ -100,9 +101,7 @@ static inline void *akcipher_instance_ctx(struct akcipher_instance *inst)
 	return crypto_instance_ctx(akcipher_crypto_instance(inst));
 }
 
-int crypto_grab_akcipher(struct crypto_akcipher_spawn *spawn,
-			 struct crypto_instance *inst,
-			 const char *name, u32 type, u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_AKCIPHER2, crypto_grab_akcipher, int, (struct crypto_akcipher_spawn *spawn, struct crypto_instance *inst, const char *name, u32 type, u32 mask), (spawn, inst, name, type, mask));
 
 static inline struct crypto_akcipher *crypto_spawn_akcipher(
 		struct crypto_akcipher_spawn *spawn)
@@ -130,7 +129,7 @@ static inline struct akcipher_alg *crypto_spawn_akcipher_alg(
  *
  * Return: zero on success; error code in case of error
  */
-int crypto_register_akcipher(struct akcipher_alg *alg);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_AKCIPHER2, crypto_register_akcipher, int, (struct akcipher_alg *alg), (alg));
 
 /**
  * crypto_unregister_akcipher() -- Unregister public key algorithm
@@ -139,7 +138,7 @@ int crypto_register_akcipher(struct akcipher_alg *alg);
  *
  * @alg:	algorithm definition
  */
-void crypto_unregister_akcipher(struct akcipher_alg *alg);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_AKCIPHER2, crypto_unregister_akcipher, void, (struct akcipher_alg *alg), (alg));
 
 /**
  * akcipher_register_instance() -- Unregister public key template instance
@@ -150,6 +149,5 @@ void crypto_unregister_akcipher(struct akcipher_alg *alg);
  * @tmpl:	the template from which the algorithm was created
  * @inst:	the template instance
  */
-int akcipher_register_instance(struct crypto_template *tmpl,
-		struct akcipher_instance *inst);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_AKCIPHER2, akcipher_register_instance, int, (struct crypto_template *tmpl, struct akcipher_instance *inst), (tmpl, inst));
 #endif
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 010/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SIG2 crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (8 preceding siblings ...)
  2026-02-12  2:45 ` [PATCH 009/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_AKCIPHER2 crypto Jay Wang
@ 2026-02-12  2:45 ` Jay Wang
  2026-02-12  2:45 ` [PATCH 011/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_KPP2 crypto Jay Wang
                   ` (95 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:45 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_SIG2-related crypto to convert them into pluggable
interface.

This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.

Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile               |  2 +-
 crypto/fips140/fips140-api.c  | 16 ++++++++++++++++
 include/crypto/internal/sig.h | 12 +++++-------
 include/crypto/sig.h          |  3 ++-
 4 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 7d55be467108..2e722f7961d4 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -34,7 +34,7 @@ crypto_hash-y += shash.o
 crypto-objs-$(CONFIG_CRYPTO_HASH2) += crypto_hash.o
 
 crypto-objs-$(CONFIG_CRYPTO_AKCIPHER2) += akcipher.o
-obj-$(CONFIG_CRYPTO_SIG2) += sig.o
+crypto-objs-$(CONFIG_CRYPTO_SIG2) += sig.o
 obj-$(CONFIG_CRYPTO_KPP2) += kpp.o
 obj-$(CONFIG_CRYPTO_HKDF) += hkdf.o
 
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 8d4d07060d86..c97806cfdd05 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -270,4 +270,20 @@ DEFINE_CRYPTO_API_STUB(akcipher_register_instance);
 DEFINE_CRYPTO_API_STUB(crypto_akcipher_sync_encrypt);
 DEFINE_CRYPTO_API_STUB(crypto_akcipher_sync_decrypt);
 
+#endif
+
+/*
+ * crypto/sig.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_SIG2)
+
+#include <crypto/sig.h>
+#include <crypto/internal/sig.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_alloc_sig);
+DEFINE_CRYPTO_API_STUB(crypto_register_sig);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_sig);
+DEFINE_CRYPTO_API_STUB(sig_register_instance);
+DEFINE_CRYPTO_API_STUB(crypto_grab_sig);
+
 #endif
\ No newline at end of file
diff --git a/include/crypto/internal/sig.h b/include/crypto/internal/sig.h
index b16648c1a986..51d3a617c00d 100644
--- a/include/crypto/internal/sig.h
+++ b/include/crypto/internal/sig.h
@@ -7,6 +7,7 @@
 #ifndef _CRYPTO_INTERNAL_SIG_H
 #define _CRYPTO_INTERNAL_SIG_H
 
+#include <crypto/api.h>
 #include <crypto/algapi.h>
 #include <crypto/sig.h>
 
@@ -39,7 +40,7 @@ static inline void *crypto_sig_ctx(struct crypto_sig *tfm)
  *
  * Return: zero on success; error code in case of error
  */
-int crypto_register_sig(struct sig_alg *alg);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SIG2, crypto_register_sig, int, (struct sig_alg *alg), (alg));
 
 /**
  * crypto_unregister_sig() -- Unregister public key signature algorithm
@@ -48,10 +49,9 @@ int crypto_register_sig(struct sig_alg *alg);
  *
  * @alg:	algorithm definition
  */
-void crypto_unregister_sig(struct sig_alg *alg);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SIG2, crypto_unregister_sig, void, (struct sig_alg *alg), (alg));
 
-int sig_register_instance(struct crypto_template *tmpl,
-			  struct sig_instance *inst);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SIG2, sig_register_instance, int, (struct crypto_template *tmpl, struct sig_instance *inst), (tmpl, inst));
 
 static inline struct sig_instance *sig_instance(struct crypto_instance *inst)
 {
@@ -74,9 +74,7 @@ static inline void *sig_instance_ctx(struct sig_instance *inst)
 	return crypto_instance_ctx(sig_crypto_instance(inst));
 }
 
-int crypto_grab_sig(struct crypto_sig_spawn *spawn,
-		    struct crypto_instance *inst,
-		    const char *name, u32 type, u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SIG2, crypto_grab_sig, int, (struct crypto_sig_spawn *spawn, struct crypto_instance *inst, const char *name, u32 type, u32 mask), (spawn, inst, name, type, mask));
 
 static inline struct crypto_sig *crypto_spawn_sig(struct crypto_sig_spawn
 								   *spawn)
diff --git a/include/crypto/sig.h b/include/crypto/sig.h
index fa6dafafab3f..1b0595b3b245 100644
--- a/include/crypto/sig.h
+++ b/include/crypto/sig.h
@@ -7,6 +7,7 @@
 #ifndef _CRYPTO_SIG_H
 #define _CRYPTO_SIG_H
 
+#include <crypto/api.h>
 #include <linux/crypto.h>
 
 /**
@@ -91,7 +92,7 @@ struct sig_alg {
  * Return: allocated handle in case of success; IS_ERR() is true in case
  *	   of an error, PTR_ERR() returns the error code.
  */
-struct crypto_sig *crypto_alloc_sig(const char *alg_name, u32 type, u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SIG2, crypto_alloc_sig, struct crypto_sig *, (const char *alg_name, u32 type, u32 mask), (alg_name, type, mask));
 
 static inline struct crypto_tfm *crypto_sig_tfm(struct crypto_sig *tfm)
 {
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 011/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_KPP2 crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (9 preceding siblings ...)
  2026-02-12  2:45 ` [PATCH 010/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SIG2 crypto Jay Wang
@ 2026-02-12  2:45 ` Jay Wang
  2026-02-12  2:45 ` [PATCH 012/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_RSA crypto Jay Wang
                   ` (94 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:45 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_KPP2-related crypto to convert them into pluggable
interface.

This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.

Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile               |  2 +-
 crypto/fips140/fips140-api.c  | 17 +++++++++++++++++
 include/crypto/internal/kpp.h | 12 +++++-------
 include/crypto/kpp.h          |  5 +++--
 4 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 2e722f7961d4..21197857ad7d 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -35,7 +35,7 @@ crypto-objs-$(CONFIG_CRYPTO_HASH2) += crypto_hash.o
 
 crypto-objs-$(CONFIG_CRYPTO_AKCIPHER2) += akcipher.o
 crypto-objs-$(CONFIG_CRYPTO_SIG2) += sig.o
-obj-$(CONFIG_CRYPTO_KPP2) += kpp.o
+crypto-objs-$(CONFIG_CRYPTO_KPP2) += kpp.o
 obj-$(CONFIG_CRYPTO_HKDF) += hkdf.o
 
 dh_generic-y := dh.o
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index c97806cfdd05..50603e7a8bb0 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -286,4 +286,21 @@ DEFINE_CRYPTO_API_STUB(crypto_unregister_sig);
 DEFINE_CRYPTO_API_STUB(sig_register_instance);
 DEFINE_CRYPTO_API_STUB(crypto_grab_sig);
 
+#endif
+
+/*
+ * crypto/kpp.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_KPP2)
+
+#include <crypto/kpp.h>
+#include <crypto/internal/kpp.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_alloc_kpp);
+DEFINE_CRYPTO_API_STUB(crypto_grab_kpp);
+DEFINE_CRYPTO_API_STUB(crypto_has_kpp);
+DEFINE_CRYPTO_API_STUB(crypto_register_kpp);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_kpp);
+DEFINE_CRYPTO_API_STUB(kpp_register_instance);
+
 #endif
\ No newline at end of file
diff --git a/include/crypto/internal/kpp.h b/include/crypto/internal/kpp.h
index 0a6db8c4a9a0..eff35727f700 100644
--- a/include/crypto/internal/kpp.h
+++ b/include/crypto/internal/kpp.h
@@ -7,6 +7,7 @@
  */
 #ifndef _CRYPTO_KPP_INT_H
 #define _CRYPTO_KPP_INT_H
+#include <crypto/api.h>
 #include <crypto/kpp.h>
 #include <crypto/algapi.h>
 
@@ -159,7 +160,7 @@ static inline void *kpp_instance_ctx(struct kpp_instance *inst)
  *
  * Return: zero on success; error code in case of error
  */
-int crypto_register_kpp(struct kpp_alg *alg);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_KPP2, crypto_register_kpp, int, (struct kpp_alg *alg), (alg));
 
 /**
  * crypto_unregister_kpp() -- Unregister key-agreement protocol primitive
@@ -170,7 +171,7 @@ int crypto_register_kpp(struct kpp_alg *alg);
  *
  * @alg:	algorithm definition
  */
-void crypto_unregister_kpp(struct kpp_alg *alg);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_KPP2, crypto_unregister_kpp, void, (struct kpp_alg *alg), (alg));
 
 /**
  * kpp_register_instance() - Register a KPP template instance.
@@ -178,8 +179,7 @@ void crypto_unregister_kpp(struct kpp_alg *alg);
  * @inst: The KPP template instance to be registered.
  * Return: %0 on success, negative error code otherwise.
  */
-int kpp_register_instance(struct crypto_template *tmpl,
-			  struct kpp_instance *inst);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_KPP2, kpp_register_instance, int, (struct crypto_template *tmpl, struct kpp_instance *inst), (tmpl, inst));
 
 /*
  * KPP spawn related functions.
@@ -193,9 +193,7 @@ int kpp_register_instance(struct crypto_template *tmpl,
  * @mask: The mask bismask to pass on to the lookup.
  * Return: %0 on success, a negative error code otherwise.
  */
-int crypto_grab_kpp(struct crypto_kpp_spawn *spawn,
-		    struct crypto_instance *inst,
-		    const char *name, u32 type, u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_KPP2, crypto_grab_kpp, int, (struct crypto_kpp_spawn *spawn, struct crypto_instance *inst, const char *name, u32 type, u32 mask), (spawn, inst, name, type, mask));
 
 /**
  * crypto_drop_kpp() - Release a spawn previously bound via crypto_grab_kpp().
diff --git a/include/crypto/kpp.h b/include/crypto/kpp.h
index 2d9c4de57b69..068a6e218344 100644
--- a/include/crypto/kpp.h
+++ b/include/crypto/kpp.h
@@ -9,6 +9,7 @@
 #ifndef _CRYPTO_KPP_
 #define _CRYPTO_KPP_
 
+#include <crypto/api.h>
 #include <linux/atomic.h>
 #include <linux/container_of.h>
 #include <linux/crypto.h>
@@ -107,9 +108,9 @@ struct kpp_alg {
  * Return: allocated handle in case of success; IS_ERR() is true in case of
  *	   an error, PTR_ERR() returns the error code.
  */
-struct crypto_kpp *crypto_alloc_kpp(const char *alg_name, u32 type, u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_KPP2, crypto_alloc_kpp, struct crypto_kpp *, (const char *alg_name, u32 type, u32 mask), (alg_name, type, mask));
 
-int crypto_has_kpp(const char *alg_name, u32 type, u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_KPP2, crypto_has_kpp, int, (const char *alg_name, u32 type, u32 mask), (alg_name, type, mask));
 
 static inline struct crypto_tfm *crypto_kpp_tfm(struct crypto_kpp *tfm)
 {
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 012/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_RSA crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (10 preceding siblings ...)
  2026-02-12  2:45 ` [PATCH 011/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_KPP2 crypto Jay Wang
@ 2026-02-12  2:45 ` Jay Wang
  2026-02-12  2:45 ` [PATCH 013/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ACOMP2 crypto Jay Wang
                   ` (93 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:45 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_RSA-related crypto to convert them into pluggable
interface.

This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.

Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile               |  2 +-
 crypto/fips140/fips140-api.c  | 12 ++++++++++++
 crypto/rsa.c                  |  4 ++--
 include/crypto/internal/rsa.h |  7 +++----
 4 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 21197857ad7d..3e12b556bfa7 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -52,7 +52,7 @@ rsa_generic-y += rsa.o
 rsa_generic-y += rsa_helper.o
 rsa_generic-y += rsa-pkcs1pad.o
 rsa_generic-y += rsassa-pkcs1.o
-obj-$(CONFIG_CRYPTO_RSA) += rsa_generic.o
+crypto-objs-$(CONFIG_CRYPTO_RSA) += rsa_generic.o
 
 $(obj)/ecdsasignature.asn1.o: $(obj)/ecdsasignature.asn1.c $(obj)/ecdsasignature.asn1.h
 $(obj)/ecdsa-x962.o: $(obj)/ecdsasignature.asn1.h
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 50603e7a8bb0..d10eded6b61e 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -303,4 +303,16 @@ DEFINE_CRYPTO_API_STUB(crypto_register_kpp);
 DEFINE_CRYPTO_API_STUB(crypto_unregister_kpp);
 DEFINE_CRYPTO_API_STUB(kpp_register_instance);
 
+#endif
+
+/*
+ * crypto/rsa_helper.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_RSA)
+
+#include <crypto/internal/rsa.h>
+
+DEFINE_CRYPTO_API_STUB(rsa_parse_pub_key);
+DEFINE_CRYPTO_API_STUB(rsa_parse_priv_key);
+
 #endif
\ No newline at end of file
diff --git a/crypto/rsa.c b/crypto/rsa.c
index 6c7734083c98..44eef74ebad8 100644
--- a/crypto/rsa.c
+++ b/crypto/rsa.c
@@ -430,8 +430,8 @@ static void __exit rsa_exit(void)
 	crypto_unregister_akcipher(&rsa);
 }
 
-module_init(rsa_init);
-module_exit(rsa_exit);
+crypto_module_init(rsa_init);
+crypto_module_exit(rsa_exit);
 MODULE_ALIAS_CRYPTO("rsa");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("RSA generic algorithm");
diff --git a/include/crypto/internal/rsa.h b/include/crypto/internal/rsa.h
index 071a1951b992..3d8fe098eaae 100644
--- a/include/crypto/internal/rsa.h
+++ b/include/crypto/internal/rsa.h
@@ -7,6 +7,7 @@
  */
 #ifndef _RSA_HELPER_
 #define _RSA_HELPER_
+#include <crypto/api.h>
 #include <linux/types.h>
 #include <crypto/akcipher.h>
 
@@ -48,11 +49,9 @@ struct rsa_key {
 	size_t qinv_sz;
 };
 
-int rsa_parse_pub_key(struct rsa_key *rsa_key, const void *key,
-		      unsigned int key_len);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_RSA, rsa_parse_pub_key, int, (struct rsa_key *rsa_key, const void *key, unsigned int key_len), (rsa_key, key, key_len));
 
-int rsa_parse_priv_key(struct rsa_key *rsa_key, const void *key,
-		       unsigned int key_len);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_RSA, rsa_parse_priv_key, int, (struct rsa_key *rsa_key, const void *key, unsigned int key_len), (rsa_key, key, key_len));
 
 #define RSA_PUB (true)
 #define RSA_PRIV (false)
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 013/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ACOMP2 crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (11 preceding siblings ...)
  2026-02-12  2:45 ` [PATCH 012/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_RSA crypto Jay Wang
@ 2026-02-12  2:45 ` Jay Wang
  2026-02-12  2:45 ` [PATCH 014/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_MANAGER2 crypto Jay Wang
                   ` (92 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:45 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_ACOMP2-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile                     |  2 +-
 crypto/fips140/fips140-api.c        | 42 +++++++++++++++++++++++++++++
 include/crypto/acompress.h          | 14 +++++-----
 include/crypto/internal/acompress.h | 27 +++++++++----------
 include/crypto/internal/scompress.h |  9 ++++---
 5 files changed, 67 insertions(+), 27 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 3e12b556bfa7..e940f9ed357d 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -66,7 +66,7 @@ obj-$(CONFIG_CRYPTO_MLDSA) += mldsa.o
 
 crypto_acompress-y := acompress.o
 crypto_acompress-y += scompress.o
-obj-$(CONFIG_CRYPTO_ACOMP2) += crypto_acompress.o
+crypto-objs-$(CONFIG_CRYPTO_ACOMP2) += crypto_acompress.o
 
 cryptomgr-y := algboss.o testmgr.o
 
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index d10eded6b61e..9a9c66cc1d90 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -315,4 +315,46 @@ DEFINE_CRYPTO_API_STUB(kpp_register_instance);
 DEFINE_CRYPTO_API_STUB(rsa_parse_pub_key);
 DEFINE_CRYPTO_API_STUB(rsa_parse_priv_key);
 
+#endif
+
+/*
+ * crypto/acompress.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_ACOMP2)
+
+#include <crypto/acompress.h>
+#include <crypto/internal/acompress.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_alloc_acomp);
+DEFINE_CRYPTO_API_STUB(crypto_alloc_acomp_node);
+DEFINE_CRYPTO_API_STUB(crypto_acomp_compress);
+DEFINE_CRYPTO_API_STUB(crypto_acomp_decompress);
+DEFINE_CRYPTO_API_STUB(crypto_register_acomp);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_acomp);
+DEFINE_CRYPTO_API_STUB(crypto_register_acomps);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_acomps);
+DEFINE_CRYPTO_API_STUB(crypto_acomp_free_streams);
+DEFINE_CRYPTO_API_STUB(crypto_acomp_alloc_streams);
+DEFINE_CRYPTO_API_STUB(_crypto_acomp_lock_stream_bh);
+DEFINE_CRYPTO_API_STUB(acomp_walk_done_src);
+DEFINE_CRYPTO_API_STUB(acomp_walk_done_dst);
+DEFINE_CRYPTO_API_STUB(acomp_walk_next_src);
+DEFINE_CRYPTO_API_STUB(acomp_walk_next_dst);
+DEFINE_CRYPTO_API_STUB(acomp_walk_virt);
+DEFINE_CRYPTO_API_STUB(acomp_request_clone);
+
+#endif
+
+/*
+ * crypto/scompress.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_ACOMP2)
+
+#include <crypto/internal/scompress.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_register_scomp);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_scomp);
+DEFINE_CRYPTO_API_STUB(crypto_register_scomps);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_scomps);
+
 #endif
\ No newline at end of file
diff --git a/include/crypto/acompress.h b/include/crypto/acompress.h
index 9eacb9fa375d..54545cd3f2f8 100644
--- a/include/crypto/acompress.h
+++ b/include/crypto/acompress.h
@@ -9,6 +9,7 @@
 #ifndef _CRYPTO_ACOMP_H
 #define _CRYPTO_ACOMP_H
 
+#include <crypto/api.h>
 #include <linux/atomic.h>
 #include <linux/args.h>
 #include <linux/compiler_types.h>
@@ -143,8 +144,7 @@ struct comp_alg_common COMP_ALG_COMMON;
  * Return:	allocated handle in case of success; IS_ERR() is true in case
  *		of an error, PTR_ERR() returns the error code.
  */
-struct crypto_acomp *crypto_alloc_acomp(const char *alg_name, u32 type,
-					u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, crypto_alloc_acomp, struct crypto_acomp *, (const char *alg_name, u32 type, u32 mask), (alg_name, type, mask));
 /**
  * crypto_alloc_acomp_node() -- allocate ACOMPRESS tfm handle with desired NUMA node
  * @alg_name:	is the cra_name / name or cra_driver_name / driver name of the
@@ -161,8 +161,7 @@ struct crypto_acomp *crypto_alloc_acomp(const char *alg_name, u32 type,
  * Return:	allocated handle in case of success; IS_ERR() is true in case
  *		of an error, PTR_ERR() returns the error code.
  */
-struct crypto_acomp *crypto_alloc_acomp_node(const char *alg_name, u32 type,
-					u32 mask, int node);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, crypto_alloc_acomp_node, struct crypto_acomp *, (const char *alg_name, u32 type, u32 mask, int node), (alg_name, type, mask, node));
 
 static inline struct crypto_tfm *crypto_acomp_tfm(struct crypto_acomp *tfm)
 {
@@ -529,7 +528,7 @@ static inline void acomp_request_set_dst_folio(struct acomp_req *req,
  *
  * Return:	zero on success; error code in case of error
  */
-int crypto_acomp_compress(struct acomp_req *req);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, crypto_acomp_compress, int, (struct acomp_req *req), (req));
 
 /**
  * crypto_acomp_decompress() -- Invoke asynchronous decompress operation
@@ -540,7 +539,7 @@ int crypto_acomp_compress(struct acomp_req *req);
  *
  * Return:	zero on success; error code in case of error
  */
-int crypto_acomp_decompress(struct acomp_req *req);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, crypto_acomp_decompress, int, (struct acomp_req *req), (req));
 
 static inline struct acomp_req *acomp_request_on_stack_init(
 	char *buf, struct crypto_acomp *tfm)
@@ -551,7 +550,6 @@ static inline struct acomp_req *acomp_request_on_stack_init(
 	return req;
 }
 
-struct acomp_req *acomp_request_clone(struct acomp_req *req,
-				      size_t total, gfp_t gfp);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, acomp_request_clone, struct acomp_req *, (struct acomp_req *req, size_t total, gfp_t gfp), (req, total, gfp));
 
 #endif
diff --git a/include/crypto/internal/acompress.h b/include/crypto/internal/acompress.h
index 9a3f28baa804..20a9c4e96e0c 100644
--- a/include/crypto/internal/acompress.h
+++ b/include/crypto/internal/acompress.h
@@ -9,6 +9,7 @@
 #ifndef _CRYPTO_ACOMP_INT_H
 #define _CRYPTO_ACOMP_INT_H
 
+#include <crypto/api.h>
 #include <crypto/acompress.h>
 #include <crypto/algapi.h>
 #include <crypto/scatterwalk.h>
@@ -130,7 +131,7 @@ static inline void acomp_request_complete(struct acomp_req *req,
  *
  * Return:	zero on success; error code in case of error
  */
-int crypto_register_acomp(struct acomp_alg *alg);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, crypto_register_acomp, int, (struct acomp_alg *alg), (alg));
 
 /**
  * crypto_unregister_acomp() -- Unregister asynchronous compression algorithm
@@ -140,10 +141,10 @@ int crypto_register_acomp(struct acomp_alg *alg);
  *
  * @alg:	algorithm definition
  */
-void crypto_unregister_acomp(struct acomp_alg *alg);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, crypto_unregister_acomp, void, (struct acomp_alg *alg), (alg));
 
-int crypto_register_acomps(struct acomp_alg *algs, int count);
-void crypto_unregister_acomps(struct acomp_alg *algs, int count);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, crypto_register_acomps, int, (struct acomp_alg *algs, int count), (algs, count));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, crypto_unregister_acomps, void, (struct acomp_alg *algs, int count), (algs, count));
 
 static inline bool acomp_request_issg(struct acomp_req *req)
 {
@@ -188,12 +189,11 @@ static inline bool crypto_acomp_req_virt(struct crypto_acomp *tfm)
 	return crypto_tfm_req_virt(&tfm->base);
 }
 
-void crypto_acomp_free_streams(struct crypto_acomp_streams *s);
-int crypto_acomp_alloc_streams(struct crypto_acomp_streams *s);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, crypto_acomp_free_streams, void, (struct crypto_acomp_streams *s), (s));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, crypto_acomp_alloc_streams, int, (struct crypto_acomp_streams *s), (s));
 
 #define crypto_acomp_lock_stream_bh(...) __acquire_ret(_crypto_acomp_lock_stream_bh(__VA_ARGS__), &__ret->lock);
-struct crypto_acomp_stream *_crypto_acomp_lock_stream_bh(
-		struct crypto_acomp_streams *s) __acquires_ret;
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, _crypto_acomp_lock_stream_bh, struct crypto_acomp_stream *, (struct crypto_acomp_streams *s), (s)) __acquires_ret;
 
 static inline void crypto_acomp_unlock_stream_bh(
 	struct crypto_acomp_stream *stream) __releases(&stream->lock)
@@ -201,12 +201,11 @@ static inline void crypto_acomp_unlock_stream_bh(
 	spin_unlock_bh(&stream->lock);
 }
 
-void acomp_walk_done_src(struct acomp_walk *walk, int used);
-void acomp_walk_done_dst(struct acomp_walk *walk, int used);
-int acomp_walk_next_src(struct acomp_walk *walk);
-int acomp_walk_next_dst(struct acomp_walk *walk);
-int acomp_walk_virt(struct acomp_walk *__restrict walk,
-		    struct acomp_req *__restrict req, bool atomic);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, acomp_walk_done_src, void, (struct acomp_walk *walk, int used), (walk, used));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, acomp_walk_done_dst, void, (struct acomp_walk *walk, int used), (walk, used));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, acomp_walk_next_src, int, (struct acomp_walk *walk), (walk));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, acomp_walk_next_dst, int, (struct acomp_walk *walk), (walk));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, acomp_walk_virt, int, (struct acomp_walk *walk, struct acomp_req *req, bool atomic), (walk, req, atomic));
 
 static inline bool acomp_walk_more_src(const struct acomp_walk *walk, int cur)
 {
diff --git a/include/crypto/internal/scompress.h b/include/crypto/internal/scompress.h
index 6a2c5f2e90f9..02226b300ea8 100644
--- a/include/crypto/internal/scompress.h
+++ b/include/crypto/internal/scompress.h
@@ -9,6 +9,7 @@
 #ifndef _CRYPTO_SCOMP_INT_H
 #define _CRYPTO_SCOMP_INT_H
 
+#include <crypto/api.h>
 #include <crypto/internal/acompress.h>
 
 struct crypto_scomp {
@@ -90,7 +91,7 @@ static inline int crypto_scomp_decompress(struct crypto_scomp *tfm,
  *
  * Return: zero on success; error code in case of error
  */
-int crypto_register_scomp(struct scomp_alg *alg);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, crypto_register_scomp, int, (struct scomp_alg *alg), (alg));
 
 /**
  * crypto_unregister_scomp() -- Unregister synchronous compression algorithm
@@ -100,9 +101,9 @@ int crypto_register_scomp(struct scomp_alg *alg);
  *
  * @alg:	algorithm definition
  */
-void crypto_unregister_scomp(struct scomp_alg *alg);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, crypto_unregister_scomp, void, (struct scomp_alg *alg), (alg));
 
-int crypto_register_scomps(struct scomp_alg *algs, int count);
-void crypto_unregister_scomps(struct scomp_alg *algs, int count);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, crypto_register_scomps, int, (struct scomp_alg *algs, int count), (algs, count));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, crypto_unregister_scomps, void, (struct scomp_alg *algs, int count), (algs, count));
 
 #endif
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 014/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_MANAGER2 crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (12 preceding siblings ...)
  2026-02-12  2:45 ` [PATCH 013/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ACOMP2 crypto Jay Wang
@ 2026-02-12  2:45 ` Jay Wang
  2026-02-12  2:45 ` [PATCH 015/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CMAC crypto Jay Wang
                   ` (91 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:45 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_MANAGER2-related crypto to convert them into pluggable
interface.

This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.

Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile              |  2 +-
 crypto/algboss.c             |  4 ++--
 crypto/fips140/fips140-api.c | 11 +++++++++++
 crypto/internal.h            |  3 ++-
 4 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index e940f9ed357d..10cf1c6991fa 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -70,7 +70,7 @@ crypto-objs-$(CONFIG_CRYPTO_ACOMP2) += crypto_acompress.o
 
 cryptomgr-y := algboss.o testmgr.o
 
-obj-$(CONFIG_CRYPTO_MANAGER2) += cryptomgr.o
+crypto-objs-$(CONFIG_CRYPTO_MANAGER2) += cryptomgr.o
 obj-$(CONFIG_CRYPTO_USER) += crypto_user.o
 obj-$(CONFIG_CRYPTO_CMAC) += cmac.o
 obj-$(CONFIG_CRYPTO_HMAC) += hmac.o
diff --git a/crypto/algboss.c b/crypto/algboss.c
index 846f586889ee..1c26524e2541 100644
--- a/crypto/algboss.c
+++ b/crypto/algboss.c
@@ -247,8 +247,8 @@ static void __exit cryptomgr_exit(void)
 	BUG_ON(err);
 }
 
-module_init(cryptomgr_init);
-module_exit(cryptomgr_exit);
+crypto_module_init(cryptomgr_init);
+crypto_module_exit(cryptomgr_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Crypto Algorithm Manager");
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 9a9c66cc1d90..17e03d4c1c9a 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -357,4 +357,15 @@ DEFINE_CRYPTO_API_STUB(crypto_unregister_scomp);
 DEFINE_CRYPTO_API_STUB(crypto_register_scomps);
 DEFINE_CRYPTO_API_STUB(crypto_unregister_scomps);
 
+#endif
+
+/*
+ * crypto/testmgr.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_MANAGER2)
+
+#include <crypto/internal.h>
+
+DEFINE_CRYPTO_API_STUB(alg_test);
+
 #endif
\ No newline at end of file
diff --git a/crypto/internal.h b/crypto/internal.h
index 8ebe4dc336bc..0296d9830c62 100644
--- a/crypto/internal.h
+++ b/crypto/internal.h
@@ -8,6 +8,7 @@
 #ifndef _CRYPTO_INTERNAL_H
 #define _CRYPTO_INTERNAL_H
 
+#include <crypto/api.h>
 #include <crypto/algapi.h>
 #include <linux/completion.h>
 #include <linux/err.h>
@@ -65,7 +66,7 @@ extern struct rw_semaphore crypto_alg_sem;
 extern struct list_head crypto_alg_list __guarded_by(&crypto_alg_sem);
 extern struct blocking_notifier_head crypto_chain;
 
-int alg_test(const char *driver, const char *alg, u32 type, u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_MANAGER2, alg_test, int, (const char *driver, const char *alg, u32 type, u32 mask), (driver, alg, type, mask));
 
 #if !IS_BUILTIN(CONFIG_CRYPTO_ALGAPI) || !IS_ENABLED(CONFIG_CRYPTO_SELFTESTS)
 static inline bool crypto_boot_test_finished(void)
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 015/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CMAC crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (13 preceding siblings ...)
  2026-02-12  2:45 ` [PATCH 014/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_MANAGER2 crypto Jay Wang
@ 2026-02-12  2:45 ` Jay Wang
  2026-02-12  2:45 ` [PATCH 016/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_HMAC crypto Jay Wang
                   ` (90 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:45 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

From: Vegard Nossum <vegard.nossum@oracle.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_CMAC-related crypto to convert them into pluggable
interface.

Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[add cmac.o into crypto-objs-y; revise commit message]
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/cmac.c   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 10cf1c6991fa..d37e00783f84 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -72,7 +72,7 @@ cryptomgr-y := algboss.o testmgr.o
 
 crypto-objs-$(CONFIG_CRYPTO_MANAGER2) += cryptomgr.o
 obj-$(CONFIG_CRYPTO_USER) += crypto_user.o
-obj-$(CONFIG_CRYPTO_CMAC) += cmac.o
+crypto-objs-$(CONFIG_CRYPTO_CMAC) += cmac.o
 obj-$(CONFIG_CRYPTO_HMAC) += hmac.o
 obj-$(CONFIG_CRYPTO_XCBC) += xcbc.o
 obj-$(CONFIG_CRYPTO_NULL) += crypto_null.o
diff --git a/crypto/cmac.c b/crypto/cmac.c
index 1b03964abe00..f898c4612312 100644
--- a/crypto/cmac.c
+++ b/crypto/cmac.c
@@ -251,8 +251,8 @@ static void __exit crypto_cmac_module_exit(void)
 	crypto_unregister_template(&crypto_cmac_tmpl);
 }
 
-module_init(crypto_cmac_module_init);
-module_exit(crypto_cmac_module_exit);
+crypto_module_init(crypto_cmac_module_init);
+crypto_module_exit(crypto_cmac_module_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("CMAC keyed hash algorithm");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 016/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_HMAC crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (14 preceding siblings ...)
  2026-02-12  2:45 ` [PATCH 015/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CMAC crypto Jay Wang
@ 2026-02-12  2:45 ` Jay Wang
  2026-02-12  2:45 ` [PATCH 017/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_MD5 crypto Jay Wang
                   ` (89 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:45 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

From: Vegard Nossum <vegard.nossum@oracle.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_HMAC-related crypto to convert them into pluggable
interface.

Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[add hmac.o into crypto-objs-y; revise commit message]
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/hmac.c   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index d37e00783f84..4d03d612b942 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -73,7 +73,7 @@ cryptomgr-y := algboss.o testmgr.o
 crypto-objs-$(CONFIG_CRYPTO_MANAGER2) += cryptomgr.o
 obj-$(CONFIG_CRYPTO_USER) += crypto_user.o
 crypto-objs-$(CONFIG_CRYPTO_CMAC) += cmac.o
-obj-$(CONFIG_CRYPTO_HMAC) += hmac.o
+crypto-objs-$(CONFIG_CRYPTO_HMAC) += hmac.o
 obj-$(CONFIG_CRYPTO_XCBC) += xcbc.o
 obj-$(CONFIG_CRYPTO_NULL) += crypto_null.o
 obj-$(CONFIG_CRYPTO_MD4) += md4.o
diff --git a/crypto/hmac.c b/crypto/hmac.c
index 148af460ae97..d8d24a2ea2f7 100644
--- a/crypto/hmac.c
+++ b/crypto/hmac.c
@@ -573,8 +573,8 @@ static void __exit hmac_module_exit(void)
 	crypto_unregister_templates(hmac_tmpls, ARRAY_SIZE(hmac_tmpls));
 }
 
-module_init(hmac_module_init);
-module_exit(hmac_module_exit);
+crypto_module_init(hmac_module_init);
+crypto_module_exit(hmac_module_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("HMAC hash algorithm");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 017/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_MD5 crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (15 preceding siblings ...)
  2026-02-12  2:45 ` [PATCH 016/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_HMAC crypto Jay Wang
@ 2026-02-12  2:45 ` Jay Wang
  2026-02-12  2:45 ` [PATCH 018/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SHA256 crypto Jay Wang
                   ` (88 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:45 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_MD5-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile              |  2 +-
 crypto/fips140/fips140-api.c | 11 +++++++++++
 crypto/md5.c                 |  4 ++--
 include/crypto/md5.h         |  8 +++++++-
 4 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 4d03d612b942..6310c3e88e4b 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -77,7 +77,7 @@ crypto-objs-$(CONFIG_CRYPTO_HMAC) += hmac.o
 obj-$(CONFIG_CRYPTO_XCBC) += xcbc.o
 obj-$(CONFIG_CRYPTO_NULL) += crypto_null.o
 obj-$(CONFIG_CRYPTO_MD4) += md4.o
-obj-$(CONFIG_CRYPTO_MD5) += md5.o
+crypto-objs-$(CONFIG_CRYPTO_MD5) += md5.o
 obj-$(CONFIG_CRYPTO_RMD160) += rmd160.o
 obj-$(CONFIG_CRYPTO_SHA1) += sha1.o
 obj-$(CONFIG_CRYPTO_SHA256) += sha256.o
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 17e03d4c1c9a..77ed24a3cd3b 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -368,4 +368,15 @@ DEFINE_CRYPTO_API_STUB(crypto_unregister_scomps);
 
 DEFINE_CRYPTO_API_STUB(alg_test);
 
+#endif
+
+/*
+ * crypto/md5.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_MD5)
+
+#include <crypto/md5.h>
+
+#undef md5_zero_message_hash
+DEFINE_CRYPTO_VAR_STUB(md5_zero_message_hash);
 #endif
\ No newline at end of file
diff --git a/crypto/md5.c b/crypto/md5.c
index c167d203c710..3a11675585c7 100644
--- a/crypto/md5.c
+++ b/crypto/md5.c
@@ -219,13 +219,13 @@ static int __init crypto_md5_mod_init(void)
 {
 	return crypto_register_shashes(algs, ARRAY_SIZE(algs));
 }
-module_init(crypto_md5_mod_init);
+crypto_module_init(crypto_md5_mod_init);
 
 static void __exit crypto_md5_mod_exit(void)
 {
 	crypto_unregister_shashes(algs, ARRAY_SIZE(algs));
 }
-module_exit(crypto_md5_mod_exit);
+crypto_module_exit(crypto_md5_mod_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Crypto API support for MD5 and HMAC-MD5");
diff --git a/include/crypto/md5.h b/include/crypto/md5.h
index c47aedfe67ec..9ec82ce94c1a 100644
--- a/include/crypto/md5.h
+++ b/include/crypto/md5.h
@@ -2,6 +2,7 @@
 #ifndef _CRYPTO_MD5_H
 #define _CRYPTO_MD5_H
 
+#include <crypto/api.h>
 #include <crypto/hash.h>
 #include <linux/types.h>
 
@@ -20,7 +21,12 @@
 #define CRYPTO_MD5_STATESIZE \
 	CRYPTO_HASH_STATESIZE(MD5_STATE_SIZE, MD5_HMAC_BLOCK_SIZE)
 
-extern const u8 md5_zero_message_hash[MD5_DIGEST_SIZE];
+DECLARE_CRYPTO_VAR(CONFIG_CRYPTO_MD5, md5_zero_message_hash, const u8, [MD5_DIGEST_SIZE]);
+
+#if defined(CONFIG_CRYPTO_FIPS140_EXTMOD) && !defined(FIPS_MODULE) && IS_BUILTIN(CONFIG_CRYPTO_MD5)
+#define md5_zero_message_hash (((const u8*)CRYPTO_VAR_NAME(md5_zero_message_hash)))
+#endif
+
 
 struct md5_state {
 	u32 hash[MD5_HASH_WORDS];
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 018/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SHA256 crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (16 preceding siblings ...)
  2026-02-12  2:45 ` [PATCH 017/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_MD5 crypto Jay Wang
@ 2026-02-12  2:45 ` Jay Wang
  2026-02-12  2:45 ` [PATCH 019/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SHA512 crypto Jay Wang
                   ` (87 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:45 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

From: Vegard Nossum <vegard.nossum@oracle.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_SHA256-related crypto to convert them into pluggable
interface.

Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[add sha256.o into crypto-objs-y; revise commit message]
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/sha256.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 6310c3e88e4b..45e055a8c0f4 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -80,7 +80,7 @@ obj-$(CONFIG_CRYPTO_MD4) += md4.o
 crypto-objs-$(CONFIG_CRYPTO_MD5) += md5.o
 obj-$(CONFIG_CRYPTO_RMD160) += rmd160.o
 obj-$(CONFIG_CRYPTO_SHA1) += sha1.o
-obj-$(CONFIG_CRYPTO_SHA256) += sha256.o
+crypto-objs-$(CONFIG_CRYPTO_SHA256) += sha256.o
 obj-$(CONFIG_CRYPTO_SHA512) += sha512.o
 obj-$(CONFIG_CRYPTO_SHA3) += sha3.o
 obj-$(CONFIG_CRYPTO_SM3_GENERIC) += sm3_generic.o
diff --git a/crypto/sha256.c b/crypto/sha256.c
index fb81defe084c..26ae39b4c1db 100644
--- a/crypto/sha256.c
+++ b/crypto/sha256.c
@@ -398,13 +398,13 @@ static int __init crypto_sha256_mod_init(void)
 {
 	return crypto_register_shashes(algs, ARRAY_SIZE(algs));
 }
-module_init(crypto_sha256_mod_init);
+crypto_module_init(crypto_sha256_mod_init);
 
 static void __exit crypto_sha256_mod_exit(void)
 {
 	crypto_unregister_shashes(algs, ARRAY_SIZE(algs));
 }
-module_exit(crypto_sha256_mod_exit);
+crypto_module_exit(crypto_sha256_mod_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Crypto API support for SHA-224, SHA-256, HMAC-SHA224, and HMAC-SHA256");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 019/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SHA512 crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (17 preceding siblings ...)
  2026-02-12  2:45 ` [PATCH 018/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SHA256 crypto Jay Wang
@ 2026-02-12  2:45 ` Jay Wang
  2026-02-12  2:45 ` [PATCH 020/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SHA3 crypto Jay Wang
                   ` (86 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:45 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

From: Vegard Nossum <vegard.nossum@oracle.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_SHA512-related crypto to convert them into pluggable
interface.

Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[add sha512.o into crypto-objs-y; revise commit message]
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/sha512.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 45e055a8c0f4..47ff0136c7c5 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -81,7 +81,7 @@ crypto-objs-$(CONFIG_CRYPTO_MD5) += md5.o
 obj-$(CONFIG_CRYPTO_RMD160) += rmd160.o
 obj-$(CONFIG_CRYPTO_SHA1) += sha1.o
 crypto-objs-$(CONFIG_CRYPTO_SHA256) += sha256.o
-obj-$(CONFIG_CRYPTO_SHA512) += sha512.o
+crypto-objs-$(CONFIG_CRYPTO_SHA512) += sha512.o
 obj-$(CONFIG_CRYPTO_SHA3) += sha3.o
 obj-$(CONFIG_CRYPTO_SM3_GENERIC) += sm3_generic.o
 obj-$(CONFIG_CRYPTO_STREEBOG) += streebog_generic.o
diff --git a/crypto/sha512.c b/crypto/sha512.c
index d320fe53913f..6e40932862d5 100644
--- a/crypto/sha512.c
+++ b/crypto/sha512.c
@@ -404,13 +404,13 @@ static int __init crypto_sha512_mod_init(void)
 {
 	return crypto_register_shashes(algs, ARRAY_SIZE(algs));
 }
-module_init(crypto_sha512_mod_init);
+crypto_module_init(crypto_sha512_mod_init);
 
 static void __exit crypto_sha512_mod_exit(void)
 {
 	crypto_unregister_shashes(algs, ARRAY_SIZE(algs));
 }
-module_exit(crypto_sha512_mod_exit);
+crypto_module_exit(crypto_sha512_mod_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Crypto API support for SHA-384, SHA-512, HMAC-SHA384, and HMAC-SHA512");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 020/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SHA3 crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (18 preceding siblings ...)
  2026-02-12  2:45 ` [PATCH 019/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SHA512 crypto Jay Wang
@ 2026-02-12  2:45 ` Jay Wang
  2026-02-12  2:45 ` [PATCH 021/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ECB crypto Jay Wang
                   ` (85 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:45 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_SHA3-related crypto to convert them into pluggable
interface.

This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.

Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/sha3.c   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 47ff0136c7c5..251b20fad9c2 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -82,7 +82,7 @@ obj-$(CONFIG_CRYPTO_RMD160) += rmd160.o
 obj-$(CONFIG_CRYPTO_SHA1) += sha1.o
 crypto-objs-$(CONFIG_CRYPTO_SHA256) += sha256.o
 crypto-objs-$(CONFIG_CRYPTO_SHA512) += sha512.o
-obj-$(CONFIG_CRYPTO_SHA3) += sha3.o
+crypto-objs-$(CONFIG_CRYPTO_SHA3) += sha3.o
 obj-$(CONFIG_CRYPTO_SM3_GENERIC) += sm3_generic.o
 obj-$(CONFIG_CRYPTO_STREEBOG) += streebog_generic.o
 obj-$(CONFIG_CRYPTO_WP512) += wp512.o
diff --git a/crypto/sha3.c b/crypto/sha3.c
index 8f364979ec89..1aefb256dd72 100644
--- a/crypto/sha3.c
+++ b/crypto/sha3.c
@@ -145,13 +145,13 @@ static int __init crypto_sha3_mod_init(void)
 {
 	return crypto_register_shashes(algs, ARRAY_SIZE(algs));
 }
-module_init(crypto_sha3_mod_init);
+crypto_module_init(crypto_sha3_mod_init);
 
 static void __exit crypto_sha3_mod_exit(void)
 {
 	crypto_unregister_shashes(algs, ARRAY_SIZE(algs));
 }
-module_exit(crypto_sha3_mod_exit);
+crypto_module_exit(crypto_sha3_mod_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Crypto API support for SHA-3");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 021/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ECB crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (19 preceding siblings ...)
  2026-02-12  2:45 ` [PATCH 020/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SHA3 crypto Jay Wang
@ 2026-02-12  2:45 ` Jay Wang
  2026-02-12  2:45 ` [PATCH 022/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CBC crypto Jay Wang
                   ` (84 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:45 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

From: Vegard Nossum <vegard.nossum@oracle.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_ECB-related crypto to convert them into pluggable
interface.

Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[add ecb.o into crypto-objs-y; revise commit message]
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/ecb.c    | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 251b20fad9c2..11a6714dee42 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -88,7 +88,7 @@ obj-$(CONFIG_CRYPTO_STREEBOG) += streebog_generic.o
 obj-$(CONFIG_CRYPTO_WP512) += wp512.o
 CFLAGS_wp512.o := $(call cc-option,-fno-schedule-insns)  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149
 obj-$(CONFIG_CRYPTO_BLAKE2B) += blake2b.o
-obj-$(CONFIG_CRYPTO_ECB) += ecb.o
+crypto-objs-$(CONFIG_CRYPTO_ECB) += ecb.o
 obj-$(CONFIG_CRYPTO_CBC) += cbc.o
 obj-$(CONFIG_CRYPTO_PCBC) += pcbc.o
 obj-$(CONFIG_CRYPTO_CTS) += cts.o
diff --git a/crypto/ecb.c b/crypto/ecb.c
index cd1b20456dad..20127b20f483 100644
--- a/crypto/ecb.c
+++ b/crypto/ecb.c
@@ -219,8 +219,8 @@ static void __exit crypto_ecb_module_exit(void)
 	crypto_unregister_template(&crypto_ecb_tmpl);
 }
 
-module_init(crypto_ecb_module_init);
-module_exit(crypto_ecb_module_exit);
+crypto_module_init(crypto_ecb_module_init);
+crypto_module_exit(crypto_ecb_module_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("ECB block cipher mode of operation");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 022/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CBC crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (20 preceding siblings ...)
  2026-02-12  2:45 ` [PATCH 021/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ECB crypto Jay Wang
@ 2026-02-12  2:45 ` Jay Wang
  2026-02-12  2:45 ` [PATCH 023/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CTR crypto Jay Wang
                   ` (83 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:45 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

From: Vegard Nossum <vegard.nossum@oracle.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_CBC-related crypto to convert them into pluggable
interface.

Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[add cbc.o into crypto-objs-y; revise commit message]
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/cbc.c    | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 11a6714dee42..354ce7a46a0a 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -89,7 +89,7 @@ obj-$(CONFIG_CRYPTO_WP512) += wp512.o
 CFLAGS_wp512.o := $(call cc-option,-fno-schedule-insns)  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149
 obj-$(CONFIG_CRYPTO_BLAKE2B) += blake2b.o
 crypto-objs-$(CONFIG_CRYPTO_ECB) += ecb.o
-obj-$(CONFIG_CRYPTO_CBC) += cbc.o
+crypto-objs-$(CONFIG_CRYPTO_CBC) += cbc.o
 obj-$(CONFIG_CRYPTO_PCBC) += pcbc.o
 obj-$(CONFIG_CRYPTO_CTS) += cts.o
 obj-$(CONFIG_CRYPTO_LRW) += lrw.o
diff --git a/crypto/cbc.c b/crypto/cbc.c
index ed3df6246765..03ee7008ab12 100644
--- a/crypto/cbc.c
+++ b/crypto/cbc.c
@@ -179,8 +179,8 @@ static void __exit crypto_cbc_module_exit(void)
 	crypto_unregister_template(&crypto_cbc_tmpl);
 }
 
-module_init(crypto_cbc_module_init);
-module_exit(crypto_cbc_module_exit);
+crypto_module_init(crypto_cbc_module_init);
+crypto_module_exit(crypto_cbc_module_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("CBC block cipher mode of operation");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 023/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CTR crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (21 preceding siblings ...)
  2026-02-12  2:45 ` [PATCH 022/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CBC crypto Jay Wang
@ 2026-02-12  2:45 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 024/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_GCM crypto Jay Wang
                   ` (82 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:45 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

From: Vegard Nossum <vegard.nossum@oracle.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_CTR-related crypto to convert them into pluggable
interface.

Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[add ctr.o into crypto-objs-y; revise commit message]
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/ctr.c    | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 354ce7a46a0a..d5b5ca797dc6 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -94,7 +94,7 @@ obj-$(CONFIG_CRYPTO_PCBC) += pcbc.o
 obj-$(CONFIG_CRYPTO_CTS) += cts.o
 obj-$(CONFIG_CRYPTO_LRW) += lrw.o
 obj-$(CONFIG_CRYPTO_XTS) += xts.o
-obj-$(CONFIG_CRYPTO_CTR) += ctr.o
+crypto-objs-$(CONFIG_CRYPTO_CTR) += ctr.o
 obj-$(CONFIG_CRYPTO_XCTR) += xctr.o
 obj-$(CONFIG_CRYPTO_HCTR2) += hctr2.o
 obj-$(CONFIG_CRYPTO_ADIANTUM) += adiantum.o
diff --git a/crypto/ctr.c b/crypto/ctr.c
index a388f0ceb3a0..fa67cf6de4b1 100644
--- a/crypto/ctr.c
+++ b/crypto/ctr.c
@@ -350,8 +350,8 @@ static void __exit crypto_ctr_module_exit(void)
 				    ARRAY_SIZE(crypto_ctr_tmpls));
 }
 
-module_init(crypto_ctr_module_init);
-module_exit(crypto_ctr_module_exit);
+crypto_module_init(crypto_ctr_module_init);
+crypto_module_exit(crypto_ctr_module_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("CTR block cipher mode of operation");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 024/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_GCM crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (22 preceding siblings ...)
  2026-02-12  2:45 ` [PATCH 023/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CTR crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 025/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CCM crypto Jay Wang
                   ` (81 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

From: Vegard Nossum <vegard.nossum@oracle.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_GCM-related crypto to convert them into pluggable
interface.

Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[add gcm.o into crypto-objs-y; revise commit message]
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/gcm.c    | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index d5b5ca797dc6..11bb65cf0094 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -98,7 +98,7 @@ crypto-objs-$(CONFIG_CRYPTO_CTR) += ctr.o
 obj-$(CONFIG_CRYPTO_XCTR) += xctr.o
 obj-$(CONFIG_CRYPTO_HCTR2) += hctr2.o
 obj-$(CONFIG_CRYPTO_ADIANTUM) += adiantum.o
-obj-$(CONFIG_CRYPTO_GCM) += gcm.o
+crypto-objs-$(CONFIG_CRYPTO_GCM) += gcm.o
 obj-$(CONFIG_CRYPTO_CCM) += ccm.o
 obj-$(CONFIG_CRYPTO_CHACHA20POLY1305) += chacha20poly1305.o
 obj-$(CONFIG_CRYPTO_AEGIS128) += aegis128.o
diff --git a/crypto/gcm.c b/crypto/gcm.c
index 97716482bed0..54a376e782d1 100644
--- a/crypto/gcm.c
+++ b/crypto/gcm.c
@@ -1119,8 +1119,8 @@ static void __exit crypto_gcm_module_exit(void)
 				    ARRAY_SIZE(crypto_gcm_tmpls));
 }
 
-module_init(crypto_gcm_module_init);
-module_exit(crypto_gcm_module_exit);
+crypto_module_init(crypto_gcm_module_init);
+crypto_module_exit(crypto_gcm_module_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Galois/Counter Mode");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 025/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CCM crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (23 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 024/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_GCM crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 026/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_AUTHENC crypto Jay Wang
                   ` (80 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

From: Vegard Nossum <vegard.nossum@oracle.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_CCM-related crypto to convert them into pluggable
interface.

Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[add ccm.o into crypto-objs-y; revise commit message]
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/ccm.c    | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 11bb65cf0094..9dc0d5d55eaa 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -99,7 +99,7 @@ obj-$(CONFIG_CRYPTO_XCTR) += xctr.o
 obj-$(CONFIG_CRYPTO_HCTR2) += hctr2.o
 obj-$(CONFIG_CRYPTO_ADIANTUM) += adiantum.o
 crypto-objs-$(CONFIG_CRYPTO_GCM) += gcm.o
-obj-$(CONFIG_CRYPTO_CCM) += ccm.o
+crypto-objs-$(CONFIG_CRYPTO_CCM) += ccm.o
 obj-$(CONFIG_CRYPTO_CHACHA20POLY1305) += chacha20poly1305.o
 obj-$(CONFIG_CRYPTO_AEGIS128) += aegis128.o
 aegis128-y := aegis128-core.o
diff --git a/crypto/ccm.c b/crypto/ccm.c
index 2ae929ffdef8..e76946e05b5e 100644
--- a/crypto/ccm.c
+++ b/crypto/ccm.c
@@ -929,8 +929,8 @@ static void __exit crypto_ccm_module_exit(void)
 				    ARRAY_SIZE(crypto_ccm_tmpls));
 }
 
-module_init(crypto_ccm_module_init);
-module_exit(crypto_ccm_module_exit);
+crypto_module_init(crypto_ccm_module_init);
+crypto_module_exit(crypto_ccm_module_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Counter with CBC MAC");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 026/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_AUTHENC crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (24 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 025/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CCM crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 027/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_LZO crypto Jay Wang
                   ` (79 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_AUTHENC-related crypto to convert them into pluggable
interface.

This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.

Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile              |  2 +-
 crypto/authenc.c             |  4 ++--
 crypto/authencesn.c          |  4 ++--
 crypto/fips140/fips140-api.c | 12 ++++++++++++
 include/crypto/authenc.h     |  6 ++++--
 5 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 9dc0d5d55eaa..3a2da61b4581 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -155,7 +155,7 @@ obj-$(CONFIG_CRYPTO_CRC32C) += crc32c-cryptoapi.o
 crc32c-cryptoapi-y := crc32c.o
 obj-$(CONFIG_CRYPTO_CRC32) += crc32-cryptoapi.o
 crc32-cryptoapi-y := crc32.o
-obj-$(CONFIG_CRYPTO_AUTHENC) += authenc.o authencesn.o
+crypto-objs-$(CONFIG_CRYPTO_AUTHENC) += authenc.o authencesn.o
 obj-$(CONFIG_CRYPTO_KRB5ENC) += krb5enc.o
 obj-$(CONFIG_CRYPTO_LZO) += lzo.o lzo-rle.o
 obj-$(CONFIG_CRYPTO_LZ4) += lz4.o
diff --git a/crypto/authenc.c b/crypto/authenc.c
index ac679ce2cb95..132c30d75165 100644
--- a/crypto/authenc.c
+++ b/crypto/authenc.c
@@ -446,8 +446,8 @@ static void __exit crypto_authenc_module_exit(void)
 	crypto_unregister_template(&crypto_authenc_tmpl);
 }
 
-module_init(crypto_authenc_module_init);
-module_exit(crypto_authenc_module_exit);
+crypto_module_init(crypto_authenc_module_init);
+crypto_module_exit(crypto_authenc_module_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Simple AEAD wrapper for IPsec");
diff --git a/crypto/authencesn.c b/crypto/authencesn.c
index 542a978663b9..6279d877a95a 100644
--- a/crypto/authencesn.c
+++ b/crypto/authencesn.c
@@ -439,8 +439,8 @@ static void __exit crypto_authenc_esn_module_exit(void)
 	crypto_unregister_template(&crypto_authenc_esn_tmpl);
 }
 
-module_init(crypto_authenc_esn_module_init);
-module_exit(crypto_authenc_esn_module_exit);
+crypto_module_init(crypto_authenc_esn_module_init);
+crypto_module_exit(crypto_authenc_esn_module_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Steffen Klassert <steffen.klassert@secunet.com>");
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 77ed24a3cd3b..3cfe147b984c 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -379,4 +379,16 @@ DEFINE_CRYPTO_API_STUB(alg_test);
 
 #undef md5_zero_message_hash
 DEFINE_CRYPTO_VAR_STUB(md5_zero_message_hash);
+
+#endif
+
+/*
+ * crypto/authenc.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_AUTHENC)
+
+#include <crypto/authenc.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_authenc_extractkeys);
+
 #endif
\ No newline at end of file
diff --git a/include/crypto/authenc.h b/include/crypto/authenc.h
index 15a9caa2354a..4871b7bdcd8e 100644
--- a/include/crypto/authenc.h
+++ b/include/crypto/authenc.h
@@ -7,6 +7,7 @@
 #ifndef _CRYPTO_AUTHENC_H
 #define _CRYPTO_AUTHENC_H
 
+#include <crypto/api.h>
 #include <linux/types.h>
 
 enum {
@@ -26,8 +27,9 @@ struct crypto_authenc_keys {
 	unsigned int enckeylen;
 };
 
-int crypto_authenc_extractkeys(struct crypto_authenc_keys *keys, const u8 *key,
-			       unsigned int keylen);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_AUTHENC, crypto_authenc_extractkeys, int,
+	(struct crypto_authenc_keys *keys, const u8 *key, unsigned int keylen),
+	(keys, key, keylen));
 int crypto_krb5enc_extractkeys(struct crypto_authenc_keys *keys, const u8 *key,
 			       unsigned int keylen);
 
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 027/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_LZO crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (25 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 026/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_AUTHENC crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 028/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_RNG2 crypto Jay Wang
                   ` (78 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_LZO-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile  | 2 +-
 crypto/lzo-rle.c | 4 ++--
 crypto/lzo.c     | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 3a2da61b4581..647797922678 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -157,7 +157,7 @@ obj-$(CONFIG_CRYPTO_CRC32) += crc32-cryptoapi.o
 crc32-cryptoapi-y := crc32.o
 crypto-objs-$(CONFIG_CRYPTO_AUTHENC) += authenc.o authencesn.o
 obj-$(CONFIG_CRYPTO_KRB5ENC) += krb5enc.o
-obj-$(CONFIG_CRYPTO_LZO) += lzo.o lzo-rle.o
+crypto-objs-$(CONFIG_CRYPTO_LZO) += lzo.o lzo-rle.o
 obj-$(CONFIG_CRYPTO_LZ4) += lz4.o
 obj-$(CONFIG_CRYPTO_LZ4HC) += lz4hc.o
 obj-$(CONFIG_CRYPTO_XXHASH) += xxhash_generic.o
diff --git a/crypto/lzo-rle.c b/crypto/lzo-rle.c
index 794e7ec49536..10af97e741fa 100644
--- a/crypto/lzo-rle.c
+++ b/crypto/lzo-rle.c
@@ -93,8 +93,8 @@ static void __exit lzorle_mod_fini(void)
 	crypto_unregister_scomp(&scomp);
 }
 
-module_init(lzorle_mod_init);
-module_exit(lzorle_mod_fini);
+crypto_module_init(lzorle_mod_init);
+crypto_module_exit(lzorle_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("LZO-RLE Compression Algorithm");
diff --git a/crypto/lzo.c b/crypto/lzo.c
index d43242b24b4e..e1f9bc40f89f 100644
--- a/crypto/lzo.c
+++ b/crypto/lzo.c
@@ -93,8 +93,8 @@ static void __exit lzo_mod_fini(void)
 	crypto_unregister_scomp(&scomp);
 }
 
-module_init(lzo_mod_init);
-module_exit(lzo_mod_fini);
+crypto_module_init(lzo_mod_init);
+crypto_module_exit(lzo_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("LZO Compression Algorithm");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 028/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_RNG2 crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (26 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 027/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_LZO crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 029/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_DRBG crypto Jay Wang
                   ` (77 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_RNG2-related crypto to convert them into pluggable
interface.

This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.

Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile               |  2 +-
 crypto/fips140/fips140-api.c  | 23 ++++++++++++++++++++++-
 include/crypto/internal/rng.h | 21 ++++++++++++++++-----
 include/crypto/rng.h          | 18 +++++++++++++-----
 4 files changed, 52 insertions(+), 12 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 647797922678..4c87e141c961 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -162,7 +162,7 @@ obj-$(CONFIG_CRYPTO_LZ4) += lz4.o
 obj-$(CONFIG_CRYPTO_LZ4HC) += lz4hc.o
 obj-$(CONFIG_CRYPTO_XXHASH) += xxhash_generic.o
 obj-$(CONFIG_CRYPTO_842) += 842.o
-obj-$(CONFIG_CRYPTO_RNG2) += rng.o
+crypto-objs-$(CONFIG_CRYPTO_RNG2) += rng.o
 obj-$(CONFIG_CRYPTO_DRBG) += drbg.o
 obj-$(CONFIG_CRYPTO_JITTERENTROPY) += jitterentropy_rng.o
 CFLAGS_jitterentropy.o = -O0
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 3cfe147b984c..20afa1c21cf0 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -391,4 +391,25 @@ DEFINE_CRYPTO_VAR_STUB(md5_zero_message_hash);
 
 DEFINE_CRYPTO_API_STUB(crypto_authenc_extractkeys);
 
-#endif
\ No newline at end of file
+#endif
+/*
+ * crypto/rng.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_RNG2)
+
+#include <crypto/rng.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_get_default_rng);
+DEFINE_CRYPTO_API_STUB(crypto_put_default_rng);
+DEFINE_CRYPTO_API_STUB(crypto_alloc_rng);
+DEFINE_CRYPTO_API_STUB(crypto_rng_reset);
+
+#include <crypto/internal/rng.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_register_rng);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_rng);
+DEFINE_CRYPTO_API_STUB(crypto_register_rngs);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_rngs);
+DEFINE_CRYPTO_API_STUB(crypto_del_default_rng);
+
+#endif
diff --git a/include/crypto/internal/rng.h b/include/crypto/internal/rng.h
index e0711b6a597f..b281d8eb9405 100644
--- a/include/crypto/internal/rng.h
+++ b/include/crypto/internal/rng.h
@@ -9,16 +9,27 @@
 #ifndef _CRYPTO_INTERNAL_RNG_H
 #define _CRYPTO_INTERNAL_RNG_H
 
+#include <crypto/api.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);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_RNG2, crypto_register_rng, int,
+	(struct rng_alg *alg),
+	(alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_RNG2, crypto_unregister_rng, void,
+	(struct rng_alg *alg),
+	(alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_RNG2, crypto_register_rngs, int,
+	(struct rng_alg *algs, int count),
+	(algs, count));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_RNG2, crypto_unregister_rngs, void,
+	(struct rng_alg *algs, int count),
+	(algs, count));
 
 #if defined(CONFIG_CRYPTO_RNG) || defined(CONFIG_CRYPTO_RNG_MODULE)
-int crypto_del_default_rng(void);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_RNG2, crypto_del_default_rng, int,
+	(void),
+	());
 #else
 static inline int crypto_del_default_rng(void)
 {
diff --git a/include/crypto/rng.h b/include/crypto/rng.h
index d451b54b322a..89a78f4a6e37 100644
--- a/include/crypto/rng.h
+++ b/include/crypto/rng.h
@@ -9,6 +9,7 @@
 #ifndef _CRYPTO_RNG_H
 #define _CRYPTO_RNG_H
 
+#include <crypto/api.h>
 #include <linux/atomic.h>
 #include <linux/container_of.h>
 #include <linux/crypto.h>
@@ -59,8 +60,12 @@ struct crypto_rng {
 
 extern struct crypto_rng *crypto_default_rng;
 
-int crypto_get_default_rng(void);
-void crypto_put_default_rng(void);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_RNG2, crypto_get_default_rng, int,
+	(void),
+	());
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_RNG2, crypto_put_default_rng, void,
+	(void),
+	());
 
 /**
  * DOC: Random number generator API
@@ -89,7 +94,9 @@ void crypto_put_default_rng(void);
  * 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);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_RNG2, crypto_alloc_rng, struct crypto_rng *,
+	(const char *alg_name, u32 type, u32 mask),
+	(alg_name, type, mask));
 
 static inline struct crypto_tfm *crypto_rng_tfm(struct crypto_rng *tfm)
 {
@@ -177,8 +184,9 @@ static inline int crypto_rng_get_bytes(struct crypto_rng *tfm,
  *
  * 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);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_RNG2, crypto_rng_reset, int,
+	(struct crypto_rng *tfm, const u8 *seed, unsigned int slen),
+	(tfm, seed, slen));
 
 /**
  * crypto_rng_seedsize() - obtain seed size of RNG
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 029/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_DRBG crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (27 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 028/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_RNG2 crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 030/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_JITTERENTROPY crypto Jay Wang
                   ` (76 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

From: Vegard Nossum <vegard.nossum@oracle.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_DRBG-related crypto to convert them into pluggable
interface.

Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[add drbg.o into crypto-objs-y; revise commit message]
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/drbg.c   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 4c87e141c961..25f0d9d56469 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -163,7 +163,7 @@ obj-$(CONFIG_CRYPTO_LZ4HC) += lz4hc.o
 obj-$(CONFIG_CRYPTO_XXHASH) += xxhash_generic.o
 obj-$(CONFIG_CRYPTO_842) += 842.o
 crypto-objs-$(CONFIG_CRYPTO_RNG2) += rng.o
-obj-$(CONFIG_CRYPTO_DRBG) += drbg.o
+crypto-objs-$(CONFIG_CRYPTO_DRBG) += drbg.o
 obj-$(CONFIG_CRYPTO_JITTERENTROPY) += jitterentropy_rng.o
 CFLAGS_jitterentropy.o = -O0
 KASAN_SANITIZE_jitterentropy.o = n
diff --git a/crypto/drbg.c b/crypto/drbg.c
index 5e7ed5f5c192..f4eba9ef6d59 100644
--- a/crypto/drbg.c
+++ b/crypto/drbg.c
@@ -1882,8 +1882,8 @@ static void __exit drbg_exit(void)
 	crypto_unregister_rngs(drbg_algs, (ARRAY_SIZE(drbg_cores) * 2));
 }
 
-module_init(drbg_init);
-module_exit(drbg_exit);
+crypto_module_init(drbg_init);
+crypto_module_exit(drbg_exit);
 #ifndef CRYPTO_DRBG_HASH_STRING
 #define CRYPTO_DRBG_HASH_STRING ""
 #endif
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 030/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_JITTERENTROPY crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (28 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 029/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_DRBG crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 031/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_GHASH crypto Jay Wang
                   ` (75 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

From: Vegard Nossum <vegard.nossum@oracle.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_JITTERENTROPY-related crypto to convert them into pluggable
interface.

Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[add jitterentropy_rng.o into crypto-objs-y; revise commit message]
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile              | 2 +-
 crypto/jitterentropy-kcapi.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 25f0d9d56469..1d5ee8dc24d9 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -164,7 +164,7 @@ obj-$(CONFIG_CRYPTO_XXHASH) += xxhash_generic.o
 obj-$(CONFIG_CRYPTO_842) += 842.o
 crypto-objs-$(CONFIG_CRYPTO_RNG2) += rng.o
 crypto-objs-$(CONFIG_CRYPTO_DRBG) += drbg.o
-obj-$(CONFIG_CRYPTO_JITTERENTROPY) += jitterentropy_rng.o
+crypto-objs-$(CONFIG_CRYPTO_JITTERENTROPY) += jitterentropy_rng.o
 CFLAGS_jitterentropy.o = -O0
 KASAN_SANITIZE_jitterentropy.o = n
 UBSAN_SANITIZE_jitterentropy.o = n
diff --git a/crypto/jitterentropy-kcapi.c b/crypto/jitterentropy-kcapi.c
index 7c880cf34c52..11115b8df694 100644
--- a/crypto/jitterentropy-kcapi.c
+++ b/crypto/jitterentropy-kcapi.c
@@ -361,8 +361,8 @@ static void __exit jent_mod_exit(void)
 	crypto_unregister_rng(&jent_alg);
 }
 
-module_init(jent_mod_init);
-module_exit(jent_mod_exit);
+crypto_module_init(jent_mod_init);
+crypto_module_exit(jent_mod_exit);
 
 MODULE_LICENSE("Dual BSD/GPL");
 MODULE_AUTHOR("Stephan Mueller <smueller@chronox.de>");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 031/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_GHASH crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (29 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 030/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_JITTERENTROPY crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 032/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYMMETRIC_KEY_TYPE crypto Jay Wang
                   ` (74 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

From: Vegard Nossum <vegard.nossum@oracle.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_GHASH-related crypto to convert them into pluggable
interface.

Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[add ghash-generic.o into crypto-objs-y; revise commit message]
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile        | 2 +-
 crypto/ghash-generic.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 1d5ee8dc24d9..d58b5e2b5b43 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -171,7 +171,7 @@ UBSAN_SANITIZE_jitterentropy.o = n
 jitterentropy_rng-y := jitterentropy.o jitterentropy-kcapi.o
 obj-$(CONFIG_CRYPTO_JITTERENTROPY_TESTINTERFACE) += jitterentropy-testing.o
 obj-$(CONFIG_CRYPTO_BENCHMARK) += tcrypt.o
-obj-$(CONFIG_CRYPTO_GHASH) += ghash-generic.o
+crypto-objs-$(CONFIG_CRYPTO_GHASH) += ghash-generic.o
 obj-$(CONFIG_CRYPTO_USER_API) += af_alg.o
 obj-$(CONFIG_CRYPTO_USER_API_HASH) += algif_hash.o
 obj-$(CONFIG_CRYPTO_USER_API_SKCIPHER) += algif_skcipher.o
diff --git a/crypto/ghash-generic.c b/crypto/ghash-generic.c
index e5803c249c12..37e98aa546c7 100644
--- a/crypto/ghash-generic.c
+++ b/crypto/ghash-generic.c
@@ -153,8 +153,8 @@ static void __exit ghash_mod_exit(void)
 	crypto_unregister_shash(&ghash_alg);
 }
 
-module_init(ghash_mod_init);
-module_exit(ghash_mod_exit);
+crypto_module_init(ghash_mod_init);
+crypto_module_exit(ghash_mod_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("GHASH hash function");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 032/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYMMETRIC_KEY_TYPE crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (30 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 031/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_GHASH crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 033/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE crypto Jay Wang
                   ` (73 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_ASYMMETRIC_KEY_TYPE-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 certs/system_keyring.c                   |  1 +
 crypto/asymmetric_keys/Makefile          |  2 +-
 crypto/asymmetric_keys/asymmetric_type.c |  4 +--
 crypto/asymmetric_keys/restrict.c        |  3 +-
 crypto/fips140/fips140-api.c             | 44 ++++++++++++++++++++++++
 include/crypto/public_key.h              | 29 +++++++++-------
 include/keys/asymmetric-parser.h         |  8 +++--
 include/keys/asymmetric-type.h           | 32 +++++++++--------
 8 files changed, 90 insertions(+), 33 deletions(-)

diff --git a/certs/system_keyring.c b/certs/system_keyring.c
index 9de610bf1f4b..a53261dc5629 100644
--- a/certs/system_keyring.c
+++ b/certs/system_keyring.c
@@ -50,6 +50,7 @@ int restrict_link_by_builtin_trusted(struct key *dest_keyring,
 	return restrict_link_by_signature(dest_keyring, type, payload,
 					  builtin_trusted_keys);
 }
+EXPORT_SYMBOL_GPL(restrict_link_by_builtin_trusted);
 
 /**
  * restrict_link_by_digsig_builtin - Restrict digitalSignature key additions by the built-in keyring
diff --git a/crypto/asymmetric_keys/Makefile b/crypto/asymmetric_keys/Makefile
index bc65d3b98dcb..252536153d73 100644
--- a/crypto/asymmetric_keys/Makefile
+++ b/crypto/asymmetric_keys/Makefile
@@ -3,7 +3,7 @@
 # Makefile for asymmetric cryptographic keys
 #
 
-obj-$(CONFIG_ASYMMETRIC_KEY_TYPE) += asymmetric_keys.o
+crypto-objs-$(CONFIG_ASYMMETRIC_KEY_TYPE) += asymmetric_keys.o
 
 asymmetric_keys-y := \
 	asymmetric_type.o \
diff --git a/crypto/asymmetric_keys/asymmetric_type.c b/crypto/asymmetric_keys/asymmetric_type.c
index 2326743310b1..9afc58536cf6 100644
--- a/crypto/asymmetric_keys/asymmetric_type.c
+++ b/crypto/asymmetric_keys/asymmetric_type.c
@@ -677,5 +677,5 @@ static void __exit asymmetric_key_cleanup(void)
 	unregister_key_type(&key_type_asymmetric);
 }
 
-module_init(asymmetric_key_init);
-module_exit(asymmetric_key_cleanup);
+crypto_module_init(asymmetric_key_init);
+crypto_module_exit(asymmetric_key_cleanup);
diff --git a/crypto/asymmetric_keys/restrict.c b/crypto/asymmetric_keys/restrict.c
index 86292965f493..5d6ecf9eadbc 100644
--- a/crypto/asymmetric_keys/restrict.c
+++ b/crypto/asymmetric_keys/restrict.c
@@ -114,7 +114,7 @@ int restrict_link_by_signature(struct key *dest_keyring,
 	key_put(key);
 	return ret;
 }
-
+EXPORT_SYMBOL_GPL(restrict_link_by_signature);
 /**
  * restrict_link_by_ca - Restrict additions to a ring of CA keys
  * @dest_keyring: Keyring being linked to.
@@ -198,6 +198,7 @@ int restrict_link_by_digsig(struct key *dest_keyring,
 	return restrict_link_by_signature(dest_keyring, type, payload,
 					  trust_keyring);
 }
+EXPORT_SYMBOL_GPL(restrict_link_by_digsig);
 
 static bool match_either_id(const struct asymmetric_key_id **pair,
 			    const struct asymmetric_key_id *single)
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 20afa1c21cf0..100f50ad7b43 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -413,3 +413,47 @@ DEFINE_CRYPTO_API_STUB(crypto_unregister_rngs);
 DEFINE_CRYPTO_API_STUB(crypto_del_default_rng);
 
 #endif
+/*
+ * crypto/asymmetric_keys/asymmetric_type.c
+ */
+#if IS_BUILTIN(CONFIG_ASYMMETRIC_KEY_TYPE)
+
+#include <keys/asymmetric-parser.h>
+
+DEFINE_CRYPTO_API_STUB(register_asymmetric_key_parser);
+DEFINE_CRYPTO_API_STUB(unregister_asymmetric_key_parser);
+
+#include <keys/asymmetric-type.h>
+
+DEFINE_CRYPTO_API_STUB(asymmetric_key_id_same);
+DEFINE_CRYPTO_API_STUB(asymmetric_key_id_partial);
+DEFINE_CRYPTO_API_STUB(asymmetric_key_generate_id);
+DEFINE_CRYPTO_API_STUB(find_asymmetric_key);
+
+#undef key_type_asymmetric
+DEFINE_CRYPTO_VAR_STUB(key_type_asymmetric);
+
+#endif
+/*
+ * crypto/asymmetric_keys/signature.c
+ */
+#if IS_BUILTIN(CONFIG_ASYMMETRIC_KEY_TYPE)
+
+#include <crypto/public_key.h>
+
+DEFINE_CRYPTO_API_STUB(public_key_signature_free);
+DEFINE_CRYPTO_API_STUB(query_asymmetric_key);
+DEFINE_CRYPTO_API_STUB(verify_signature);
+
+#endif
+/*
+ * crypto/asymmetric_keys/restrict.c
+ */
+#if IS_BUILTIN(CONFIG_ASYMMETRIC_KEY_TYPE)
+
+#include <crypto/public_key.h>
+
+DEFINE_CRYPTO_API_STUB(restrict_link_by_signature);
+DEFINE_CRYPTO_API_STUB(restrict_link_by_digsig);
+
+#endif
diff --git a/include/crypto/public_key.h b/include/crypto/public_key.h
index 4c5199b20338..be789854fdcb 100644
--- a/include/crypto/public_key.h
+++ b/include/crypto/public_key.h
@@ -10,6 +10,7 @@
 #ifndef _LINUX_PUBLIC_KEY_H
 #define _LINUX_PUBLIC_KEY_H
 
+#include <crypto/api.h>
 #include <linux/errno.h>
 #include <linux/keyctl.h>
 #include <linux/oid_registry.h>
@@ -53,7 +54,9 @@ struct public_key_signature {
 	const char *encoding;
 };
 
-extern void public_key_signature_free(struct public_key_signature *sig);
+DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, public_key_signature_free, void,
+	(struct public_key_signature *sig),
+	(sig));
 
 extern struct asymmetric_key_subtype public_key_subtype;
 
@@ -61,10 +64,9 @@ struct key;
 struct key_type;
 union key_payload;
 
-extern int restrict_link_by_signature(struct key *dest_keyring,
-				      const struct key_type *type,
-				      const union key_payload *payload,
-				      struct key *trust_keyring);
+DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, restrict_link_by_signature, int,
+	(struct key *dest_keyring, const struct key_type *type, const union key_payload *payload, struct key *trust_keyring),
+	(dest_keyring, type, payload, trust_keyring));
 
 extern int restrict_link_by_key_or_keyring(struct key *dest_keyring,
 					   const struct key_type *type,
@@ -81,10 +83,9 @@ extern int restrict_link_by_ca(struct key *dest_keyring,
 			       const struct key_type *type,
 			       const union key_payload *payload,
 			       struct key *trust_keyring);
-int restrict_link_by_digsig(struct key *dest_keyring,
-			    const struct key_type *type,
-			    const union key_payload *payload,
-			    struct key *trust_keyring);
+DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, restrict_link_by_digsig, int,
+	(struct key *dest_keyring, const struct key_type *type, const union key_payload *payload, struct key *trust_keyring),
+	(dest_keyring, type, payload, trust_keyring));
 #else
 static inline int restrict_link_by_ca(struct key *dest_keyring,
 				      const struct key_type *type,
@@ -103,11 +104,13 @@ static inline int restrict_link_by_digsig(struct key *dest_keyring,
 }
 #endif
 
-extern int query_asymmetric_key(const struct kernel_pkey_params *,
-				struct kernel_pkey_query *);
+DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, query_asymmetric_key, int,
+	(const struct kernel_pkey_params *arg1, struct kernel_pkey_query *arg2),
+	(arg1, arg2));
 
-extern int verify_signature(const struct key *,
-			    const struct public_key_signature *);
+DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, verify_signature, int,
+	(const struct key *arg1, const struct public_key_signature *arg2),
+	(arg1, arg2));
 
 #if IS_REACHABLE(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE)
 int public_key_verify_signature(const struct public_key *pkey,
diff --git a/include/keys/asymmetric-parser.h b/include/keys/asymmetric-parser.h
index 516a3f51179e..13474b17055b 100644
--- a/include/keys/asymmetric-parser.h
+++ b/include/keys/asymmetric-parser.h
@@ -29,7 +29,11 @@ struct asymmetric_key_parser {
 	int (*parse)(struct key_preparsed_payload *prep);
 };
 
-extern int register_asymmetric_key_parser(struct asymmetric_key_parser *);
-extern void unregister_asymmetric_key_parser(struct asymmetric_key_parser *);
+DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, register_asymmetric_key_parser, int,
+	(struct asymmetric_key_parser *parser),
+	(parser));
+DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, unregister_asymmetric_key_parser, void,
+	(struct asymmetric_key_parser *parser),
+	(parser));
 
 #endif /* _KEYS_ASYMMETRIC_PARSER_H */
diff --git a/include/keys/asymmetric-type.h b/include/keys/asymmetric-type.h
index 1b91c8f98688..96e718a550a3 100644
--- a/include/keys/asymmetric-type.h
+++ b/include/keys/asymmetric-type.h
@@ -10,10 +10,15 @@
 #ifndef _KEYS_ASYMMETRIC_TYPE_H
 #define _KEYS_ASYMMETRIC_TYPE_H
 
+#include <crypto/api.h>
 #include <linux/key-type.h>
 #include <linux/verification.h>
 
-extern struct key_type key_type_asymmetric;
+DECLARE_CRYPTO_VAR(CONFIG_ASYMMETRIC_KEY_TYPE, key_type_asymmetric, struct key_type, );
+
+#if defined(CONFIG_CRYPTO_FIPS140_EXTMOD) && !defined(FIPS_MODULE) && IS_BUILTIN(CONFIG_ASYMMETRIC_KEY_TYPE)
+#define key_type_asymmetric (*((struct key_type*)CRYPTO_VAR_NAME(key_type_asymmetric)))
+#endif
 
 /*
  * The key payload is four words.  The asymmetric-type key uses them as
@@ -56,16 +61,17 @@ struct asymmetric_key_ids {
 	void		*id[3];
 };
 
-extern bool asymmetric_key_id_same(const struct asymmetric_key_id *kid1,
-				   const struct asymmetric_key_id *kid2);
+DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, asymmetric_key_id_same, bool,
+	(const struct asymmetric_key_id *kid1, const struct asymmetric_key_id *kid2),
+	(kid1, kid2));
 
-extern bool asymmetric_key_id_partial(const struct asymmetric_key_id *kid1,
-				      const struct asymmetric_key_id *kid2);
+DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, asymmetric_key_id_partial, bool,
+	(const struct asymmetric_key_id *kid1, const struct asymmetric_key_id *kid2),
+	(kid1, kid2));
 
-extern struct asymmetric_key_id *asymmetric_key_generate_id(const void *val_1,
-							    size_t len_1,
-							    const void *val_2,
-							    size_t len_2);
+DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, asymmetric_key_generate_id, struct asymmetric_key_id *,
+	(const void *val_1, size_t len_1, const void *val_2, size_t len_2),
+	(val_1, len_1, val_2, len_2));
 static inline
 const struct asymmetric_key_ids *asymmetric_key_ids(const struct key *key)
 {
@@ -78,11 +84,9 @@ const struct public_key *asymmetric_key_public_key(const struct key *key)
 	return key->payload.data[asym_crypto];
 }
 
-extern struct key *find_asymmetric_key(struct key *keyring,
-				       const struct asymmetric_key_id *id_0,
-				       const struct asymmetric_key_id *id_1,
-				       const struct asymmetric_key_id *id_2,
-				       bool partial);
+DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, find_asymmetric_key, struct key *,
+	(struct key *keyring, const struct asymmetric_key_id *id_0, const struct asymmetric_key_id *id_1, const struct asymmetric_key_id *id_2, bool partial),
+	(keyring, id_0, id_1, id_2, partial));
 
 int x509_load_certificate_list(const u8 cert_list[], const unsigned long list_size,
 			       const struct key *keyring);
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 033/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (31 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 032/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYMMETRIC_KEY_TYPE crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 034/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_X509_CERTIFICATE_PARSER crypto Jay Wang
                   ` (72 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE-related crypto to convert them into
pluggable interface.

This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.

Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/asymmetric_keys/Makefile |  2 +-
 crypto/fips140/fips140-api.c    | 14 ++++++++++++++
 include/crypto/public_key.h     | 15 +++++++++++----
 3 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/crypto/asymmetric_keys/Makefile b/crypto/asymmetric_keys/Makefile
index 252536153d73..4f29401016f1 100644
--- a/crypto/asymmetric_keys/Makefile
+++ b/crypto/asymmetric_keys/Makefile
@@ -10,7 +10,7 @@ asymmetric_keys-y := \
 	restrict.o \
 	signature.o
 
-obj-$(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE) += public_key.o
+crypto-objs-$(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE) += public_key.o
 
 #
 # X.509 Certificate handling
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 100f50ad7b43..6dce18f81e91 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -457,3 +457,17 @@ DEFINE_CRYPTO_API_STUB(restrict_link_by_signature);
 DEFINE_CRYPTO_API_STUB(restrict_link_by_digsig);
 
 #endif
+/*
+ * crypto/asymmetric_keys/public_key.c
+ */
+#if IS_BUILTIN(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE)
+
+#include <crypto/public_key.h>
+
+DEFINE_CRYPTO_API_STUB(public_key_free);
+DEFINE_CRYPTO_API_STUB(public_key_verify_signature);
+
+#undef public_key_subtype
+DEFINE_CRYPTO_VAR_STUB(public_key_subtype);
+
+#endif
diff --git a/include/crypto/public_key.h b/include/crypto/public_key.h
index be789854fdcb..b0e737d1dc1a 100644
--- a/include/crypto/public_key.h
+++ b/include/crypto/public_key.h
@@ -36,7 +36,9 @@ struct public_key {
 #define KEY_EFLAG_KEYCERTSIGN	2	/* set if the keyCertSign usage is set */
 };
 
-extern void public_key_free(struct public_key *key);
+DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE, public_key_free, void,
+	(struct public_key *key),
+	(key));
 
 /*
  * Public key cryptography signature data
@@ -58,7 +60,11 @@ DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, public_key_signature_free, void,
 	(struct public_key_signature *sig),
 	(sig));
 
-extern struct asymmetric_key_subtype public_key_subtype;
+DECLARE_CRYPTO_VAR(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE, public_key_subtype, struct asymmetric_key_subtype, );
+
+#if defined(CONFIG_CRYPTO_FIPS140_EXTMOD) && !defined(FIPS_MODULE) && IS_BUILTIN(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE)
+#define public_key_subtype (*((struct asymmetric_key_subtype*)CRYPTO_VAR_NAME(public_key_subtype)))
+#endif
 
 struct key;
 struct key_type;
@@ -113,8 +119,9 @@ DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, verify_signature, int,
 	(arg1, arg2));
 
 #if IS_REACHABLE(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE)
-int public_key_verify_signature(const struct public_key *pkey,
-				const struct public_key_signature *sig);
+DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE, public_key_verify_signature, int,
+	(const struct public_key *pkey, const struct public_key_signature *sig),
+	(pkey, sig));
 #else
 static inline
 int public_key_verify_signature(const struct public_key *pkey,
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 034/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_X509_CERTIFICATE_PARSER crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (32 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 033/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 035/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_PKCS7_MESSAGE_PARSER crypto Jay Wang
                   ` (71 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_X509_CERTIFICATE_PARSER-related crypto to convert them into
pluggable interface.

This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.

Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/asymmetric_keys/Makefile          |  2 +-
 crypto/asymmetric_keys/x509_parser.h     | 15 ++++++++++-----
 crypto/asymmetric_keys/x509_public_key.c |  4 ++--
 crypto/fips140/fips140-api.c             | 22 ++++++++++++++++++++++
 include/keys/asymmetric-type.h           |  5 +++--
 5 files changed, 38 insertions(+), 10 deletions(-)

diff --git a/crypto/asymmetric_keys/Makefile b/crypto/asymmetric_keys/Makefile
index 4f29401016f1..b42c48d973d3 100644
--- a/crypto/asymmetric_keys/Makefile
+++ b/crypto/asymmetric_keys/Makefile
@@ -15,7 +15,7 @@ crypto-objs-$(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE) += public_key.o
 #
 # X.509 Certificate handling
 #
-obj-$(CONFIG_X509_CERTIFICATE_PARSER) += x509_key_parser.o
+crypto-objs-$(CONFIG_X509_CERTIFICATE_PARSER) += x509_key_parser.o
 x509_key_parser-y := \
 	x509.asn1.o \
 	x509_akid.asn1.o \
diff --git a/crypto/asymmetric_keys/x509_parser.h b/crypto/asymmetric_keys/x509_parser.h
index b7aeebdddb36..53bfc5f807bb 100644
--- a/crypto/asymmetric_keys/x509_parser.h
+++ b/crypto/asymmetric_keys/x509_parser.h
@@ -5,6 +5,7 @@
  * Written by David Howells (dhowells@redhat.com)
  */
 
+#include <crypto/api.h>
 #include <linux/cleanup.h>
 #include <linux/time.h>
 #include <crypto/public_key.h>
@@ -46,13 +47,17 @@ struct x509_certificate {
 /*
  * x509_cert_parser.c
  */
-extern void x509_free_certificate(struct x509_certificate *cert);
+DECLARE_CRYPTO_API(CONFIG_X509_CERTIFICATE_PARSER, x509_free_certificate, void,
+	(struct x509_certificate *cert),
+	(cert));
 DEFINE_FREE(x509_free_certificate, struct x509_certificate *,
 	    if (!IS_ERR(_T)) x509_free_certificate(_T))
-extern struct x509_certificate *x509_cert_parse(const void *data, size_t datalen);
-extern int x509_decode_time(time64_t *_t,  size_t hdrlen,
-			    unsigned char tag,
-			    const unsigned char *value, size_t vlen);
+DECLARE_CRYPTO_API(CONFIG_X509_CERTIFICATE_PARSER, x509_cert_parse, struct x509_certificate *,
+	(const void *data, size_t datalen),
+	(data, datalen));
+DECLARE_CRYPTO_API(CONFIG_X509_CERTIFICATE_PARSER, x509_decode_time, int,
+	(time64_t *_t, size_t hdrlen, unsigned char tag, const unsigned char *value, size_t vlen),
+	(_t, hdrlen, tag, value, vlen));
 
 /*
  * x509_public_key.c
diff --git a/crypto/asymmetric_keys/x509_public_key.c b/crypto/asymmetric_keys/x509_public_key.c
index 27b4fea37845..e840bd8019be 100644
--- a/crypto/asymmetric_keys/x509_public_key.c
+++ b/crypto/asymmetric_keys/x509_public_key.c
@@ -258,8 +258,8 @@ static void __exit x509_key_exit(void)
 	unregister_asymmetric_key_parser(&x509_key_parser);
 }
 
-module_init(x509_key_init);
-module_exit(x509_key_exit);
+crypto_module_init(x509_key_init);
+crypto_module_exit(x509_key_exit);
 
 MODULE_DESCRIPTION("X.509 certificate parser");
 MODULE_AUTHOR("Red Hat, Inc.");
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 6dce18f81e91..d08a001bb0db 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -471,3 +471,25 @@ DEFINE_CRYPTO_API_STUB(public_key_verify_signature);
 DEFINE_CRYPTO_VAR_STUB(public_key_subtype);
 
 #endif
+/*
+ * crypto/asymmetric_keys/x509_cert_parser.c
+ */
+#if IS_BUILTIN(CONFIG_X509_CERTIFICATE_PARSER)
+
+#include <crypto/asymmetric_keys/x509_parser.h>
+
+DEFINE_CRYPTO_API_STUB(x509_free_certificate);
+DEFINE_CRYPTO_API_STUB(x509_cert_parse);
+DEFINE_CRYPTO_API_STUB(x509_decode_time);
+
+#endif
+/*
+ * crypto/asymmetric_keys/x509_loader.c
+ */
+#if IS_BUILTIN(CONFIG_X509_CERTIFICATE_PARSER)
+
+#include <keys/asymmetric-type.h>
+
+DEFINE_CRYPTO_API_STUB(x509_load_certificate_list);
+
+#endif
diff --git a/include/keys/asymmetric-type.h b/include/keys/asymmetric-type.h
index 96e718a550a3..dd5b4d9980c1 100644
--- a/include/keys/asymmetric-type.h
+++ b/include/keys/asymmetric-type.h
@@ -88,8 +88,9 @@ DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, find_asymmetric_key, struct key *
 	(struct key *keyring, const struct asymmetric_key_id *id_0, const struct asymmetric_key_id *id_1, const struct asymmetric_key_id *id_2, bool partial),
 	(keyring, id_0, id_1, id_2, partial));
 
-int x509_load_certificate_list(const u8 cert_list[], const unsigned long list_size,
-			       const struct key *keyring);
+DECLARE_CRYPTO_API(CONFIG_X509_CERTIFICATE_PARSER, x509_load_certificate_list, int,
+	(const u8 cert_list[], const unsigned long list_size, const struct key *keyring),
+	(cert_list, list_size, keyring));
 
 /*
  * The payload is at the discretion of the subtype.
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 035/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_PKCS7_MESSAGE_PARSER crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (33 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 034/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_X509_CERTIFICATE_PARSER crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 036/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ENGINE crypto Jay Wang
                   ` (70 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_PKCS7_MESSAGE_PARSER-related crypto to convert them into pluggable
interface.

This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.

Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/asymmetric_keys/Makefile |  2 +-
 crypto/fips140/fips140-api.c    | 33 +++++++++++++++++++++++++++++++++
 include/crypto/pkcs7.h          | 31 +++++++++++++++++++------------
 3 files changed, 53 insertions(+), 13 deletions(-)

diff --git a/crypto/asymmetric_keys/Makefile b/crypto/asymmetric_keys/Makefile
index b42c48d973d3..c68fdcd2c5cf 100644
--- a/crypto/asymmetric_keys/Makefile
+++ b/crypto/asymmetric_keys/Makefile
@@ -50,7 +50,7 @@ clean-files	+= pkcs8.asn1.c pkcs8.asn1.h
 #
 # PKCS#7 message handling
 #
-obj-$(CONFIG_PKCS7_MESSAGE_PARSER) += pkcs7_message.o
+crypto-objs-$(CONFIG_PKCS7_MESSAGE_PARSER) += pkcs7_message.o
 pkcs7_message-y := \
 	pkcs7.asn1.o \
 	pkcs7_parser.o \
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index d08a001bb0db..e679932ab552 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -493,3 +493,36 @@ DEFINE_CRYPTO_API_STUB(x509_decode_time);
 DEFINE_CRYPTO_API_STUB(x509_load_certificate_list);
 
 #endif
+/*
+ * crypto/asymmetric_keys/pkcs7_parser.c
+ */
+#if IS_BUILTIN(CONFIG_PKCS7_MESSAGE_PARSER)
+
+#include <crypto/pkcs7.h>
+
+DEFINE_CRYPTO_API_STUB(pkcs7_parse_message);
+DEFINE_CRYPTO_API_STUB(pkcs7_free_message);
+DEFINE_CRYPTO_API_STUB(pkcs7_get_content_data);
+
+#endif
+/*
+ * crypto/asymmetric_keys/pkcs7_trust.c
+ */
+#if IS_BUILTIN(CONFIG_PKCS7_MESSAGE_PARSER)
+
+#include <crypto/pkcs7.h>
+
+DEFINE_CRYPTO_API_STUB(pkcs7_validate_trust);
+
+#endif
+/*
+ * crypto/asymmetric_keys/pkcs7_verify.c
+ */
+#if IS_BUILTIN(CONFIG_PKCS7_MESSAGE_PARSER)
+
+#include <crypto/pkcs7.h>
+
+DEFINE_CRYPTO_API_STUB(pkcs7_verify);
+DEFINE_CRYPTO_API_STUB(pkcs7_supply_detached_data);
+
+#endif
diff --git a/include/crypto/pkcs7.h b/include/crypto/pkcs7.h
index 38ec7f5f9041..63a7f2dbe627 100644
--- a/include/crypto/pkcs7.h
+++ b/include/crypto/pkcs7.h
@@ -8,6 +8,7 @@
 #ifndef _CRYPTO_PKCS7_H
 #define _CRYPTO_PKCS7_H
 
+#include <crypto/api.h>
 #include <linux/verification.h>
 #include <linux/hash_info.h>
 #include <crypto/public_key.h>
@@ -18,28 +19,34 @@ struct pkcs7_message;
 /*
  * pkcs7_parser.c
  */
-extern struct pkcs7_message *pkcs7_parse_message(const void *data,
-						 size_t datalen);
-extern void pkcs7_free_message(struct pkcs7_message *pkcs7);
+DECLARE_CRYPTO_API(CONFIG_PKCS7_MESSAGE_PARSER, pkcs7_parse_message, struct pkcs7_message *,
+	(const void *data, size_t datalen),
+	(data, datalen));
+DECLARE_CRYPTO_API(CONFIG_PKCS7_MESSAGE_PARSER, pkcs7_free_message, void,
+	(struct pkcs7_message *pkcs7),
+	(pkcs7));
 
-extern int pkcs7_get_content_data(const struct pkcs7_message *pkcs7,
-				  const void **_data, size_t *_datalen,
-				  size_t *_headerlen);
+DECLARE_CRYPTO_API(CONFIG_PKCS7_MESSAGE_PARSER, pkcs7_get_content_data, int,
+	(const struct pkcs7_message *pkcs7, const void **_data, size_t *_datalen, size_t *_headerlen),
+	(pkcs7, _data, _datalen, _headerlen));
 
 /*
  * pkcs7_trust.c
  */
-extern int pkcs7_validate_trust(struct pkcs7_message *pkcs7,
-				struct key *trust_keyring);
+DECLARE_CRYPTO_API(CONFIG_PKCS7_MESSAGE_PARSER, pkcs7_validate_trust, int,
+	(struct pkcs7_message *pkcs7, struct key *trust_keyring),
+	(pkcs7, trust_keyring));
 
 /*
  * pkcs7_verify.c
  */
-extern int pkcs7_verify(struct pkcs7_message *pkcs7,
-			enum key_being_used_for usage);
+DECLARE_CRYPTO_API(CONFIG_PKCS7_MESSAGE_PARSER, pkcs7_verify, int,
+	(struct pkcs7_message *pkcs7, enum key_being_used_for usage),
+	(pkcs7, usage));
 
-extern int pkcs7_supply_detached_data(struct pkcs7_message *pkcs7,
-				      const void *data, size_t datalen);
+DECLARE_CRYPTO_API(CONFIG_PKCS7_MESSAGE_PARSER, pkcs7_supply_detached_data, int,
+	(struct pkcs7_message *pkcs7, const void *data, size_t datalen),
+	(pkcs7, data, datalen));
 
 extern int pkcs7_get_digest(struct pkcs7_message *pkcs7, const u8 **buf,
 			    u32 *len, enum hash_algo *hash_algo);
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 036/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ENGINE crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (34 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 035/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_PKCS7_MESSAGE_PARSER crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 037/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_HKDF crypto Jay Wang
                   ` (69 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_ENGINE-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile              |   2 +-
 crypto/fips140/fips140-api.c |  40 ++++++++++
 include/crypto/engine.h      | 140 +++++++++++++++++++++++------------
 3 files changed, 135 insertions(+), 47 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index d58b5e2b5b43..f2b9532a0320 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -8,7 +8,7 @@ CONTEXT_ANALYSIS := y
 crypto-objs-$(CONFIG_CRYPTO) += crypto.o
 crypto-y := api.o cipher.o
 
-obj-$(CONFIG_CRYPTO_ENGINE) += crypto_engine.o
+crypto-objs-$(CONFIG_CRYPTO_ENGINE) += crypto_engine.o
 obj-$(CONFIG_CRYPTO_FIPS) += fips.o
 
 crypto_algapi-$(CONFIG_PROC_FS) += proc.o
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index e679932ab552..05ada434d1ac 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -526,3 +526,43 @@ DEFINE_CRYPTO_API_STUB(pkcs7_verify);
 DEFINE_CRYPTO_API_STUB(pkcs7_supply_detached_data);
 
 #endif
+/*
+ * crypto/crypto_engine.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_ENGINE)
+
+#include <crypto/engine.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_transfer_aead_request_to_engine);
+DEFINE_CRYPTO_API_STUB(crypto_transfer_akcipher_request_to_engine);
+DEFINE_CRYPTO_API_STUB(crypto_transfer_hash_request_to_engine);
+DEFINE_CRYPTO_API_STUB(crypto_transfer_kpp_request_to_engine);
+DEFINE_CRYPTO_API_STUB(crypto_transfer_skcipher_request_to_engine);
+DEFINE_CRYPTO_API_STUB(crypto_finalize_aead_request);
+DEFINE_CRYPTO_API_STUB(crypto_finalize_akcipher_request);
+DEFINE_CRYPTO_API_STUB(crypto_finalize_hash_request);
+DEFINE_CRYPTO_API_STUB(crypto_finalize_kpp_request);
+DEFINE_CRYPTO_API_STUB(crypto_finalize_skcipher_request);
+DEFINE_CRYPTO_API_STUB(crypto_engine_start);
+DEFINE_CRYPTO_API_STUB(crypto_engine_stop);
+DEFINE_CRYPTO_API_STUB(crypto_engine_alloc_init);
+DEFINE_CRYPTO_API_STUB(crypto_engine_alloc_init_and_set);
+DEFINE_CRYPTO_API_STUB(crypto_engine_exit);
+DEFINE_CRYPTO_API_STUB(crypto_engine_register_aead);
+DEFINE_CRYPTO_API_STUB(crypto_engine_unregister_aead);
+DEFINE_CRYPTO_API_STUB(crypto_engine_register_aeads);
+DEFINE_CRYPTO_API_STUB(crypto_engine_unregister_aeads);
+DEFINE_CRYPTO_API_STUB(crypto_engine_register_ahash);
+DEFINE_CRYPTO_API_STUB(crypto_engine_unregister_ahash);
+DEFINE_CRYPTO_API_STUB(crypto_engine_register_ahashes);
+DEFINE_CRYPTO_API_STUB(crypto_engine_unregister_ahashes);
+DEFINE_CRYPTO_API_STUB(crypto_engine_register_akcipher);
+DEFINE_CRYPTO_API_STUB(crypto_engine_unregister_akcipher);
+DEFINE_CRYPTO_API_STUB(crypto_engine_register_kpp);
+DEFINE_CRYPTO_API_STUB(crypto_engine_unregister_kpp);
+DEFINE_CRYPTO_API_STUB(crypto_engine_register_skcipher);
+DEFINE_CRYPTO_API_STUB(crypto_engine_unregister_skcipher);
+DEFINE_CRYPTO_API_STUB(crypto_engine_register_skciphers);
+DEFINE_CRYPTO_API_STUB(crypto_engine_unregister_skciphers);
+
+#endif
\ No newline at end of file
diff --git a/include/crypto/engine.h b/include/crypto/engine.h
index 2e60344437da..82552e11880a 100644
--- a/include/crypto/engine.h
+++ b/include/crypto/engine.h
@@ -7,6 +7,7 @@
 #ifndef _CRYPTO_ENGINE_H
 #define _CRYPTO_ENGINE_H
 
+#include <crypto/api.h>
 #include <crypto/aead.h>
 #include <crypto/akcipher.h>
 #include <crypto/hash.h>
@@ -51,56 +52,103 @@ struct skcipher_engine_alg {
 	struct crypto_engine_op op;
 };
 
-int crypto_transfer_aead_request_to_engine(struct crypto_engine *engine,
-					   struct aead_request *req);
-int crypto_transfer_akcipher_request_to_engine(struct crypto_engine *engine,
-					       struct akcipher_request *req);
-int crypto_transfer_hash_request_to_engine(struct crypto_engine *engine,
-					       struct ahash_request *req);
-int crypto_transfer_kpp_request_to_engine(struct crypto_engine *engine,
-					  struct kpp_request *req);
-int crypto_transfer_skcipher_request_to_engine(struct crypto_engine *engine,
-					       struct skcipher_request *req);
-void crypto_finalize_aead_request(struct crypto_engine *engine,
-				  struct aead_request *req, int err);
-void crypto_finalize_akcipher_request(struct crypto_engine *engine,
-				      struct akcipher_request *req, int err);
-void crypto_finalize_hash_request(struct crypto_engine *engine,
-				  struct ahash_request *req, int err);
-void crypto_finalize_kpp_request(struct crypto_engine *engine,
-				 struct kpp_request *req, int err);
-void crypto_finalize_skcipher_request(struct crypto_engine *engine,
-				      struct skcipher_request *req, int err);
-int crypto_engine_start(struct crypto_engine *engine);
-int crypto_engine_stop(struct crypto_engine *engine);
-struct crypto_engine *crypto_engine_alloc_init(struct device *dev, bool rt);
-struct crypto_engine *crypto_engine_alloc_init_and_set(struct device *dev,
-						       bool retry_support,
-						       bool rt, int qlen);
-void crypto_engine_exit(struct crypto_engine *engine);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_transfer_aead_request_to_engine, int,
+	(struct crypto_engine *engine, struct aead_request *req),
+	(engine, req));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_transfer_akcipher_request_to_engine, int,
+	(struct crypto_engine *engine, struct akcipher_request *req),
+	(engine, req));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_transfer_hash_request_to_engine, int,
+	(struct crypto_engine *engine, struct ahash_request *req),
+	(engine, req));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_transfer_kpp_request_to_engine, int,
+	(struct crypto_engine *engine, struct kpp_request *req),
+	(engine, req));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_transfer_skcipher_request_to_engine, int,
+	(struct crypto_engine *engine, struct skcipher_request *req),
+	(engine, req));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_finalize_aead_request, void,
+	(struct crypto_engine *engine, struct aead_request *req, int err),
+	(engine, req, err));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_finalize_akcipher_request, void,
+	(struct crypto_engine *engine, struct akcipher_request *req, int err),
+	(engine, req, err));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_finalize_hash_request, void,
+	(struct crypto_engine *engine, struct ahash_request *req, int err),
+	(engine, req, err));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_finalize_kpp_request, void,
+	(struct crypto_engine *engine, struct kpp_request *req, int err),
+	(engine, req, err));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_finalize_skcipher_request, void,
+	(struct crypto_engine *engine, struct skcipher_request *req, int err),
+	(engine, req, err));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_start, int,
+	(struct crypto_engine *engine),
+	(engine));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_stop, int,
+	(struct crypto_engine *engine),
+	(engine));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_alloc_init, struct crypto_engine *,
+	(struct device *dev, bool rt),
+	(dev, rt));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_alloc_init_and_set, struct crypto_engine *,
+	(struct device *dev, bool retry_support, bool rt, int qlen),
+	(dev, retry_support, rt, qlen));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_exit, void,
+	(struct crypto_engine *engine),
+	(engine));
 
-int crypto_engine_register_aead(struct aead_engine_alg *alg);
-void crypto_engine_unregister_aead(struct aead_engine_alg *alg);
-int crypto_engine_register_aeads(struct aead_engine_alg *algs, int count);
-void crypto_engine_unregister_aeads(struct aead_engine_alg *algs, int count);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_register_aead, int,
+	(struct aead_engine_alg *alg),
+	(alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_unregister_aead, void,
+	(struct aead_engine_alg *alg),
+	(alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_register_aeads, int,
+	(struct aead_engine_alg *algs, int count),
+	(algs, count));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_unregister_aeads, void,
+	(struct aead_engine_alg *algs, int count),
+	(algs, count));
 
-int crypto_engine_register_ahash(struct ahash_engine_alg *alg);
-void crypto_engine_unregister_ahash(struct ahash_engine_alg *alg);
-int crypto_engine_register_ahashes(struct ahash_engine_alg *algs, int count);
-void crypto_engine_unregister_ahashes(struct ahash_engine_alg *algs,
-				      int count);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_register_ahash, int,
+	(struct ahash_engine_alg *alg),
+	(alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_unregister_ahash, void,
+	(struct ahash_engine_alg *alg),
+	(alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_register_ahashes, int,
+	(struct ahash_engine_alg *algs, int count),
+	(algs, count));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_unregister_ahashes, void,
+	(struct ahash_engine_alg *algs, int count),
+	(algs, count));
 
-int crypto_engine_register_akcipher(struct akcipher_engine_alg *alg);
-void crypto_engine_unregister_akcipher(struct akcipher_engine_alg *alg);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_register_akcipher, int,
+	(struct akcipher_engine_alg *alg),
+	(alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_unregister_akcipher, void,
+	(struct akcipher_engine_alg *alg),
+	(alg));
 
-int crypto_engine_register_kpp(struct kpp_engine_alg *alg);
-void crypto_engine_unregister_kpp(struct kpp_engine_alg *alg);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_register_kpp, int,
+	(struct kpp_engine_alg *alg),
+	(alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_unregister_kpp, void,
+	(struct kpp_engine_alg *alg),
+	(alg));
 
-int crypto_engine_register_skcipher(struct skcipher_engine_alg *alg);
-void crypto_engine_unregister_skcipher(struct skcipher_engine_alg *alg);
-int crypto_engine_register_skciphers(struct skcipher_engine_alg *algs,
-				     int count);
-void crypto_engine_unregister_skciphers(struct skcipher_engine_alg *algs,
-					int count);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_register_skcipher, int,
+	(struct skcipher_engine_alg *alg),
+	(alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_unregister_skcipher, void,
+	(struct skcipher_engine_alg *alg),
+	(alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_register_skciphers, int,
+	(struct skcipher_engine_alg *algs, int count),
+	(algs, count));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_unregister_skciphers, void,
+	(struct skcipher_engine_alg *algs, int count),
+	(algs, count));
 
 #endif /* _CRYPTO_ENGINE_H */
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 037/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_HKDF crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (35 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 036/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ENGINE crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 038/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_DH crypto Jay Wang
                   ` (68 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_HKDF-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile              |  2 +-
 crypto/fips140/fips140-api.c | 22 ++++++++++++++++++++++
 crypto/hkdf.c                |  4 ++--
 include/crypto/hkdf.h        | 13 +++++++------
 4 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index f2b9532a0320..42b45a8941b4 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -36,7 +36,7 @@ crypto-objs-$(CONFIG_CRYPTO_HASH2) += crypto_hash.o
 crypto-objs-$(CONFIG_CRYPTO_AKCIPHER2) += akcipher.o
 crypto-objs-$(CONFIG_CRYPTO_SIG2) += sig.o
 crypto-objs-$(CONFIG_CRYPTO_KPP2) += kpp.o
-obj-$(CONFIG_CRYPTO_HKDF) += hkdf.o
+crypto-objs-$(CONFIG_CRYPTO_HKDF) += hkdf.o
 
 dh_generic-y := dh.o
 dh_generic-y += dh_helper.o
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 05ada434d1ac..8db92603bd59 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -565,4 +565,26 @@ DEFINE_CRYPTO_API_STUB(crypto_engine_unregister_skcipher);
 DEFINE_CRYPTO_API_STUB(crypto_engine_register_skciphers);
 DEFINE_CRYPTO_API_STUB(crypto_engine_unregister_skciphers);
 
+#endif
+/*
+ * crypto/hkdf.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_HKDF)
+
+#include <crypto/hkdf.h>
+
+DEFINE_CRYPTO_API_STUB(hkdf_extract);
+DEFINE_CRYPTO_API_STUB(hkdf_expand);
+
+#endif
+/*
+ * crypto/hkdf.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_HKDF)
+
+#include <crypto/hkdf.h>
+
+DEFINE_CRYPTO_API_STUB(hkdf_extract);
+DEFINE_CRYPTO_API_STUB(hkdf_expand);
+
 #endif
\ No newline at end of file
diff --git a/crypto/hkdf.c b/crypto/hkdf.c
index 82d1b32ca6ce..c779353be68f 100644
--- a/crypto/hkdf.c
+++ b/crypto/hkdf.c
@@ -566,8 +566,8 @@ static int __init crypto_hkdf_module_init(void)
 
 static void __exit crypto_hkdf_module_exit(void) {}
 
-late_initcall(crypto_hkdf_module_init);
-module_exit(crypto_hkdf_module_exit);
+crypto_late_initcall(crypto_hkdf_module_init);
+crypto_module_exit(crypto_hkdf_module_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("HMAC-based Key Derivation Function (HKDF)");
diff --git a/include/crypto/hkdf.h b/include/crypto/hkdf.h
index 6a9678f508f5..8253aa2e004c 100644
--- a/include/crypto/hkdf.h
+++ b/include/crypto/hkdf.h
@@ -9,12 +9,13 @@
 #ifndef _CRYPTO_HKDF_H
 #define _CRYPTO_HKDF_H
 
+#include <crypto/api.h>
 #include <crypto/hash.h>
 
-int hkdf_extract(struct crypto_shash *hmac_tfm, const u8 *ikm,
-		 unsigned int ikmlen, const u8 *salt, unsigned int saltlen,
-		 u8 *prk);
-int hkdf_expand(struct crypto_shash *hmac_tfm,
-		const u8 *info, unsigned int infolen,
-		u8 *okm, unsigned int okmlen);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HKDF, hkdf_extract, int,
+	(struct crypto_shash *hmac_tfm, const u8 *ikm, unsigned int ikmlen, const u8 *salt, unsigned int saltlen, u8 *prk),
+	(hmac_tfm, ikm, ikmlen, salt, saltlen, prk));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_HKDF, hkdf_expand, int,
+	(struct crypto_shash *hmac_tfm, const u8 *info, unsigned int infolen, u8 *okm, unsigned int okmlen),
+	(hmac_tfm, info, infolen, okm, okmlen));
 #endif
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 038/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_DH crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (36 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 037/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_HKDF crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 039/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ECDSA and CONFIG_CRYPTO_ECC crypto Jay Wang
                   ` (67 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_DH-related crypto to convert them into pluggable
interface.

This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.

Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile              |  2 +-
 crypto/dh.c                  |  4 ++--
 crypto/fips140/fips140-api.c | 13 +++++++------
 include/crypto/dh.h          | 14 +++++++++++---
 4 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 42b45a8941b4..7b1188d5d953 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -40,7 +40,7 @@ crypto-objs-$(CONFIG_CRYPTO_HKDF) += hkdf.o
 
 dh_generic-y := dh.o
 dh_generic-y += dh_helper.o
-obj-$(CONFIG_CRYPTO_DH) += dh_generic.o
+crypto-objs-$(CONFIG_CRYPTO_DH) += dh_generic.o
 
 $(obj)/rsapubkey.asn1.o: $(obj)/rsapubkey.asn1.c $(obj)/rsapubkey.asn1.h
 $(obj)/rsaprivkey.asn1.o: $(obj)/rsaprivkey.asn1.c $(obj)/rsaprivkey.asn1.h
diff --git a/crypto/dh.c b/crypto/dh.c
index 8250eeeebd0f..5eacd5a4a92a 100644
--- a/crypto/dh.c
+++ b/crypto/dh.c
@@ -920,8 +920,8 @@ static void __exit dh_exit(void)
 	crypto_unregister_kpp(&dh);
 }
 
-module_init(dh_init);
-module_exit(dh_exit);
+crypto_module_init(dh_init);
+crypto_module_exit(dh_exit);
 MODULE_ALIAS_CRYPTO("dh");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("DH generic algorithm");
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 8db92603bd59..0b1794340b77 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -578,13 +578,14 @@ DEFINE_CRYPTO_API_STUB(hkdf_expand);
 
 #endif
 /*
- * crypto/hkdf.c
+ * crypto/dh_helper.c
  */
-#if IS_BUILTIN(CONFIG_CRYPTO_HKDF)
+#if IS_BUILTIN(CONFIG_CRYPTO_DH)
 
-#include <crypto/hkdf.h>
+#include <crypto/dh.h>
 
-DEFINE_CRYPTO_API_STUB(hkdf_extract);
-DEFINE_CRYPTO_API_STUB(hkdf_expand);
+DEFINE_CRYPTO_API_STUB(crypto_dh_key_len);
+DEFINE_CRYPTO_API_STUB(crypto_dh_encode_key);
+DEFINE_CRYPTO_API_STUB(crypto_dh_decode_key);
 
-#endif
\ No newline at end of file
+#endif
diff --git a/include/crypto/dh.h b/include/crypto/dh.h
index 7b863e911cb4..08d74c548535 100644
--- a/include/crypto/dh.h
+++ b/include/crypto/dh.h
@@ -8,6 +8,8 @@
 #ifndef _CRYPTO_DH_
 #define _CRYPTO_DH_
 
+#include <crypto/api.h>
+
 /**
  * DOC: DH Helper Functions
  *
@@ -48,7 +50,9 @@ struct dh {
  *
  * Return: size of the key in bytes
  */
-unsigned int crypto_dh_key_len(const struct dh *params);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_DH, crypto_dh_key_len, unsigned int,
+	(const struct dh *params),
+	(params));
 
 /**
  * crypto_dh_encode_key() - encode the private key
@@ -63,7 +67,9 @@ unsigned int crypto_dh_key_len(const struct dh *params);
  *
  * Return:	-EINVAL if buffer has insufficient size, 0 on success
  */
-int crypto_dh_encode_key(char *buf, unsigned int len, const struct dh *params);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_DH, crypto_dh_encode_key, int,
+	(char *buf, unsigned int len, const struct dh *params),
+	(buf, len, params));
 
 /**
  * crypto_dh_decode_key() - decode a private key
@@ -77,7 +83,9 @@ int crypto_dh_encode_key(char *buf, unsigned int len, const struct dh *params);
  *
  * Return:	-EINVAL if buffer has insufficient size, 0 on success
  */
-int crypto_dh_decode_key(const char *buf, unsigned int len, struct dh *params);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_DH, crypto_dh_decode_key, int,
+	(const char *buf, unsigned int len, struct dh *params),
+	(buf, len, params));
 
 /**
  * __crypto_dh_decode_key() - decode a private key without parameter checks
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 039/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ECDSA and CONFIG_CRYPTO_ECC crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (37 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 038/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_DH crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 040/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_USER crypto Jay Wang
                   ` (66 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_ECDSA- and CONFIG_CRYPTO_ECC-related crypto to convert
them into pluggable interface.

This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.

Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile               |  4 +-
 crypto/ecdsa.c                |  4 +-
 crypto/fips140/fips140-api.c  | 33 +++++++++++++
 include/crypto/ecc_curve.h    |  9 +++-
 include/crypto/internal/ecc.h | 91 ++++++++++++++++++++++-------------
 5 files changed, 102 insertions(+), 39 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 7b1188d5d953..2e3704e67e14 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -60,7 +60,7 @@ ecdsa_generic-y += ecdsa.o
 ecdsa_generic-y += ecdsa-x962.o
 ecdsa_generic-y += ecdsa-p1363.o
 ecdsa_generic-y += ecdsasignature.asn1.o
-obj-$(CONFIG_CRYPTO_ECDSA) += ecdsa_generic.o
+crypto-objs-$(CONFIG_CRYPTO_ECDSA) += ecdsa_generic.o
 
 obj-$(CONFIG_CRYPTO_MLDSA) += mldsa.o
 
@@ -178,7 +178,7 @@ obj-$(CONFIG_CRYPTO_USER_API_SKCIPHER) += algif_skcipher.o
 obj-$(CONFIG_CRYPTO_USER_API_RNG) += algif_rng.o
 obj-$(CONFIG_CRYPTO_USER_API_AEAD) += algif_aead.o
 obj-$(CONFIG_CRYPTO_ZSTD) += zstd.o
-obj-$(CONFIG_CRYPTO_ECC) += ecc.o
+crypto-objs-$(CONFIG_CRYPTO_ECC) += ecc.o
 obj-$(CONFIG_CRYPTO_ESSIV) += essiv.o
 
 ecdh_generic-y += ecdh.o
diff --git a/crypto/ecdsa.c b/crypto/ecdsa.c
index ce8e4364842f..64903419e6db 100644
--- a/crypto/ecdsa.c
+++ b/crypto/ecdsa.c
@@ -334,8 +334,8 @@ static void __exit ecdsa_exit(void)
 	crypto_unregister_sig(&ecdsa_nist_p521);
 }
 
-module_init(ecdsa_init);
-module_exit(ecdsa_exit);
+crypto_module_init(ecdsa_init);
+crypto_module_exit(ecdsa_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Stefan Berger <stefanb@linux.ibm.com>");
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 0b1794340b77..3c6dfcac5db5 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -589,3 +589,36 @@ DEFINE_CRYPTO_API_STUB(crypto_dh_encode_key);
 DEFINE_CRYPTO_API_STUB(crypto_dh_decode_key);
 
 #endif
+/*
+ * crypto/ecc.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_ECC)
+
+#include <crypto/ecc_curve.h>
+
+DEFINE_CRYPTO_API_STUB(ecc_get_curve);
+DEFINE_CRYPTO_API_STUB(ecc_get_curve25519);
+
+#include <crypto/internal/ecc.h>
+
+DEFINE_CRYPTO_API_STUB(ecc_digits_from_bytes);
+DEFINE_CRYPTO_API_STUB(ecc_is_key_valid);
+DEFINE_CRYPTO_API_STUB(ecc_gen_privkey);
+DEFINE_CRYPTO_API_STUB(ecc_make_pub_key);
+DEFINE_CRYPTO_API_STUB(crypto_ecdh_shared_secret);
+DEFINE_CRYPTO_API_STUB(ecc_is_pubkey_valid_partial);
+DEFINE_CRYPTO_API_STUB(ecc_is_pubkey_valid_full);
+DEFINE_CRYPTO_API_STUB(vli_is_zero);
+DEFINE_CRYPTO_API_STUB(vli_cmp);
+DEFINE_CRYPTO_API_STUB(vli_sub);
+DEFINE_CRYPTO_API_STUB(vli_from_be64);
+DEFINE_CRYPTO_API_STUB(vli_from_le64);
+DEFINE_CRYPTO_API_STUB(vli_mod_inv);
+DEFINE_CRYPTO_API_STUB(vli_mod_mult_slow);
+DEFINE_CRYPTO_API_STUB(vli_num_bits);
+DEFINE_CRYPTO_API_STUB(ecc_alloc_point);
+DEFINE_CRYPTO_API_STUB(ecc_free_point);
+DEFINE_CRYPTO_API_STUB(ecc_point_is_zero);
+DEFINE_CRYPTO_API_STUB(ecc_point_mult_shamir);
+
+#endif
diff --git a/include/crypto/ecc_curve.h b/include/crypto/ecc_curve.h
index 7d90c5e82266..f0804215de69 100644
--- a/include/crypto/ecc_curve.h
+++ b/include/crypto/ecc_curve.h
@@ -4,6 +4,7 @@
 #ifndef _CRYTO_ECC_CURVE_H
 #define _CRYTO_ECC_CURVE_H
 
+#include <crypto/api.h>
 #include <linux/types.h>
 
 /**
@@ -50,13 +51,17 @@ struct ecc_curve {
  *
  * Returns curve if get curve succssful, NULL otherwise
  */
-const struct ecc_curve *ecc_get_curve(unsigned int curve_id);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ECC, ecc_get_curve, const struct ecc_curve *,
+	(unsigned int curve_id),
+	(curve_id));
 
 /**
  * ecc_get_curve25519() - get curve25519 curve;
  *
  * Returns curve25519
  */
-const struct ecc_curve *ecc_get_curve25519(void);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ECC, ecc_get_curve25519, const struct ecc_curve *,
+	(void),
+	());
 
 #endif
diff --git a/include/crypto/internal/ecc.h b/include/crypto/internal/ecc.h
index 57cd75242141..0325d4edf82a 100644
--- a/include/crypto/internal/ecc.h
+++ b/include/crypto/internal/ecc.h
@@ -26,6 +26,7 @@
 #ifndef _CRYPTO_ECC_H
 #define _CRYPTO_ECC_H
 
+#include <crypto/api.h>
 #include <crypto/ecc_curve.h>
 #include <linux/unaligned.h>
 
@@ -79,8 +80,9 @@ static inline void ecc_swap_digits(const void *in, u64 *out, unsigned int ndigit
  * The first byte in the input byte array is expected to hold the most
  * significant bits of the large integer.
  */
-void ecc_digits_from_bytes(const u8 *in, unsigned int nbytes,
-			   u64 *out, unsigned int ndigits);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ECC, ecc_digits_from_bytes, void,
+	(const u8 *in, unsigned int nbytes, u64 *out, unsigned int ndigits),
+	(in, nbytes, out, ndigits));
 
 /**
  * ecc_is_key_valid() - Validate a given ECDH private key
@@ -92,8 +94,9 @@ void ecc_digits_from_bytes(const u8 *in, unsigned int nbytes,
  *
  * Returns 0 if the key is acceptable, a negative value otherwise
  */
-int ecc_is_key_valid(unsigned int curve_id, unsigned int ndigits,
-		     const u64 *private_key, unsigned int private_key_len);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ECC, ecc_is_key_valid, int,
+	(unsigned int curve_id, unsigned int ndigits, const u64 *private_key, unsigned int private_key_len),
+	(curve_id, ndigits, private_key, private_key_len));
 
 /**
  * ecc_gen_privkey() -  Generates an ECC private key.
@@ -107,8 +110,9 @@ int ecc_is_key_valid(unsigned int curve_id, unsigned int ndigits,
  * Returns 0 if the private key was generated successfully, a negative value
  * if an error occurred.
  */
-int ecc_gen_privkey(unsigned int curve_id, unsigned int ndigits,
-		    u64 *private_key);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ECC, ecc_gen_privkey, int,
+	(unsigned int curve_id, unsigned int ndigits, u64 *private_key),
+	(curve_id, ndigits, private_key));
 
 /**
  * ecc_make_pub_key() - Compute an ECC public key
@@ -121,8 +125,9 @@ int ecc_gen_privkey(unsigned int curve_id, unsigned int ndigits,
  * Returns 0 if the public key was generated successfully, a negative value
  * if an error occurred.
  */
-int ecc_make_pub_key(const unsigned int curve_id, unsigned int ndigits,
-		     const u64 *private_key, u64 *public_key);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ECC, ecc_make_pub_key, int,
+	(const unsigned int curve_id, unsigned int ndigits, const u64 *private_key, u64 *public_key),
+	(curve_id, ndigits, private_key, public_key));
 
 /**
  * crypto_ecdh_shared_secret() - Compute a shared secret
@@ -139,9 +144,9 @@ int ecc_make_pub_key(const unsigned int curve_id, unsigned int ndigits,
  * Returns 0 if the shared secret was generated successfully, a negative value
  * if an error occurred.
  */
-int crypto_ecdh_shared_secret(unsigned int curve_id, unsigned int ndigits,
-			      const u64 *private_key, const u64 *public_key,
-			      u64 *secret);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ECC, crypto_ecdh_shared_secret, int,
+	(unsigned int curve_id, unsigned int ndigits, const u64 *private_key, const u64 *public_key, u64 *secret),
+	(curve_id, ndigits, private_key, public_key, secret));
 
 /**
  * ecc_is_pubkey_valid_partial() - Partial public key validation
@@ -157,8 +162,9 @@ int crypto_ecdh_shared_secret(unsigned int curve_id, unsigned int ndigits,
  *
  * Return: 0 if validation is successful, -EINVAL if validation is failed.
  */
-int ecc_is_pubkey_valid_partial(const struct ecc_curve *curve,
-				struct ecc_point *pk);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ECC, ecc_is_pubkey_valid_partial, int,
+	(const struct ecc_curve *curve, struct ecc_point *pk),
+	(curve, pk));
 
 /**
  * ecc_is_pubkey_valid_full() - Full public key validation
@@ -171,8 +177,9 @@ int ecc_is_pubkey_valid_partial(const struct ecc_curve *curve,
  *
  * Return: 0 if validation is successful, -EINVAL if validation is failed.
  */
-int ecc_is_pubkey_valid_full(const struct ecc_curve *curve,
-			     struct ecc_point *pk);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ECC, ecc_is_pubkey_valid_full, int,
+	(const struct ecc_curve *curve, struct ecc_point *pk),
+	(curve, pk));
 
 /**
  * vli_is_zero() - Determine is vli is zero
@@ -180,7 +187,9 @@ int ecc_is_pubkey_valid_full(const struct ecc_curve *curve,
  * @vli:		vli to check.
  * @ndigits:		length of the @vli
  */
-bool vli_is_zero(const u64 *vli, unsigned int ndigits);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ECC, vli_is_zero, bool,
+	(const u64 *vli, unsigned int ndigits),
+	(vli, ndigits));
 
 /**
  * vli_cmp() - compare left and right vlis
@@ -192,7 +201,9 @@ bool vli_is_zero(const u64 *vli, unsigned int ndigits);
  * Returns sign of @left - @right, i.e. -1 if @left < @right,
  * 0 if @left == @right, 1 if @left > @right.
  */
-int vli_cmp(const u64 *left, const u64 *right, unsigned int ndigits);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ECC, vli_cmp, int,
+	(const u64 *left, const u64 *right, unsigned int ndigits),
+	(left, right, ndigits));
 
 /**
  * vli_sub() - Subtracts right from left
@@ -206,8 +217,9 @@ int vli_cmp(const u64 *left, const u64 *right, unsigned int ndigits);
  *
  * Return: carry bit.
  */
-u64 vli_sub(u64 *result, const u64 *left, const u64 *right,
-	    unsigned int ndigits);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ECC, vli_sub, u64,
+	(u64 *result, const u64 *left, const u64 *right, unsigned int ndigits),
+	(result, left, right, ndigits));
 
 /**
  * vli_from_be64() - Load vli from big-endian u64 array
@@ -216,7 +228,9 @@ u64 vli_sub(u64 *result, const u64 *left, const u64 *right,
  * @src:		source array of u64 BE values
  * @ndigits:		length of both vli and array
  */
-void vli_from_be64(u64 *dest, const void *src, unsigned int ndigits);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ECC, vli_from_be64, void,
+	(u64 *dest, const void *src, unsigned int ndigits),
+	(dest, src, ndigits));
 
 /**
  * vli_from_le64() - Load vli from little-endian u64 array
@@ -225,7 +239,9 @@ void vli_from_be64(u64 *dest, const void *src, unsigned int ndigits);
  * @src:		source array of u64 LE values
  * @ndigits:		length of both vli and array
  */
-void vli_from_le64(u64 *dest, const void *src, unsigned int ndigits);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ECC, vli_from_le64, void,
+	(u64 *dest, const void *src, unsigned int ndigits),
+	(dest, src, ndigits));
 
 /**
  * vli_mod_inv() - Modular inversion
@@ -235,8 +251,9 @@ void vli_from_le64(u64 *dest, const void *src, unsigned int ndigits);
  * @mod:		modulus
  * @ndigits:		length of all vlis
  */
-void vli_mod_inv(u64 *result, const u64 *input, const u64 *mod,
-		 unsigned int ndigits);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ECC, vli_mod_inv, void,
+	(u64 *result, const u64 *input, const u64 *mod, unsigned int ndigits),
+	(result, input, mod, ndigits));
 
 /**
  * vli_mod_mult_slow() - Modular multiplication
@@ -249,8 +266,9 @@ void vli_mod_inv(u64 *result, const u64 *input, const u64 *mod,
  *
  * Note: Assumes that mod is big enough curve order.
  */
-void vli_mod_mult_slow(u64 *result, const u64 *left, const u64 *right,
-		       const u64 *mod, unsigned int ndigits);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ECC, vli_mod_mult_slow, void,
+	(u64 *result, const u64 *left, const u64 *right, const u64 *mod, unsigned int ndigits),
+	(result, left, right, mod, ndigits));
 
 /**
  * vli_num_bits() - Counts the number of bits required for vli.
@@ -260,7 +278,9 @@ void vli_mod_mult_slow(u64 *result, const u64 *left, const u64 *right,
  *
  * Return: The number of bits required to represent @vli.
  */
-unsigned int vli_num_bits(const u64 *vli, unsigned int ndigits);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ECC, vli_num_bits, unsigned int,
+	(const u64 *vli, unsigned int ndigits),
+	(vli, ndigits));
 
 /**
  * ecc_aloc_point() - Allocate ECC point.
@@ -269,14 +289,18 @@ unsigned int vli_num_bits(const u64 *vli, unsigned int ndigits);
  *
  * Return: Pointer to the allocated point or NULL if allocation failed.
  */
-struct ecc_point *ecc_alloc_point(unsigned int ndigits);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ECC, ecc_alloc_point, struct ecc_point *,
+	(unsigned int ndigits),
+	(ndigits));
 
 /**
  * ecc_free_point() - Free ECC point.
  *
  * @p:			The point to free.
  */
-void ecc_free_point(struct ecc_point *p);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ECC, ecc_free_point, void,
+	(struct ecc_point *p),
+	(p));
 
 /**
  * ecc_point_is_zero() - Check if point is zero.
@@ -285,7 +309,9 @@ void ecc_free_point(struct ecc_point *p);
  *
  * Return: true if point is the point at infinity, false otherwise.
  */
-bool ecc_point_is_zero(const struct ecc_point *point);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ECC, ecc_point_is_zero, bool,
+	(const struct ecc_point *point),
+	(point));
 
 /**
  * ecc_point_mult_shamir() - Add two points multiplied by scalars
@@ -300,10 +326,9 @@ bool ecc_point_is_zero(const struct ecc_point *point);
  * Returns result = x * p + x * q over the curve.
  * This works faster than two multiplications and addition.
  */
-void ecc_point_mult_shamir(const struct ecc_point *result,
-			   const u64 *x, const struct ecc_point *p,
-			   const u64 *y, const struct ecc_point *q,
-			   const struct ecc_curve *curve);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ECC, ecc_point_mult_shamir, void,
+	(const struct ecc_point *result, const u64 *x, const struct ecc_point *p, const u64 *y, const struct ecc_point *q, const struct ecc_curve *curve),
+	(result, x, p, y, q, curve));
 
 extern struct crypto_template ecdsa_x962_tmpl;
 extern struct crypto_template ecdsa_p1363_tmpl;
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 040/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_USER crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (38 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 039/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ECDSA and CONFIG_CRYPTO_ECC crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 041/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_XCBC crypto Jay Wang
                   ` (65 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_USER-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile      | 2 +-
 crypto/crypto_user.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 2e3704e67e14..390d38d17e4b 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -71,7 +71,7 @@ crypto-objs-$(CONFIG_CRYPTO_ACOMP2) += crypto_acompress.o
 cryptomgr-y := algboss.o testmgr.o
 
 crypto-objs-$(CONFIG_CRYPTO_MANAGER2) += cryptomgr.o
-obj-$(CONFIG_CRYPTO_USER) += crypto_user.o
+crypto-objs-$(CONFIG_CRYPTO_USER) += crypto_user.o
 crypto-objs-$(CONFIG_CRYPTO_CMAC) += cmac.o
 crypto-objs-$(CONFIG_CRYPTO_HMAC) += hmac.o
 obj-$(CONFIG_CRYPTO_XCBC) += xcbc.o
diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
index 3187e0d276f9..8d03a2ff24de 100644
--- a/crypto/crypto_user.c
+++ b/crypto/crypto_user.c
@@ -498,8 +498,8 @@ static void __exit crypto_user_exit(void)
 	unregister_pernet_subsys(&crypto_netlink_net_ops);
 }
 
-module_init(crypto_user_init);
-module_exit(crypto_user_exit);
+crypto_module_init(crypto_user_init);
+crypto_module_exit(crypto_user_exit);
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Steffen Klassert <steffen.klassert@secunet.com>");
 MODULE_DESCRIPTION("Crypto userspace configuration API");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 041/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_XCBC crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (39 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 040/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_USER crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 042/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_NULL crypto Jay Wang
                   ` (64 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_XCBC-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/xcbc.c   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 390d38d17e4b..c98e6a397159 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -74,7 +74,7 @@ crypto-objs-$(CONFIG_CRYPTO_MANAGER2) += cryptomgr.o
 crypto-objs-$(CONFIG_CRYPTO_USER) += crypto_user.o
 crypto-objs-$(CONFIG_CRYPTO_CMAC) += cmac.o
 crypto-objs-$(CONFIG_CRYPTO_HMAC) += hmac.o
-obj-$(CONFIG_CRYPTO_XCBC) += xcbc.o
+crypto-objs-$(CONFIG_CRYPTO_XCBC) += xcbc.o
 obj-$(CONFIG_CRYPTO_NULL) += crypto_null.o
 obj-$(CONFIG_CRYPTO_MD4) += md4.o
 crypto-objs-$(CONFIG_CRYPTO_MD5) += md5.o
diff --git a/crypto/xcbc.c b/crypto/xcbc.c
index 6c5f6766fdd6..90da46fe3bb7 100644
--- a/crypto/xcbc.c
+++ b/crypto/xcbc.c
@@ -199,8 +199,8 @@ static void __exit crypto_xcbc_module_exit(void)
 	crypto_unregister_template(&crypto_xcbc_tmpl);
 }
 
-module_init(crypto_xcbc_module_init);
-module_exit(crypto_xcbc_module_exit);
+crypto_module_init(crypto_xcbc_module_init);
+crypto_module_exit(crypto_xcbc_module_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("XCBC keyed hash algorithm");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 042/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_NULL crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (40 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 041/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_XCBC crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 043/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_MD4 crypto Jay Wang
                   ` (63 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_NULL-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile      | 2 +-
 crypto/crypto_null.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index c98e6a397159..6d1077d11538 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -75,7 +75,7 @@ crypto-objs-$(CONFIG_CRYPTO_USER) += crypto_user.o
 crypto-objs-$(CONFIG_CRYPTO_CMAC) += cmac.o
 crypto-objs-$(CONFIG_CRYPTO_HMAC) += hmac.o
 crypto-objs-$(CONFIG_CRYPTO_XCBC) += xcbc.o
-obj-$(CONFIG_CRYPTO_NULL) += crypto_null.o
+crypto-objs-$(CONFIG_CRYPTO_NULL) += crypto_null.o
 obj-$(CONFIG_CRYPTO_MD4) += md4.o
 crypto-objs-$(CONFIG_CRYPTO_MD5) += md5.o
 obj-$(CONFIG_CRYPTO_RMD160) += rmd160.o
diff --git a/crypto/crypto_null.c b/crypto/crypto_null.c
index 34588f39fdfc..e2245e691585 100644
--- a/crypto/crypto_null.c
+++ b/crypto/crypto_null.c
@@ -148,8 +148,8 @@ static void __exit crypto_null_mod_fini(void)
 	crypto_unregister_skcipher(&skcipher_null);
 }
 
-module_init(crypto_null_mod_init);
-module_exit(crypto_null_mod_fini);
+crypto_module_init(crypto_null_mod_init);
+crypto_module_exit(crypto_null_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Null Cryptographic Algorithms");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 043/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_MD4 crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (41 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 042/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_NULL crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 044/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_RMD160 crypto Jay Wang
                   ` (62 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_MD4-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/md4.c    | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 6d1077d11538..32f038ff47de 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -76,7 +76,7 @@ crypto-objs-$(CONFIG_CRYPTO_CMAC) += cmac.o
 crypto-objs-$(CONFIG_CRYPTO_HMAC) += hmac.o
 crypto-objs-$(CONFIG_CRYPTO_XCBC) += xcbc.o
 crypto-objs-$(CONFIG_CRYPTO_NULL) += crypto_null.o
-obj-$(CONFIG_CRYPTO_MD4) += md4.o
+crypto-objs-$(CONFIG_CRYPTO_MD4) += md4.o
 crypto-objs-$(CONFIG_CRYPTO_MD5) += md5.o
 obj-$(CONFIG_CRYPTO_RMD160) += rmd160.o
 obj-$(CONFIG_CRYPTO_SHA1) += sha1.o
diff --git a/crypto/md4.c b/crypto/md4.c
index 55bf47e23c13..04a7ce7eb460 100644
--- a/crypto/md4.c
+++ b/crypto/md4.c
@@ -233,8 +233,8 @@ static void __exit md4_mod_fini(void)
 	crypto_unregister_shash(&alg);
 }
 
-module_init(md4_mod_init);
-module_exit(md4_mod_fini);
+crypto_module_init(md4_mod_init);
+crypto_module_exit(md4_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("MD4 Message Digest Algorithm");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 044/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_RMD160 crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (42 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 043/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_MD4 crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 045/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SHA1 crypto Jay Wang
                   ` (61 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_RMD160-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/rmd160.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 32f038ff47de..45f0ae639ccd 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -78,7 +78,7 @@ crypto-objs-$(CONFIG_CRYPTO_XCBC) += xcbc.o
 crypto-objs-$(CONFIG_CRYPTO_NULL) += crypto_null.o
 crypto-objs-$(CONFIG_CRYPTO_MD4) += md4.o
 crypto-objs-$(CONFIG_CRYPTO_MD5) += md5.o
-obj-$(CONFIG_CRYPTO_RMD160) += rmd160.o
+crypto-objs-$(CONFIG_CRYPTO_RMD160) += rmd160.o
 obj-$(CONFIG_CRYPTO_SHA1) += sha1.o
 crypto-objs-$(CONFIG_CRYPTO_SHA256) += sha256.o
 crypto-objs-$(CONFIG_CRYPTO_SHA512) += sha512.o
diff --git a/crypto/rmd160.c b/crypto/rmd160.c
index 9860b60c9be4..0d68e7b763d8 100644
--- a/crypto/rmd160.c
+++ b/crypto/rmd160.c
@@ -342,8 +342,8 @@ static void __exit rmd160_mod_fini(void)
 	crypto_unregister_shash(&alg);
 }
 
-module_init(rmd160_mod_init);
-module_exit(rmd160_mod_fini);
+crypto_module_init(rmd160_mod_init);
+crypto_module_exit(rmd160_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Adrian-Ken Rueegsegger <ken@codelabs.ch>");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 045/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SHA1 crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (43 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 044/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_RMD160 crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 046/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SM3_GENERIC crypto Jay Wang
                   ` (60 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_SHA1-related crypto to convert them into pluggable
interface.

Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/sha1.c   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 45f0ae639ccd..ba7bc1e3a65a 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -79,7 +79,7 @@ crypto-objs-$(CONFIG_CRYPTO_NULL) += crypto_null.o
 crypto-objs-$(CONFIG_CRYPTO_MD4) += md4.o
 crypto-objs-$(CONFIG_CRYPTO_MD5) += md5.o
 crypto-objs-$(CONFIG_CRYPTO_RMD160) += rmd160.o
-obj-$(CONFIG_CRYPTO_SHA1) += sha1.o
+crypto-objs-$(CONFIG_CRYPTO_SHA1) += sha1.o
 crypto-objs-$(CONFIG_CRYPTO_SHA256) += sha256.o
 crypto-objs-$(CONFIG_CRYPTO_SHA512) += sha512.o
 crypto-objs-$(CONFIG_CRYPTO_SHA3) += sha3.o
diff --git a/crypto/sha1.c b/crypto/sha1.c
index 4fbf61cf0370..fe7028d018a8 100644
--- a/crypto/sha1.c
+++ b/crypto/sha1.c
@@ -223,13 +223,13 @@ static int __init crypto_sha1_mod_init(void)
 {
 	return crypto_register_shashes(algs, ARRAY_SIZE(algs));
 }
-module_init(crypto_sha1_mod_init);
+crypto_module_init(crypto_sha1_mod_init);
 
 static void __exit crypto_sha1_mod_exit(void)
 {
 	crypto_unregister_shashes(algs, ARRAY_SIZE(algs));
 }
-module_exit(crypto_sha1_mod_exit);
+crypto_module_exit(crypto_sha1_mod_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Crypto API support for SHA-1 and HMAC-SHA1");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 046/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SM3_GENERIC crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (44 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 045/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SHA1 crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 047/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_STREEBOG crypto Jay Wang
                   ` (59 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_SM3_GENERIC-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile      | 2 +-
 crypto/sm3_generic.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index ba7bc1e3a65a..64df3408cca0 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -83,7 +83,7 @@ crypto-objs-$(CONFIG_CRYPTO_SHA1) += sha1.o
 crypto-objs-$(CONFIG_CRYPTO_SHA256) += sha256.o
 crypto-objs-$(CONFIG_CRYPTO_SHA512) += sha512.o
 crypto-objs-$(CONFIG_CRYPTO_SHA3) += sha3.o
-obj-$(CONFIG_CRYPTO_SM3_GENERIC) += sm3_generic.o
+crypto-objs-$(CONFIG_CRYPTO_SM3_GENERIC) += sm3_generic.o
 obj-$(CONFIG_CRYPTO_STREEBOG) += streebog_generic.o
 obj-$(CONFIG_CRYPTO_WP512) += wp512.o
 CFLAGS_wp512.o := $(call cc-option,-fno-schedule-insns)  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149
diff --git a/crypto/sm3_generic.c b/crypto/sm3_generic.c
index 7529139fcc96..90e75d3576d2 100644
--- a/crypto/sm3_generic.c
+++ b/crypto/sm3_generic.c
@@ -62,8 +62,8 @@ static void __exit sm3_generic_mod_fini(void)
 	crypto_unregister_shash(&sm3_alg);
 }
 
-module_init(sm3_generic_mod_init);
-module_exit(sm3_generic_mod_fini);
+crypto_module_init(sm3_generic_mod_init);
+crypto_module_exit(sm3_generic_mod_fini);
 
 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("SM3 Secure Hash Algorithm");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 047/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_STREEBOG crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (45 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 046/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SM3_GENERIC crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 048/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_WP512 crypto Jay Wang
                   ` (58 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_STREEBOG-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile           | 2 +-
 crypto/streebog_generic.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 64df3408cca0..c83ad9bb4324 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -84,7 +84,7 @@ crypto-objs-$(CONFIG_CRYPTO_SHA256) += sha256.o
 crypto-objs-$(CONFIG_CRYPTO_SHA512) += sha512.o
 crypto-objs-$(CONFIG_CRYPTO_SHA3) += sha3.o
 crypto-objs-$(CONFIG_CRYPTO_SM3_GENERIC) += sm3_generic.o
-obj-$(CONFIG_CRYPTO_STREEBOG) += streebog_generic.o
+crypto-objs-$(CONFIG_CRYPTO_STREEBOG) += streebog_generic.o
 obj-$(CONFIG_CRYPTO_WP512) += wp512.o
 CFLAGS_wp512.o := $(call cc-option,-fno-schedule-insns)  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149
 obj-$(CONFIG_CRYPTO_BLAKE2B) += blake2b.o
diff --git a/crypto/streebog_generic.c b/crypto/streebog_generic.c
index 57bbf70f4c22..1ed42a26bec9 100644
--- a/crypto/streebog_generic.c
+++ b/crypto/streebog_generic.c
@@ -1061,8 +1061,8 @@ static void __exit streebog_mod_fini(void)
 	crypto_unregister_shashes(algs, ARRAY_SIZE(algs));
 }
 
-module_init(streebog_mod_init);
-module_exit(streebog_mod_fini);
+crypto_module_init(streebog_mod_init);
+crypto_module_exit(streebog_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Vitaly Chikunov <vt@altlinux.org>");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 048/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_WP512 crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (46 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 047/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_STREEBOG crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 049/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_BLAKE2B crypto Jay Wang
                   ` (57 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_WP512-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/wp512.c  | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index c83ad9bb4324..0a0190292dd0 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -85,7 +85,7 @@ crypto-objs-$(CONFIG_CRYPTO_SHA512) += sha512.o
 crypto-objs-$(CONFIG_CRYPTO_SHA3) += sha3.o
 crypto-objs-$(CONFIG_CRYPTO_SM3_GENERIC) += sm3_generic.o
 crypto-objs-$(CONFIG_CRYPTO_STREEBOG) += streebog_generic.o
-obj-$(CONFIG_CRYPTO_WP512) += wp512.o
+crypto-objs-$(CONFIG_CRYPTO_WP512) += wp512.o
 CFLAGS_wp512.o := $(call cc-option,-fno-schedule-insns)  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149
 obj-$(CONFIG_CRYPTO_BLAKE2B) += blake2b.o
 crypto-objs-$(CONFIG_CRYPTO_ECB) += ecb.o
diff --git a/crypto/wp512.c b/crypto/wp512.c
index 229b189a7988..2d76d4639d44 100644
--- a/crypto/wp512.c
+++ b/crypto/wp512.c
@@ -1138,8 +1138,8 @@ MODULE_ALIAS_CRYPTO("wp512");
 MODULE_ALIAS_CRYPTO("wp384");
 MODULE_ALIAS_CRYPTO("wp256");
 
-module_init(wp512_mod_init);
-module_exit(wp512_mod_fini);
+crypto_module_init(wp512_mod_init);
+crypto_module_exit(wp512_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Whirlpool Message Digest Algorithm");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 049/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_BLAKE2B crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (47 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 048/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_WP512 crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 050/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_PCBC crypto Jay Wang
                   ` (56 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_BLAKE2B-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile  | 2 +-
 crypto/blake2b.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 0a0190292dd0..dfcfcd0601dd 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -87,7 +87,7 @@ crypto-objs-$(CONFIG_CRYPTO_SM3_GENERIC) += sm3_generic.o
 crypto-objs-$(CONFIG_CRYPTO_STREEBOG) += streebog_generic.o
 crypto-objs-$(CONFIG_CRYPTO_WP512) += wp512.o
 CFLAGS_wp512.o := $(call cc-option,-fno-schedule-insns)  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149
-obj-$(CONFIG_CRYPTO_BLAKE2B) += blake2b.o
+crypto-objs-$(CONFIG_CRYPTO_BLAKE2B) += blake2b.o
 crypto-objs-$(CONFIG_CRYPTO_ECB) += ecb.o
 crypto-objs-$(CONFIG_CRYPTO_CBC) += cbc.o
 obj-$(CONFIG_CRYPTO_PCBC) += pcbc.o
diff --git a/crypto/blake2b.c b/crypto/blake2b.c
index 67a6dae43a54..74a2706aa7be 100644
--- a/crypto/blake2b.c
+++ b/crypto/blake2b.c
@@ -90,13 +90,13 @@ static int __init crypto_blake2b_mod_init(void)
 {
 	return crypto_register_shashes(algs, ARRAY_SIZE(algs));
 }
-module_init(crypto_blake2b_mod_init);
+crypto_module_init(crypto_blake2b_mod_init);
 
 static void __exit crypto_blake2b_mod_exit(void)
 {
 	crypto_unregister_shashes(algs, ARRAY_SIZE(algs));
 }
-module_exit(crypto_blake2b_mod_exit);
+crypto_module_exit(crypto_blake2b_mod_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Crypto API support for BLAKE2b");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 050/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_PCBC crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (48 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 049/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_BLAKE2B crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 051/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CTS crypto Jay Wang
                   ` (55 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_PCBC-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/pcbc.c   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index dfcfcd0601dd..6515459115d8 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -90,7 +90,7 @@ CFLAGS_wp512.o := $(call cc-option,-fno-schedule-insns)  # https://gcc.gnu.org/b
 crypto-objs-$(CONFIG_CRYPTO_BLAKE2B) += blake2b.o
 crypto-objs-$(CONFIG_CRYPTO_ECB) += ecb.o
 crypto-objs-$(CONFIG_CRYPTO_CBC) += cbc.o
-obj-$(CONFIG_CRYPTO_PCBC) += pcbc.o
+crypto-objs-$(CONFIG_CRYPTO_PCBC) += pcbc.o
 obj-$(CONFIG_CRYPTO_CTS) += cts.o
 obj-$(CONFIG_CRYPTO_LRW) += lrw.o
 obj-$(CONFIG_CRYPTO_XTS) += xts.o
diff --git a/crypto/pcbc.c b/crypto/pcbc.c
index d092717ea4fc..a0f3e16f049f 100644
--- a/crypto/pcbc.c
+++ b/crypto/pcbc.c
@@ -186,8 +186,8 @@ static void __exit crypto_pcbc_module_exit(void)
 	crypto_unregister_template(&crypto_pcbc_tmpl);
 }
 
-module_init(crypto_pcbc_module_init);
-module_exit(crypto_pcbc_module_exit);
+crypto_module_init(crypto_pcbc_module_init);
+crypto_module_exit(crypto_pcbc_module_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("PCBC block cipher mode of operation");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 051/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CTS crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (49 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 050/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_PCBC crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 052/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_LRW crypto Jay Wang
                   ` (54 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_CTS-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/cts.c    | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 6515459115d8..9ee71f7c0af7 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -91,7 +91,7 @@ crypto-objs-$(CONFIG_CRYPTO_BLAKE2B) += blake2b.o
 crypto-objs-$(CONFIG_CRYPTO_ECB) += ecb.o
 crypto-objs-$(CONFIG_CRYPTO_CBC) += cbc.o
 crypto-objs-$(CONFIG_CRYPTO_PCBC) += pcbc.o
-obj-$(CONFIG_CRYPTO_CTS) += cts.o
+crypto-objs-$(CONFIG_CRYPTO_CTS) += cts.o
 obj-$(CONFIG_CRYPTO_LRW) += lrw.o
 obj-$(CONFIG_CRYPTO_XTS) += xts.o
 crypto-objs-$(CONFIG_CRYPTO_CTR) += ctr.o
diff --git a/crypto/cts.c b/crypto/cts.c
index 48898d5e24ff..8b762d0d42cd 100644
--- a/crypto/cts.c
+++ b/crypto/cts.c
@@ -402,8 +402,8 @@ static void __exit crypto_cts_module_exit(void)
 	crypto_unregister_template(&crypto_cts_tmpl);
 }
 
-module_init(crypto_cts_module_init);
-module_exit(crypto_cts_module_exit);
+crypto_module_init(crypto_cts_module_init);
+crypto_module_exit(crypto_cts_module_exit);
 
 MODULE_LICENSE("Dual BSD/GPL");
 MODULE_DESCRIPTION("CTS-CBC CipherText Stealing for CBC");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 052/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_LRW crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (50 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 051/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CTS crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 053/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_XTS crypto Jay Wang
                   ` (53 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_LRW-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/lrw.c    | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 9ee71f7c0af7..73c700538792 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -92,7 +92,7 @@ crypto-objs-$(CONFIG_CRYPTO_ECB) += ecb.o
 crypto-objs-$(CONFIG_CRYPTO_CBC) += cbc.o
 crypto-objs-$(CONFIG_CRYPTO_PCBC) += pcbc.o
 crypto-objs-$(CONFIG_CRYPTO_CTS) += cts.o
-obj-$(CONFIG_CRYPTO_LRW) += lrw.o
+crypto-objs-$(CONFIG_CRYPTO_LRW) += lrw.o
 obj-$(CONFIG_CRYPTO_XTS) += xts.o
 crypto-objs-$(CONFIG_CRYPTO_CTR) += ctr.o
 obj-$(CONFIG_CRYPTO_XCTR) += xctr.o
diff --git a/crypto/lrw.c b/crypto/lrw.c
index dd403b800513..776f052fa56d 100644
--- a/crypto/lrw.c
+++ b/crypto/lrw.c
@@ -420,8 +420,8 @@ static void __exit lrw_module_exit(void)
 	crypto_unregister_template(&lrw_tmpl);
 }
 
-module_init(lrw_module_init);
-module_exit(lrw_module_exit);
+crypto_module_init(lrw_module_init);
+crypto_module_exit(lrw_module_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("LRW block cipher mode");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 053/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_XTS crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (51 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 052/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_LRW crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 054/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_XCTR and CONFIG_CRYPTO_HCTR2 crypto Jay Wang
                   ` (52 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_XTS-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/xts.c    | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 73c700538792..33e4e3a03c40 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -93,7 +93,7 @@ crypto-objs-$(CONFIG_CRYPTO_CBC) += cbc.o
 crypto-objs-$(CONFIG_CRYPTO_PCBC) += pcbc.o
 crypto-objs-$(CONFIG_CRYPTO_CTS) += cts.o
 crypto-objs-$(CONFIG_CRYPTO_LRW) += lrw.o
-obj-$(CONFIG_CRYPTO_XTS) += xts.o
+crypto-objs-$(CONFIG_CRYPTO_XTS) += xts.o
 crypto-objs-$(CONFIG_CRYPTO_CTR) += ctr.o
 obj-$(CONFIG_CRYPTO_XCTR) += xctr.o
 obj-$(CONFIG_CRYPTO_HCTR2) += hctr2.o
diff --git a/crypto/xts.c b/crypto/xts.c
index 3da8f5e053d6..97e499893292 100644
--- a/crypto/xts.c
+++ b/crypto/xts.c
@@ -466,8 +466,8 @@ static void __exit xts_module_exit(void)
 	crypto_unregister_template(&xts_tmpl);
 }
 
-module_init(xts_module_init);
-module_exit(xts_module_exit);
+crypto_module_init(xts_module_init);
+crypto_module_exit(xts_module_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("XTS block cipher mode");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 054/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_XCTR and CONFIG_CRYPTO_HCTR2 crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (52 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 053/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_XTS crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 055/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ADIANTUM crypto Jay Wang
                   ` (51 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_XCTR- and CONFIG_CRYPTO_HCTR2-related crypto to convert
them into pluggable interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 4 ++--
 crypto/hctr2.c  | 4 ++--
 crypto/xctr.c   | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 33e4e3a03c40..c3b0de034a47 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -95,8 +95,8 @@ crypto-objs-$(CONFIG_CRYPTO_CTS) += cts.o
 crypto-objs-$(CONFIG_CRYPTO_LRW) += lrw.o
 crypto-objs-$(CONFIG_CRYPTO_XTS) += xts.o
 crypto-objs-$(CONFIG_CRYPTO_CTR) += ctr.o
-obj-$(CONFIG_CRYPTO_XCTR) += xctr.o
-obj-$(CONFIG_CRYPTO_HCTR2) += hctr2.o
+crypto-objs-$(CONFIG_CRYPTO_XCTR) += xctr.o
+crypto-objs-$(CONFIG_CRYPTO_HCTR2) += hctr2.o
 obj-$(CONFIG_CRYPTO_ADIANTUM) += adiantum.o
 crypto-objs-$(CONFIG_CRYPTO_GCM) += gcm.o
 crypto-objs-$(CONFIG_CRYPTO_CCM) += ccm.o
diff --git a/crypto/hctr2.c b/crypto/hctr2.c
index f4cd6c29b4d3..78c0fc9faee5 100644
--- a/crypto/hctr2.c
+++ b/crypto/hctr2.c
@@ -472,8 +472,8 @@ static void __exit hctr2_module_exit(void)
 					   ARRAY_SIZE(hctr2_tmpls));
 }
 
-module_init(hctr2_module_init);
-module_exit(hctr2_module_exit);
+crypto_module_init(hctr2_module_init);
+crypto_module_exit(hctr2_module_exit);
 
 MODULE_DESCRIPTION("HCTR2 length-preserving encryption mode");
 MODULE_LICENSE("GPL v2");
diff --git a/crypto/xctr.c b/crypto/xctr.c
index 607ab82cb19b..e3dee674b941 100644
--- a/crypto/xctr.c
+++ b/crypto/xctr.c
@@ -182,8 +182,8 @@ static void __exit crypto_xctr_module_exit(void)
 	crypto_unregister_template(&crypto_xctr_tmpl);
 }
 
-module_init(crypto_xctr_module_init);
-module_exit(crypto_xctr_module_exit);
+crypto_module_init(crypto_xctr_module_init);
+crypto_module_exit(crypto_xctr_module_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("XCTR block cipher mode of operation");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 055/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ADIANTUM crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (53 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 054/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_XCTR and CONFIG_CRYPTO_HCTR2 crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 056/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CHACHA20 crypto Jay Wang
                   ` (50 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_ADIANTUM-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile   | 2 +-
 crypto/adiantum.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index c3b0de034a47..34e278185d16 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -97,7 +97,7 @@ crypto-objs-$(CONFIG_CRYPTO_XTS) += xts.o
 crypto-objs-$(CONFIG_CRYPTO_CTR) += ctr.o
 crypto-objs-$(CONFIG_CRYPTO_XCTR) += xctr.o
 crypto-objs-$(CONFIG_CRYPTO_HCTR2) += hctr2.o
-obj-$(CONFIG_CRYPTO_ADIANTUM) += adiantum.o
+crypto-objs-$(CONFIG_CRYPTO_ADIANTUM) += adiantum.o
 crypto-objs-$(CONFIG_CRYPTO_GCM) += gcm.o
 crypto-objs-$(CONFIG_CRYPTO_CCM) += ccm.o
 obj-$(CONFIG_CRYPTO_CHACHA20POLY1305) += chacha20poly1305.o
diff --git a/crypto/adiantum.c b/crypto/adiantum.c
index 5ddf585abb66..8e8e8654432c 100644
--- a/crypto/adiantum.c
+++ b/crypto/adiantum.c
@@ -683,8 +683,8 @@ static void __exit adiantum_module_exit(void)
 	crypto_unregister_template(&adiantum_tmpl);
 }
 
-module_init(adiantum_module_init);
-module_exit(adiantum_module_exit);
+crypto_module_init(adiantum_module_init);
+crypto_module_exit(adiantum_module_exit);
 
 MODULE_DESCRIPTION("Adiantum length-preserving encryption mode");
 MODULE_LICENSE("GPL v2");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 056/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CHACHA20 crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (54 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 055/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ADIANTUM crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 057/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CHACHA20POLY1305 crypto Jay Wang
                   ` (49 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_CHACHA20-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/chacha.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 34e278185d16..cb509e854784 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -147,7 +147,7 @@ obj-$(CONFIG_CRYPTO_KHAZAD) += khazad.o
 obj-$(CONFIG_CRYPTO_ANUBIS) += anubis.o
 obj-$(CONFIG_CRYPTO_SEED) += seed.o
 obj-$(CONFIG_CRYPTO_ARIA) += aria_generic.o
-obj-$(CONFIG_CRYPTO_CHACHA20) += chacha.o
+crypto-objs-$(CONFIG_CRYPTO_CHACHA20) += chacha.o
 CFLAGS_chacha.o += -DARCH=$(ARCH)
 obj-$(CONFIG_CRYPTO_DEFLATE) += deflate.o
 obj-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o
diff --git a/crypto/chacha.c b/crypto/chacha.c
index ec16d5a33f3c..13335c7e4941 100644
--- a/crypto/chacha.c
+++ b/crypto/chacha.c
@@ -161,8 +161,8 @@ static void __exit crypto_chacha_mod_fini(void)
 	crypto_unregister_skciphers(algs, ARRAY_SIZE(algs));
 }
 
-module_init(crypto_chacha_mod_init);
-module_exit(crypto_chacha_mod_fini);
+crypto_module_init(crypto_chacha_mod_init);
+crypto_module_exit(crypto_chacha_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Martin Willi <martin@strongswan.org>");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 057/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CHACHA20POLY1305 crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (55 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 056/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CHACHA20 crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 058/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_AEGIS128 crypto Jay Wang
                   ` (48 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_CHACHA20POLY1305-related crypto to convert them into
pluggable interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile           | 2 +-
 crypto/chacha20poly1305.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index cb509e854784..f71f2359ce08 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -100,7 +100,7 @@ crypto-objs-$(CONFIG_CRYPTO_HCTR2) += hctr2.o
 crypto-objs-$(CONFIG_CRYPTO_ADIANTUM) += adiantum.o
 crypto-objs-$(CONFIG_CRYPTO_GCM) += gcm.o
 crypto-objs-$(CONFIG_CRYPTO_CCM) += ccm.o
-obj-$(CONFIG_CRYPTO_CHACHA20POLY1305) += chacha20poly1305.o
+crypto-objs-$(CONFIG_CRYPTO_CHACHA20POLY1305) += chacha20poly1305.o
 obj-$(CONFIG_CRYPTO_AEGIS128) += aegis128.o
 aegis128-y := aegis128-core.o
 
diff --git a/crypto/chacha20poly1305.c b/crypto/chacha20poly1305.c
index b4b5a7198d84..2e5fe0b060af 100644
--- a/crypto/chacha20poly1305.c
+++ b/crypto/chacha20poly1305.c
@@ -476,8 +476,8 @@ static void __exit chacha20poly1305_module_exit(void)
 				    ARRAY_SIZE(rfc7539_tmpls));
 }
 
-module_init(chacha20poly1305_module_init);
-module_exit(chacha20poly1305_module_exit);
+crypto_module_init(chacha20poly1305_module_init);
+crypto_module_exit(chacha20poly1305_module_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Martin Willi <martin@strongswan.org>");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 058/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_AEGIS128 crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (56 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 057/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CHACHA20POLY1305 crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 059/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_PCRYPT crypto Jay Wang
                   ` (47 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_AEGIS128-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile        | 2 +-
 crypto/aegis128-core.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index f71f2359ce08..cb1761303151 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -101,7 +101,7 @@ crypto-objs-$(CONFIG_CRYPTO_ADIANTUM) += adiantum.o
 crypto-objs-$(CONFIG_CRYPTO_GCM) += gcm.o
 crypto-objs-$(CONFIG_CRYPTO_CCM) += ccm.o
 crypto-objs-$(CONFIG_CRYPTO_CHACHA20POLY1305) += chacha20poly1305.o
-obj-$(CONFIG_CRYPTO_AEGIS128) += aegis128.o
+crypto-objs-$(CONFIG_CRYPTO_AEGIS128) += aegis128.o
 aegis128-y := aegis128-core.o
 
 ifeq ($(ARCH),arm)
diff --git a/crypto/aegis128-core.c b/crypto/aegis128-core.c
index ca80d861345d..2c8dfafcfdc8 100644
--- a/crypto/aegis128-core.c
+++ b/crypto/aegis128-core.c
@@ -566,8 +566,8 @@ static void __exit crypto_aegis128_module_exit(void)
 	crypto_unregister_aead(&crypto_aegis128_alg_generic);
 }
 
-module_init(crypto_aegis128_module_init);
-module_exit(crypto_aegis128_module_exit);
+crypto_module_init(crypto_aegis128_module_init);
+crypto_module_exit(crypto_aegis128_module_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Ondrej Mosnacek <omosnacek@gmail.com>");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 059/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_PCRYPT crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (57 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 058/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_AEGIS128 crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 060/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CRYPTD crypto Jay Wang
                   ` (46 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

From: Vegard Nossum <vegard.nossum@oracle.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_PCRYPT-related crypto to convert them into pluggable
interface.

Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[add pcrypt.o into crypto-objs-y; revise commit message]
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/pcrypt.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index cb1761303151..b371a8788d39 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -124,7 +124,7 @@ endif
 # Enable <arm_neon.h>
 CFLAGS_aegis128-neon-inner.o += -isystem $(shell $(CC) -print-file-name=include)
 
-obj-$(CONFIG_CRYPTO_PCRYPT) += pcrypt.o
+crypto-objs-$(CONFIG_CRYPTO_PCRYPT) += pcrypt.o
 obj-$(CONFIG_CRYPTO_CRYPTD) += cryptd.o
 obj-$(CONFIG_CRYPTO_DES) += des_generic.o
 obj-$(CONFIG_CRYPTO_FCRYPT) += fcrypt.o
diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
index c3a9d4f2995c..b9cf7df64c4e 100644
--- a/crypto/pcrypt.c
+++ b/crypto/pcrypt.c
@@ -378,8 +378,8 @@ static void __exit pcrypt_exit(void)
 	kset_unregister(pcrypt_kset);
 }
 
-module_init(pcrypt_init);
-module_exit(pcrypt_exit);
+crypto_module_init(pcrypt_init);
+crypto_module_exit(pcrypt_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Steffen Klassert <steffen.klassert@secunet.com>");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 060/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CRYPTD crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (58 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 059/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_PCRYPT crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 061/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_DES crypto Jay Wang
                   ` (45 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_CRYPTD-related crypto to convert them into pluggable
interface.

This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.

Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile              |  2 +-
 crypto/cryptd.c              |  4 +--
 crypto/fips140/fips140-api.c | 22 ++++++++++++++
 include/crypto/cryptd.h      | 56 +++++++++++++++++++++++++-----------
 4 files changed, 65 insertions(+), 19 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index b371a8788d39..f029e0decaa1 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -125,7 +125,7 @@ endif
 CFLAGS_aegis128-neon-inner.o += -isystem $(shell $(CC) -print-file-name=include)
 
 crypto-objs-$(CONFIG_CRYPTO_PCRYPT) += pcrypt.o
-obj-$(CONFIG_CRYPTO_CRYPTD) += cryptd.o
+crypto-objs-$(CONFIG_CRYPTO_CRYPTD) += cryptd.o
 obj-$(CONFIG_CRYPTO_DES) += des_generic.o
 obj-$(CONFIG_CRYPTO_FCRYPT) += fcrypt.o
 obj-$(CONFIG_CRYPTO_BLOWFISH) += blowfish_generic.o
diff --git a/crypto/cryptd.c b/crypto/cryptd.c
index cd38f4676176..8b1ba67d752c 100644
--- a/crypto/cryptd.c
+++ b/crypto/cryptd.c
@@ -1145,8 +1145,8 @@ static void __exit cryptd_exit(void)
 	crypto_unregister_template(&cryptd_tmpl);
 }
 
-module_init(cryptd_init);
-module_exit(cryptd_exit);
+crypto_module_init(cryptd_init);
+crypto_module_exit(cryptd_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Software async crypto daemon");
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 3c6dfcac5db5..1452439319cc 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -622,3 +622,25 @@ DEFINE_CRYPTO_API_STUB(ecc_point_is_zero);
 DEFINE_CRYPTO_API_STUB(ecc_point_mult_shamir);
 
 #endif
+/*
+ * crypto/cryptd.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_CRYPTD)
+
+#include <crypto/cryptd.h>
+
+DEFINE_CRYPTO_API_STUB(cryptd_alloc_skcipher);
+DEFINE_CRYPTO_API_STUB(cryptd_skcipher_child);
+DEFINE_CRYPTO_API_STUB(cryptd_skcipher_queued);
+DEFINE_CRYPTO_API_STUB(cryptd_free_skcipher);
+DEFINE_CRYPTO_API_STUB(cryptd_alloc_ahash);
+DEFINE_CRYPTO_API_STUB(cryptd_ahash_child);
+DEFINE_CRYPTO_API_STUB(cryptd_shash_desc);
+DEFINE_CRYPTO_API_STUB(cryptd_ahash_queued);
+DEFINE_CRYPTO_API_STUB(cryptd_free_ahash);
+DEFINE_CRYPTO_API_STUB(cryptd_alloc_aead);
+DEFINE_CRYPTO_API_STUB(cryptd_aead_child);
+DEFINE_CRYPTO_API_STUB(cryptd_aead_queued);
+DEFINE_CRYPTO_API_STUB(cryptd_free_aead);
+
+#endif
diff --git a/include/crypto/cryptd.h b/include/crypto/cryptd.h
index 796d986e58e1..35b4d06e41f5 100644
--- a/include/crypto/cryptd.h
+++ b/include/crypto/cryptd.h
@@ -13,6 +13,7 @@
 #ifndef _CRYPTO_CRYPT_H
 #define _CRYPTO_CRYPT_H
 
+#include <crypto/api.h>
 #include <linux/types.h>
 
 #include <crypto/aead.h>
@@ -24,12 +25,19 @@ struct cryptd_skcipher {
 };
 
 /* alg_name should be algorithm to be cryptd-ed */
-struct cryptd_skcipher *cryptd_alloc_skcipher(const char *alg_name,
-					      u32 type, u32 mask);
-struct crypto_skcipher *cryptd_skcipher_child(struct cryptd_skcipher *tfm);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CRYPTD, cryptd_alloc_skcipher, struct cryptd_skcipher *,
+	(const char *alg_name, u32 type, u32 mask),
+	(alg_name, type, mask));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CRYPTD, cryptd_skcipher_child, struct crypto_skcipher *,
+	(struct cryptd_skcipher *tfm),
+	(tfm));
 /* Must be called without moving CPUs. */
-bool cryptd_skcipher_queued(struct cryptd_skcipher *tfm);
-void cryptd_free_skcipher(struct cryptd_skcipher *tfm);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CRYPTD, cryptd_skcipher_queued, bool,
+	(struct cryptd_skcipher *tfm),
+	(tfm));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CRYPTD, cryptd_free_skcipher, void,
+	(struct cryptd_skcipher *tfm),
+	(tfm));
 
 struct cryptd_ahash {
 	struct crypto_ahash base;
@@ -42,13 +50,22 @@ static inline struct cryptd_ahash *__cryptd_ahash_cast(
 }
 
 /* alg_name should be algorithm to be cryptd-ed */
-struct cryptd_ahash *cryptd_alloc_ahash(const char *alg_name,
-					u32 type, u32 mask);
-struct crypto_shash *cryptd_ahash_child(struct cryptd_ahash *tfm);
-struct shash_desc *cryptd_shash_desc(struct ahash_request *req);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CRYPTD, cryptd_alloc_ahash, struct cryptd_ahash *,
+	(const char *alg_name, u32 type, u32 mask),
+	(alg_name, type, mask));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CRYPTD, cryptd_ahash_child, struct crypto_shash *,
+	(struct cryptd_ahash *tfm),
+	(tfm));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CRYPTD, cryptd_shash_desc, struct shash_desc *,
+	(struct ahash_request *req),
+	(req));
 /* Must be called without moving CPUs. */
-bool cryptd_ahash_queued(struct cryptd_ahash *tfm);
-void cryptd_free_ahash(struct cryptd_ahash *tfm);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CRYPTD, cryptd_ahash_queued, bool,
+	(struct cryptd_ahash *tfm),
+	(tfm));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CRYPTD, cryptd_free_ahash, void,
+	(struct cryptd_ahash *tfm),
+	(tfm));
 
 struct cryptd_aead {
 	struct crypto_aead base;
@@ -60,13 +77,20 @@ static inline struct cryptd_aead *__cryptd_aead_cast(
 	return (struct cryptd_aead *)tfm;
 }
 
-struct cryptd_aead *cryptd_alloc_aead(const char *alg_name,
-					  u32 type, u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CRYPTD, cryptd_alloc_aead, struct cryptd_aead *,
+	(const char *alg_name, u32 type, u32 mask),
+	(alg_name, type, mask));
 
-struct crypto_aead *cryptd_aead_child(struct cryptd_aead *tfm);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CRYPTD, cryptd_aead_child, struct crypto_aead *,
+	(struct cryptd_aead *tfm),
+	(tfm));
 /* Must be called without moving CPUs. */
-bool cryptd_aead_queued(struct cryptd_aead *tfm);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CRYPTD, cryptd_aead_queued, bool,
+	(struct cryptd_aead *tfm),
+	(tfm));
 
-void cryptd_free_aead(struct cryptd_aead *tfm);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CRYPTD, cryptd_free_aead, void,
+	(struct cryptd_aead *tfm),
+	(tfm));
 
 #endif
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 061/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_DES crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (59 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 060/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CRYPTD crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 062/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_FCRYPT crypto Jay Wang
                   ` (44 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_DES-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile      | 2 +-
 crypto/des_generic.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index f029e0decaa1..05fdb0e2f1be 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -126,7 +126,7 @@ CFLAGS_aegis128-neon-inner.o += -isystem $(shell $(CC) -print-file-name=include)
 
 crypto-objs-$(CONFIG_CRYPTO_PCRYPT) += pcrypt.o
 crypto-objs-$(CONFIG_CRYPTO_CRYPTD) += cryptd.o
-obj-$(CONFIG_CRYPTO_DES) += des_generic.o
+crypto-objs-$(CONFIG_CRYPTO_DES) += des_generic.o
 obj-$(CONFIG_CRYPTO_FCRYPT) += fcrypt.o
 obj-$(CONFIG_CRYPTO_BLOWFISH) += blowfish_generic.o
 obj-$(CONFIG_CRYPTO_BLOWFISH_COMMON) += blowfish_common.o
diff --git a/crypto/des_generic.c b/crypto/des_generic.c
index fce341400914..8f767317d396 100644
--- a/crypto/des_generic.c
+++ b/crypto/des_generic.c
@@ -122,8 +122,8 @@ static void __exit des_generic_mod_fini(void)
 	crypto_unregister_algs(des_algs, ARRAY_SIZE(des_algs));
 }
 
-module_init(des_generic_mod_init);
-module_exit(des_generic_mod_fini);
+crypto_module_init(des_generic_mod_init);
+crypto_module_exit(des_generic_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("DES & Triple DES EDE Cipher Algorithms");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 062/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_FCRYPT crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (60 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 061/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_DES crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 063/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_BLOWFISH and CONFIG_CRYPTO_BLOWFISH_COMMON crypto Jay Wang
                   ` (43 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_FCRYPT-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/fcrypt.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 05fdb0e2f1be..84dff7084f71 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -127,7 +127,7 @@ CFLAGS_aegis128-neon-inner.o += -isystem $(shell $(CC) -print-file-name=include)
 crypto-objs-$(CONFIG_CRYPTO_PCRYPT) += pcrypt.o
 crypto-objs-$(CONFIG_CRYPTO_CRYPTD) += cryptd.o
 crypto-objs-$(CONFIG_CRYPTO_DES) += des_generic.o
-obj-$(CONFIG_CRYPTO_FCRYPT) += fcrypt.o
+crypto-objs-$(CONFIG_CRYPTO_FCRYPT) += fcrypt.o
 obj-$(CONFIG_CRYPTO_BLOWFISH) += blowfish_generic.o
 obj-$(CONFIG_CRYPTO_BLOWFISH_COMMON) += blowfish_common.o
 obj-$(CONFIG_CRYPTO_TWOFISH) += twofish_generic.o
diff --git a/crypto/fcrypt.c b/crypto/fcrypt.c
index 80036835cec5..f1c9ae91d4b5 100644
--- a/crypto/fcrypt.c
+++ b/crypto/fcrypt.c
@@ -411,8 +411,8 @@ static void __exit fcrypt_mod_fini(void)
 	crypto_unregister_alg(&fcrypt_alg);
 }
 
-module_init(fcrypt_mod_init);
-module_exit(fcrypt_mod_fini);
+crypto_module_init(fcrypt_mod_init);
+crypto_module_exit(fcrypt_mod_fini);
 
 MODULE_LICENSE("Dual BSD/GPL");
 MODULE_DESCRIPTION("FCrypt Cipher Algorithm");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 063/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_BLOWFISH and CONFIG_CRYPTO_BLOWFISH_COMMON crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (61 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 062/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_FCRYPT crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 064/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SM4 and CONFIG_CRYPTO_SM4_GENERIC crypto Jay Wang
                   ` (42 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_BLOWFISH- and CONFIG_CRYPTO_BLOWFISH_COMMON-related crypto
to convert them into pluggable interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile              |  4 ++--
 crypto/blowfish_generic.c    |  4 ++--
 crypto/fips140/fips140-api.c | 10 ++++++++++
 include/crypto/blowfish.h    |  6 ++++--
 4 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 84dff7084f71..795c76357bff 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -128,8 +128,8 @@ crypto-objs-$(CONFIG_CRYPTO_PCRYPT) += pcrypt.o
 crypto-objs-$(CONFIG_CRYPTO_CRYPTD) += cryptd.o
 crypto-objs-$(CONFIG_CRYPTO_DES) += des_generic.o
 crypto-objs-$(CONFIG_CRYPTO_FCRYPT) += fcrypt.o
-obj-$(CONFIG_CRYPTO_BLOWFISH) += blowfish_generic.o
-obj-$(CONFIG_CRYPTO_BLOWFISH_COMMON) += blowfish_common.o
+crypto-objs-$(CONFIG_CRYPTO_BLOWFISH) += blowfish_generic.o
+crypto-objs-$(CONFIG_CRYPTO_BLOWFISH_COMMON) += blowfish_common.o
 obj-$(CONFIG_CRYPTO_TWOFISH) += twofish_generic.o
 obj-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o
 obj-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o
diff --git a/crypto/blowfish_generic.c b/crypto/blowfish_generic.c
index f3c5f9b09850..8a0390b14867 100644
--- a/crypto/blowfish_generic.c
+++ b/crypto/blowfish_generic.c
@@ -124,8 +124,8 @@ static void __exit blowfish_mod_fini(void)
 	crypto_unregister_alg(&alg);
 }
 
-module_init(blowfish_mod_init);
-module_exit(blowfish_mod_fini);
+crypto_module_init(blowfish_mod_init);
+crypto_module_exit(blowfish_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Blowfish Cipher Algorithm");
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 1452439319cc..61f7884d0f34 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -644,3 +644,13 @@ DEFINE_CRYPTO_API_STUB(cryptd_aead_queued);
 DEFINE_CRYPTO_API_STUB(cryptd_free_aead);
 
 #endif
+/*
+ * crypto/blowfish_common.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_BLOWFISH_COMMON)
+
+#include <crypto/blowfish.h>
+
+DEFINE_CRYPTO_API_STUB(blowfish_setkey);
+
+#endif
diff --git a/include/crypto/blowfish.h b/include/crypto/blowfish.h
index 9b384670b356..46e42a89bdf9 100644
--- a/include/crypto/blowfish.h
+++ b/include/crypto/blowfish.h
@@ -6,6 +6,7 @@
 #ifndef _CRYPTO_BLOWFISH_H
 #define _CRYPTO_BLOWFISH_H
 
+#include <crypto/api.h>
 #include <linux/types.h>
 #include <linux/crypto.h>
 
@@ -18,7 +19,8 @@ struct bf_ctx {
 	u32 s[1024];
 };
 
-int blowfish_setkey(struct crypto_tfm *tfm, const u8 *key,
-		    unsigned int key_len);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_BLOWFISH_COMMON, blowfish_setkey, int,
+	(struct crypto_tfm *tfm, const u8 *key, unsigned int key_len),
+	(tfm, key, key_len));
 
 #endif
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 064/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SM4 and CONFIG_CRYPTO_SM4_GENERIC crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (62 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 063/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_BLOWFISH and CONFIG_CRYPTO_BLOWFISH_COMMON crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 065/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_TWOFISH and CONFIG_CRYPTO_TWOFISH_COMMON crypto Jay Wang
                   ` (41 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_SM4- and CONFIG_CRYPTO_SM4_GENERIC-related crypto to
convert them into pluggable interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile              |  4 ++--
 crypto/fips140/fips140-api.c | 18 ++++++++++++++++++
 crypto/sm4_generic.c         |  4 ++--
 include/crypto/sm4.h         | 22 ++++++++++++++++------
 4 files changed, 38 insertions(+), 10 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 795c76357bff..326b37002e3d 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -135,8 +135,8 @@ obj-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o
 obj-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o
 CFLAGS_serpent_generic.o := $(call cc-option,-fsched-pressure)  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149
 crypto-objs-$(CONFIG_CRYPTO_AES) += aes.o
-obj-$(CONFIG_CRYPTO_SM4) += sm4.o
-obj-$(CONFIG_CRYPTO_SM4_GENERIC) += sm4_generic.o
+crypto-objs-$(CONFIG_CRYPTO_SM4) += sm4.o
+crypto-objs-$(CONFIG_CRYPTO_SM4_GENERIC) += sm4_generic.o
 obj-$(CONFIG_CRYPTO_CAMELLIA) += camellia_generic.o
 obj-$(CONFIG_CRYPTO_CAST_COMMON) += cast_common.o
 obj-$(CONFIG_CRYPTO_CAST5) += cast5_generic.o
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 61f7884d0f34..5b0ae8476ce7 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -654,3 +654,21 @@ DEFINE_CRYPTO_API_STUB(cryptd_free_aead);
 DEFINE_CRYPTO_API_STUB(blowfish_setkey);
 
 #endif
+/*
+ * crypto/sm4.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_SM4)
+
+#include <crypto/sm4.h>
+
+#undef crypto_sm4_fk
+#undef crypto_sm4_ck
+#undef crypto_sm4_sbox
+DEFINE_CRYPTO_VAR_STUB(crypto_sm4_fk);
+DEFINE_CRYPTO_VAR_STUB(crypto_sm4_ck);
+DEFINE_CRYPTO_VAR_STUB(crypto_sm4_sbox);
+
+DEFINE_CRYPTO_API_STUB(sm4_expandkey);
+DEFINE_CRYPTO_API_STUB(sm4_crypt_block);
+
+#endif
diff --git a/crypto/sm4_generic.c b/crypto/sm4_generic.c
index d57444e8428c..aba3e3271d37 100644
--- a/crypto/sm4_generic.c
+++ b/crypto/sm4_generic.c
@@ -83,8 +83,8 @@ static void __exit sm4_fini(void)
 	crypto_unregister_alg(&sm4_alg);
 }
 
-module_init(sm4_init);
-module_exit(sm4_fini);
+crypto_module_init(sm4_init);
+crypto_module_exit(sm4_fini);
 
 MODULE_DESCRIPTION("SM4 Cipher Algorithm");
 MODULE_LICENSE("GPL v2");
diff --git a/include/crypto/sm4.h b/include/crypto/sm4.h
index 9656a9a40326..10cb9c379357 100644
--- a/include/crypto/sm4.h
+++ b/include/crypto/sm4.h
@@ -9,6 +9,7 @@
 #ifndef _CRYPTO_SM4_H
 #define _CRYPTO_SM4_H
 
+#include <crypto/api.h>
 #include <linux/types.h>
 #include <linux/crypto.h>
 
@@ -21,9 +22,15 @@ struct sm4_ctx {
 	u32 rkey_dec[SM4_RKEY_WORDS];
 };
 
-extern const u32 crypto_sm4_fk[];
-extern const u32 crypto_sm4_ck[];
-extern const u8 crypto_sm4_sbox[];
+DECLARE_CRYPTO_VAR(CONFIG_CRYPTO_SM4, crypto_sm4_fk, const u32, [4]);
+DECLARE_CRYPTO_VAR(CONFIG_CRYPTO_SM4, crypto_sm4_ck, const u32, [32]);
+DECLARE_CRYPTO_VAR(CONFIG_CRYPTO_SM4, crypto_sm4_sbox, const u8, [256]);
+
+#if defined(CONFIG_CRYPTO_FIPS140_EXTMOD) && !defined(FIPS_MODULE) && IS_BUILTIN(CONFIG_CRYPTO_SM4)
+#define crypto_sm4_fk (((const u32*)CRYPTO_VAR_NAME(crypto_sm4_fk)))
+#define crypto_sm4_ck (((const u32*)CRYPTO_VAR_NAME(crypto_sm4_ck)))
+#define crypto_sm4_sbox (((const u8*)CRYPTO_VAR_NAME(crypto_sm4_sbox)))
+#endif
 
 /**
  * sm4_expandkey - Expands the SM4 key as described in GB/T 32907-2016
@@ -34,8 +41,9 @@ extern const u8 crypto_sm4_sbox[];
  * Returns 0 on success. The function fails only if an invalid key size (or
  * pointer) is supplied.
  */
-int sm4_expandkey(struct sm4_ctx *ctx, const u8 *in_key,
-			  unsigned int key_len);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SM4, sm4_expandkey, int,
+	(struct sm4_ctx *ctx, const u8 *in_key, unsigned int key_len),
+	(ctx, in_key, key_len));
 
 /**
  * sm4_crypt_block - Encrypt or decrypt a single SM4 block
@@ -43,6 +51,8 @@ int sm4_expandkey(struct sm4_ctx *ctx, const u8 *in_key,
  * @out:	Buffer to store output data
  * @in: 	Buffer containing the input data
  */
-void sm4_crypt_block(const u32 *rk, u8 *out, const u8 *in);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SM4, sm4_crypt_block, void,
+	(const u32 *rk, u8 *out, const u8 *in),
+	(rk, out, in));
 
 #endif
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 065/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_TWOFISH and CONFIG_CRYPTO_TWOFISH_COMMON crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (63 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 064/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SM4 and CONFIG_CRYPTO_SM4_GENERIC crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 066/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SERPENT crypto Jay Wang
                   ` (40 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_TWOFISH- and CONFIG_CRYPTO_TWOFISH_COMMON-related crypto
to convert them into pluggable interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile              |  4 ++--
 crypto/fips140/fips140-api.c | 11 +++++++++++
 crypto/twofish_generic.c     |  4 ++--
 include/crypto/twofish.h     | 11 ++++++++---
 4 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 326b37002e3d..e93edc49840a 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -130,8 +130,8 @@ crypto-objs-$(CONFIG_CRYPTO_DES) += des_generic.o
 crypto-objs-$(CONFIG_CRYPTO_FCRYPT) += fcrypt.o
 crypto-objs-$(CONFIG_CRYPTO_BLOWFISH) += blowfish_generic.o
 crypto-objs-$(CONFIG_CRYPTO_BLOWFISH_COMMON) += blowfish_common.o
-obj-$(CONFIG_CRYPTO_TWOFISH) += twofish_generic.o
-obj-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o
+crypto-objs-$(CONFIG_CRYPTO_TWOFISH) += twofish_generic.o
+crypto-objs-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o
 obj-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o
 CFLAGS_serpent_generic.o := $(call cc-option,-fsched-pressure)  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149
 crypto-objs-$(CONFIG_CRYPTO_AES) += aes.o
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 5b0ae8476ce7..9ad530743d1f 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -672,3 +672,14 @@ DEFINE_CRYPTO_API_STUB(sm4_expandkey);
 DEFINE_CRYPTO_API_STUB(sm4_crypt_block);
 
 #endif
+/*
+ * crypto/twofish_common.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_TWOFISH_COMMON)
+
+#include <crypto/twofish.h>
+
+DEFINE_CRYPTO_API_STUB(__twofish_setkey);
+DEFINE_CRYPTO_API_STUB(twofish_setkey);
+
+#endif
diff --git a/crypto/twofish_generic.c b/crypto/twofish_generic.c
index 368018cfa9bf..0d9cefa3350b 100644
--- a/crypto/twofish_generic.c
+++ b/crypto/twofish_generic.c
@@ -187,8 +187,8 @@ static void __exit twofish_mod_fini(void)
 	crypto_unregister_alg(&alg);
 }
 
-module_init(twofish_mod_init);
-module_exit(twofish_mod_fini);
+crypto_module_init(twofish_mod_init);
+crypto_module_exit(twofish_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION ("Twofish Cipher Algorithm");
diff --git a/include/crypto/twofish.h b/include/crypto/twofish.h
index f6b307a58554..4695480f5d44 100644
--- a/include/crypto/twofish.h
+++ b/include/crypto/twofish.h
@@ -2,6 +2,7 @@
 #ifndef _CRYPTO_TWOFISH_H
 #define _CRYPTO_TWOFISH_H
 
+#include <crypto/api.h>
 #include <linux/types.h>
 
 #define TF_MIN_KEY_SIZE 16
@@ -18,8 +19,12 @@ struct twofish_ctx {
 	u32 s[4][256], w[8], k[32];
 };
 
-int __twofish_setkey(struct twofish_ctx *ctx, const u8 *key,
-		     unsigned int key_len);
-int twofish_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int key_len);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_TWOFISH_COMMON, __twofish_setkey, int,
+	(struct twofish_ctx *ctx, const u8 *key, unsigned int key_len),
+	(ctx, key, key_len));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_TWOFISH_COMMON, twofish_setkey, int,
+	(struct crypto_tfm *tfm, const u8 *key, unsigned int key_len),
+	(tfm, key, key_len));
 
 #endif
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 066/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SERPENT crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (64 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 065/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_TWOFISH and CONFIG_CRYPTO_TWOFISH_COMMON crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 067/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CAMELLIA crypto Jay Wang
                   ` (39 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_SERPENT-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile              |  2 +-
 crypto/fips140/fips140-api.c | 13 +++++++++++++
 crypto/serpent_generic.c     |  4 ++--
 include/crypto/serpent.h     | 20 +++++++++++++++-----
 4 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index e93edc49840a..c14713e9cc55 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -132,7 +132,7 @@ crypto-objs-$(CONFIG_CRYPTO_BLOWFISH) += blowfish_generic.o
 crypto-objs-$(CONFIG_CRYPTO_BLOWFISH_COMMON) += blowfish_common.o
 crypto-objs-$(CONFIG_CRYPTO_TWOFISH) += twofish_generic.o
 crypto-objs-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o
-obj-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o
+crypto-objs-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o
 CFLAGS_serpent_generic.o := $(call cc-option,-fsched-pressure)  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149
 crypto-objs-$(CONFIG_CRYPTO_AES) += aes.o
 crypto-objs-$(CONFIG_CRYPTO_SM4) += sm4.o
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 9ad530743d1f..475cab990549 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -683,3 +683,16 @@ DEFINE_CRYPTO_API_STUB(__twofish_setkey);
 DEFINE_CRYPTO_API_STUB(twofish_setkey);
 
 #endif
+/*
+ * crypto/serpent_generic.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_SERPENT)
+
+#include <crypto/serpent.h>
+
+DEFINE_CRYPTO_API_STUB(__serpent_setkey);
+DEFINE_CRYPTO_API_STUB(serpent_setkey);
+DEFINE_CRYPTO_API_STUB(__serpent_encrypt);
+DEFINE_CRYPTO_API_STUB(__serpent_decrypt);
+
+#endif
diff --git a/crypto/serpent_generic.c b/crypto/serpent_generic.c
index b21e7606c652..27c2da015d20 100644
--- a/crypto/serpent_generic.c
+++ b/crypto/serpent_generic.c
@@ -599,8 +599,8 @@ static void __exit serpent_mod_fini(void)
 	crypto_unregister_alg(&srp_alg);
 }
 
-module_init(serpent_mod_init);
-module_exit(serpent_mod_fini);
+crypto_module_init(serpent_mod_init);
+crypto_module_exit(serpent_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Serpent Cipher Algorithm");
diff --git a/include/crypto/serpent.h b/include/crypto/serpent.h
index 75c7eaa20853..8985ff684aeb 100644
--- a/include/crypto/serpent.h
+++ b/include/crypto/serpent.h
@@ -6,6 +6,7 @@
 #ifndef _CRYPTO_SERPENT_H
 #define _CRYPTO_SERPENT_H
 
+#include <crypto/api.h>
 #include <linux/types.h>
 #include <linux/crypto.h>
 
@@ -18,11 +19,20 @@ struct serpent_ctx {
 	u32 expkey[SERPENT_EXPKEY_WORDS];
 };
 
-int __serpent_setkey(struct serpent_ctx *ctx, const u8 *key,
-		     unsigned int keylen);
-int serpent_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SERPENT, __serpent_setkey, int,
+	(struct serpent_ctx *ctx, const u8 *key, unsigned int keylen),
+	(ctx, key, keylen));
 
-void __serpent_encrypt(const void *ctx, u8 *dst, const u8 *src);
-void __serpent_decrypt(const void *ctx, u8 *dst, const u8 *src);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SERPENT, serpent_setkey, int,
+	(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen),
+	(tfm, key, keylen));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SERPENT, __serpent_encrypt, void,
+	(const void *ctx, u8 *dst, const u8 *src),
+	(ctx, dst, src));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SERPENT, __serpent_decrypt, void,
+	(const void *ctx, u8 *dst, const u8 *src),
+	(ctx, dst, src));
 
 #endif
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 067/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CAMELLIA crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (65 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 066/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SERPENT crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 068/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CAST_COMMON, CONFIG_CRYPTO_CAST5, CONFIG_CRYPTO_CAST6 crypto Jay Wang
                   ` (38 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_CAMELLIA-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile           | 2 +-
 crypto/camellia_generic.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index c14713e9cc55..4b6e56ad4d1c 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -137,7 +137,7 @@ CFLAGS_serpent_generic.o := $(call cc-option,-fsched-pressure)  # https://gcc.gn
 crypto-objs-$(CONFIG_CRYPTO_AES) += aes.o
 crypto-objs-$(CONFIG_CRYPTO_SM4) += sm4.o
 crypto-objs-$(CONFIG_CRYPTO_SM4_GENERIC) += sm4_generic.o
-obj-$(CONFIG_CRYPTO_CAMELLIA) += camellia_generic.o
+crypto-objs-$(CONFIG_CRYPTO_CAMELLIA) += camellia_generic.o
 obj-$(CONFIG_CRYPTO_CAST_COMMON) += cast_common.o
 obj-$(CONFIG_CRYPTO_CAST5) += cast5_generic.o
 obj-$(CONFIG_CRYPTO_CAST6) += cast6_generic.o
diff --git a/crypto/camellia_generic.c b/crypto/camellia_generic.c
index ee4336a04b93..15a68abc387b 100644
--- a/crypto/camellia_generic.c
+++ b/crypto/camellia_generic.c
@@ -1064,8 +1064,8 @@ static void __exit camellia_fini(void)
 	crypto_unregister_alg(&camellia_alg);
 }
 
-module_init(camellia_init);
-module_exit(camellia_fini);
+crypto_module_init(camellia_init);
+crypto_module_exit(camellia_fini);
 
 MODULE_DESCRIPTION("Camellia Cipher Algorithm");
 MODULE_LICENSE("GPL");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 068/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CAST_COMMON, CONFIG_CRYPTO_CAST5, CONFIG_CRYPTO_CAST6 crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (66 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 067/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CAMELLIA crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 069/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ARC4 crypto Jay Wang
                   ` (37 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_CAST_COMMON-, CONFIG_CRYPTO_CAST5-, and
CONFIG_CRYPTO_CAST6-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile              |  6 +++---
 crypto/cast5_generic.c       |  4 ++--
 crypto/cast6_generic.c       |  4 ++--
 crypto/fips140/fips140-api.c | 42 ++++++++++++++++++++++++++++++++++++
 include/crypto/cast5.h       | 14 +++++++++---
 include/crypto/cast6.h       | 19 ++++++++++++----
 include/crypto/cast_common.h | 17 +++++++++++----
 7 files changed, 88 insertions(+), 18 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 4b6e56ad4d1c..7635fd4b698c 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -138,9 +138,9 @@ crypto-objs-$(CONFIG_CRYPTO_AES) += aes.o
 crypto-objs-$(CONFIG_CRYPTO_SM4) += sm4.o
 crypto-objs-$(CONFIG_CRYPTO_SM4_GENERIC) += sm4_generic.o
 crypto-objs-$(CONFIG_CRYPTO_CAMELLIA) += camellia_generic.o
-obj-$(CONFIG_CRYPTO_CAST_COMMON) += cast_common.o
-obj-$(CONFIG_CRYPTO_CAST5) += cast5_generic.o
-obj-$(CONFIG_CRYPTO_CAST6) += cast6_generic.o
+crypto-objs-$(CONFIG_CRYPTO_CAST_COMMON) += cast_common.o
+crypto-objs-$(CONFIG_CRYPTO_CAST5) += cast5_generic.o
+crypto-objs-$(CONFIG_CRYPTO_CAST6) += cast6_generic.o
 obj-$(CONFIG_CRYPTO_ARC4) += arc4.o
 obj-$(CONFIG_CRYPTO_TEA) += tea.o
 obj-$(CONFIG_CRYPTO_KHAZAD) += khazad.o
diff --git a/crypto/cast5_generic.c b/crypto/cast5_generic.c
index f68330793e0c..241738e09945 100644
--- a/crypto/cast5_generic.c
+++ b/crypto/cast5_generic.c
@@ -531,8 +531,8 @@ static void __exit cast5_mod_fini(void)
 	crypto_unregister_alg(&alg);
 }
 
-module_init(cast5_mod_init);
-module_exit(cast5_mod_fini);
+crypto_module_init(cast5_mod_init);
+crypto_module_exit(cast5_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Cast5 Cipher Algorithm");
diff --git a/crypto/cast6_generic.c b/crypto/cast6_generic.c
index 4c08c42646f0..53deace18e63 100644
--- a/crypto/cast6_generic.c
+++ b/crypto/cast6_generic.c
@@ -271,8 +271,8 @@ static void __exit cast6_mod_fini(void)
 	crypto_unregister_alg(&alg);
 }
 
-module_init(cast6_mod_init);
-module_exit(cast6_mod_fini);
+crypto_module_init(cast6_mod_init);
+crypto_module_exit(cast6_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Cast6 Cipher Algorithm");
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 475cab990549..f6d6a6e79a9e 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -696,3 +696,45 @@ DEFINE_CRYPTO_API_STUB(__serpent_encrypt);
 DEFINE_CRYPTO_API_STUB(__serpent_decrypt);
 
 #endif
+/*
+ * crypto/cast_common.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_CAST_COMMON)
+
+#include <crypto/cast_common.h>
+
+#undef cast_s1
+#undef cast_s2
+#undef cast_s3
+#undef cast_s4
+DEFINE_CRYPTO_VAR_STUB(cast_s1);
+DEFINE_CRYPTO_VAR_STUB(cast_s2);
+DEFINE_CRYPTO_VAR_STUB(cast_s3);
+DEFINE_CRYPTO_VAR_STUB(cast_s4);
+
+#endif
+/*
+ * crypto/cast5_generic.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_CAST5)
+
+#include <crypto/cast5.h>
+
+DEFINE_CRYPTO_API_STUB(cast5_setkey);
+DEFINE_CRYPTO_API_STUB(__cast5_encrypt);
+DEFINE_CRYPTO_API_STUB(__cast5_decrypt);
+
+#endif
+/*
+ * crypto/cast6_generic.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_CAST6)
+
+#include <crypto/cast6.h>
+
+DEFINE_CRYPTO_API_STUB(__cast6_setkey);
+DEFINE_CRYPTO_API_STUB(cast6_setkey);
+DEFINE_CRYPTO_API_STUB(__cast6_encrypt);
+DEFINE_CRYPTO_API_STUB(__cast6_decrypt);
+
+#endif
diff --git a/include/crypto/cast5.h b/include/crypto/cast5.h
index 3d4ed4ea9c3b..cdd85cd974bb 100644
--- a/include/crypto/cast5.h
+++ b/include/crypto/cast5.h
@@ -2,6 +2,7 @@
 #ifndef _CRYPTO_CAST5_H
 #define _CRYPTO_CAST5_H
 
+#include <crypto/api.h>
 #include <linux/types.h>
 #include <linux/crypto.h>
 #include <crypto/cast_common.h>
@@ -16,9 +17,16 @@ struct cast5_ctx {
 	int rr;	/* rr ? rounds = 12 : rounds = 16; (rfc 2144) */
 };
 
-int cast5_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CAST5, cast5_setkey, int,
+	(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen),
+	(tfm, key, keylen));
 
-void __cast5_encrypt(struct cast5_ctx *ctx, u8 *dst, const u8 *src);
-void __cast5_decrypt(struct cast5_ctx *ctx, u8 *dst, const u8 *src);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CAST5, __cast5_encrypt, void,
+	(struct cast5_ctx *ctx, u8 *dst, const u8 *src),
+	(ctx, dst, src));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CAST5, __cast5_decrypt, void,
+	(struct cast5_ctx *ctx, u8 *dst, const u8 *src),
+	(ctx, dst, src));
 
 #endif
diff --git a/include/crypto/cast6.h b/include/crypto/cast6.h
index 38f490cd50a8..5fd28d7ed70f 100644
--- a/include/crypto/cast6.h
+++ b/include/crypto/cast6.h
@@ -2,6 +2,7 @@
 #ifndef _CRYPTO_CAST6_H
 #define _CRYPTO_CAST6_H
 
+#include <crypto/api.h>
 #include <linux/types.h>
 #include <linux/crypto.h>
 #include <crypto/cast_common.h>
@@ -15,10 +16,20 @@ struct cast6_ctx {
 	u8 Kr[12][4];
 };
 
-int __cast6_setkey(struct cast6_ctx *ctx, const u8 *key, unsigned int keylen);
-int cast6_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CAST6, __cast6_setkey, int,
+	(struct cast6_ctx *ctx, const u8 *key, unsigned int keylen),
+	(ctx, key, keylen));
 
-void __cast6_encrypt(const void *ctx, u8 *dst, const u8 *src);
-void __cast6_decrypt(const void *ctx, u8 *dst, const u8 *src);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CAST6, cast6_setkey, int,
+	(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen),
+	(tfm, key, keylen));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CAST6, __cast6_encrypt, void,
+	(const void *ctx, u8 *dst, const u8 *src),
+	(ctx, dst, src));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CAST6, __cast6_decrypt, void,
+	(const void *ctx, u8 *dst, const u8 *src),
+	(ctx, dst, src));
 
 #endif
diff --git a/include/crypto/cast_common.h b/include/crypto/cast_common.h
index b90090244164..68f8b4b5ea76 100644
--- a/include/crypto/cast_common.h
+++ b/include/crypto/cast_common.h
@@ -2,9 +2,18 @@
 #ifndef _CRYPTO_CAST_COMMON_H
 #define _CRYPTO_CAST_COMMON_H
 
-extern const u32 cast_s1[256];
-extern const u32 cast_s2[256];
-extern const u32 cast_s3[256];
-extern const u32 cast_s4[256];
+#include <crypto/api.h>
+
+DECLARE_CRYPTO_VAR(CONFIG_CRYPTO_CAST_COMMON, cast_s1, const u32, [256]);
+DECLARE_CRYPTO_VAR(CONFIG_CRYPTO_CAST_COMMON, cast_s2, const u32, [256]);
+DECLARE_CRYPTO_VAR(CONFIG_CRYPTO_CAST_COMMON, cast_s3, const u32, [256]);
+DECLARE_CRYPTO_VAR(CONFIG_CRYPTO_CAST_COMMON, cast_s4, const u32, [256]);
+
+#if defined(CONFIG_CRYPTO_FIPS140_EXTMOD) && !defined(FIPS_MODULE) && IS_BUILTIN(CONFIG_CRYPTO_CAST_COMMON)
+#define cast_s1 (((const u32*)CRYPTO_VAR_NAME(cast_s1)))
+#define cast_s2 (((const u32*)CRYPTO_VAR_NAME(cast_s2)))
+#define cast_s3 (((const u32*)CRYPTO_VAR_NAME(cast_s3)))
+#define cast_s4 (((const u32*)CRYPTO_VAR_NAME(cast_s4)))
+#endif
 
 #endif
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 069/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ARC4 crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (67 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 068/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CAST_COMMON, CONFIG_CRYPTO_CAST5, CONFIG_CRYPTO_CAST6 crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 070/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_USER_API crypto Jay Wang
                   ` (36 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_ARC4-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/arc4.c   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 7635fd4b698c..623651445612 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -141,7 +141,7 @@ crypto-objs-$(CONFIG_CRYPTO_CAMELLIA) += camellia_generic.o
 crypto-objs-$(CONFIG_CRYPTO_CAST_COMMON) += cast_common.o
 crypto-objs-$(CONFIG_CRYPTO_CAST5) += cast5_generic.o
 crypto-objs-$(CONFIG_CRYPTO_CAST6) += cast6_generic.o
-obj-$(CONFIG_CRYPTO_ARC4) += arc4.o
+crypto-objs-$(CONFIG_CRYPTO_ARC4) += arc4.o
 obj-$(CONFIG_CRYPTO_TEA) += tea.o
 obj-$(CONFIG_CRYPTO_KHAZAD) += khazad.o
 obj-$(CONFIG_CRYPTO_ANUBIS) += anubis.o
diff --git a/crypto/arc4.c b/crypto/arc4.c
index 1608018111d0..f2bad33acb74 100644
--- a/crypto/arc4.c
+++ b/crypto/arc4.c
@@ -73,8 +73,8 @@ static void __exit arc4_exit(void)
 	crypto_unregister_lskcipher(&arc4_alg);
 }
 
-module_init(arc4_init);
-module_exit(arc4_exit);
+crypto_module_init(arc4_init);
+crypto_module_exit(arc4_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("ARC4 Cipher Algorithm");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 070/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_USER_API crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (68 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 069/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ARC4 crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 071/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_USER_API_SKCIPHER crypto Jay Wang
                   ` (35 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_USER_API-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile              |  2 +-
 crypto/af_alg.c              |  4 +-
 crypto/fips140/fips140-api.c | 25 +++++++++++
 include/crypto/if_alg.h      | 84 ++++++++++++++++++++++++++----------
 4 files changed, 89 insertions(+), 26 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 623651445612..5c363d865b45 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -172,7 +172,7 @@ jitterentropy_rng-y := jitterentropy.o jitterentropy-kcapi.o
 obj-$(CONFIG_CRYPTO_JITTERENTROPY_TESTINTERFACE) += jitterentropy-testing.o
 obj-$(CONFIG_CRYPTO_BENCHMARK) += tcrypt.o
 crypto-objs-$(CONFIG_CRYPTO_GHASH) += ghash-generic.o
-obj-$(CONFIG_CRYPTO_USER_API) += af_alg.o
+crypto-objs-$(CONFIG_CRYPTO_USER_API) += af_alg.o
 obj-$(CONFIG_CRYPTO_USER_API_HASH) += algif_hash.o
 obj-$(CONFIG_CRYPTO_USER_API_SKCIPHER) += algif_skcipher.o
 obj-$(CONFIG_CRYPTO_USER_API_RNG) += algif_rng.o
diff --git a/crypto/af_alg.c b/crypto/af_alg.c
index e468714f539d..48ce5a420fed 100644
--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -1322,8 +1322,8 @@ static void __exit af_alg_exit(void)
 	proto_unregister(&alg_proto);
 }
 
-module_init(af_alg_init);
-module_exit(af_alg_exit);
+crypto_module_init(af_alg_init);
+crypto_module_exit(af_alg_exit);
 MODULE_DESCRIPTION("Crypto userspace interface");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS_NETPROTO(AF_ALG);
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index f6d6a6e79a9e..e20c9601637a 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -738,3 +738,28 @@ DEFINE_CRYPTO_API_STUB(__cast6_encrypt);
 DEFINE_CRYPTO_API_STUB(__cast6_decrypt);
 
 #endif
+/*
+ * crypto/af_alg.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_USER_API)
+
+#include <crypto/if_alg.h>
+
+DEFINE_CRYPTO_API_STUB(af_alg_register_type);
+DEFINE_CRYPTO_API_STUB(af_alg_unregister_type);
+DEFINE_CRYPTO_API_STUB(af_alg_release);
+DEFINE_CRYPTO_API_STUB(af_alg_release_parent);
+DEFINE_CRYPTO_API_STUB(af_alg_accept);
+DEFINE_CRYPTO_API_STUB(af_alg_free_sg);
+DEFINE_CRYPTO_API_STUB(af_alg_count_tsgl);
+DEFINE_CRYPTO_API_STUB(af_alg_pull_tsgl);
+DEFINE_CRYPTO_API_STUB(af_alg_wmem_wakeup);
+DEFINE_CRYPTO_API_STUB(af_alg_wait_for_data);
+DEFINE_CRYPTO_API_STUB(af_alg_sendmsg);
+DEFINE_CRYPTO_API_STUB(af_alg_free_resources);
+DEFINE_CRYPTO_API_STUB(af_alg_async_cb);
+DEFINE_CRYPTO_API_STUB(af_alg_poll);
+DEFINE_CRYPTO_API_STUB(af_alg_alloc_areq);
+DEFINE_CRYPTO_API_STUB(af_alg_get_rsgl);
+
+#endif
diff --git a/include/crypto/if_alg.h b/include/crypto/if_alg.h
index 107b797c33ec..1c5f2ed140ea 100644
--- a/include/crypto/if_alg.h
+++ b/include/crypto/if_alg.h
@@ -8,6 +8,7 @@
 #ifndef _CRYPTO_IF_ALG_H
 #define _CRYPTO_IF_ALG_H
 
+#include <crypto/api.h>
 #include <linux/compiler.h>
 #include <linux/completion.h>
 #include <linux/if_alg.h>
@@ -163,15 +164,29 @@ struct af_alg_ctx {
 	unsigned int inflight;
 };
 
-int af_alg_register_type(const struct af_alg_type *type);
-int af_alg_unregister_type(const struct af_alg_type *type);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_register_type, int,
+	(const struct af_alg_type *type),
+	(type));
 
-int af_alg_release(struct socket *sock);
-void af_alg_release_parent(struct sock *sk);
-int af_alg_accept(struct sock *sk, struct socket *newsock,
-		  struct proto_accept_arg *arg);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_unregister_type, int,
+	(const struct af_alg_type *type),
+	(type));
 
-void af_alg_free_sg(struct af_alg_sgl *sgl);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_release, int,
+	(struct socket *sock),
+	(sock));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_release_parent, void,
+	(struct sock *sk),
+	(sk));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_accept, int,
+	(struct sock *sk, struct socket *newsock, struct proto_accept_arg *arg),
+	(sk, newsock, arg));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_free_sg, void,
+	(struct af_alg_sgl *sgl),
+	(sgl));
 
 static inline struct alg_sock *alg_sk(struct sock *sk)
 {
@@ -230,21 +245,44 @@ static inline bool af_alg_readable(struct sock *sk)
 	return PAGE_SIZE <= af_alg_rcvbuf(sk);
 }
 
-unsigned int af_alg_count_tsgl(struct sock *sk, size_t bytes, size_t offset);
-void af_alg_pull_tsgl(struct sock *sk, size_t used, struct scatterlist *dst,
-		      size_t dst_offset);
-void af_alg_wmem_wakeup(struct sock *sk);
-int af_alg_wait_for_data(struct sock *sk, unsigned flags, unsigned min);
-int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size,
-		   unsigned int ivsize);
-void af_alg_free_resources(struct af_alg_async_req *areq);
-void af_alg_async_cb(void *data, int err);
-__poll_t af_alg_poll(struct file *file, struct socket *sock,
-			 poll_table *wait);
-struct af_alg_async_req *af_alg_alloc_areq(struct sock *sk,
-					   unsigned int areqlen);
-int af_alg_get_rsgl(struct sock *sk, struct msghdr *msg, int flags,
-		    struct af_alg_async_req *areq, size_t maxsize,
-		    size_t *outlen);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_count_tsgl, unsigned int,
+	(struct sock *sk, size_t bytes, size_t offset),
+	(sk, bytes, offset));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_pull_tsgl, void,
+	(struct sock *sk, size_t used, struct scatterlist *dst, size_t dst_offset),
+	(sk, used, dst, dst_offset));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_wmem_wakeup, void,
+	(struct sock *sk),
+	(sk));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_wait_for_data, int,
+	(struct sock *sk, unsigned flags, unsigned min),
+	(sk, flags, min));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_sendmsg, int,
+	(struct socket *sock, struct msghdr *msg, size_t size, unsigned int ivsize),
+	(sock, msg, size, ivsize));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_free_resources, void,
+	(struct af_alg_async_req *areq),
+	(areq));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_async_cb, void,
+	(void *data, int err),
+	(data, err));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_poll, __poll_t,
+	(struct file *file, struct socket *sock, poll_table *wait),
+	(file, sock, wait));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_alloc_areq, struct af_alg_async_req *,
+	(struct sock *sk, unsigned int areqlen),
+	(sk, areqlen));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_get_rsgl, int,
+	(struct sock *sk, struct msghdr *msg, int flags, struct af_alg_async_req *areq, size_t maxsize, size_t *outlen),
+	(sk, msg, flags, areq, maxsize, outlen));
 
 #endif	/* _CRYPTO_IF_ALG_H */
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 071/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_USER_API_SKCIPHER crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (69 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 070/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_USER_API crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 072/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_TEA crypto Jay Wang
                   ` (34 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_USER_API_SKCIPHER-related crypto to convert them into
pluggable interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile         | 2 +-
 crypto/algif_skcipher.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 5c363d865b45..a7ad0f5dd1d9 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -174,7 +174,7 @@ obj-$(CONFIG_CRYPTO_BENCHMARK) += tcrypt.o
 crypto-objs-$(CONFIG_CRYPTO_GHASH) += ghash-generic.o
 crypto-objs-$(CONFIG_CRYPTO_USER_API) += af_alg.o
 obj-$(CONFIG_CRYPTO_USER_API_HASH) += algif_hash.o
-obj-$(CONFIG_CRYPTO_USER_API_SKCIPHER) += algif_skcipher.o
+crypto-objs-$(CONFIG_CRYPTO_USER_API_SKCIPHER) += algif_skcipher.o
 obj-$(CONFIG_CRYPTO_USER_API_RNG) += algif_rng.o
 obj-$(CONFIG_CRYPTO_USER_API_AEAD) += algif_aead.o
 obj-$(CONFIG_CRYPTO_ZSTD) += zstd.o
diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c
index 125d395c5e00..8fbfb6c7ba14 100644
--- a/crypto/algif_skcipher.c
+++ b/crypto/algif_skcipher.c
@@ -435,7 +435,7 @@ static void __exit algif_skcipher_exit(void)
 	BUG_ON(err);
 }
 
-module_init(algif_skcipher_init);
-module_exit(algif_skcipher_exit);
+crypto_module_init(algif_skcipher_init);
+crypto_module_exit(algif_skcipher_exit);
 MODULE_DESCRIPTION("Userspace interface for skcipher algorithms");
 MODULE_LICENSE("GPL");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 072/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_TEA crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (70 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 071/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_USER_API_SKCIPHER crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 073/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_KHAZAD crypto Jay Wang
                   ` (33 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_TEA-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/tea.c    | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index a7ad0f5dd1d9..1854a70babc0 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -142,7 +142,7 @@ crypto-objs-$(CONFIG_CRYPTO_CAST_COMMON) += cast_common.o
 crypto-objs-$(CONFIG_CRYPTO_CAST5) += cast5_generic.o
 crypto-objs-$(CONFIG_CRYPTO_CAST6) += cast6_generic.o
 crypto-objs-$(CONFIG_CRYPTO_ARC4) += arc4.o
-obj-$(CONFIG_CRYPTO_TEA) += tea.o
+crypto-objs-$(CONFIG_CRYPTO_TEA) += tea.o
 obj-$(CONFIG_CRYPTO_KHAZAD) += khazad.o
 obj-$(CONFIG_CRYPTO_ANUBIS) += anubis.o
 obj-$(CONFIG_CRYPTO_SEED) += seed.o
diff --git a/crypto/tea.c b/crypto/tea.c
index cb05140e3470..9f42e296377f 100644
--- a/crypto/tea.c
+++ b/crypto/tea.c
@@ -255,8 +255,8 @@ MODULE_ALIAS_CRYPTO("tea");
 MODULE_ALIAS_CRYPTO("xtea");
 MODULE_ALIAS_CRYPTO("xeta");
 
-module_init(tea_mod_init);
-module_exit(tea_mod_fini);
+crypto_module_init(tea_mod_init);
+crypto_module_exit(tea_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("TEA, XTEA & XETA Cryptographic Algorithms");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 073/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_KHAZAD crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (71 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 072/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_TEA crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 074/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ANUBIS crypto Jay Wang
                   ` (32 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_KHAZAD-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/khazad.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 1854a70babc0..87f1b0e315f2 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -143,7 +143,7 @@ crypto-objs-$(CONFIG_CRYPTO_CAST5) += cast5_generic.o
 crypto-objs-$(CONFIG_CRYPTO_CAST6) += cast6_generic.o
 crypto-objs-$(CONFIG_CRYPTO_ARC4) += arc4.o
 crypto-objs-$(CONFIG_CRYPTO_TEA) += tea.o
-obj-$(CONFIG_CRYPTO_KHAZAD) += khazad.o
+crypto-objs-$(CONFIG_CRYPTO_KHAZAD) += khazad.o
 obj-$(CONFIG_CRYPTO_ANUBIS) += anubis.o
 obj-$(CONFIG_CRYPTO_SEED) += seed.o
 obj-$(CONFIG_CRYPTO_ARIA) += aria_generic.o
diff --git a/crypto/khazad.c b/crypto/khazad.c
index dee54ad5f0e4..d54214a9bc3f 100644
--- a/crypto/khazad.c
+++ b/crypto/khazad.c
@@ -868,8 +868,8 @@ static void __exit khazad_mod_fini(void)
 }
 
 
-module_init(khazad_mod_init);
-module_exit(khazad_mod_fini);
+crypto_module_init(khazad_mod_init);
+crypto_module_exit(khazad_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Khazad Cryptographic Algorithm");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 074/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ANUBIS crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (72 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 073/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_KHAZAD crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 075/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SEED crypto Jay Wang
                   ` (31 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_ANUBIS-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/anubis.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 87f1b0e315f2..fb863dcef44f 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -144,7 +144,7 @@ crypto-objs-$(CONFIG_CRYPTO_CAST6) += cast6_generic.o
 crypto-objs-$(CONFIG_CRYPTO_ARC4) += arc4.o
 crypto-objs-$(CONFIG_CRYPTO_TEA) += tea.o
 crypto-objs-$(CONFIG_CRYPTO_KHAZAD) += khazad.o
-obj-$(CONFIG_CRYPTO_ANUBIS) += anubis.o
+crypto-objs-$(CONFIG_CRYPTO_ANUBIS) += anubis.o
 obj-$(CONFIG_CRYPTO_SEED) += seed.o
 obj-$(CONFIG_CRYPTO_ARIA) += aria_generic.o
 crypto-objs-$(CONFIG_CRYPTO_CHACHA20) += chacha.o
diff --git a/crypto/anubis.c b/crypto/anubis.c
index 4b01b6ec961a..3d179d739fbd 100644
--- a/crypto/anubis.c
+++ b/crypto/anubis.c
@@ -691,8 +691,8 @@ static void __exit anubis_mod_fini(void)
 	crypto_unregister_alg(&anubis_alg);
 }
 
-module_init(anubis_mod_init);
-module_exit(anubis_mod_fini);
+crypto_module_init(anubis_mod_init);
+crypto_module_exit(anubis_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Anubis Cryptographic Algorithm");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 075/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SEED crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (73 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 074/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ANUBIS crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 076/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ARIA crypto Jay Wang
                   ` (30 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_SEED-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/seed.c   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index fb863dcef44f..3e515caa72f5 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -145,7 +145,7 @@ crypto-objs-$(CONFIG_CRYPTO_ARC4) += arc4.o
 crypto-objs-$(CONFIG_CRYPTO_TEA) += tea.o
 crypto-objs-$(CONFIG_CRYPTO_KHAZAD) += khazad.o
 crypto-objs-$(CONFIG_CRYPTO_ANUBIS) += anubis.o
-obj-$(CONFIG_CRYPTO_SEED) += seed.o
+crypto-objs-$(CONFIG_CRYPTO_SEED) += seed.o
 obj-$(CONFIG_CRYPTO_ARIA) += aria_generic.o
 crypto-objs-$(CONFIG_CRYPTO_CHACHA20) += chacha.o
 CFLAGS_chacha.o += -DARCH=$(ARCH)
diff --git a/crypto/seed.c b/crypto/seed.c
index 815391f213de..f98ea0d623bd 100644
--- a/crypto/seed.c
+++ b/crypto/seed.c
@@ -460,8 +460,8 @@ static void __exit seed_fini(void)
 	crypto_unregister_alg(&seed_alg);
 }
 
-module_init(seed_init);
-module_exit(seed_fini);
+crypto_module_init(seed_init);
+crypto_module_exit(seed_fini);
 
 MODULE_DESCRIPTION("SEED Cipher Algorithm");
 MODULE_LICENSE("GPL");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 076/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ARIA crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (74 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 075/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SEED crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 077/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_DEFLATE crypto Jay Wang
                   ` (29 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_ARIA-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile              |  2 +-
 crypto/aria_generic.c        |  4 ++--
 crypto/fips140/fips140-api.c | 12 ++++++++++++
 include/crypto/aria.h        | 16 ++++++++++++----
 4 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 3e515caa72f5..c7dcc0e55325 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -146,7 +146,7 @@ crypto-objs-$(CONFIG_CRYPTO_TEA) += tea.o
 crypto-objs-$(CONFIG_CRYPTO_KHAZAD) += khazad.o
 crypto-objs-$(CONFIG_CRYPTO_ANUBIS) += anubis.o
 crypto-objs-$(CONFIG_CRYPTO_SEED) += seed.o
-obj-$(CONFIG_CRYPTO_ARIA) += aria_generic.o
+crypto-objs-$(CONFIG_CRYPTO_ARIA) += aria_generic.o
 crypto-objs-$(CONFIG_CRYPTO_CHACHA20) += chacha.o
 CFLAGS_chacha.o += -DARCH=$(ARCH)
 obj-$(CONFIG_CRYPTO_DEFLATE) += deflate.o
diff --git a/crypto/aria_generic.c b/crypto/aria_generic.c
index faa7900383f6..7a66ae96312a 100644
--- a/crypto/aria_generic.c
+++ b/crypto/aria_generic.c
@@ -304,8 +304,8 @@ static void __exit aria_fini(void)
 	crypto_unregister_alg(&aria_alg);
 }
 
-module_init(aria_init);
-module_exit(aria_fini);
+crypto_module_init(aria_init);
+crypto_module_exit(aria_fini);
 
 MODULE_DESCRIPTION("ARIA Cipher Algorithm");
 MODULE_LICENSE("GPL");
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index e20c9601637a..e6d2e3680792 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -763,3 +763,15 @@ DEFINE_CRYPTO_API_STUB(af_alg_alloc_areq);
 DEFINE_CRYPTO_API_STUB(af_alg_get_rsgl);
 
 #endif
+/*
+ * crypto/aria_generic.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_ARIA)
+
+#include <crypto/aria.h>
+
+DEFINE_CRYPTO_API_STUB(aria_set_key);
+DEFINE_CRYPTO_API_STUB(aria_encrypt);
+DEFINE_CRYPTO_API_STUB(aria_decrypt);
+
+#endif
diff --git a/include/crypto/aria.h b/include/crypto/aria.h
index 73295146be11..55108db53ca3 100644
--- a/include/crypto/aria.h
+++ b/include/crypto/aria.h
@@ -18,6 +18,7 @@
 #ifndef _CRYPTO_ARIA_H
 #define _CRYPTO_ARIA_H
 
+#include <crypto/api.h>
 #include <crypto/algapi.h>
 #include <linux/module.h>
 #include <linux/init.h>
@@ -450,9 +451,16 @@ static inline void aria_gsrk(u32 *rk, u32 *x, u32 *y, u32 n)
 		((y[(q + 2) % 4]) << (32 - r));
 }
 
-void aria_encrypt(void *ctx, u8 *out, const u8 *in);
-void aria_decrypt(void *ctx, u8 *out, const u8 *in);
-int aria_set_key(struct crypto_tfm *tfm, const u8 *in_key,
-		 unsigned int key_len);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ARIA, aria_encrypt, void,
+	(void *ctx, u8 *out, const u8 *in),
+	(ctx, out, in));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ARIA, aria_decrypt, void,
+	(void *ctx, u8 *out, const u8 *in),
+	(ctx, out, in));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ARIA, aria_set_key, int,
+	(struct crypto_tfm *tfm, const u8 *in_key, unsigned int key_len),
+	(tfm, in_key, key_len));
 
 #endif
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 077/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_DEFLATE crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (75 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 076/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ARIA crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 078/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_MICHAEL_MIC crypto Jay Wang
                   ` (28 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_DEFLATE-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile  | 2 +-
 crypto/deflate.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index c7dcc0e55325..a989d103c191 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -149,7 +149,7 @@ crypto-objs-$(CONFIG_CRYPTO_SEED) += seed.o
 crypto-objs-$(CONFIG_CRYPTO_ARIA) += aria_generic.o
 crypto-objs-$(CONFIG_CRYPTO_CHACHA20) += chacha.o
 CFLAGS_chacha.o += -DARCH=$(ARCH)
-obj-$(CONFIG_CRYPTO_DEFLATE) += deflate.o
+crypto-objs-$(CONFIG_CRYPTO_DEFLATE) += deflate.o
 obj-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o
 obj-$(CONFIG_CRYPTO_CRC32C) += crc32c-cryptoapi.o
 crc32c-cryptoapi-y := crc32c.o
diff --git a/crypto/deflate.c b/crypto/deflate.c
index a3e1fff55661..7c8e331556cf 100644
--- a/crypto/deflate.c
+++ b/crypto/deflate.c
@@ -249,8 +249,8 @@ static void __exit deflate_mod_fini(void)
 	crypto_acomp_free_streams(&deflate_streams);
 }
 
-module_init(deflate_mod_init);
-module_exit(deflate_mod_fini);
+crypto_module_init(deflate_mod_init);
+crypto_module_exit(deflate_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Deflate Compression Algorithm for IPCOMP");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 078/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_MICHAEL_MIC crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (76 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 077/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_DEFLATE crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 079/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CRC32C and CONFIG_CRYPTO_CRC32 crypto Jay Wang
                   ` (27 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_MICHAEL_MIC-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile      | 2 +-
 crypto/michael_mic.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index a989d103c191..f8cd388ca03c 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -150,7 +150,7 @@ crypto-objs-$(CONFIG_CRYPTO_ARIA) += aria_generic.o
 crypto-objs-$(CONFIG_CRYPTO_CHACHA20) += chacha.o
 CFLAGS_chacha.o += -DARCH=$(ARCH)
 crypto-objs-$(CONFIG_CRYPTO_DEFLATE) += deflate.o
-obj-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o
+crypto-objs-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o
 obj-$(CONFIG_CRYPTO_CRC32C) += crc32c-cryptoapi.o
 crc32c-cryptoapi-y := crc32c.o
 obj-$(CONFIG_CRYPTO_CRC32) += crc32-cryptoapi.o
diff --git a/crypto/michael_mic.c b/crypto/michael_mic.c
index 69ad35f524d7..8acdf39a7004 100644
--- a/crypto/michael_mic.c
+++ b/crypto/michael_mic.c
@@ -167,8 +167,8 @@ static void __exit michael_mic_exit(void)
 }
 
 
-module_init(michael_mic_init);
-module_exit(michael_mic_exit);
+crypto_module_init(michael_mic_init);
+crypto_module_exit(michael_mic_exit);
 
 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("Michael MIC");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 079/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CRC32C and CONFIG_CRYPTO_CRC32 crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (77 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 078/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_MICHAEL_MIC crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 080/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_KRB5ENC crypto Jay Wang
                   ` (26 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_CRC32C- and CONFIG_CRYPTO_CRC32-related crypto to convert
them into pluggable interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 4 ++--
 crypto/crc32.c  | 4 ++--
 crypto/crc32c.c | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index f8cd388ca03c..6d332c55fd4e 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -151,9 +151,9 @@ crypto-objs-$(CONFIG_CRYPTO_CHACHA20) += chacha.o
 CFLAGS_chacha.o += -DARCH=$(ARCH)
 crypto-objs-$(CONFIG_CRYPTO_DEFLATE) += deflate.o
 crypto-objs-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o
-obj-$(CONFIG_CRYPTO_CRC32C) += crc32c-cryptoapi.o
+crypto-objs-$(CONFIG_CRYPTO_CRC32C) += crc32c-cryptoapi.o
 crc32c-cryptoapi-y := crc32c.o
-obj-$(CONFIG_CRYPTO_CRC32) += crc32-cryptoapi.o
+crypto-objs-$(CONFIG_CRYPTO_CRC32) += crc32-cryptoapi.o
 crc32-cryptoapi-y := crc32.o
 crypto-objs-$(CONFIG_CRYPTO_AUTHENC) += authenc.o authencesn.o
 obj-$(CONFIG_CRYPTO_KRB5ENC) += krb5enc.o
diff --git a/crypto/crc32.c b/crypto/crc32.c
index 489cbed9422e..cfbf86ed9926 100644
--- a/crypto/crc32.c
+++ b/crypto/crc32.c
@@ -120,8 +120,8 @@ static void __exit crc32_mod_fini(void)
 	crypto_unregister_shash(&alg);
 }
 
-module_init(crc32_mod_init);
-module_exit(crc32_mod_fini);
+crypto_module_init(crc32_mod_init);
+crypto_module_exit(crc32_mod_fini);
 
 MODULE_AUTHOR("Alexander Boyko <alexander_boyko@xyratex.com>");
 MODULE_DESCRIPTION("CRC32 calculations wrapper for lib/crc32");
diff --git a/crypto/crc32c.c b/crypto/crc32c.c
index 1eff54dde2f7..d8122c4aa26e 100644
--- a/crypto/crc32c.c
+++ b/crypto/crc32c.c
@@ -157,8 +157,8 @@ static void __exit crc32c_mod_fini(void)
 	crypto_unregister_shash(&alg);
 }
 
-module_init(crc32c_mod_init);
-module_exit(crc32c_mod_fini);
+crypto_module_init(crc32c_mod_init);
+crypto_module_exit(crc32c_mod_fini);
 
 MODULE_AUTHOR("Clay Haapala <chaapala@cisco.com>");
 MODULE_DESCRIPTION("CRC32c (Castagnoli) calculations wrapper for lib/crc32c");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 080/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_KRB5ENC crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (78 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 079/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CRC32C and CONFIG_CRYPTO_CRC32 crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 081/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_LZ4 and CONFIG_CRYPTO_LZ4HC crypto Jay Wang
                   ` (25 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_KRB5ENC-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile              |  2 +-
 crypto/fips140/fips140-api.c | 10 ++++++++++
 crypto/krb5enc.c             |  4 ++--
 include/crypto/authenc.h     |  6 ++++--
 4 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 6d332c55fd4e..61fdf39dc1ec 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -156,7 +156,7 @@ crc32c-cryptoapi-y := crc32c.o
 crypto-objs-$(CONFIG_CRYPTO_CRC32) += crc32-cryptoapi.o
 crc32-cryptoapi-y := crc32.o
 crypto-objs-$(CONFIG_CRYPTO_AUTHENC) += authenc.o authencesn.o
-obj-$(CONFIG_CRYPTO_KRB5ENC) += krb5enc.o
+crypto-objs-$(CONFIG_CRYPTO_KRB5ENC) += krb5enc.o
 crypto-objs-$(CONFIG_CRYPTO_LZO) += lzo.o lzo-rle.o
 obj-$(CONFIG_CRYPTO_LZ4) += lz4.o
 obj-$(CONFIG_CRYPTO_LZ4HC) += lz4hc.o
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index e6d2e3680792..70b57939c753 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -775,3 +775,13 @@ DEFINE_CRYPTO_API_STUB(aria_encrypt);
 DEFINE_CRYPTO_API_STUB(aria_decrypt);
 
 #endif
+/*
+ * crypto/krb5enc.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_KRB5ENC)
+
+#include <crypto/authenc.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_krb5enc_extractkeys);
+
+#endif
diff --git a/crypto/krb5enc.c b/crypto/krb5enc.c
index a1de55994d92..5688f8916fd0 100644
--- a/crypto/krb5enc.c
+++ b/crypto/krb5enc.c
@@ -496,8 +496,8 @@ static void __exit crypto_krb5enc_module_exit(void)
 	crypto_unregister_template(&crypto_krb5enc_tmpl);
 }
 
-module_init(crypto_krb5enc_module_init);
-module_exit(crypto_krb5enc_module_exit);
+crypto_module_init(crypto_krb5enc_module_init);
+crypto_module_exit(crypto_krb5enc_module_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Simple AEAD wrapper for Kerberos 5 RFC3961");
diff --git a/include/crypto/authenc.h b/include/crypto/authenc.h
index 4871b7bdcd8e..710e0976b295 100644
--- a/include/crypto/authenc.h
+++ b/include/crypto/authenc.h
@@ -30,7 +30,9 @@ struct crypto_authenc_keys {
 DECLARE_CRYPTO_API(CONFIG_CRYPTO_AUTHENC, crypto_authenc_extractkeys, int,
 	(struct crypto_authenc_keys *keys, const u8 *key, unsigned int keylen),
 	(keys, key, keylen));
-int crypto_krb5enc_extractkeys(struct crypto_authenc_keys *keys, const u8 *key,
-			       unsigned int keylen);
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_KRB5ENC, crypto_krb5enc_extractkeys, int,
+	(struct crypto_authenc_keys *keys, const u8 *key, unsigned int keylen),
+	(keys, key, keylen));
 
 #endif	/* _CRYPTO_AUTHENC_H */
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 081/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_LZ4 and CONFIG_CRYPTO_LZ4HC crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (79 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 080/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_KRB5ENC crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 082/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_XXHASH crypto Jay Wang
                   ` (24 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_LZ4- and CONFIG_CRYPTO_LZ4HC-related crypto to convert
them into pluggable interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 4 ++--
 crypto/lz4.c    | 4 ++--
 crypto/lz4hc.c  | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 61fdf39dc1ec..665299fd5a5a 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -158,8 +158,8 @@ crc32-cryptoapi-y := crc32.o
 crypto-objs-$(CONFIG_CRYPTO_AUTHENC) += authenc.o authencesn.o
 crypto-objs-$(CONFIG_CRYPTO_KRB5ENC) += krb5enc.o
 crypto-objs-$(CONFIG_CRYPTO_LZO) += lzo.o lzo-rle.o
-obj-$(CONFIG_CRYPTO_LZ4) += lz4.o
-obj-$(CONFIG_CRYPTO_LZ4HC) += lz4hc.o
+crypto-objs-$(CONFIG_CRYPTO_LZ4) += lz4.o
+crypto-objs-$(CONFIG_CRYPTO_LZ4HC) += lz4hc.o
 obj-$(CONFIG_CRYPTO_XXHASH) += xxhash_generic.o
 obj-$(CONFIG_CRYPTO_842) += 842.o
 crypto-objs-$(CONFIG_CRYPTO_RNG2) += rng.o
diff --git a/crypto/lz4.c b/crypto/lz4.c
index 57b713516aef..e0aa6f465627 100644
--- a/crypto/lz4.c
+++ b/crypto/lz4.c
@@ -91,8 +91,8 @@ static void __exit lz4_mod_fini(void)
 	crypto_unregister_scomp(&scomp);
 }
 
-module_init(lz4_mod_init);
-module_exit(lz4_mod_fini);
+crypto_module_init(lz4_mod_init);
+crypto_module_exit(lz4_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("LZ4 Compression Algorithm");
diff --git a/crypto/lz4hc.c b/crypto/lz4hc.c
index bb84f8a68cb5..5365a0a8477d 100644
--- a/crypto/lz4hc.c
+++ b/crypto/lz4hc.c
@@ -89,8 +89,8 @@ static void __exit lz4hc_mod_fini(void)
 	crypto_unregister_scomp(&scomp);
 }
 
-module_init(lz4hc_mod_init);
-module_exit(lz4hc_mod_fini);
+crypto_module_init(lz4hc_mod_init);
+crypto_module_exit(lz4hc_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("LZ4HC Compression Algorithm");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 082/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_XXHASH crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (80 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 081/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_LZ4 and CONFIG_CRYPTO_LZ4HC crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:46 ` [PATCH 083/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_842 crypto Jay Wang
                   ` (23 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_XXHASH-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile         | 2 +-
 crypto/xxhash_generic.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 665299fd5a5a..6dc023d0851c 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -160,7 +160,7 @@ crypto-objs-$(CONFIG_CRYPTO_KRB5ENC) += krb5enc.o
 crypto-objs-$(CONFIG_CRYPTO_LZO) += lzo.o lzo-rle.o
 crypto-objs-$(CONFIG_CRYPTO_LZ4) += lz4.o
 crypto-objs-$(CONFIG_CRYPTO_LZ4HC) += lz4hc.o
-obj-$(CONFIG_CRYPTO_XXHASH) += xxhash_generic.o
+crypto-objs-$(CONFIG_CRYPTO_XXHASH) += xxhash_generic.o
 obj-$(CONFIG_CRYPTO_842) += 842.o
 crypto-objs-$(CONFIG_CRYPTO_RNG2) += rng.o
 crypto-objs-$(CONFIG_CRYPTO_DRBG) += drbg.o
diff --git a/crypto/xxhash_generic.c b/crypto/xxhash_generic.c
index 175bb7ae0fcd..4e41c4d213df 100644
--- a/crypto/xxhash_generic.c
+++ b/crypto/xxhash_generic.c
@@ -96,8 +96,8 @@ static void __exit xxhash_mod_fini(void)
 	crypto_unregister_shash(&alg);
 }
 
-module_init(xxhash_mod_init);
-module_exit(xxhash_mod_fini);
+crypto_module_init(xxhash_mod_init);
+crypto_module_exit(xxhash_mod_fini);
 
 MODULE_AUTHOR("Nikolay Borisov <nborisov@suse.com>");
 MODULE_DESCRIPTION("xxhash calculations wrapper for lib/xxhash.c");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 083/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_842 crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (81 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 082/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_XXHASH crypto Jay Wang
@ 2026-02-12  2:46 ` Jay Wang
  2026-02-12  2:47 ` [PATCH 084/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_JITTERENTROPY_TESTINTERFACE crypto Jay Wang
                   ` (22 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_842-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/842.c    | 4 ++--
 crypto/Makefile | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/842.c b/crypto/842.c
index 4007e87bed80..965f0f8dbc43 100644
--- a/crypto/842.c
+++ b/crypto/842.c
@@ -72,13 +72,13 @@ static int __init crypto842_mod_init(void)
 {
 	return crypto_register_scomp(&scomp);
 }
-module_init(crypto842_mod_init);
+crypto_module_init(crypto842_mod_init);
 
 static void __exit crypto842_mod_exit(void)
 {
 	crypto_unregister_scomp(&scomp);
 }
-module_exit(crypto842_mod_exit);
+crypto_module_exit(crypto842_mod_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("842 Software Compression Algorithm");
diff --git a/crypto/Makefile b/crypto/Makefile
index 6dc023d0851c..66319c92a983 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -161,7 +161,7 @@ crypto-objs-$(CONFIG_CRYPTO_LZO) += lzo.o lzo-rle.o
 crypto-objs-$(CONFIG_CRYPTO_LZ4) += lz4.o
 crypto-objs-$(CONFIG_CRYPTO_LZ4HC) += lz4hc.o
 crypto-objs-$(CONFIG_CRYPTO_XXHASH) += xxhash_generic.o
-obj-$(CONFIG_CRYPTO_842) += 842.o
+crypto-objs-$(CONFIG_CRYPTO_842) += 842.o
 crypto-objs-$(CONFIG_CRYPTO_RNG2) += rng.o
 crypto-objs-$(CONFIG_CRYPTO_DRBG) += drbg.o
 crypto-objs-$(CONFIG_CRYPTO_JITTERENTROPY) += jitterentropy_rng.o
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 084/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_JITTERENTROPY_TESTINTERFACE crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (82 preceding siblings ...)
  2026-02-12  2:46 ` [PATCH 083/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_842 crypto Jay Wang
@ 2026-02-12  2:47 ` Jay Wang
  2026-02-12  2:47 ` [PATCH 085/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_BENCHMARK crypto Jay Wang
                   ` (21 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:47 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Unlike most patches, we do not add a DECLARE_CRYPTO_API() wrapper for the
exported function in crypto/jitterentropy.h. This is because this header is
used by both jitterentropy_rng.o and jitterentropy-testing.o, but the
compilation flags for jitterentropy_rng.o do not support declaration of a
static call key.

This is acceptable since the only user of this exported function is
jitterentropy_rng.o itself. The jitterentropy-testing.o code will naturally
either be included alongside jitterentropy_rng.o in the crypto kernel
module, or it will be disabled.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 66319c92a983..d1db3a1e3b3b 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -169,7 +169,7 @@ CFLAGS_jitterentropy.o = -O0
 KASAN_SANITIZE_jitterentropy.o = n
 UBSAN_SANITIZE_jitterentropy.o = n
 jitterentropy_rng-y := jitterentropy.o jitterentropy-kcapi.o
-obj-$(CONFIG_CRYPTO_JITTERENTROPY_TESTINTERFACE) += jitterentropy-testing.o
+crypto-objs-$(CONFIG_CRYPTO_JITTERENTROPY_TESTINTERFACE) += jitterentropy-testing.o
 obj-$(CONFIG_CRYPTO_BENCHMARK) += tcrypt.o
 crypto-objs-$(CONFIG_CRYPTO_GHASH) += ghash-generic.o
 crypto-objs-$(CONFIG_CRYPTO_USER_API) += af_alg.o
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 085/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_BENCHMARK crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (83 preceding siblings ...)
  2026-02-12  2:47 ` [PATCH 084/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_JITTERENTROPY_TESTINTERFACE crypto Jay Wang
@ 2026-02-12  2:47 ` Jay Wang
  2026-02-12  2:47 ` [PATCH 086/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_USER_API_HASH crypto Jay Wang
                   ` (20 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:47 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_BENCHMARK-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/tcrypt.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index d1db3a1e3b3b..39b42843d321 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -170,7 +170,7 @@ KASAN_SANITIZE_jitterentropy.o = n
 UBSAN_SANITIZE_jitterentropy.o = n
 jitterentropy_rng-y := jitterentropy.o jitterentropy-kcapi.o
 crypto-objs-$(CONFIG_CRYPTO_JITTERENTROPY_TESTINTERFACE) += jitterentropy-testing.o
-obj-$(CONFIG_CRYPTO_BENCHMARK) += tcrypt.o
+crypto-objs-$(CONFIG_CRYPTO_BENCHMARK) += tcrypt.o
 crypto-objs-$(CONFIG_CRYPTO_GHASH) += ghash-generic.o
 crypto-objs-$(CONFIG_CRYPTO_USER_API) += af_alg.o
 obj-$(CONFIG_CRYPTO_USER_API_HASH) += algif_hash.o
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 62fef100e599..1f3b6c1922cb 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -2840,8 +2840,8 @@ static int __init tcrypt_mod_init(void)
  */
 static void __exit tcrypt_mod_fini(void) { }
 
-late_initcall(tcrypt_mod_init);
-module_exit(tcrypt_mod_fini);
+crypto_late_initcall(tcrypt_mod_init);
+crypto_module_exit(tcrypt_mod_fini);
 
 module_param(alg, charp, 0);
 module_param(type, uint, 0);
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 086/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_USER_API_HASH crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (84 preceding siblings ...)
  2026-02-12  2:47 ` [PATCH 085/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_BENCHMARK crypto Jay Wang
@ 2026-02-12  2:47 ` Jay Wang
  2026-02-12  2:47 ` [PATCH 087/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_USER_API_RNG crypto Jay Wang
                   ` (19 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:47 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_USER_API_HASH-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile     | 2 +-
 crypto/algif_hash.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 39b42843d321..13d0ee856885 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -173,7 +173,7 @@ crypto-objs-$(CONFIG_CRYPTO_JITTERENTROPY_TESTINTERFACE) += jitterentropy-testin
 crypto-objs-$(CONFIG_CRYPTO_BENCHMARK) += tcrypt.o
 crypto-objs-$(CONFIG_CRYPTO_GHASH) += ghash-generic.o
 crypto-objs-$(CONFIG_CRYPTO_USER_API) += af_alg.o
-obj-$(CONFIG_CRYPTO_USER_API_HASH) += algif_hash.o
+crypto-objs-$(CONFIG_CRYPTO_USER_API_HASH) += algif_hash.o
 crypto-objs-$(CONFIG_CRYPTO_USER_API_SKCIPHER) += algif_skcipher.o
 obj-$(CONFIG_CRYPTO_USER_API_RNG) += algif_rng.o
 obj-$(CONFIG_CRYPTO_USER_API_AEAD) += algif_aead.o
diff --git a/crypto/algif_hash.c b/crypto/algif_hash.c
index 4d3dfc60a16a..b5ec5cfb2ae8 100644
--- a/crypto/algif_hash.c
+++ b/crypto/algif_hash.c
@@ -464,7 +464,7 @@ static void __exit algif_hash_exit(void)
 	BUG_ON(err);
 }
 
-module_init(algif_hash_init);
-module_exit(algif_hash_exit);
+crypto_module_init(algif_hash_init);
+crypto_module_exit(algif_hash_exit);
 MODULE_DESCRIPTION("Userspace interface for hash algorithms");
 MODULE_LICENSE("GPL");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 087/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_USER_API_RNG crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (85 preceding siblings ...)
  2026-02-12  2:47 ` [PATCH 086/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_USER_API_HASH crypto Jay Wang
@ 2026-02-12  2:47 ` Jay Wang
  2026-02-12  2:47 ` [PATCH 088/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_USER_API_AEAD crypto Jay Wang
                   ` (18 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:47 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_USER_API_RNG-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile    | 2 +-
 crypto/algif_rng.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 13d0ee856885..9d96e67cdfdf 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -175,7 +175,7 @@ crypto-objs-$(CONFIG_CRYPTO_GHASH) += ghash-generic.o
 crypto-objs-$(CONFIG_CRYPTO_USER_API) += af_alg.o
 crypto-objs-$(CONFIG_CRYPTO_USER_API_HASH) += algif_hash.o
 crypto-objs-$(CONFIG_CRYPTO_USER_API_SKCIPHER) += algif_skcipher.o
-obj-$(CONFIG_CRYPTO_USER_API_RNG) += algif_rng.o
+crypto-objs-$(CONFIG_CRYPTO_USER_API_RNG) += algif_rng.o
 obj-$(CONFIG_CRYPTO_USER_API_AEAD) += algif_aead.o
 obj-$(CONFIG_CRYPTO_ZSTD) += zstd.o
 crypto-objs-$(CONFIG_CRYPTO_ECC) += ecc.o
diff --git a/crypto/algif_rng.c b/crypto/algif_rng.c
index 1a86e40c8372..1604b164d973 100644
--- a/crypto/algif_rng.c
+++ b/crypto/algif_rng.c
@@ -335,5 +335,5 @@ static void __exit rng_exit(void)
 	BUG_ON(err);
 }
 
-module_init(rng_init);
-module_exit(rng_exit);
+crypto_module_init(rng_init);
+crypto_module_exit(rng_exit);
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 088/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_USER_API_AEAD crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (86 preceding siblings ...)
  2026-02-12  2:47 ` [PATCH 087/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_USER_API_RNG crypto Jay Wang
@ 2026-02-12  2:47 ` Jay Wang
  2026-02-12  2:47 ` [PATCH 089/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ZSTD crypto Jay Wang
                   ` (17 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:47 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_USER_API_AEAD-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile     | 2 +-
 crypto/algif_aead.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 9d96e67cdfdf..3f4cd954ef06 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -176,7 +176,7 @@ crypto-objs-$(CONFIG_CRYPTO_USER_API) += af_alg.o
 crypto-objs-$(CONFIG_CRYPTO_USER_API_HASH) += algif_hash.o
 crypto-objs-$(CONFIG_CRYPTO_USER_API_SKCIPHER) += algif_skcipher.o
 crypto-objs-$(CONFIG_CRYPTO_USER_API_RNG) += algif_rng.o
-obj-$(CONFIG_CRYPTO_USER_API_AEAD) += algif_aead.o
+crypto-objs-$(CONFIG_CRYPTO_USER_API_AEAD) += algif_aead.o
 obj-$(CONFIG_CRYPTO_ZSTD) += zstd.o
 crypto-objs-$(CONFIG_CRYPTO_ECC) += ecc.o
 obj-$(CONFIG_CRYPTO_ESSIV) += essiv.o
diff --git a/crypto/algif_aead.c b/crypto/algif_aead.c
index 79b016a899a1..59df4eabd2f5 100644
--- a/crypto/algif_aead.c
+++ b/crypto/algif_aead.c
@@ -521,8 +521,8 @@ static void __exit algif_aead_exit(void)
 	BUG_ON(err);
 }
 
-module_init(algif_aead_init);
-module_exit(algif_aead_exit);
+crypto_module_init(algif_aead_init);
+crypto_module_exit(algif_aead_exit);
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Stephan Mueller <smueller@chronox.de>");
 MODULE_DESCRIPTION("AEAD kernel crypto API user space interface");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 089/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ZSTD crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (87 preceding siblings ...)
  2026-02-12  2:47 ` [PATCH 088/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_USER_API_AEAD crypto Jay Wang
@ 2026-02-12  2:47 ` Jay Wang
  2026-02-12  2:47 ` [PATCH 090/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ESSIV crypto Jay Wang
                   ` (16 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:47 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_ZSTD-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/zstd.c   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 3f4cd954ef06..c4516e1943a7 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -177,7 +177,7 @@ crypto-objs-$(CONFIG_CRYPTO_USER_API_HASH) += algif_hash.o
 crypto-objs-$(CONFIG_CRYPTO_USER_API_SKCIPHER) += algif_skcipher.o
 crypto-objs-$(CONFIG_CRYPTO_USER_API_RNG) += algif_rng.o
 crypto-objs-$(CONFIG_CRYPTO_USER_API_AEAD) += algif_aead.o
-obj-$(CONFIG_CRYPTO_ZSTD) += zstd.o
+crypto-objs-$(CONFIG_CRYPTO_ZSTD) += zstd.o
 crypto-objs-$(CONFIG_CRYPTO_ECC) += ecc.o
 obj-$(CONFIG_CRYPTO_ESSIV) += essiv.o
 
diff --git a/crypto/zstd.c b/crypto/zstd.c
index cbbd0413751a..3b9fe204c68c 100644
--- a/crypto/zstd.c
+++ b/crypto/zstd.c
@@ -307,8 +307,8 @@ static void __exit zstd_mod_fini(void)
 	crypto_acomp_free_streams(&zstd_streams);
 }
 
-module_init(zstd_mod_init);
-module_exit(zstd_mod_fini);
+crypto_module_init(zstd_mod_init);
+crypto_module_exit(zstd_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Zstd Compression Algorithm");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 090/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ESSIV crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (88 preceding siblings ...)
  2026-02-12  2:47 ` [PATCH 089/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ZSTD crypto Jay Wang
@ 2026-02-12  2:47 ` Jay Wang
  2026-02-12  2:47 ` [PATCH 091/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ECDH crypto Jay Wang
                   ` (15 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:47 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_ESSIV-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/essiv.c  | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index c4516e1943a7..3247d53c1fc6 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -179,7 +179,7 @@ crypto-objs-$(CONFIG_CRYPTO_USER_API_RNG) += algif_rng.o
 crypto-objs-$(CONFIG_CRYPTO_USER_API_AEAD) += algif_aead.o
 crypto-objs-$(CONFIG_CRYPTO_ZSTD) += zstd.o
 crypto-objs-$(CONFIG_CRYPTO_ECC) += ecc.o
-obj-$(CONFIG_CRYPTO_ESSIV) += essiv.o
+crypto-objs-$(CONFIG_CRYPTO_ESSIV) += essiv.o
 
 ecdh_generic-y += ecdh.o
 ecdh_generic-y += ecdh_helper.o
diff --git a/crypto/essiv.c b/crypto/essiv.c
index a47a3eab6935..859486b9b063 100644
--- a/crypto/essiv.c
+++ b/crypto/essiv.c
@@ -639,8 +639,8 @@ static void __exit essiv_module_exit(void)
 	crypto_unregister_template(&essiv_tmpl);
 }
 
-module_init(essiv_module_init);
-module_exit(essiv_module_exit);
+crypto_module_init(essiv_module_init);
+crypto_module_exit(essiv_module_exit);
 
 MODULE_DESCRIPTION("ESSIV skcipher/aead wrapper for block encryption");
 MODULE_LICENSE("GPL v2");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 091/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ECDH crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (89 preceding siblings ...)
  2026-02-12  2:47 ` [PATCH 090/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ESSIV crypto Jay Wang
@ 2026-02-12  2:47 ` Jay Wang
  2026-02-12  2:47 ` [PATCH 092/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ECRDSA crypto Jay Wang
                   ` (14 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:47 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_ECDH-related crypto to convert them into pluggable
interface.

This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.

Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile              |  2 +-
 crypto/ecdh.c                |  4 ++--
 crypto/fips140/fips140-api.c | 12 ++++++++++++
 include/crypto/ecdh.h        | 14 +++++++++++---
 4 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 3247d53c1fc6..cdc74dcea2f1 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -183,7 +183,7 @@ crypto-objs-$(CONFIG_CRYPTO_ESSIV) += essiv.o
 
 ecdh_generic-y += ecdh.o
 ecdh_generic-y += ecdh_helper.o
-obj-$(CONFIG_CRYPTO_ECDH) += ecdh_generic.o
+crypto-objs-$(CONFIG_CRYPTO_ECDH) += ecdh_generic.o
 
 $(obj)/ecrdsa_params.asn1.o: $(obj)/ecrdsa_params.asn1.c $(obj)/ecrdsa_params.asn1.h
 $(obj)/ecrdsa_pub_key.asn1.o: $(obj)/ecrdsa_pub_key.asn1.c $(obj)/ecrdsa_pub_key.asn1.h
diff --git a/crypto/ecdh.c b/crypto/ecdh.c
index 9f0b93b3166d..32c98cebfda6 100644
--- a/crypto/ecdh.c
+++ b/crypto/ecdh.c
@@ -240,8 +240,8 @@ static void __exit ecdh_exit(void)
 	crypto_unregister_kpp(&ecdh_nist_p384);
 }
 
-module_init(ecdh_init);
-module_exit(ecdh_exit);
+crypto_module_init(ecdh_init);
+crypto_module_exit(ecdh_exit);
 MODULE_ALIAS_CRYPTO("ecdh");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("ECDH generic algorithm");
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 70b57939c753..298ab496a395 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -785,3 +785,15 @@ DEFINE_CRYPTO_API_STUB(aria_decrypt);
 DEFINE_CRYPTO_API_STUB(crypto_krb5enc_extractkeys);
 
 #endif
+/*
+ * crypto/ecdh_helper.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_ECDH)
+
+#include <crypto/ecdh.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_ecdh_key_len);
+DEFINE_CRYPTO_API_STUB(crypto_ecdh_encode_key);
+DEFINE_CRYPTO_API_STUB(crypto_ecdh_decode_key);
+
+#endif
\ No newline at end of file
diff --git a/include/crypto/ecdh.h b/include/crypto/ecdh.h
index 9784ecdd2fb4..03d54f531ca2 100644
--- a/include/crypto/ecdh.h
+++ b/include/crypto/ecdh.h
@@ -8,6 +8,8 @@
 #ifndef _CRYPTO_ECDH_
 #define _CRYPTO_ECDH_
 
+#include <crypto/api.h>
+
 /**
  * DOC: ECDH Helper Functions
  *
@@ -49,7 +51,9 @@ struct ecdh {
  *
  * Return: size of the key in bytes
  */
-unsigned int crypto_ecdh_key_len(const struct ecdh *params);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ECDH, crypto_ecdh_key_len, unsigned int,
+	(const struct ecdh *params),
+	(params));
 
 /**
  * crypto_ecdh_encode_key() - encode the private key
@@ -64,7 +68,9 @@ unsigned int crypto_ecdh_key_len(const struct ecdh *params);
  *
  * Return:	-EINVAL if buffer has insufficient size, 0 on success
  */
-int crypto_ecdh_encode_key(char *buf, unsigned int len, const struct ecdh *p);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ECDH, crypto_ecdh_encode_key, int,
+	(char *buf, unsigned int len, const struct ecdh *p),
+	(buf, len, p));
 
 /**
  * crypto_ecdh_decode_key() - decode a private key
@@ -78,6 +84,8 @@ int crypto_ecdh_encode_key(char *buf, unsigned int len, const struct ecdh *p);
  *
  * Return:	-EINVAL if buffer has insufficient size, 0 on success
  */
-int crypto_ecdh_decode_key(const char *buf, unsigned int len, struct ecdh *p);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ECDH, crypto_ecdh_decode_key, int,
+	(const char *buf, unsigned int len, struct ecdh *p),
+	(buf, len, p));
 
 #endif
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 092/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ECRDSA crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (90 preceding siblings ...)
  2026-02-12  2:47 ` [PATCH 091/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ECDH crypto Jay Wang
@ 2026-02-12  2:47 ` Jay Wang
  2026-02-12  2:47 ` [PATCH 093/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_XOR_BLOCKS crypto Jay Wang
                   ` (13 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:47 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_ECRDSA-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/ecrdsa.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index cdc74dcea2f1..dc70a464fc1a 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -191,7 +191,7 @@ $(obj)/ecrdsa.o: $(obj)/ecrdsa_params.asn1.h $(obj)/ecrdsa_pub_key.asn1.h
 ecrdsa_generic-y += ecrdsa.o
 ecrdsa_generic-y += ecrdsa_params.asn1.o
 ecrdsa_generic-y += ecrdsa_pub_key.asn1.o
-obj-$(CONFIG_CRYPTO_ECRDSA) += ecrdsa_generic.o
+crypto-objs-$(CONFIG_CRYPTO_ECRDSA) += ecrdsa_generic.o
 
 #
 # generic algorithms and the async_tx api
diff --git a/crypto/ecrdsa.c b/crypto/ecrdsa.c
index 2c0602f0cd40..b9cd02a7e515 100644
--- a/crypto/ecrdsa.c
+++ b/crypto/ecrdsa.c
@@ -288,8 +288,8 @@ static void __exit ecrdsa_mod_fini(void)
 	crypto_unregister_sig(&ecrdsa_alg);
 }
 
-module_init(ecrdsa_mod_init);
-module_exit(ecrdsa_mod_fini);
+crypto_module_init(ecrdsa_mod_init);
+crypto_module_exit(ecrdsa_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Vitaly Chikunov <vt@altlinux.org>");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 093/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_XOR_BLOCKS crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (91 preceding siblings ...)
  2026-02-12  2:47 ` [PATCH 092/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ECRDSA crypto Jay Wang
@ 2026-02-12  2:47 ` Jay Wang
  2026-02-12  2:47 ` [PATCH 094/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYNC_CORE crypto Jay Wang
                   ` (12 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:47 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_XOR_BLOCKS-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile              |  2 +-
 crypto/fips140/fips140-api.c | 10 ++++++++++
 crypto/xor.c                 |  4 ++--
 include/linux/raid/xor.h     |  7 +++++--
 4 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index dc70a464fc1a..29e674c1f2ad 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -196,7 +196,7 @@ crypto-objs-$(CONFIG_CRYPTO_ECRDSA) += ecrdsa_generic.o
 #
 # generic algorithms and the async_tx api
 #
-obj-$(CONFIG_XOR_BLOCKS) += xor.o
+crypto-objs-$(CONFIG_XOR_BLOCKS) += xor.o
 obj-$(CONFIG_ASYNC_CORE) += async_tx/
 obj-$(CONFIG_ASYMMETRIC_KEY_TYPE) += asymmetric_keys/
 crypto_simd-y := simd.o
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 298ab496a395..5bcfc1a3cc7e 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -784,6 +784,16 @@ DEFINE_CRYPTO_API_STUB(aria_decrypt);
 
 DEFINE_CRYPTO_API_STUB(crypto_krb5enc_extractkeys);
 
+#endif
+/*
+ * crypto/xor.c
+ */
+#if IS_BUILTIN(CONFIG_XOR_BLOCKS)
+
+#include <linux/raid/xor.h>
+
+DEFINE_CRYPTO_API_STUB(xor_blocks);
+
 #endif
 /*
  * crypto/ecdh_helper.c
diff --git a/crypto/xor.c b/crypto/xor.c
index f39621a57bb3..a6b4e3b88f67 100644
--- a/crypto/xor.c
+++ b/crypto/xor.c
@@ -170,5 +170,5 @@ MODULE_LICENSE("GPL");
 core_initcall(register_xor_blocks);
 #endif
 
-module_init(calibrate_xor_blocks);
-module_exit(xor_exit);
+crypto_module_init(calibrate_xor_blocks);
+crypto_module_exit(xor_exit);
diff --git a/include/linux/raid/xor.h b/include/linux/raid/xor.h
index 51b811b62322..df8797d00b78 100644
--- a/include/linux/raid/xor.h
+++ b/include/linux/raid/xor.h
@@ -2,10 +2,13 @@
 #ifndef _XOR_H
 #define _XOR_H
 
+#include <crypto/api.h>
+
 #define MAX_XOR_BLOCKS 4
 
-extern void xor_blocks(unsigned int count, unsigned int bytes,
-	void *dest, void **srcs);
+DECLARE_CRYPTO_API(CONFIG_XOR_BLOCKS, xor_blocks, void,
+	(unsigned int count, unsigned int bytes, void *dest, void **srcs),
+	(count, bytes, dest, srcs));
 
 struct xor_block_template {
         struct xor_block_template *next;
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 094/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYNC_CORE crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (92 preceding siblings ...)
  2026-02-12  2:47 ` [PATCH 093/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_XOR_BLOCKS crypto Jay Wang
@ 2026-02-12  2:47 ` Jay Wang
  2026-02-12  2:47 ` [PATCH 095/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYNC_MEMCPY crypto Jay Wang
                   ` (11 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:47 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_ASYNC_CORE-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/async_tx/Makefile     |  2 +-
 crypto/async_tx/async_tx.c   |  4 ++--
 crypto/fips140/fips140-api.c | 15 +++++++++++++++
 include/linux/async_tx.h     | 21 ++++++++++++++-------
 4 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/crypto/async_tx/Makefile b/crypto/async_tx/Makefile
index 056e48245373..2cfa2dc1947d 100644
--- a/crypto/async_tx/Makefile
+++ b/crypto/async_tx/Makefile
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-obj-$(CONFIG_ASYNC_CORE) += async_tx.o
+crypto-objs-$(CONFIG_ASYNC_CORE) += async_tx.o
 obj-$(CONFIG_ASYNC_MEMCPY) += async_memcpy.o
 obj-$(CONFIG_ASYNC_XOR) += async_xor.o
 obj-$(CONFIG_ASYNC_PQ) += async_pq.o
diff --git a/crypto/async_tx/async_tx.c b/crypto/async_tx/async_tx.c
index ad72057a5e0d..4df0363f4764 100644
--- a/crypto/async_tx/async_tx.c
+++ b/crypto/async_tx/async_tx.c
@@ -30,8 +30,8 @@ static void __exit async_tx_exit(void)
 	async_dmaengine_put();
 }
 
-module_init(async_tx_init);
-module_exit(async_tx_exit);
+crypto_module_init(async_tx_init);
+crypto_module_exit(async_tx_exit);
 
 /**
  * __async_tx_find_channel - find a channel to carry out the operation or let
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 5bcfc1a3cc7e..ff58e8946821 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -794,6 +794,21 @@ DEFINE_CRYPTO_API_STUB(crypto_krb5enc_extractkeys);
 
 DEFINE_CRYPTO_API_STUB(xor_blocks);
 
+#endif
+/*
+ * crypto/async_tx/async_tx.c
+ */
+#if IS_BUILTIN(CONFIG_ASYNC_CORE)
+
+#include <linux/async_tx.h>
+
+#ifdef CONFIG_DMA_ENGINE
+DEFINE_CRYPTO_API_STUB(__async_tx_find_channel);
+#endif
+DEFINE_CRYPTO_API_STUB(async_tx_submit);
+DEFINE_CRYPTO_API_STUB(async_trigger_callback);
+DEFINE_CRYPTO_API_STUB(async_tx_quiesce);
+
 #endif
 /*
  * crypto/ecdh_helper.c
diff --git a/include/linux/async_tx.h b/include/linux/async_tx.h
index 1ca9f9e05f4f..25dfd3750859 100644
--- a/include/linux/async_tx.h
+++ b/include/linux/async_tx.h
@@ -4,6 +4,8 @@
  */
 #ifndef _ASYNC_TX_H_
 #define _ASYNC_TX_H_
+
+#include <crypto/api.h>
 #include <linux/dmaengine.h>
 #include <linux/spinlock.h>
 #include <linux/interrupt.h>
@@ -99,9 +101,9 @@ static inline void async_tx_issue_pending(struct dma_async_tx_descriptor *tx)
 #else
 #define async_tx_find_channel(dep, type, dst, dst_count, src, src_count, len) \
 	 __async_tx_find_channel(dep, type)
-struct dma_chan *
-__async_tx_find_channel(struct async_submit_ctl *submit,
-			enum dma_transaction_type tx_type);
+DECLARE_CRYPTO_API(CONFIG_ASYNC_CORE, __async_tx_find_channel, struct dma_chan *,
+	(struct async_submit_ctl *submit, enum dma_transaction_type tx_type),
+	(submit, tx_type));
 #endif /* CONFIG_ARCH_HAS_ASYNC_TX_FIND_CHANNEL */
 #else
 static inline void async_tx_issue_pending_all(void)
@@ -155,8 +157,9 @@ init_async_submit(struct async_submit_ctl *args, enum async_tx_flags flags,
 	args->scribble = scribble;
 }
 
-void async_tx_submit(struct dma_chan *chan, struct dma_async_tx_descriptor *tx,
-		     struct async_submit_ctl *submit);
+DECLARE_CRYPTO_API(CONFIG_ASYNC_CORE, async_tx_submit, void,
+	(struct dma_chan *chan, struct dma_async_tx_descriptor *tx, struct async_submit_ctl *submit),
+	(chan, tx, submit));
 
 struct dma_async_tx_descriptor *
 async_xor(struct page *dest, struct page **src_list, unsigned int offset,
@@ -178,7 +181,9 @@ async_memcpy(struct page *dest, struct page *src, unsigned int dest_offset,
 	     unsigned int src_offset, size_t len,
 	     struct async_submit_ctl *submit);
 
-struct dma_async_tx_descriptor *async_trigger_callback(struct async_submit_ctl *submit);
+DECLARE_CRYPTO_API(CONFIG_ASYNC_CORE, async_trigger_callback, struct dma_async_tx_descriptor *,
+	(struct async_submit_ctl *submit),
+	(submit));
 
 struct dma_async_tx_descriptor *
 async_gen_syndrome(struct page **blocks, unsigned int *offsets, int src_cnt,
@@ -199,5 +204,7 @@ async_raid6_datap_recov(int src_num, size_t bytes, int faila,
 			struct page **ptrs, unsigned int *offs,
 			struct async_submit_ctl *submit);
 
-void async_tx_quiesce(struct dma_async_tx_descriptor **tx);
+DECLARE_CRYPTO_API(CONFIG_ASYNC_CORE, async_tx_quiesce, void,
+	(struct dma_async_tx_descriptor **tx),
+	(tx));
 #endif /* _ASYNC_TX_H_ */
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 095/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYNC_MEMCPY crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (93 preceding siblings ...)
  2026-02-12  2:47 ` [PATCH 094/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYNC_CORE crypto Jay Wang
@ 2026-02-12  2:47 ` Jay Wang
  2026-02-12  2:47 ` [PATCH 096/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYNC_XOR crypto Jay Wang
                   ` (10 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:47 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_ASYNC_MEMCPY-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/async_tx/Makefile     |  2 +-
 crypto/fips140/fips140-api.c | 10 ++++++++++
 include/linux/async_tx.h     |  7 +++----
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/crypto/async_tx/Makefile b/crypto/async_tx/Makefile
index 2cfa2dc1947d..9de69630d930 100644
--- a/crypto/async_tx/Makefile
+++ b/crypto/async_tx/Makefile
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 crypto-objs-$(CONFIG_ASYNC_CORE) += async_tx.o
-obj-$(CONFIG_ASYNC_MEMCPY) += async_memcpy.o
+crypto-objs-$(CONFIG_ASYNC_MEMCPY) += async_memcpy.o
 obj-$(CONFIG_ASYNC_XOR) += async_xor.o
 obj-$(CONFIG_ASYNC_PQ) += async_pq.o
 obj-$(CONFIG_ASYNC_RAID6_RECOV) += async_raid6_recov.o
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index ff58e8946821..6644fce6555a 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -809,6 +809,16 @@ DEFINE_CRYPTO_API_STUB(async_tx_submit);
 DEFINE_CRYPTO_API_STUB(async_trigger_callback);
 DEFINE_CRYPTO_API_STUB(async_tx_quiesce);
 
+#endif
+/*
+ * crypto/async_tx/async_memcpy.c
+ */
+#if IS_BUILTIN(CONFIG_ASYNC_MEMCPY)
+
+#include <linux/async_tx.h>
+
+DEFINE_CRYPTO_API_STUB(async_memcpy);
+
 #endif
 /*
  * crypto/ecdh_helper.c
diff --git a/include/linux/async_tx.h b/include/linux/async_tx.h
index 25dfd3750859..194228a8d1c4 100644
--- a/include/linux/async_tx.h
+++ b/include/linux/async_tx.h
@@ -176,10 +176,9 @@ async_xor_val_offs(struct page *dest, unsigned int offset,
 		int src_cnt, size_t len, enum sum_check_flags *result,
 		struct async_submit_ctl *submit);
 
-struct dma_async_tx_descriptor *
-async_memcpy(struct page *dest, struct page *src, unsigned int dest_offset,
-	     unsigned int src_offset, size_t len,
-	     struct async_submit_ctl *submit);
+DECLARE_CRYPTO_API(CONFIG_ASYNC_MEMCPY, async_memcpy, struct dma_async_tx_descriptor *,
+	(struct page *dest, struct page *src, unsigned int dest_offset, unsigned int src_offset, size_t len, struct async_submit_ctl *submit),
+	(dest, src, dest_offset, src_offset, len, submit));
 
 DECLARE_CRYPTO_API(CONFIG_ASYNC_CORE, async_trigger_callback, struct dma_async_tx_descriptor *,
 	(struct async_submit_ctl *submit),
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 096/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYNC_XOR crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (94 preceding siblings ...)
  2026-02-12  2:47 ` [PATCH 095/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYNC_MEMCPY crypto Jay Wang
@ 2026-02-12  2:47 ` Jay Wang
  2026-02-12  2:47 ` [PATCH 097/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYNC_PQ crypto Jay Wang
                   ` (9 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:47 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_ASYNC_XOR-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/async_tx/Makefile     |  2 +-
 crypto/fips140/fips140-api.c | 12 ++++++++++++
 include/linux/async_tx.h     | 21 +++++++++------------
 3 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/crypto/async_tx/Makefile b/crypto/async_tx/Makefile
index 9de69630d930..3ceb7c8d7598 100644
--- a/crypto/async_tx/Makefile
+++ b/crypto/async_tx/Makefile
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 crypto-objs-$(CONFIG_ASYNC_CORE) += async_tx.o
 crypto-objs-$(CONFIG_ASYNC_MEMCPY) += async_memcpy.o
-obj-$(CONFIG_ASYNC_XOR) += async_xor.o
+crypto-objs-$(CONFIG_ASYNC_XOR) += async_xor.o
 obj-$(CONFIG_ASYNC_PQ) += async_pq.o
 obj-$(CONFIG_ASYNC_RAID6_RECOV) += async_raid6_recov.o
 obj-$(CONFIG_ASYNC_RAID6_TEST) += raid6test.o
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 6644fce6555a..67e7b03e4dc4 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -819,6 +819,18 @@ DEFINE_CRYPTO_API_STUB(async_tx_quiesce);
 
 DEFINE_CRYPTO_API_STUB(async_memcpy);
 
+#endif
+/*
+ * crypto/async_tx/async_xor.c
+ */
+#if IS_BUILTIN(CONFIG_ASYNC_XOR)
+
+#include <linux/async_tx.h>
+
+DEFINE_CRYPTO_API_STUB(async_xor);
+DEFINE_CRYPTO_API_STUB(async_xor_offs);
+DEFINE_CRYPTO_API_STUB(async_xor_val_offs);
+
 #endif
 /*
  * crypto/ecdh_helper.c
diff --git a/include/linux/async_tx.h b/include/linux/async_tx.h
index 194228a8d1c4..36bcc93c6944 100644
--- a/include/linux/async_tx.h
+++ b/include/linux/async_tx.h
@@ -161,20 +161,17 @@ DECLARE_CRYPTO_API(CONFIG_ASYNC_CORE, async_tx_submit, void,
 	(struct dma_chan *chan, struct dma_async_tx_descriptor *tx, struct async_submit_ctl *submit),
 	(chan, tx, submit));
 
-struct dma_async_tx_descriptor *
-async_xor(struct page *dest, struct page **src_list, unsigned int offset,
-	  int src_cnt, size_t len, struct async_submit_ctl *submit);
+DECLARE_CRYPTO_API(CONFIG_ASYNC_XOR, async_xor, struct dma_async_tx_descriptor *,
+	(struct page *dest, struct page **src_list, unsigned int offset, int src_cnt, size_t len, struct async_submit_ctl *submit),
+	(dest, src_list, offset, src_cnt, len, submit));
 
-struct dma_async_tx_descriptor *
-async_xor_offs(struct page *dest, unsigned int offset,
-		struct page **src_list, unsigned int *src_offset,
-		int src_cnt, size_t len, struct async_submit_ctl *submit);
+DECLARE_CRYPTO_API(CONFIG_ASYNC_XOR, async_xor_offs, struct dma_async_tx_descriptor *,
+	(struct page *dest, unsigned int offset, struct page **src_list, unsigned int *src_offset, int src_cnt, size_t len, struct async_submit_ctl *submit),
+	(dest, offset, src_list, src_offset, src_cnt, len, submit));
 
-struct dma_async_tx_descriptor *
-async_xor_val_offs(struct page *dest, unsigned int offset,
-		struct page **src_list, unsigned int *src_offset,
-		int src_cnt, size_t len, enum sum_check_flags *result,
-		struct async_submit_ctl *submit);
+DECLARE_CRYPTO_API(CONFIG_ASYNC_XOR, async_xor_val_offs, struct dma_async_tx_descriptor *,
+	(struct page *dest, unsigned int offset, struct page **src_list, unsigned int *src_offset, int src_cnt, size_t len, enum sum_check_flags *result, struct async_submit_ctl *submit),
+	(dest, offset, src_list, src_offset, src_cnt, len, result, submit));
 
 DECLARE_CRYPTO_API(CONFIG_ASYNC_MEMCPY, async_memcpy, struct dma_async_tx_descriptor *,
 	(struct page *dest, struct page *src, unsigned int dest_offset, unsigned int src_offset, size_t len, struct async_submit_ctl *submit),
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 097/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYNC_PQ crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (95 preceding siblings ...)
  2026-02-12  2:47 ` [PATCH 096/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYNC_XOR crypto Jay Wang
@ 2026-02-12  2:47 ` Jay Wang
  2026-02-12  2:47 ` [PATCH 098/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYNC_RAID6_RECOV crypto Jay Wang
                   ` (8 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:47 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_ASYNC_PQ-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/async_tx/Makefile     |  2 +-
 crypto/async_tx/async_pq.c   |  4 ++--
 crypto/fips140/fips140-api.c | 11 +++++++++++
 include/linux/async_tx.h     | 13 ++++++-------
 4 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/crypto/async_tx/Makefile b/crypto/async_tx/Makefile
index 3ceb7c8d7598..9b0277843bb3 100644
--- a/crypto/async_tx/Makefile
+++ b/crypto/async_tx/Makefile
@@ -2,6 +2,6 @@
 crypto-objs-$(CONFIG_ASYNC_CORE) += async_tx.o
 crypto-objs-$(CONFIG_ASYNC_MEMCPY) += async_memcpy.o
 crypto-objs-$(CONFIG_ASYNC_XOR) += async_xor.o
-obj-$(CONFIG_ASYNC_PQ) += async_pq.o
+crypto-objs-$(CONFIG_ASYNC_PQ) += async_pq.o
 obj-$(CONFIG_ASYNC_RAID6_RECOV) += async_raid6_recov.o
 obj-$(CONFIG_ASYNC_RAID6_TEST) += raid6test.o
diff --git a/crypto/async_tx/async_pq.c b/crypto/async_tx/async_pq.c
index 9e4bb7fbde25..b80fb50fffb2 100644
--- a/crypto/async_tx/async_pq.c
+++ b/crypto/async_tx/async_pq.c
@@ -456,8 +456,8 @@ static void __exit async_pq_exit(void)
 	__free_page(pq_scribble_page);
 }
 
-module_init(async_pq_init);
-module_exit(async_pq_exit);
+crypto_module_init(async_pq_init);
+crypto_module_exit(async_pq_exit);
 
 MODULE_DESCRIPTION("asynchronous raid6 syndrome generation/validation");
 MODULE_LICENSE("GPL");
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 67e7b03e4dc4..6c22baf0ce10 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -831,6 +831,17 @@ DEFINE_CRYPTO_API_STUB(async_xor);
 DEFINE_CRYPTO_API_STUB(async_xor_offs);
 DEFINE_CRYPTO_API_STUB(async_xor_val_offs);
 
+#endif
+/*
+ * crypto/async_tx/async_pq.c
+ */
+#if IS_BUILTIN(CONFIG_ASYNC_PQ)
+
+#include <linux/async_tx.h>
+
+DEFINE_CRYPTO_API_STUB(async_gen_syndrome);
+DEFINE_CRYPTO_API_STUB(async_syndrome_val);
+
 #endif
 /*
  * crypto/ecdh_helper.c
diff --git a/include/linux/async_tx.h b/include/linux/async_tx.h
index 36bcc93c6944..9f733d01f69e 100644
--- a/include/linux/async_tx.h
+++ b/include/linux/async_tx.h
@@ -181,14 +181,13 @@ DECLARE_CRYPTO_API(CONFIG_ASYNC_CORE, async_trigger_callback, struct dma_async_t
 	(struct async_submit_ctl *submit),
 	(submit));
 
-struct dma_async_tx_descriptor *
-async_gen_syndrome(struct page **blocks, unsigned int *offsets, int src_cnt,
-		   size_t len, struct async_submit_ctl *submit);
+DECLARE_CRYPTO_API(CONFIG_ASYNC_PQ, async_gen_syndrome, struct dma_async_tx_descriptor *,
+	(struct page **blocks, unsigned int *offsets, int src_cnt, size_t len, struct async_submit_ctl *submit),
+	(blocks, offsets, src_cnt, len, submit));
 
-struct dma_async_tx_descriptor *
-async_syndrome_val(struct page **blocks, unsigned int *offsets, int src_cnt,
-		   size_t len, enum sum_check_flags *pqres, struct page *spare,
-		   unsigned int s_off, struct async_submit_ctl *submit);
+DECLARE_CRYPTO_API(CONFIG_ASYNC_PQ, async_syndrome_val, struct dma_async_tx_descriptor *,
+	(struct page **blocks, unsigned int *offsets, int src_cnt, size_t len, enum sum_check_flags *pqres, struct page *spare, unsigned int s_off, struct async_submit_ctl *submit),
+	(blocks, offsets, src_cnt, len, pqres, spare, s_off, submit));
 
 struct dma_async_tx_descriptor *
 async_raid6_2data_recov(int src_num, size_t bytes, int faila, int failb,
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 098/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYNC_RAID6_RECOV crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (96 preceding siblings ...)
  2026-02-12  2:47 ` [PATCH 097/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYNC_PQ crypto Jay Wang
@ 2026-02-12  2:47 ` Jay Wang
  2026-02-12  2:47 ` [PATCH 099/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_KDF800108_CTR crypto Jay Wang
                   ` (7 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:47 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_ASYNC_RAID6_RECOV-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/async_tx/Makefile     |  2 +-
 crypto/fips140/fips140-api.c | 11 +++++++++++
 include/linux/async_tx.h     | 16 +++++++---------
 3 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/crypto/async_tx/Makefile b/crypto/async_tx/Makefile
index 9b0277843bb3..2f700c2312af 100644
--- a/crypto/async_tx/Makefile
+++ b/crypto/async_tx/Makefile
@@ -3,5 +3,5 @@ crypto-objs-$(CONFIG_ASYNC_CORE) += async_tx.o
 crypto-objs-$(CONFIG_ASYNC_MEMCPY) += async_memcpy.o
 crypto-objs-$(CONFIG_ASYNC_XOR) += async_xor.o
 crypto-objs-$(CONFIG_ASYNC_PQ) += async_pq.o
-obj-$(CONFIG_ASYNC_RAID6_RECOV) += async_raid6_recov.o
+crypto-objs-$(CONFIG_ASYNC_RAID6_RECOV) += async_raid6_recov.o
 obj-$(CONFIG_ASYNC_RAID6_TEST) += raid6test.o
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 6c22baf0ce10..7159c796d87f 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -842,6 +842,17 @@ DEFINE_CRYPTO_API_STUB(async_xor_val_offs);
 DEFINE_CRYPTO_API_STUB(async_gen_syndrome);
 DEFINE_CRYPTO_API_STUB(async_syndrome_val);
 
+#endif
+/*
+ * crypto/async_tx/async_raid6_recov.c
+ */
+#if IS_BUILTIN(CONFIG_ASYNC_RAID6_RECOV)
+
+#include <linux/async_tx.h>
+
+DEFINE_CRYPTO_API_STUB(async_raid6_2data_recov);
+DEFINE_CRYPTO_API_STUB(async_raid6_datap_recov);
+
 #endif
 /*
  * crypto/ecdh_helper.c
diff --git a/include/linux/async_tx.h b/include/linux/async_tx.h
index 9f733d01f69e..4e791a978ac3 100644
--- a/include/linux/async_tx.h
+++ b/include/linux/async_tx.h
@@ -189,15 +189,13 @@ DECLARE_CRYPTO_API(CONFIG_ASYNC_PQ, async_syndrome_val, struct dma_async_tx_desc
 	(struct page **blocks, unsigned int *offsets, int src_cnt, size_t len, enum sum_check_flags *pqres, struct page *spare, unsigned int s_off, struct async_submit_ctl *submit),
 	(blocks, offsets, src_cnt, len, pqres, spare, s_off, submit));
 
-struct dma_async_tx_descriptor *
-async_raid6_2data_recov(int src_num, size_t bytes, int faila, int failb,
-			struct page **ptrs, unsigned int *offs,
-			struct async_submit_ctl *submit);
-
-struct dma_async_tx_descriptor *
-async_raid6_datap_recov(int src_num, size_t bytes, int faila,
-			struct page **ptrs, unsigned int *offs,
-			struct async_submit_ctl *submit);
+DECLARE_CRYPTO_API(CONFIG_ASYNC_RAID6_RECOV, async_raid6_2data_recov, struct dma_async_tx_descriptor *,
+	(int src_num, size_t bytes, int faila, int failb, struct page **ptrs, unsigned int *offs, struct async_submit_ctl *submit),
+	(src_num, bytes, faila, failb, ptrs, offs, submit));
+
+DECLARE_CRYPTO_API(CONFIG_ASYNC_RAID6_RECOV, async_raid6_datap_recov, struct dma_async_tx_descriptor *,
+	(int src_num, size_t bytes, int faila, struct page **ptrs, unsigned int *offs, struct async_submit_ctl *submit),
+	(src_num, bytes, faila, ptrs, offs, submit));
 
 DECLARE_CRYPTO_API(CONFIG_ASYNC_CORE, async_tx_quiesce, void,
 	(struct dma_async_tx_descriptor **tx),
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 099/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_KDF800108_CTR crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (97 preceding siblings ...)
  2026-02-12  2:47 ` [PATCH 098/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYNC_RAID6_RECOV crypto Jay Wang
@ 2026-02-12  2:47 ` Jay Wang
  2026-02-12  2:47 ` [PATCH 100/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_KRB5 crypto Jay Wang
                   ` (6 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:47 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_KDF800108_CTR-related crypto to convert them into
pluggable interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile               |  2 +-
 crypto/fips140/fips140-api.c  | 11 +++++++++++
 crypto/kdf_sp800108.c         |  4 ++--
 include/crypto/kdf_sp800108.h | 14 ++++++++------
 4 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 29e674c1f2ad..c1088b10f49a 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -205,7 +205,7 @@ obj-$(CONFIG_CRYPTO_SIMD) += crypto_simd.o
 #
 # Key derivation function
 #
-obj-$(CONFIG_CRYPTO_KDF800108_CTR) += kdf_sp800108.o
+crypto-objs-$(CONFIG_CRYPTO_KDF800108_CTR) += kdf_sp800108.o
 
 obj-$(CONFIG_CRYPTO_DF80090A) += df_sp80090a.o
 
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 7159c796d87f..0ed89baa3865 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -853,6 +853,17 @@ DEFINE_CRYPTO_API_STUB(async_syndrome_val);
 DEFINE_CRYPTO_API_STUB(async_raid6_2data_recov);
 DEFINE_CRYPTO_API_STUB(async_raid6_datap_recov);
 
+#endif
+/*
+ * crypto/kdf_sp800108.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_KDF800108_CTR)
+
+#include <crypto/kdf_sp800108.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_kdf108_ctr_generate);
+DEFINE_CRYPTO_API_STUB(crypto_kdf108_setkey);
+
 #endif
 /*
  * crypto/ecdh_helper.c
diff --git a/crypto/kdf_sp800108.c b/crypto/kdf_sp800108.c
index b7a6bf9da773..bf23a39bb657 100644
--- a/crypto/kdf_sp800108.c
+++ b/crypto/kdf_sp800108.c
@@ -149,8 +149,8 @@ static int __init crypto_kdf108_init(void)
 
 static void __exit crypto_kdf108_exit(void) { }
 
-module_init(crypto_kdf108_init);
-module_exit(crypto_kdf108_exit);
+crypto_module_init(crypto_kdf108_init);
+crypto_module_exit(crypto_kdf108_exit);
 
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Stephan Mueller <smueller@chronox.de>");
diff --git a/include/crypto/kdf_sp800108.h b/include/crypto/kdf_sp800108.h
index b7b20a778fb7..33cc2e75b014 100644
--- a/include/crypto/kdf_sp800108.h
+++ b/include/crypto/kdf_sp800108.h
@@ -7,6 +7,8 @@
 #ifndef _CRYPTO_KDF108_H
 #define _CRYPTO_KDF108_H
 
+#include <crypto/api.h>
+
 #include <crypto/hash.h>
 #include <linux/uio.h>
 
@@ -28,9 +30,9 @@
  *
  * @return 0 on success, < 0 on error
  */
-int crypto_kdf108_ctr_generate(struct crypto_shash *kmd,
-			       const struct kvec *info, unsigned int info_nvec,
-			       u8 *dst, unsigned int dlen);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_KDF800108_CTR, crypto_kdf108_ctr_generate, int,
+	(struct crypto_shash *kmd, const struct kvec *info, unsigned int info_nvec, u8 *dst, unsigned int dlen),
+	(kmd, info, info_nvec, dst, dlen));
 
 /**
  * Counter KDF setkey operation
@@ -54,8 +56,8 @@ int crypto_kdf108_ctr_generate(struct crypto_shash *kmd,
  *
  * @return 0 on success, < 0 on error
  */
-int crypto_kdf108_setkey(struct crypto_shash *kmd,
-			 const u8 *key, size_t keylen,
-			 const u8 *ikm, size_t ikmlen);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_KDF800108_CTR, crypto_kdf108_setkey, int,
+	(struct crypto_shash *kmd, const u8 *key, size_t keylen, const u8 *ikm, size_t ikmlen),
+	(kmd, key, keylen, ikm, ikmlen));
 
 #endif /* _CRYPTO_KDF108_H */
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 100/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_KRB5 crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (98 preceding siblings ...)
  2026-02-12  2:47 ` [PATCH 099/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_KDF800108_CTR crypto Jay Wang
@ 2026-02-12  2:47 ` Jay Wang
  2026-02-12  2:47 ` [PATCH 101/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_FIPS_SIGNATURE_SELFTEST crypto Jay Wang
                   ` (5 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:47 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_KRB5-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/fips140/fips140-api.c | 27 +++++++++++++
 crypto/krb5/Makefile         |  2 +-
 crypto/krb5/krb5_api.c       |  4 +-
 include/crypto/krb5.h        | 78 ++++++++++++++++--------------------
 4 files changed, 65 insertions(+), 46 deletions(-)

diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 0ed89baa3865..3e4203dd2aeb 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -864,6 +864,33 @@ DEFINE_CRYPTO_API_STUB(async_raid6_datap_recov);
 DEFINE_CRYPTO_API_STUB(crypto_kdf108_ctr_generate);
 DEFINE_CRYPTO_API_STUB(crypto_kdf108_setkey);
 
+#endif
+/*
+ * crypto/krb5/krb5.o
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_KRB5)
+
+#include <crypto/krb5.h>
+
+/*
+ * crypto/krb5/krb5_kdf.c
+ */
+DEFINE_CRYPTO_API_STUB(crypto_krb5_calc_PRFplus);
+
+/*
+ * crypto/krb5/krb5_api.c
+ */
+DEFINE_CRYPTO_API_STUB(crypto_krb5_find_enctype);
+DEFINE_CRYPTO_API_STUB(crypto_krb5_how_much_buffer);
+DEFINE_CRYPTO_API_STUB(crypto_krb5_how_much_data);
+DEFINE_CRYPTO_API_STUB(crypto_krb5_where_is_the_data);
+DEFINE_CRYPTO_API_STUB(crypto_krb5_prepare_encryption);
+DEFINE_CRYPTO_API_STUB(crypto_krb5_prepare_checksum);
+DEFINE_CRYPTO_API_STUB(crypto_krb5_encrypt);
+DEFINE_CRYPTO_API_STUB(crypto_krb5_decrypt);
+DEFINE_CRYPTO_API_STUB(crypto_krb5_get_mic);
+DEFINE_CRYPTO_API_STUB(crypto_krb5_verify_mic);
+
 #endif
 /*
  * crypto/ecdh_helper.c
diff --git a/crypto/krb5/Makefile b/crypto/krb5/Makefile
index d38890c0b247..513759fc8dcc 100644
--- a/crypto/krb5/Makefile
+++ b/crypto/krb5/Makefile
@@ -15,4 +15,4 @@ krb5-$(CONFIG_CRYPTO_KRB5_SELFTESTS) += \
 	selftest.o \
 	selftest_data.o
 
-obj-$(CONFIG_CRYPTO_KRB5) += krb5.o
+crypto-objs-$(CONFIG_CRYPTO_KRB5) += krb5.o
diff --git a/crypto/krb5/krb5_api.c b/crypto/krb5/krb5_api.c
index 23026d4206c8..5725ed1cb4b7 100644
--- a/crypto/krb5/krb5_api.c
+++ b/crypto/krb5/krb5_api.c
@@ -444,9 +444,9 @@ static int __init crypto_krb5_init(void)
 {
 	return krb5_selftest();
 }
-module_init(crypto_krb5_init);
+crypto_module_init(crypto_krb5_init);
 
 static void __exit crypto_krb5_exit(void)
 {
 }
-module_exit(crypto_krb5_exit);
+crypto_module_exit(crypto_krb5_exit);
diff --git a/include/crypto/krb5.h b/include/crypto/krb5.h
index 71dd38f59be1..e2de2d0391a1 100644
--- a/include/crypto/krb5.h
+++ b/include/crypto/krb5.h
@@ -8,6 +8,8 @@
 #ifndef _CRYPTO_KRB5_H
 #define _CRYPTO_KRB5_H
 
+#include <crypto/api.h>
+
 #include <linux/crypto.h>
 #include <crypto/aead.h>
 #include <crypto/hash.h>
@@ -114,52 +116,42 @@ struct krb5_enctype {
 /*
  * krb5_api.c
  */
-const struct krb5_enctype *crypto_krb5_find_enctype(u32 enctype);
-size_t crypto_krb5_how_much_buffer(const struct krb5_enctype *krb5,
-				   enum krb5_crypto_mode mode,
-				   size_t data_size, size_t *_offset);
-size_t crypto_krb5_how_much_data(const struct krb5_enctype *krb5,
-				 enum krb5_crypto_mode mode,
-				 size_t *_buffer_size, size_t *_offset);
-void crypto_krb5_where_is_the_data(const struct krb5_enctype *krb5,
-				   enum krb5_crypto_mode mode,
-				   size_t *_offset, size_t *_len);
-struct crypto_aead *crypto_krb5_prepare_encryption(const struct krb5_enctype *krb5,
-						   const struct krb5_buffer *TK,
-						   u32 usage, gfp_t gfp);
-struct crypto_shash *crypto_krb5_prepare_checksum(const struct krb5_enctype *krb5,
-						  const struct krb5_buffer *TK,
-						  u32 usage, gfp_t gfp);
-ssize_t crypto_krb5_encrypt(const struct krb5_enctype *krb5,
-			    struct crypto_aead *aead,
-			    struct scatterlist *sg, unsigned int nr_sg,
-			    size_t sg_len,
-			    size_t data_offset, size_t data_len,
-			    bool preconfounded);
-int crypto_krb5_decrypt(const struct krb5_enctype *krb5,
-			struct crypto_aead *aead,
-			struct scatterlist *sg, unsigned int nr_sg,
-			size_t *_offset, size_t *_len);
-ssize_t crypto_krb5_get_mic(const struct krb5_enctype *krb5,
-			    struct crypto_shash *shash,
-			    const struct krb5_buffer *metadata,
-			    struct scatterlist *sg, unsigned int nr_sg,
-			    size_t sg_len,
-			    size_t data_offset, size_t data_len);
-int crypto_krb5_verify_mic(const struct krb5_enctype *krb5,
-			   struct crypto_shash *shash,
-			   const struct krb5_buffer *metadata,
-			   struct scatterlist *sg, unsigned int nr_sg,
-			   size_t *_offset, size_t *_len);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_KRB5, crypto_krb5_find_enctype, const struct krb5_enctype *,
+	(u32 enctype),
+	(enctype));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_KRB5, crypto_krb5_how_much_buffer, size_t,
+	(const struct krb5_enctype *krb5, enum krb5_crypto_mode mode, size_t data_size, size_t *_offset),
+	(krb5, mode, data_size, _offset));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_KRB5, crypto_krb5_how_much_data, size_t,
+	(const struct krb5_enctype *krb5, enum krb5_crypto_mode mode, size_t *_buffer_size, size_t *_offset),
+	(krb5, mode, _buffer_size, _offset));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_KRB5, crypto_krb5_where_is_the_data, void,
+	(const struct krb5_enctype *krb5, enum krb5_crypto_mode mode, size_t *_offset, size_t *_len),
+	(krb5, mode, _offset, _len));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_KRB5, crypto_krb5_prepare_encryption, struct crypto_aead *,
+	(const struct krb5_enctype *krb5, const struct krb5_buffer *TK, u32 usage, gfp_t gfp),
+	(krb5, TK, usage, gfp));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_KRB5, crypto_krb5_prepare_checksum, struct crypto_shash *,
+	(const struct krb5_enctype *krb5, const struct krb5_buffer *TK, u32 usage, gfp_t gfp),
+	(krb5, TK, usage, gfp));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_KRB5, crypto_krb5_encrypt, ssize_t,
+	(const struct krb5_enctype *krb5, struct crypto_aead *aead, struct scatterlist *sg, unsigned int nr_sg, size_t sg_len, size_t data_offset, size_t data_len, bool preconfounded),
+	(krb5, aead, sg, nr_sg, sg_len, data_offset, data_len, preconfounded));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_KRB5, crypto_krb5_decrypt, int,
+	(const struct krb5_enctype *krb5, struct crypto_aead *aead, struct scatterlist *sg, unsigned int nr_sg, size_t *_offset, size_t *_len),
+	(krb5, aead, sg, nr_sg, _offset, _len));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_KRB5, crypto_krb5_get_mic, ssize_t,
+	(const struct krb5_enctype *krb5, struct crypto_shash *shash, const struct krb5_buffer *metadata, struct scatterlist *sg, unsigned int nr_sg, size_t sg_len, size_t data_offset, size_t data_len),
+	(krb5, shash, metadata, sg, nr_sg, sg_len, data_offset, data_len));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_KRB5, crypto_krb5_verify_mic, int,
+	(const struct krb5_enctype *krb5, struct crypto_shash *shash, const struct krb5_buffer *metadata, struct scatterlist *sg, unsigned int nr_sg, size_t *_offset, size_t *_len),
+	(krb5, shash, metadata, sg, nr_sg, _offset, _len));
 
 /*
  * krb5_kdf.c
  */
-int crypto_krb5_calc_PRFplus(const struct krb5_enctype *krb5,
-			     const struct krb5_buffer *K,
-			     unsigned int L,
-			     const struct krb5_buffer *S,
-			     struct krb5_buffer *result,
-			     gfp_t gfp);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_KRB5, crypto_krb5_calc_PRFplus, int,
+	(const struct krb5_enctype *krb5, const struct krb5_buffer *K, unsigned int L, const struct krb5_buffer *S, struct krb5_buffer *result, gfp_t gfp),
+	(krb5, K, L, S, result, gfp));
 
 #endif /* _CRYPTO_KRB5_H */
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 101/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_FIPS_SIGNATURE_SELFTEST crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (99 preceding siblings ...)
  2026-02-12  2:47 ` [PATCH 100/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_KRB5 crypto Jay Wang
@ 2026-02-12  2:47 ` Jay Wang
  2026-02-12  2:47 ` [PATCH 102/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_PKCS8_PRIVATE_KEY_PARSER crypto Jay Wang
                   ` (4 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:47 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_FIPS_SIGNATURE_SELFTEST-related crypto to convert them into
pluggable interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/asymmetric_keys/Makefile   | 2 +-
 crypto/asymmetric_keys/selftest.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/crypto/asymmetric_keys/Makefile b/crypto/asymmetric_keys/Makefile
index c68fdcd2c5cf..bffa2e199a5d 100644
--- a/crypto/asymmetric_keys/Makefile
+++ b/crypto/asymmetric_keys/Makefile
@@ -22,7 +22,7 @@ x509_key_parser-y := \
 	x509_cert_parser.o \
 	x509_loader.o \
 	x509_public_key.o
-obj-$(CONFIG_FIPS_SIGNATURE_SELFTEST) += x509_selftest.o
+crypto-objs-$(CONFIG_FIPS_SIGNATURE_SELFTEST) += x509_selftest.o
 x509_selftest-y += selftest.o
 x509_selftest-$(CONFIG_FIPS_SIGNATURE_SELFTEST_RSA) += selftest_rsa.o
 x509_selftest-$(CONFIG_FIPS_SIGNATURE_SELFTEST_ECDSA) += selftest_ecdsa.o
diff --git a/crypto/asymmetric_keys/selftest.c b/crypto/asymmetric_keys/selftest.c
index 98dc5cdfdebe..4f3b6ef85d1b 100644
--- a/crypto/asymmetric_keys/selftest.c
+++ b/crypto/asymmetric_keys/selftest.c
@@ -65,7 +65,7 @@ static int __init fips_signature_selftest_init(void)
 	return 0;
 }
 
-late_initcall(fips_signature_selftest_init);
+crypto_late_initcall(fips_signature_selftest_init);
 
 MODULE_DESCRIPTION("X.509 self tests");
 MODULE_AUTHOR("Red Hat, Inc.");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 102/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_PKCS8_PRIVATE_KEY_PARSER crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (100 preceding siblings ...)
  2026-02-12  2:47 ` [PATCH 101/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_FIPS_SIGNATURE_SELFTEST crypto Jay Wang
@ 2026-02-12  2:47 ` Jay Wang
  2026-02-12  2:47 ` [PATCH 103/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_PKCS7_TEST_KEY crypto Jay Wang
                   ` (3 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:47 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_PKCS8_PRIVATE_KEY_PARSER-related crypto to convert them into
pluggable interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/asymmetric_keys/Makefile       | 2 +-
 crypto/asymmetric_keys/pkcs8_parser.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/asymmetric_keys/Makefile b/crypto/asymmetric_keys/Makefile
index bffa2e199a5d..3fdd11ea399a 100644
--- a/crypto/asymmetric_keys/Makefile
+++ b/crypto/asymmetric_keys/Makefile
@@ -37,7 +37,7 @@ $(obj)/x509_akid.asn1.o: $(obj)/x509_akid.asn1.c $(obj)/x509_akid.asn1.h
 #
 # PKCS#8 private key handling
 #
-obj-$(CONFIG_PKCS8_PRIVATE_KEY_PARSER) += pkcs8_key_parser.o
+crypto-objs-$(CONFIG_PKCS8_PRIVATE_KEY_PARSER) += pkcs8_key_parser.o
 pkcs8_key_parser-y := \
 	pkcs8.asn1.o \
 	pkcs8_parser.o
diff --git a/crypto/asymmetric_keys/pkcs8_parser.c b/crypto/asymmetric_keys/pkcs8_parser.c
index 105dcce27f71..f26464639232 100644
--- a/crypto/asymmetric_keys/pkcs8_parser.c
+++ b/crypto/asymmetric_keys/pkcs8_parser.c
@@ -173,8 +173,8 @@ static void __exit pkcs8_key_exit(void)
 	unregister_asymmetric_key_parser(&pkcs8_key_parser);
 }
 
-module_init(pkcs8_key_init);
-module_exit(pkcs8_key_exit);
+crypto_module_init(pkcs8_key_init);
+crypto_module_exit(pkcs8_key_exit);
 
 MODULE_DESCRIPTION("PKCS#8 certificate parser");
 MODULE_LICENSE("GPL");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 103/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_PKCS7_TEST_KEY crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (101 preceding siblings ...)
  2026-02-12  2:47 ` [PATCH 102/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_PKCS8_PRIVATE_KEY_PARSER crypto Jay Wang
@ 2026-02-12  2:47 ` Jay Wang
  2026-02-12  2:47 ` [PATCH 104/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_SIGNED_PE_FILE_VERIFICATION crypto Jay Wang
                   ` (2 subsequent siblings)
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:47 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_PKCS7_TEST_KEY-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/asymmetric_keys/Makefile         | 2 +-
 crypto/asymmetric_keys/pkcs7_key_type.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/crypto/asymmetric_keys/Makefile b/crypto/asymmetric_keys/Makefile
index 3fdd11ea399a..6a17f563c359 100644
--- a/crypto/asymmetric_keys/Makefile
+++ b/crypto/asymmetric_keys/Makefile
@@ -63,7 +63,7 @@ $(obj)/pkcs7.asn1.o: $(obj)/pkcs7.asn1.c $(obj)/pkcs7.asn1.h
 #
 # PKCS#7 parser testing key
 #
-obj-$(CONFIG_PKCS7_TEST_KEY) += pkcs7_test_key.o
+crypto-objs-$(CONFIG_PKCS7_TEST_KEY) += pkcs7_test_key.o
 pkcs7_test_key-y := \
 	pkcs7_key_type.o
 
diff --git a/crypto/asymmetric_keys/pkcs7_key_type.c b/crypto/asymmetric_keys/pkcs7_key_type.c
index b930d3bbf1af..a6921222ced1 100644
--- a/crypto/asymmetric_keys/pkcs7_key_type.c
+++ b/crypto/asymmetric_keys/pkcs7_key_type.c
@@ -4,8 +4,8 @@
  * Copyright (C) 2014 Red Hat, Inc. All Rights Reserved.
  * Written by David Howells (dhowells@redhat.com)
  */
-
 #define pr_fmt(fmt) "PKCS7key: "fmt
+#include <crypto/api.h>
 #include <linux/key.h>
 #include <linux/err.h>
 #include <linux/module.h>
@@ -91,5 +91,5 @@ static void __exit pkcs7_key_cleanup(void)
 	unregister_key_type(&key_type_pkcs7);
 }
 
-module_init(pkcs7_key_init);
-module_exit(pkcs7_key_cleanup);
+crypto_module_init(pkcs7_key_init);
+crypto_module_exit(pkcs7_key_cleanup);
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 104/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_SIGNED_PE_FILE_VERIFICATION crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (102 preceding siblings ...)
  2026-02-12  2:47 ` [PATCH 103/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_PKCS7_TEST_KEY crypto Jay Wang
@ 2026-02-12  2:47 ` Jay Wang
  2026-02-12  2:47 ` [PATCH 105/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SIMD crypto Jay Wang
  2026-02-12  2:47 ` [PATCH 106/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYNC_RAID6_TEST crypto Jay Wang
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:47 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_SIGNED_PE_FILE_VERIFICATION-related crypto to convert them into
pluggable interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/asymmetric_keys/Makefile        |  2 +-
 crypto/asymmetric_keys/verify_pefile.c |  1 +
 crypto/fips140/fips140-api.c           | 10 ++++++++++
 include/linux/verification.h           |  8 +++++---
 4 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/crypto/asymmetric_keys/Makefile b/crypto/asymmetric_keys/Makefile
index 6a17f563c359..bccf6952e0e5 100644
--- a/crypto/asymmetric_keys/Makefile
+++ b/crypto/asymmetric_keys/Makefile
@@ -70,7 +70,7 @@ pkcs7_test_key-y := \
 #
 # Signed PE binary-wrapped key handling
 #
-obj-$(CONFIG_SIGNED_PE_FILE_VERIFICATION) += verify_signed_pefile.o
+crypto-objs-$(CONFIG_SIGNED_PE_FILE_VERIFICATION) += verify_signed_pefile.o
 
 verify_signed_pefile-y := \
 	verify_pefile.o \
diff --git a/crypto/asymmetric_keys/verify_pefile.c b/crypto/asymmetric_keys/verify_pefile.c
index 1f3b227ba7f2..15e4e51f9f35 100644
--- a/crypto/asymmetric_keys/verify_pefile.c
+++ b/crypto/asymmetric_keys/verify_pefile.c
@@ -454,3 +454,4 @@ int verify_pefile_signature(const void *pebuf, unsigned pelen,
 	kfree_sensitive(ctx.digest);
 	return ret;
 }
+EXPORT_SYMBOL(verify_pefile_signature);
\ No newline at end of file
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 3e4203dd2aeb..74eae8815067 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -903,4 +903,14 @@ DEFINE_CRYPTO_API_STUB(crypto_ecdh_key_len);
 DEFINE_CRYPTO_API_STUB(crypto_ecdh_encode_key);
 DEFINE_CRYPTO_API_STUB(crypto_ecdh_decode_key);
 
+#endif
+/*
+ * crypto/asymmetric_keys/verify_pefile.c
+ */
+#if IS_BUILTIN(CONFIG_SIGNED_PE_FILE_VERIFICATION)
+
+#include <linux/verification.h>
+
+DEFINE_CRYPTO_API_STUB(verify_pefile_signature);
+
 #endif
\ No newline at end of file
diff --git a/include/linux/verification.h b/include/linux/verification.h
index dec7f2beabfd..b050da314117 100644
--- a/include/linux/verification.h
+++ b/include/linux/verification.h
@@ -8,6 +8,8 @@
 #ifndef _LINUX_VERIFICATION_H
 #define _LINUX_VERIFICATION_H
 
+#include <crypto/api.h>
+
 #include <linux/errno.h>
 #include <linux/types.h>
 
@@ -63,9 +65,9 @@ extern int verify_pkcs7_message_sig(const void *data, size_t len,
 				    void *ctx);
 
 #ifdef CONFIG_SIGNED_PE_FILE_VERIFICATION
-extern int verify_pefile_signature(const void *pebuf, unsigned pelen,
-				   struct key *trusted_keys,
-				   enum key_being_used_for usage);
+DECLARE_CRYPTO_API(CONFIG_SIGNED_PE_FILE_VERIFICATION, verify_pefile_signature, int,
+	(const void *pebuf, unsigned pelen, struct key *trusted_keys, enum key_being_used_for usage),
+	(pebuf, pelen, trusted_keys, usage));
 #endif
 
 #endif /* CONFIG_SYSTEM_DATA_VERIFICATION */
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 105/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SIMD crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (103 preceding siblings ...)
  2026-02-12  2:47 ` [PATCH 104/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_SIGNED_PE_FILE_VERIFICATION crypto Jay Wang
@ 2026-02-12  2:47 ` Jay Wang
  2026-02-12  2:47 ` [PATCH 106/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYNC_RAID6_TEST crypto Jay Wang
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:47 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_SIMD-related crypto to convert them into pluggable
interface.

This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.

Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile                |  2 +-
 crypto/fips140/fips140-api.c   | 15 +++++++++++++++
 include/crypto/internal/simd.h | 33 ++++++++++++++++++++-------------
 3 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index c1088b10f49a..7403364c9afa 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -200,7 +200,7 @@ crypto-objs-$(CONFIG_XOR_BLOCKS) += xor.o
 obj-$(CONFIG_ASYNC_CORE) += async_tx/
 obj-$(CONFIG_ASYMMETRIC_KEY_TYPE) += asymmetric_keys/
 crypto_simd-y := simd.o
-obj-$(CONFIG_CRYPTO_SIMD) += crypto_simd.o
+crypto-objs-$(CONFIG_CRYPTO_SIMD) += crypto_simd.o
 
 #
 # Key derivation function
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 74eae8815067..126ecd09ae07 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -913,4 +913,19 @@ DEFINE_CRYPTO_API_STUB(crypto_ecdh_decode_key);
 
 DEFINE_CRYPTO_API_STUB(verify_pefile_signature);
 
+#endif
+/*
+ * crypto/simd.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_SIMD)
+
+#include <crypto/internal/simd.h>
+
+DEFINE_CRYPTO_API_STUB(simd_skcipher_create_compat);
+DEFINE_CRYPTO_API_STUB(simd_skcipher_free);
+DEFINE_CRYPTO_API_STUB(simd_register_skciphers_compat);
+DEFINE_CRYPTO_API_STUB(simd_unregister_skciphers);
+DEFINE_CRYPTO_API_STUB(simd_register_aeads_compat);
+DEFINE_CRYPTO_API_STUB(simd_unregister_aeads);
+
 #endif
\ No newline at end of file
diff --git a/include/crypto/internal/simd.h b/include/crypto/internal/simd.h
index 9e338e7aafbd..be84d67f3ceb 100644
--- a/include/crypto/internal/simd.h
+++ b/include/crypto/internal/simd.h
@@ -6,6 +6,8 @@
 #ifndef _CRYPTO_INTERNAL_SIMD_H
 #define _CRYPTO_INTERNAL_SIMD_H
 
+#include <crypto/api.h>
+
 #include <asm/simd.h>
 #include <linux/percpu.h>
 #include <linux/types.h>
@@ -15,28 +17,33 @@
 struct simd_skcipher_alg;
 struct skcipher_alg;
 
-struct simd_skcipher_alg *simd_skcipher_create_compat(struct skcipher_alg *ialg,
-						      const char *algname,
-						      const char *drvname,
-						      const char *basename);
-void simd_skcipher_free(struct simd_skcipher_alg *alg);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SIMD, simd_skcipher_create_compat, struct simd_skcipher_alg *,
+	(struct skcipher_alg *ialg, const char *algname, const char *drvname, const char *basename),
+	(ialg, algname, drvname, basename));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SIMD, simd_skcipher_free, void,
+	(struct simd_skcipher_alg *alg),
+	(alg));
 
-int simd_register_skciphers_compat(struct skcipher_alg *algs, int count,
-				   struct simd_skcipher_alg **simd_algs);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SIMD, simd_register_skciphers_compat, int,
+	(struct skcipher_alg *algs, int count, struct simd_skcipher_alg **simd_algs),
+	(algs, count, simd_algs));
 
-void simd_unregister_skciphers(struct skcipher_alg *algs, int count,
-			       struct simd_skcipher_alg **simd_algs);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SIMD, simd_unregister_skciphers, void,
+	(struct skcipher_alg *algs, int count, struct simd_skcipher_alg **simd_algs),
+	(algs, count, simd_algs));
 
 /* AEAD support */
 
 struct simd_aead_alg;
 struct aead_alg;
 
-int simd_register_aeads_compat(struct aead_alg *algs, int count,
-			       struct simd_aead_alg **simd_algs);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SIMD, simd_register_aeads_compat, int,
+	(struct aead_alg *algs, int count, struct simd_aead_alg **simd_algs),
+	(algs, count, simd_algs));
 
-void simd_unregister_aeads(struct aead_alg *algs, int count,
-			   struct simd_aead_alg **simd_algs);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SIMD, simd_unregister_aeads, void,
+	(struct aead_alg *algs, int count, struct simd_aead_alg **simd_algs),
+	(algs, count, simd_algs));
 
 /*
  * crypto_simd_usable() - is it allowed at this time to use SIMD instructions or
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

* [PATCH 106/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYNC_RAID6_TEST crypto
  2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
                   ` (104 preceding siblings ...)
  2026-02-12  2:47 ` [PATCH 105/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SIMD crypto Jay Wang
@ 2026-02-12  2:47 ` Jay Wang
  105 siblings, 0 replies; 107+ messages in thread
From: Jay Wang @ 2026-02-12  2:47 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_ASYNC_RAID6_TEST-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/async_tx/Makefile    | 2 +-
 crypto/async_tx/raid6test.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/async_tx/Makefile b/crypto/async_tx/Makefile
index 2f700c2312af..9642987ebd71 100644
--- a/crypto/async_tx/Makefile
+++ b/crypto/async_tx/Makefile
@@ -4,4 +4,4 @@ crypto-objs-$(CONFIG_ASYNC_MEMCPY) += async_memcpy.o
 crypto-objs-$(CONFIG_ASYNC_XOR) += async_xor.o
 crypto-objs-$(CONFIG_ASYNC_PQ) += async_pq.o
 crypto-objs-$(CONFIG_ASYNC_RAID6_RECOV) += async_raid6_recov.o
-obj-$(CONFIG_ASYNC_RAID6_TEST) += raid6test.o
+crypto-objs-$(CONFIG_ASYNC_RAID6_TEST) += raid6test.o
diff --git a/crypto/async_tx/raid6test.c b/crypto/async_tx/raid6test.c
index d3fbee1e03e5..253aa4787f5a 100644
--- a/crypto/async_tx/raid6test.c
+++ b/crypto/async_tx/raid6test.c
@@ -243,8 +243,8 @@ static void __exit raid6_test_exit(void)
 /* when compiled-in wait for drivers to load first (assumes dma drivers
  * are also compiled-in)
  */
-late_initcall(raid6_test);
-module_exit(raid6_test_exit);
+crypto_late_initcall(raid6_test);
+crypto_module_exit(raid6_test_exit);
 MODULE_AUTHOR("Dan Williams <dan.j.williams@intel.com>");
 MODULE_DESCRIPTION("asynchronous RAID-6 recovery self tests");
 MODULE_LICENSE("GPL");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 107+ messages in thread

end of thread, other threads:[~2026-02-12  3:14 UTC | newest]

Thread overview: 107+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-12  2:45 [PATCH v1 00/106] crypto: Standalone crypto module (Series 2/4): Arch-independent crypto Jay Wang
2026-02-12  2:45 ` [PATCH 001/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO and CONFIG_CRYPTO_ALGAPI2 crypto Jay Wang
2026-02-12  2:45 ` [PATCH 002/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_AES crypto Jay Wang
2026-02-12  2:45 ` [PATCH 003/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_AEAD2 crypto Jay Wang
2026-02-12  2:45 ` [PATCH 004/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_GENIV crypto Jay Wang
2026-02-12  2:45 ` [PATCH 005/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SKCIPHER2 crypto Jay Wang
2026-02-12  2:45 ` [PATCH 006/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SEQIV crypto Jay Wang
2026-02-12  2:45 ` [PATCH 007/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ECHAINIV crypto Jay Wang
2026-02-12  2:45 ` [PATCH 008/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_HASH2 crypto Jay Wang
2026-02-12  2:45 ` [PATCH 009/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_AKCIPHER2 crypto Jay Wang
2026-02-12  2:45 ` [PATCH 010/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SIG2 crypto Jay Wang
2026-02-12  2:45 ` [PATCH 011/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_KPP2 crypto Jay Wang
2026-02-12  2:45 ` [PATCH 012/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_RSA crypto Jay Wang
2026-02-12  2:45 ` [PATCH 013/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ACOMP2 crypto Jay Wang
2026-02-12  2:45 ` [PATCH 014/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_MANAGER2 crypto Jay Wang
2026-02-12  2:45 ` [PATCH 015/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CMAC crypto Jay Wang
2026-02-12  2:45 ` [PATCH 016/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_HMAC crypto Jay Wang
2026-02-12  2:45 ` [PATCH 017/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_MD5 crypto Jay Wang
2026-02-12  2:45 ` [PATCH 018/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SHA256 crypto Jay Wang
2026-02-12  2:45 ` [PATCH 019/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SHA512 crypto Jay Wang
2026-02-12  2:45 ` [PATCH 020/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SHA3 crypto Jay Wang
2026-02-12  2:45 ` [PATCH 021/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ECB crypto Jay Wang
2026-02-12  2:45 ` [PATCH 022/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CBC crypto Jay Wang
2026-02-12  2:45 ` [PATCH 023/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CTR crypto Jay Wang
2026-02-12  2:46 ` [PATCH 024/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_GCM crypto Jay Wang
2026-02-12  2:46 ` [PATCH 025/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CCM crypto Jay Wang
2026-02-12  2:46 ` [PATCH 026/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_AUTHENC crypto Jay Wang
2026-02-12  2:46 ` [PATCH 027/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_LZO crypto Jay Wang
2026-02-12  2:46 ` [PATCH 028/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_RNG2 crypto Jay Wang
2026-02-12  2:46 ` [PATCH 029/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_DRBG crypto Jay Wang
2026-02-12  2:46 ` [PATCH 030/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_JITTERENTROPY crypto Jay Wang
2026-02-12  2:46 ` [PATCH 031/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_GHASH crypto Jay Wang
2026-02-12  2:46 ` [PATCH 032/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYMMETRIC_KEY_TYPE crypto Jay Wang
2026-02-12  2:46 ` [PATCH 033/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE crypto Jay Wang
2026-02-12  2:46 ` [PATCH 034/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_X509_CERTIFICATE_PARSER crypto Jay Wang
2026-02-12  2:46 ` [PATCH 035/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_PKCS7_MESSAGE_PARSER crypto Jay Wang
2026-02-12  2:46 ` [PATCH 036/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ENGINE crypto Jay Wang
2026-02-12  2:46 ` [PATCH 037/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_HKDF crypto Jay Wang
2026-02-12  2:46 ` [PATCH 038/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_DH crypto Jay Wang
2026-02-12  2:46 ` [PATCH 039/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ECDSA and CONFIG_CRYPTO_ECC crypto Jay Wang
2026-02-12  2:46 ` [PATCH 040/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_USER crypto Jay Wang
2026-02-12  2:46 ` [PATCH 041/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_XCBC crypto Jay Wang
2026-02-12  2:46 ` [PATCH 042/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_NULL crypto Jay Wang
2026-02-12  2:46 ` [PATCH 043/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_MD4 crypto Jay Wang
2026-02-12  2:46 ` [PATCH 044/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_RMD160 crypto Jay Wang
2026-02-12  2:46 ` [PATCH 045/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SHA1 crypto Jay Wang
2026-02-12  2:46 ` [PATCH 046/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SM3_GENERIC crypto Jay Wang
2026-02-12  2:46 ` [PATCH 047/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_STREEBOG crypto Jay Wang
2026-02-12  2:46 ` [PATCH 048/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_WP512 crypto Jay Wang
2026-02-12  2:46 ` [PATCH 049/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_BLAKE2B crypto Jay Wang
2026-02-12  2:46 ` [PATCH 050/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_PCBC crypto Jay Wang
2026-02-12  2:46 ` [PATCH 051/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CTS crypto Jay Wang
2026-02-12  2:46 ` [PATCH 052/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_LRW crypto Jay Wang
2026-02-12  2:46 ` [PATCH 053/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_XTS crypto Jay Wang
2026-02-12  2:46 ` [PATCH 054/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_XCTR and CONFIG_CRYPTO_HCTR2 crypto Jay Wang
2026-02-12  2:46 ` [PATCH 055/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ADIANTUM crypto Jay Wang
2026-02-12  2:46 ` [PATCH 056/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CHACHA20 crypto Jay Wang
2026-02-12  2:46 ` [PATCH 057/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CHACHA20POLY1305 crypto Jay Wang
2026-02-12  2:46 ` [PATCH 058/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_AEGIS128 crypto Jay Wang
2026-02-12  2:46 ` [PATCH 059/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_PCRYPT crypto Jay Wang
2026-02-12  2:46 ` [PATCH 060/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CRYPTD crypto Jay Wang
2026-02-12  2:46 ` [PATCH 061/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_DES crypto Jay Wang
2026-02-12  2:46 ` [PATCH 062/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_FCRYPT crypto Jay Wang
2026-02-12  2:46 ` [PATCH 063/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_BLOWFISH and CONFIG_CRYPTO_BLOWFISH_COMMON crypto Jay Wang
2026-02-12  2:46 ` [PATCH 064/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SM4 and CONFIG_CRYPTO_SM4_GENERIC crypto Jay Wang
2026-02-12  2:46 ` [PATCH 065/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_TWOFISH and CONFIG_CRYPTO_TWOFISH_COMMON crypto Jay Wang
2026-02-12  2:46 ` [PATCH 066/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SERPENT crypto Jay Wang
2026-02-12  2:46 ` [PATCH 067/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CAMELLIA crypto Jay Wang
2026-02-12  2:46 ` [PATCH 068/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CAST_COMMON, CONFIG_CRYPTO_CAST5, CONFIG_CRYPTO_CAST6 crypto Jay Wang
2026-02-12  2:46 ` [PATCH 069/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ARC4 crypto Jay Wang
2026-02-12  2:46 ` [PATCH 070/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_USER_API crypto Jay Wang
2026-02-12  2:46 ` [PATCH 071/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_USER_API_SKCIPHER crypto Jay Wang
2026-02-12  2:46 ` [PATCH 072/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_TEA crypto Jay Wang
2026-02-12  2:46 ` [PATCH 073/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_KHAZAD crypto Jay Wang
2026-02-12  2:46 ` [PATCH 074/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ANUBIS crypto Jay Wang
2026-02-12  2:46 ` [PATCH 075/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SEED crypto Jay Wang
2026-02-12  2:46 ` [PATCH 076/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ARIA crypto Jay Wang
2026-02-12  2:46 ` [PATCH 077/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_DEFLATE crypto Jay Wang
2026-02-12  2:46 ` [PATCH 078/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_MICHAEL_MIC crypto Jay Wang
2026-02-12  2:46 ` [PATCH 079/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CRC32C and CONFIG_CRYPTO_CRC32 crypto Jay Wang
2026-02-12  2:46 ` [PATCH 080/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_KRB5ENC crypto Jay Wang
2026-02-12  2:46 ` [PATCH 081/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_LZ4 and CONFIG_CRYPTO_LZ4HC crypto Jay Wang
2026-02-12  2:46 ` [PATCH 082/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_XXHASH crypto Jay Wang
2026-02-12  2:46 ` [PATCH 083/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_842 crypto Jay Wang
2026-02-12  2:47 ` [PATCH 084/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_JITTERENTROPY_TESTINTERFACE crypto Jay Wang
2026-02-12  2:47 ` [PATCH 085/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_BENCHMARK crypto Jay Wang
2026-02-12  2:47 ` [PATCH 086/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_USER_API_HASH crypto Jay Wang
2026-02-12  2:47 ` [PATCH 087/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_USER_API_RNG crypto Jay Wang
2026-02-12  2:47 ` [PATCH 088/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_USER_API_AEAD crypto Jay Wang
2026-02-12  2:47 ` [PATCH 089/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ZSTD crypto Jay Wang
2026-02-12  2:47 ` [PATCH 090/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ESSIV crypto Jay Wang
2026-02-12  2:47 ` [PATCH 091/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ECDH crypto Jay Wang
2026-02-12  2:47 ` [PATCH 092/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ECRDSA crypto Jay Wang
2026-02-12  2:47 ` [PATCH 093/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_XOR_BLOCKS crypto Jay Wang
2026-02-12  2:47 ` [PATCH 094/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYNC_CORE crypto Jay Wang
2026-02-12  2:47 ` [PATCH 095/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYNC_MEMCPY crypto Jay Wang
2026-02-12  2:47 ` [PATCH 096/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYNC_XOR crypto Jay Wang
2026-02-12  2:47 ` [PATCH 097/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYNC_PQ crypto Jay Wang
2026-02-12  2:47 ` [PATCH 098/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYNC_RAID6_RECOV crypto Jay Wang
2026-02-12  2:47 ` [PATCH 099/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_KDF800108_CTR crypto Jay Wang
2026-02-12  2:47 ` [PATCH 100/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_KRB5 crypto Jay Wang
2026-02-12  2:47 ` [PATCH 101/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_FIPS_SIGNATURE_SELFTEST crypto Jay Wang
2026-02-12  2:47 ` [PATCH 102/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_PKCS8_PRIVATE_KEY_PARSER crypto Jay Wang
2026-02-12  2:47 ` [PATCH 103/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_PKCS7_TEST_KEY crypto Jay Wang
2026-02-12  2:47 ` [PATCH 104/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_SIGNED_PE_FILE_VERIFICATION crypto Jay Wang
2026-02-12  2:47 ` [PATCH 105/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SIMD crypto Jay Wang
2026-02-12  2:47 ` [PATCH 106/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYNC_RAID6_TEST crypto Jay Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox