rsa.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # This file is dual licensed under the terms of the Apache License, Version
  2. # 2.0, and the BSD License. See the LICENSE file in the root of this repository
  3. # for complete details.
  4. from __future__ import absolute_import, division, print_function
  5. INCLUDES = """
  6. #include <openssl/rsa.h>
  7. """
  8. TYPES = """
  9. typedef ... RSA;
  10. typedef ... BN_GENCB;
  11. static const int RSA_PKCS1_PADDING;
  12. static const int RSA_NO_PADDING;
  13. static const int RSA_PKCS1_OAEP_PADDING;
  14. static const int RSA_PKCS1_PSS_PADDING;
  15. static const int RSA_F4;
  16. static const int Cryptography_HAS_RSA_OAEP_MD;
  17. static const int Cryptography_HAS_RSA_OAEP_LABEL;
  18. """
  19. FUNCTIONS = """
  20. RSA *RSA_new(void);
  21. void RSA_free(RSA *);
  22. int RSA_generate_key_ex(RSA *, int, BIGNUM *, BN_GENCB *);
  23. int RSA_check_key(const RSA *);
  24. RSA *RSAPublicKey_dup(RSA *);
  25. int RSA_blinding_on(RSA *, BN_CTX *);
  26. int RSA_print(BIO *, const RSA *, int);
  27. /* added in 1.1.0 when the RSA struct was opaqued */
  28. int RSA_set0_key(RSA *, BIGNUM *, BIGNUM *, BIGNUM *);
  29. int RSA_set0_factors(RSA *, BIGNUM *, BIGNUM *);
  30. int RSA_set0_crt_params(RSA *, BIGNUM *, BIGNUM *, BIGNUM *);
  31. void RSA_get0_key(const RSA *, const BIGNUM **, const BIGNUM **,
  32. const BIGNUM **);
  33. void RSA_get0_factors(const RSA *, const BIGNUM **, const BIGNUM **);
  34. void RSA_get0_crt_params(const RSA *, const BIGNUM **, const BIGNUM **,
  35. const BIGNUM **);
  36. int EVP_PKEY_CTX_set_rsa_padding(EVP_PKEY_CTX *, int);
  37. int EVP_PKEY_CTX_set_rsa_pss_saltlen(EVP_PKEY_CTX *, int);
  38. int EVP_PKEY_CTX_set_rsa_mgf1_md(EVP_PKEY_CTX *, EVP_MD *);
  39. int EVP_PKEY_CTX_set0_rsa_oaep_label(EVP_PKEY_CTX *, unsigned char *, int);
  40. int EVP_PKEY_CTX_set_rsa_oaep_md(EVP_PKEY_CTX *, EVP_MD *);
  41. """
  42. CUSTOMIZATIONS = """
  43. #if !CRYPTOGRAPHY_IS_LIBRESSL
  44. static const long Cryptography_HAS_RSA_OAEP_MD = 1;
  45. static const long Cryptography_HAS_RSA_OAEP_LABEL = 1;
  46. #else
  47. static const long Cryptography_HAS_RSA_OAEP_MD = 0;
  48. static const long Cryptography_HAS_RSA_OAEP_LABEL = 0;
  49. int (*EVP_PKEY_CTX_set_rsa_oaep_md)(EVP_PKEY_CTX *, EVP_MD *) = NULL;
  50. int (*EVP_PKEY_CTX_set0_rsa_oaep_label)(EVP_PKEY_CTX *, unsigned char *,
  51. int) = NULL;
  52. #endif
  53. """