2
0

RSA_get0_key.pod 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. =pod
  2. =head1 NAME
  3. RSA_set0_key, RSA_set0_factors, RSA_set0_crt_params, RSA_get0_key,
  4. RSA_get0_factors, RSA_get0_crt_params, RSA_clear_flags,
  5. RSA_test_flags, RSA_set_flags, RSA_get0_engine - Routines for getting
  6. and setting data in an RSA object
  7. =head1 SYNOPSIS
  8. #include <openssl/rsa.h>
  9. int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d);
  10. int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q);
  11. int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp);
  12. void RSA_get0_key(const RSA *r,
  13. const BIGNUM **n, const BIGNUM **e, const BIGNUM **d);
  14. void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q);
  15. void RSA_get0_crt_params(const RSA *r,
  16. const BIGNUM **dmp1, const BIGNUM **dmq1,
  17. const BIGNUM **iqmp);
  18. void RSA_clear_flags(RSA *r, int flags);
  19. int RSA_test_flags(const RSA *r, int flags);
  20. void RSA_set_flags(RSA *r, int flags);
  21. ENGINE *RSA_get0_engine(RSA *r);
  22. =head1 DESCRIPTION
  23. An RSA object contains the components for the public and private key,
  24. B<n>, B<e>, B<d>, B<p>, B<q>, B<dmp1>, B<dmq1> and B<iqmp>. B<n> is
  25. the modulus common to both public and private key, B<e> is the public
  26. exponent and B<d> is the private exponent. B<p>, B<q>, B<dmp1>,
  27. B<dmq1> and B<iqmp> are the factors for the second representation of a
  28. private key (see PKCS#1 section 3 Key Types), where B<p> and B<q> are
  29. the first and second factor of B<n> and B<dmp1>, B<dmq1> and B<iqmp>
  30. are the exponents and coefficient for CRT calculations.
  31. The B<n>, B<e> and B<d> parameters can be obtained by calling
  32. RSA_get0_key(). If they have not been set yet, then B<*n>, B<*e> and
  33. B<*d> will be set to NULL. Otherwise, they are set to pointers to
  34. their respective values. These point directly to the internal
  35. representations of the values and therefore should not be freed
  36. by the caller.
  37. The B<n>, B<e> and B<d> parameter values can be set by calling
  38. RSA_set0_key() and passing the new values for B<n>, B<e> and B<d> as
  39. parameters to the function. The values B<n> and B<e> must be non-NULL
  40. the first time this function is called on a given RSA object. The
  41. value B<d> may be NULL. On subsequent calls any of these values may be
  42. NULL which means the corresponding RSA field is left untouched.
  43. Calling this function transfers the memory management of the values to
  44. the RSA object, and therefore the values that have been passed in
  45. should not be freed by the caller after this function has been called.
  46. In a similar fashion, the B<p> and B<q> parameters can be obtained and
  47. set with RSA_get0_factors() and RSA_set0_factors(), and the B<dmp1>,
  48. B<dmq1> and B<iqmp> parameters can be obtained and set with
  49. RSA_get0_crt_params() and RSA_set0_crt_params().
  50. For RSA_get0_key(), RSA_get0_factors(), and RSA_get0_crt_params(),
  51. NULL value BIGNUM ** output parameters are permitted. The functions
  52. ignore NULL parameters but return values for other, non-NULL, parameters.
  53. RSA_set_flags() sets the flags in the B<flags> parameter on the RSA
  54. object. Multiple flags can be passed in one go (bitwise ORed together).
  55. Any flags that are already set are left set. RSA_test_flags() tests to
  56. see whether the flags passed in the B<flags> parameter are currently
  57. set in the RSA object. Multiple flags can be tested in one go. All
  58. flags that are currently set are returned, or zero if none of the
  59. flags are set. RSA_clear_flags() clears the specified flags within the
  60. RSA object.
  61. RSA_get0_engine() returns a handle to the ENGINE that has been set for
  62. this RSA object, or NULL if no such ENGINE has been set.
  63. =head1 NOTES
  64. Values retrieved with RSA_get0_key() are owned by the RSA object used
  65. in the call and may therefore I<not> be passed to RSA_set0_key(). If
  66. needed, duplicate the received value using BN_dup() and pass the
  67. duplicate. The same applies to RSA_get0_factors() and RSA_set0_factors()
  68. as well as RSA_get0_crt_params() and RSA_set0_crt_params().
  69. =head1 RETURN VALUES
  70. RSA_set0_key(), RSA_set0_factors and RSA_set0_crt_params() return 1 on
  71. success or 0 on failure.
  72. RSA_test_flags() returns the current state of the flags in the RSA object.
  73. RSA_get0_engine() returns the ENGINE set for the RSA object or NULL if no
  74. ENGINE has been set.
  75. =head1 SEE ALSO
  76. L<rsa(3)>, L<RSA_new(3)>, L<RSA_size(3)>
  77. =head1 HISTORY
  78. The functions described here were added in OpenSSL 1.1.0.
  79. =head1 COPYRIGHT
  80. Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
  81. Licensed under the OpenSSL license (the "License"). You may not use
  82. this file except in compliance with the License. You can obtain a copy
  83. in the file LICENSE in the source distribution or at
  84. L<https://www.openssl.org/source/license.html>.
  85. =cut