RSA_check_key.pod 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. =pod
  2. =head1 NAME
  3. RSA_check_key_ex, RSA_check_key - validate private RSA keys
  4. =head1 SYNOPSIS
  5. #include <openssl/rsa.h>
  6. The following functions have been deprecated since OpenSSL 3.0, and can be
  7. hidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value,
  8. see L<openssl_user_macros(7)>:
  9. int RSA_check_key_ex(const RSA *rsa, BN_GENCB *cb);
  10. int RSA_check_key(const RSA *rsa);
  11. =head1 DESCRIPTION
  12. Both of the functions described on this page are deprecated.
  13. Applications should instead use L<EVP_PKEY_public_check(3)>,
  14. L<EVP_PKEY_private_check(3)> and L<EVP_PKEY_pairwise_check(3)>.
  15. RSA_check_key_ex() function validates RSA keys.
  16. It checks that B<p> and B<q> are
  17. in fact prime, and that B<n = p*q>.
  18. It does not work on RSA public keys that have only the modulus
  19. and public exponent elements populated.
  20. It also checks that B<d*e = 1 mod (p-1*q-1)>,
  21. and that B<dmp1>, B<dmq1> and B<iqmp> are set correctly or are B<NULL>.
  22. It performs integrity checks on all
  23. the RSA key material, so the RSA key structure must contain all the private
  24. key data too.
  25. Therefore, it cannot be used with any arbitrary RSA key object,
  26. even if it is otherwise fit for regular RSA operation.
  27. The B<cb> parameter is a callback that will be invoked in the same
  28. manner as L<BN_is_prime_ex(3)>.
  29. RSA_check_key() is equivalent to RSA_check_key_ex() with a NULL B<cb>.
  30. =head1 RETURN VALUES
  31. RSA_check_key_ex() and RSA_check_key()
  32. return 1 if B<rsa> is a valid RSA key, and 0 otherwise.
  33. They return -1 if an error occurs while checking the key.
  34. If the key is invalid or an error occurred, the reason code can be
  35. obtained using L<ERR_get_error(3)>.
  36. =head1 NOTES
  37. Unlike most other RSA functions, this function does B<not> work
  38. transparently with any underlying ENGINE implementation because it uses the
  39. key data in the RSA structure directly. An ENGINE implementation can
  40. override the way key data is stored and handled, and can even provide
  41. support for HSM keys - in which case the RSA structure may contain B<no>
  42. key data at all! If the ENGINE in question is only being used for
  43. acceleration or analysis purposes, then in all likelihood the RSA key data
  44. is complete and untouched, but this can't be assumed in the general case.
  45. =head1 BUGS
  46. A method of verifying the RSA key using opaque RSA API functions might need
  47. to be considered. Right now RSA_check_key() simply uses the RSA structure
  48. elements directly, bypassing the RSA_METHOD table altogether (and
  49. completely violating encapsulation and object-orientation in the process).
  50. The best fix will probably be to introduce a "check_key()" handler to the
  51. RSA_METHOD function table so that alternative implementations can also
  52. provide their own verifiers.
  53. =head1 SEE ALSO
  54. L<BN_is_prime_ex(3)>,
  55. L<ERR_get_error(3)>
  56. =head1 HISTORY
  57. All of these functions were deprecated in OpenSSL 3.0.
  58. RSA_check_key_ex() appeared after OpenSSL 1.0.2.
  59. =head1 COPYRIGHT
  60. Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
  61. Licensed under the Apache License 2.0 (the "License"). You may not use
  62. this file except in compliance with the License. You can obtain a copy
  63. in the file LICENSE in the source distribution or at
  64. L<https://www.openssl.org/source/license.html>.
  65. =cut