]> git.ipfire.org Git - thirdparty/openssl.git/blame - doc/crypto/RSA_get0_key.pod
RSA, DSA, DH: Allow some given input to be NULL on already initialised keys
[thirdparty/openssl.git] / doc / crypto / RSA_get0_key.pod
CommitLineData
b879882a
RL
1=pod
2
3=head1 NAME
4
5RSA_set0_key, RSA_set0_factors, RSA_set0_crt_params, RSA_get0_key,
6RSA_get0_factors, RSA_get0_crt_params, RSA_clear_flags,
7RSA_test_flags, RSA_set_flags, RSA_get0_engine - Routines for getting
8and setting data in an RSA object
9
10=head1 SYNOPSIS
11
12 #include <openssl/rsa.h>
13
14 int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d);
15 int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q);
16 int RSA_set0_crt_params(RSA *r,BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp);
17 void RSA_get0_key(const RSA *r, BIGNUM **n, BIGNUM **e, BIGNUM **d);
18 void RSA_get0_factors(const RSA *r, BIGNUM **p, BIGNUM **q);
19 void RSA_get0_crt_params(const RSA *r,
20 BIGNUM **dmp1, BIGNUM **dmq1, BIGNUM **iqmp);
21 void RSA_clear_flags(RSA *r, int flags);
22 int RSA_test_flags(const RSA *r, int flags);
23 void RSA_set_flags(RSA *r, int flags);
24 ENGINE *RSA_get0_engine(RSA *r);
25
26=head1 DESCRIPTION
27
28An RSA object contains the components for the public and private key,
29B<n>, B<e>, B<d>, B<p>, B<q>, B<dmp1>, B<dmq1> and B<iqmp>. B<n> is
30the modulus common to both public and private key, B<e> is the public
31exponent and B<d> is the private exponent. B<p>, B<q>, B<dmp1>,
32B<dmq1> and B<iqmp> are the factors for the second representation of a
33private key (see PKCS#1 section 3 Key Types), where B<p> and B<q> are
34the first and second factor of B<n> and B<dmp1>, B<dmq1> and B<iqmp>
35are the exponents and coefficient for CRT calculations.
36
37The B<n>, B<e> and B<d> parameters can be obtained by calling
38RSA_get0_key(). If they have not been set yet, then B<*n>, B<*e> and
39B<*d> will be set to NULL. Otherwise, they are set to pointers to
40their respective values. These point directly to the internal
41representations of the values and therefore should not be freed
42by the caller.
43
44The B<n>, B<e> and B<d> parameter values can be set by calling
45RSA_set0_key() and passing the new values for B<n>, B<e> and B<d> as
46parameters to the function. Calling this function transfers the memory
47management of the values to the RSA object, and therefore the values
48that have been passed in should not be freed by the caller after this
49function has been called.
50
51In a similar fashion, the B<p> and B<q> parameters can be obtained and
52set with RSA_get0_factors() and RSA_set0_factors(), and the B<dmp1>,
53B<dmq1> and B<iqmp> parameters can be obtained and set with
54RSA_get0_crt_params() and RSA_set0_crt_params().
55
56RSA_set_flags() sets the flags in the B<flags> parameter on the RSA
57object. Multiple flags can be passed in one go (bitwise ORed together).
58Any flags that are already set are left set. RSA_test_flags() tests to
59see whether the flags passed in the B<flags> parameter are currently
60set in the RSA object. Multiple flags can be tested in one go. All
61flags that are currently set are returned, or zero if none of the
62flags are set. RSA_clear_flags() clears the specified flags within the
63RSA object.
64
65RSA_get0_engine() returns a handle to the ENGINE that has been set for
66this RSA object, or NULL if no such ENGINE has been set.
67
68=head1 RETURN VALUES
69
70RSA_set0_key(), RSA_set0_factors and RSA_set0_crt_params() return 1 on
71success or 0 on failure.
72
73RSA_test_flags() returns the current state of the flags in the RSA object.
74
75RSA_get0_engine() returns the ENGINE set for the RSA object or NULL if no
76ENGINE has been set.
77
78=head1 SEE ALSO
79
80L<rsa(3)>, L<RSA_new(3)>, L<RSA_size(3)>
81
82=head1 HISTORY
83
84The functions described here were added in OpenSSL version 1.1.0.
85
86=cut