Home | History | Annotate | Line # | Download | only in man3
      1      1.1  christos =pod
      2      1.1  christos 
      3      1.1  christos =head1 NAME
      4      1.1  christos 
      5      1.1  christos RSA_set0_key, RSA_set0_factors, RSA_set0_crt_params, RSA_get0_key,
      6      1.1  christos RSA_get0_factors, RSA_get0_crt_params,
      7      1.1  christos RSA_get0_n, RSA_get0_e, RSA_get0_d, RSA_get0_p, RSA_get0_q,
      8  1.1.1.3  christos RSA_get0_dmp1, RSA_get0_dmq1, RSA_get0_iqmp, RSA_get0_pss_params,
      9      1.1  christos RSA_clear_flags,
     10      1.1  christos RSA_test_flags, RSA_set_flags, RSA_get0_engine, RSA_get_multi_prime_extra_count,
     11      1.1  christos RSA_get0_multi_prime_factors, RSA_get0_multi_prime_crt_params,
     12      1.1  christos RSA_set0_multi_prime_params, RSA_get_version
     13      1.1  christos - Routines for getting and setting data in an RSA object
     14      1.1  christos 
     15      1.1  christos =head1 SYNOPSIS
     16      1.1  christos 
     17      1.1  christos  #include <openssl/rsa.h>
     18      1.1  christos 
     19  1.1.1.4  christos The following functions have been deprecated since OpenSSL 3.0, and can be
     20  1.1.1.4  christos hidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value,
     21  1.1.1.4  christos see L<openssl_user_macros(7)>:
     22  1.1.1.4  christos 
     23      1.1  christos  int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d);
     24      1.1  christos  int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q);
     25      1.1  christos  int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp);
     26      1.1  christos  void RSA_get0_key(const RSA *r,
     27      1.1  christos                    const BIGNUM **n, const BIGNUM **e, const BIGNUM **d);
     28      1.1  christos  void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q);
     29      1.1  christos  void RSA_get0_crt_params(const RSA *r,
     30      1.1  christos                           const BIGNUM **dmp1, const BIGNUM **dmq1,
     31      1.1  christos                           const BIGNUM **iqmp);
     32      1.1  christos  const BIGNUM *RSA_get0_n(const RSA *d);
     33      1.1  christos  const BIGNUM *RSA_get0_e(const RSA *d);
     34      1.1  christos  const BIGNUM *RSA_get0_d(const RSA *d);
     35      1.1  christos  const BIGNUM *RSA_get0_p(const RSA *d);
     36      1.1  christos  const BIGNUM *RSA_get0_q(const RSA *d);
     37      1.1  christos  const BIGNUM *RSA_get0_dmp1(const RSA *r);
     38      1.1  christos  const BIGNUM *RSA_get0_dmq1(const RSA *r);
     39      1.1  christos  const BIGNUM *RSA_get0_iqmp(const RSA *r);
     40  1.1.1.3  christos  const RSA_PSS_PARAMS *RSA_get0_pss_params(const RSA *r);
     41      1.1  christos  void RSA_clear_flags(RSA *r, int flags);
     42      1.1  christos  int RSA_test_flags(const RSA *r, int flags);
     43      1.1  christos  void RSA_set_flags(RSA *r, int flags);
     44      1.1  christos  ENGINE *RSA_get0_engine(RSA *r);
     45      1.1  christos  int RSA_get_multi_prime_extra_count(const RSA *r);
     46      1.1  christos  int RSA_get0_multi_prime_factors(const RSA *r, const BIGNUM *primes[]);
     47      1.1  christos  int RSA_get0_multi_prime_crt_params(const RSA *r, const BIGNUM *exps[],
     48      1.1  christos                                      const BIGNUM *coeffs[]);
     49      1.1  christos  int RSA_set0_multi_prime_params(RSA *r, BIGNUM *primes[], BIGNUM *exps[],
     50      1.1  christos                                 BIGNUM *coeffs[], int pnum);
     51      1.1  christos  int RSA_get_version(RSA *r);
     52      1.1  christos 
     53      1.1  christos =head1 DESCRIPTION
     54      1.1  christos 
     55  1.1.1.4  christos All of the functions described on this page are deprecated.
     56  1.1.1.4  christos Applications should instead use L<EVP_PKEY_get_bn_param(3)> for any methods that
     57  1.1.1.5  christos return a B<BIGNUM>. Refer to L<EVP_PKEY-DH(7)> for more information.
     58  1.1.1.4  christos 
     59      1.1  christos An RSA object contains the components for the public and private key,
     60      1.1  christos B<n>, B<e>, B<d>, B<p>, B<q>, B<dmp1>, B<dmq1> and B<iqmp>.  B<n> is
     61      1.1  christos the modulus common to both public and private key, B<e> is the public
     62      1.1  christos exponent and B<d> is the private exponent.  B<p>, B<q>, B<dmp1>,
     63      1.1  christos B<dmq1> and B<iqmp> are the factors for the second representation of a
     64      1.1  christos private key (see PKCS#1 section 3 Key Types), where B<p> and B<q> are
     65      1.1  christos the first and second factor of B<n> and B<dmp1>, B<dmq1> and B<iqmp>
     66      1.1  christos are the exponents and coefficient for CRT calculations.
     67      1.1  christos 
     68      1.1  christos For multi-prime RSA (defined in RFC 8017), there are also one or more
     69      1.1  christos 'triplet' in an RSA object. A triplet contains three members, B<r>, B<d>
     70      1.1  christos and B<t>. B<r> is the additional prime besides B<p> and B<q>. B<d> and
     71      1.1  christos B<t> are the exponent and coefficient for CRT calculations.
     72      1.1  christos 
     73      1.1  christos The B<n>, B<e> and B<d> parameters can be obtained by calling
     74      1.1  christos RSA_get0_key().  If they have not been set yet, then B<*n>, B<*e> and
     75      1.1  christos B<*d> will be set to NULL.  Otherwise, they are set to pointers to
     76      1.1  christos their respective values. These point directly to the internal
     77      1.1  christos representations of the values and therefore should not be freed
     78      1.1  christos by the caller.
     79      1.1  christos 
     80      1.1  christos The B<n>, B<e> and B<d> parameter values can be set by calling
     81      1.1  christos RSA_set0_key() and passing the new values for B<n>, B<e> and B<d> as
     82      1.1  christos parameters to the function.  The values B<n> and B<e> must be non-NULL
     83      1.1  christos the first time this function is called on a given RSA object. The
     84      1.1  christos value B<d> may be NULL. On subsequent calls any of these values may be
     85      1.1  christos NULL which means the corresponding RSA field is left untouched.
     86      1.1  christos Calling this function transfers the memory management of the values to
     87      1.1  christos the RSA object, and therefore the values that have been passed in
     88      1.1  christos should not be freed by the caller after this function has been called.
     89      1.1  christos 
     90      1.1  christos In a similar fashion, the B<p> and B<q> parameters can be obtained and
     91      1.1  christos set with RSA_get0_factors() and RSA_set0_factors(), and the B<dmp1>,
     92      1.1  christos B<dmq1> and B<iqmp> parameters can be obtained and set with
     93      1.1  christos RSA_get0_crt_params() and RSA_set0_crt_params().
     94      1.1  christos 
     95      1.1  christos For RSA_get0_key(), RSA_get0_factors(), and RSA_get0_crt_params(),
     96      1.1  christos NULL value BIGNUM ** output parameters are permitted. The functions
     97      1.1  christos ignore NULL parameters but return values for other, non-NULL, parameters.
     98      1.1  christos 
     99      1.1  christos For multi-prime RSA, RSA_get0_multi_prime_factors() and RSA_get0_multi_prime_params()
    100      1.1  christos can be used to obtain other primes and related CRT parameters. The
    101      1.1  christos return values are stored in an array of B<BIGNUM *>. RSA_set0_multi_prime_params()
    102      1.1  christos sets a collect of multi-prime 'triplet' members (prime, exponent and coefficient)
    103      1.1  christos into an RSA object.
    104      1.1  christos 
    105      1.1  christos Any of the values B<n>, B<e>, B<d>, B<p>, B<q>, B<dmp1>, B<dmq1>, and B<iqmp> can also be
    106      1.1  christos retrieved separately by the corresponding function
    107      1.1  christos RSA_get0_n(), RSA_get0_e(), RSA_get0_d(), RSA_get0_p(), RSA_get0_q(),
    108      1.1  christos RSA_get0_dmp1(), RSA_get0_dmq1(), and RSA_get0_iqmp(), respectively.
    109      1.1  christos 
    110  1.1.1.3  christos RSA_get0_pss_params() is used to retrieve the RSA-PSS parameters.
    111  1.1.1.3  christos 
    112      1.1  christos RSA_set_flags() sets the flags in the B<flags> parameter on the RSA
    113      1.1  christos object. Multiple flags can be passed in one go (bitwise ORed together).
    114      1.1  christos Any flags that are already set are left set. RSA_test_flags() tests to
    115      1.1  christos see whether the flags passed in the B<flags> parameter are currently
    116      1.1  christos set in the RSA object. Multiple flags can be tested in one go. All
    117      1.1  christos flags that are currently set are returned, or zero if none of the
    118      1.1  christos flags are set. RSA_clear_flags() clears the specified flags within the
    119      1.1  christos RSA object.
    120      1.1  christos 
    121      1.1  christos RSA_get0_engine() returns a handle to the ENGINE that has been set for
    122      1.1  christos this RSA object, or NULL if no such ENGINE has been set.
    123      1.1  christos 
    124      1.1  christos RSA_get_version() returns the version of an RSA object B<r>.
    125      1.1  christos 
    126      1.1  christos =head1 NOTES
    127      1.1  christos 
    128      1.1  christos Values retrieved with RSA_get0_key() are owned by the RSA object used
    129      1.1  christos in the call and may therefore I<not> be passed to RSA_set0_key().  If
    130      1.1  christos needed, duplicate the received value using BN_dup() and pass the
    131      1.1  christos duplicate.  The same applies to RSA_get0_factors() and RSA_set0_factors()
    132      1.1  christos as well as RSA_get0_crt_params() and RSA_set0_crt_params().
    133      1.1  christos 
    134      1.1  christos The caller should obtain the size by calling RSA_get_multi_prime_extra_count()
    135      1.1  christos in advance and allocate sufficient buffer to store the return values before
    136      1.1  christos calling RSA_get0_multi_prime_factors() and RSA_get0_multi_prime_params().
    137      1.1  christos 
    138      1.1  christos RSA_set0_multi_prime_params() always clears the original multi-prime
    139      1.1  christos triplets in RSA object B<r> and assign the new set of triplets into it.
    140      1.1  christos 
    141      1.1  christos =head1 RETURN VALUES
    142      1.1  christos 
    143      1.1  christos RSA_set0_key(), RSA_set0_factors(), RSA_set0_crt_params() and
    144      1.1  christos RSA_set0_multi_prime_params() return 1 on success or 0 on failure.
    145      1.1  christos 
    146      1.1  christos RSA_get0_n(), RSA_get0_e(), RSA_get0_d(), RSA_get0_p(), RSA_get0_q(),
    147      1.1  christos RSA_get0_dmp1(), RSA_get0_dmq1(), and RSA_get0_iqmp()
    148      1.1  christos return the respective value.
    149      1.1  christos 
    150  1.1.1.4  christos RSA_get0_pss_params() returns a B<RSA_PSS_PARAMS> pointer, or NULL if
    151  1.1.1.4  christos there is none.
    152  1.1.1.4  christos 
    153      1.1  christos RSA_get0_multi_prime_factors() and RSA_get0_multi_prime_crt_params() return
    154      1.1  christos 1 on success or 0 on failure.
    155      1.1  christos 
    156      1.1  christos RSA_get_multi_prime_extra_count() returns two less than the number of primes
    157      1.1  christos in use, which is 0 for traditional RSA and the number of extra primes for
    158      1.1  christos multi-prime RSA.
    159      1.1  christos 
    160      1.1  christos RSA_get_version() returns B<RSA_ASN1_VERSION_MULTI> for multi-prime RSA and
    161      1.1  christos B<RSA_ASN1_VERSION_DEFAULT> for normal two-prime RSA, as defined in RFC 8017.
    162      1.1  christos 
    163      1.1  christos RSA_test_flags() returns the current state of the flags in the RSA object.
    164      1.1  christos 
    165      1.1  christos RSA_get0_engine() returns the ENGINE set for the RSA object or NULL if no
    166      1.1  christos ENGINE has been set.
    167      1.1  christos 
    168      1.1  christos =head1 SEE ALSO
    169      1.1  christos 
    170      1.1  christos L<RSA_new(3)>, L<RSA_size(3)>
    171      1.1  christos 
    172      1.1  christos =head1 HISTORY
    173      1.1  christos 
    174  1.1.1.3  christos The RSA_get0_pss_params() function was added in OpenSSL 1.1.1e.
    175  1.1.1.3  christos 
    176  1.1.1.2  christos The
    177      1.1  christos RSA_get_multi_prime_extra_count(), RSA_get0_multi_prime_factors(),
    178      1.1  christos RSA_get0_multi_prime_crt_params(), RSA_set0_multi_prime_params(),
    179      1.1  christos and RSA_get_version() functions were added in OpenSSL 1.1.1.
    180      1.1  christos 
    181      1.1  christos Other functions described here were added in OpenSSL 1.1.0.
    182      1.1  christos 
    183  1.1.1.4  christos All of these functions were deprecated in OpenSSL 3.0.
    184  1.1.1.4  christos 
    185      1.1  christos =head1 COPYRIGHT
    186      1.1  christos 
    187  1.1.1.5  christos Copyright 2016-2023 The OpenSSL Project Authors. All Rights Reserved.
    188      1.1  christos 
    189  1.1.1.4  christos Licensed under the Apache License 2.0 (the "License").  You may not use
    190      1.1  christos this file except in compliance with the License.  You can obtain a copy
    191      1.1  christos in the file LICENSE in the source distribution or at
    192      1.1  christos L<https://www.openssl.org/source/license.html>.
    193      1.1  christos 
    194      1.1  christos =cut
    195