1 /* SPDX-License-Identifier: GPL-2.0-or-later * << 2 /* 1 /* 3 * RSA internal helpers 2 * RSA internal helpers 4 * 3 * 5 * Copyright (c) 2015, Intel Corporation 4 * Copyright (c) 2015, Intel Corporation 6 * Authors: Tadeusz Struk <tadeusz.struk@intel 5 * Authors: Tadeusz Struk <tadeusz.struk@intel.com> >> 6 * >> 7 * This program is free software; you can redistribute it and/or modify it >> 8 * under the terms of the GNU General Public License as published by the Free >> 9 * Software Foundation; either version 2 of the License, or (at your option) >> 10 * any later version. >> 11 * 7 */ 12 */ 8 #ifndef _RSA_HELPER_ 13 #ifndef _RSA_HELPER_ 9 #define _RSA_HELPER_ 14 #define _RSA_HELPER_ 10 #include <linux/types.h> 15 #include <linux/types.h> 11 16 12 /** 17 /** 13 * rsa_key - RSA key structure 18 * rsa_key - RSA key structure 14 * @n : RSA modulus raw byte stream 19 * @n : RSA modulus raw byte stream 15 * @e : RSA public exponent raw byte 20 * @e : RSA public exponent raw byte stream 16 * @d : RSA private exponent raw byt 21 * @d : RSA private exponent raw byte stream 17 * @p : RSA prime factor p of n raw 22 * @p : RSA prime factor p of n raw byte stream 18 * @q : RSA prime factor q of n raw 23 * @q : RSA prime factor q of n raw byte stream 19 * @dp : RSA exponent d mod (p - 1) r 24 * @dp : RSA exponent d mod (p - 1) raw byte stream 20 * @dq : RSA exponent d mod (q - 1) r 25 * @dq : RSA exponent d mod (q - 1) raw byte stream 21 * @qinv : RSA CRT coefficient q^(-1) m 26 * @qinv : RSA CRT coefficient q^(-1) mod p raw byte stream 22 * @n_sz : length in bytes of RSA modul 27 * @n_sz : length in bytes of RSA modulus n 23 * @e_sz : length in bytes of RSA publi 28 * @e_sz : length in bytes of RSA public exponent 24 * @d_sz : length in bytes of RSA priva 29 * @d_sz : length in bytes of RSA private exponent 25 * @p_sz : length in bytes of p field 30 * @p_sz : length in bytes of p field 26 * @q_sz : length in bytes of q field 31 * @q_sz : length in bytes of q field 27 * @dp_sz : length in bytes of dp field 32 * @dp_sz : length in bytes of dp field 28 * @dq_sz : length in bytes of dq field 33 * @dq_sz : length in bytes of dq field 29 * @qinv_sz : length in bytes of qinv fiel 34 * @qinv_sz : length in bytes of qinv field 30 */ 35 */ 31 struct rsa_key { 36 struct rsa_key { 32 const u8 *n; 37 const u8 *n; 33 const u8 *e; 38 const u8 *e; 34 const u8 *d; 39 const u8 *d; 35 const u8 *p; 40 const u8 *p; 36 const u8 *q; 41 const u8 *q; 37 const u8 *dp; 42 const u8 *dp; 38 const u8 *dq; 43 const u8 *dq; 39 const u8 *qinv; 44 const u8 *qinv; 40 size_t n_sz; 45 size_t n_sz; 41 size_t e_sz; 46 size_t e_sz; 42 size_t d_sz; 47 size_t d_sz; 43 size_t p_sz; 48 size_t p_sz; 44 size_t q_sz; 49 size_t q_sz; 45 size_t dp_sz; 50 size_t dp_sz; 46 size_t dq_sz; 51 size_t dq_sz; 47 size_t qinv_sz; 52 size_t qinv_sz; 48 }; 53 }; 49 54 50 int rsa_parse_pub_key(struct rsa_key *rsa_key, 55 int rsa_parse_pub_key(struct rsa_key *rsa_key, const void *key, 51 unsigned int key_len); 56 unsigned int key_len); 52 57 53 int rsa_parse_priv_key(struct rsa_key *rsa_key 58 int rsa_parse_priv_key(struct rsa_key *rsa_key, const void *key, 54 unsigned int key_len); 59 unsigned int key_len); 55 60 56 extern struct crypto_template rsa_pkcs1pad_tmp 61 extern struct crypto_template rsa_pkcs1pad_tmpl; 57 #endif 62 #endif 58 63
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.