2015-06-16 20:31:01 +03:00
|
|
|
/*
|
|
|
|
* RSA internal helpers
|
|
|
|
*
|
|
|
|
* Copyright (c) 2015, Intel Corporation
|
|
|
|
* Authors: Tadeusz Struk <tadeusz.struk@intel.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the Free
|
|
|
|
* Software Foundation; either version 2 of the License, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#ifndef _RSA_HELPER_
|
|
|
|
#define _RSA_HELPER_
|
2016-06-14 16:14:58 +03:00
|
|
|
#include <linux/types.h>
|
2015-06-16 20:31:01 +03:00
|
|
|
|
2016-06-14 16:14:58 +03:00
|
|
|
/**
|
|
|
|
* rsa_key - RSA key structure
|
|
|
|
* @n : RSA modulus raw byte stream
|
|
|
|
* @e : RSA public exponent raw byte stream
|
|
|
|
* @d : RSA private exponent raw byte stream
|
2016-07-04 19:21:38 +03:00
|
|
|
* @p : RSA prime factor p of n raw byte stream
|
|
|
|
* @q : RSA prime factor q of n raw byte stream
|
|
|
|
* @dp : RSA exponent d mod (p - 1) raw byte stream
|
|
|
|
* @dq : RSA exponent d mod (q - 1) raw byte stream
|
|
|
|
* @qinv : RSA CRT coefficient q^(-1) mod p raw byte stream
|
2016-06-14 16:14:58 +03:00
|
|
|
* @n_sz : length in bytes of RSA modulus n
|
|
|
|
* @e_sz : length in bytes of RSA public exponent
|
|
|
|
* @d_sz : length in bytes of RSA private exponent
|
2016-07-04 19:21:38 +03:00
|
|
|
* @p_sz : length in bytes of p field
|
|
|
|
* @q_sz : length in bytes of q field
|
|
|
|
* @dp_sz : length in bytes of dp field
|
|
|
|
* @dq_sz : length in bytes of dq field
|
|
|
|
* @qinv_sz : length in bytes of qinv field
|
2016-06-14 16:14:58 +03:00
|
|
|
*/
|
2015-06-16 20:31:01 +03:00
|
|
|
struct rsa_key {
|
2016-06-14 16:14:58 +03:00
|
|
|
const u8 *n;
|
|
|
|
const u8 *e;
|
|
|
|
const u8 *d;
|
2016-07-04 19:21:38 +03:00
|
|
|
const u8 *p;
|
|
|
|
const u8 *q;
|
|
|
|
const u8 *dp;
|
|
|
|
const u8 *dq;
|
|
|
|
const u8 *qinv;
|
2016-06-14 16:14:58 +03:00
|
|
|
size_t n_sz;
|
|
|
|
size_t e_sz;
|
|
|
|
size_t d_sz;
|
2016-07-04 19:21:38 +03:00
|
|
|
size_t p_sz;
|
|
|
|
size_t q_sz;
|
|
|
|
size_t dp_sz;
|
|
|
|
size_t dq_sz;
|
|
|
|
size_t qinv_sz;
|
2015-06-16 20:31:01 +03:00
|
|
|
};
|
|
|
|
|
2015-10-08 19:26:55 +03:00
|
|
|
int rsa_parse_pub_key(struct rsa_key *rsa_key, const void *key,
|
|
|
|
unsigned int key_len);
|
|
|
|
|
|
|
|
int rsa_parse_priv_key(struct rsa_key *rsa_key, const void *key,
|
|
|
|
unsigned int key_len);
|
2015-06-16 20:31:01 +03:00
|
|
|
|
2015-12-05 19:09:34 +03:00
|
|
|
extern struct crypto_template rsa_pkcs1pad_tmpl;
|
2015-06-16 20:31:01 +03:00
|
|
|
#endif
|