1 /* SPDX-License-Identifier: GPL-2.0-or-later */
5 * Copyright (c) 2015, Intel Corporation
6 * Authors: Tadeusz Struk <tadeusz.struk@intel.com>
10 #include <linux/types.h>
11 #include <crypto/akcipher.h>
14 * rsa_key - RSA key structure
15 * @n : RSA modulus raw byte stream
16 * @e : RSA public exponent raw byte stream
17 * @d : RSA private exponent raw byte stream
18 * @p : RSA prime factor p of n raw byte stream
19 * @q : RSA prime factor q of n raw byte stream
20 * @dp : RSA exponent d mod (p - 1) raw byte stream
21 * @dq : RSA exponent d mod (q - 1) raw byte stream
22 * @qinv : RSA CRT coefficient q^(-1) mod p raw byte stream
23 * @n_sz : length in bytes of RSA modulus n
24 * @e_sz : length in bytes of RSA public exponent
25 * @d_sz : length in bytes of RSA private exponent
26 * @p_sz : length in bytes of p field
27 * @q_sz : length in bytes of q field
28 * @dp_sz : length in bytes of dp field
29 * @dq_sz : length in bytes of dq field
30 * @qinv_sz : length in bytes of qinv field
51 int rsa_parse_pub_key(struct rsa_key
*rsa_key
, const void *key
,
52 unsigned int key_len
);
54 int rsa_parse_priv_key(struct rsa_key
*rsa_key
, const void *key
,
55 unsigned int key_len
);
57 #define RSA_PUB (true)
58 #define RSA_PRIV (false)
60 static inline int rsa_set_key(struct crypto_akcipher
*child
,
61 unsigned int *key_size
, bool is_pubkey
,
62 const void *key
, unsigned int keylen
)
69 err
= crypto_akcipher_set_pub_key(child
, key
, keylen
);
71 err
= crypto_akcipher_set_priv_key(child
, key
, keylen
);
75 /* Find out new modulus size from rsa implementation */
76 err
= crypto_akcipher_maxsize(child
);
84 extern struct crypto_template rsa_pkcs1pad_tmpl
;
85 extern struct crypto_template rsassa_pkcs1_tmpl
;