rsa.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * RSA internal helpers
  4. *
  5. * Copyright (c) 2015, Intel Corporation
  6. * Authors: Tadeusz Struk <[email protected]>
  7. */
  8. #ifndef _RSA_HELPER_
  9. #define _RSA_HELPER_
  10. #include <linux/types.h>
  11. /**
  12. * rsa_key - RSA key structure
  13. * @n : RSA modulus raw byte stream
  14. * @e : RSA public exponent raw byte stream
  15. * @d : RSA private exponent raw byte stream
  16. * @p : RSA prime factor p of n raw byte stream
  17. * @q : RSA prime factor q of n raw byte stream
  18. * @dp : RSA exponent d mod (p - 1) raw byte stream
  19. * @dq : RSA exponent d mod (q - 1) raw byte stream
  20. * @qinv : RSA CRT coefficient q^(-1) mod p raw byte stream
  21. * @n_sz : length in bytes of RSA modulus n
  22. * @e_sz : length in bytes of RSA public exponent
  23. * @d_sz : length in bytes of RSA private exponent
  24. * @p_sz : length in bytes of p field
  25. * @q_sz : length in bytes of q field
  26. * @dp_sz : length in bytes of dp field
  27. * @dq_sz : length in bytes of dq field
  28. * @qinv_sz : length in bytes of qinv field
  29. */
  30. struct rsa_key {
  31. const u8 *n;
  32. const u8 *e;
  33. const u8 *d;
  34. const u8 *p;
  35. const u8 *q;
  36. const u8 *dp;
  37. const u8 *dq;
  38. const u8 *qinv;
  39. size_t n_sz;
  40. size_t e_sz;
  41. size_t d_sz;
  42. size_t p_sz;
  43. size_t q_sz;
  44. size_t dp_sz;
  45. size_t dq_sz;
  46. size_t qinv_sz;
  47. };
  48. int rsa_parse_pub_key(struct rsa_key *rsa_key, const void *key,
  49. unsigned int key_len);
  50. int rsa_parse_priv_key(struct rsa_key *rsa_key, const void *key,
  51. unsigned int key_len);
  52. extern struct crypto_template rsa_pkcs1pad_tmpl;
  53. #endif