crypto: Move RSA+MPI constructs into an #include file
Subsystems (2)
PATCH 1/1 crypto: Move RSA+MPI constructs into an #include file
Move RSA support of general use into internal/rsa.h. This allows reuse of, e.g. RSA MPI keys and support functions.
Signed-off-by Gary R Hook <[email protected]>
--- crypto/rsa.c | 16 ---------------- include/crypto/internal/rsa.h | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 16 deletions(-)
crypto/rsa.c +0 -16
@@ -16,12 +16,6 @@#include <crypto/akcipher.h> #include <crypto/algapi.h> -struct rsa_mpi_key { -MPI n; -MPI e; -MPI d; -}; -/* * RSAEP function [RFC3447 sec 5.1.1] * c = m^e mod n;
@@ -240,16 +234,6 @@ err_free_m:return ret; } -static void rsa_free_mpi_key (struct rsa_mpi_key *key) -{ -mpi_free (key->d); -mpi_free (key->e); -mpi_free (key->n); - key->d =NULL ; - key->e =NULL ; - key->n =NULL ; -} -static int rsa_check_key_length (unsigned int len) {switch (len) {
include/crypto/internal/rsa.h +17 -0
@@ -13,6 +13,7 @@#ifndef _RSA_HELPER_#define _RSA_HELPER_#include <linux/types.h> +#include <linux/mpi.h> /** * rsa_key - RSA key structure
@@ -52,6 +53,22 @@ struct rsa_key {size_t qinv_sz; }; +struct rsa_mpi_key { +MPI n; +MPI e; +MPI d; +}; + +static inline void rsa_free_mpi_key (struct rsa_mpi_key *key) +{ +mpi_free (key->d); +mpi_free (key->e); +mpi_free (key->n); + key->d =NULL ; + key->e =NULL ; + key->n =NULL ; +} +int rsa_parse_pub_key (struct rsa_key *rsa_key,const void *key,unsigned int key_len);
Herbert Xu
maintainerQuoted 5 lines · Gary R Hook
Move RSA support of general use into
internal/rsa.h. This allows reuse of, e.g. RSA MPI keys and support functions.Signed-off-by Gary R Hook <[email protected]>
Please fold this patch into the series that makes use of it.
Thanks,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt