summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/doc/EVP_PKEY_keygen.pod
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lib/libcrypto/doc/EVP_PKEY_keygen.pod170
1 files changed, 0 insertions, 170 deletions
diff --git a/src/lib/libcrypto/doc/EVP_PKEY_keygen.pod b/src/lib/libcrypto/doc/EVP_PKEY_keygen.pod
deleted file mode 100644
index adcf3560e0..0000000000
--- a/src/lib/libcrypto/doc/EVP_PKEY_keygen.pod
+++ /dev/null
@@ -1,170 +0,0 @@
1=pod
2
3=head1 NAME
4
5EVP_PKEY_keygen_init, EVP_PKEY_keygen, EVP_PKEY_paramgen_init,
6EVP_PKEY_paramgen, EVP_PKEY_CTX_set_cb, EVP_PKEY_CTX_get_cb,
7EVP_PKEY_CTX_get_keygen_info, EVP_PKEY_CTX_set_app_data,
8EVP_PKEY_CTX_get_app_data - key and parameter generation functions
9
10=head1 SYNOPSIS
11
12 #include <openssl/evp.h>
13
14 int EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx);
15 int EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);
16 int EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx);
17 int EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);
18
19 typedef int EVP_PKEY_gen_cb(EVP_PKEY_CTX *ctx);
20
21 void EVP_PKEY_CTX_set_cb(EVP_PKEY_CTX *ctx, EVP_PKEY_gen_cb *cb);
22 EVP_PKEY_gen_cb *EVP_PKEY_CTX_get_cb(EVP_PKEY_CTX *ctx);
23
24 int EVP_PKEY_CTX_get_keygen_info(EVP_PKEY_CTX *ctx, int idx);
25
26 void EVP_PKEY_CTX_set_app_data(EVP_PKEY_CTX *ctx, void *data);
27 void *EVP_PKEY_CTX_get_app_data(EVP_PKEY_CTX *ctx);
28
29=head1 DESCRIPTION
30
31The EVP_PKEY_keygen_init() function initializes a public key algorithm
32context using key B<pkey> for a key generation operation.
33
34The EVP_PKEY_keygen() function performs a key generation operation, the
35generated key is written to B<ppkey>.
36
37The functions EVP_PKEY_paramgen_init() and EVP_PKEY_paramgen() are similar
38except parameters are generated.
39
40The function EVP_PKEY_set_cb() sets the key or parameter generation callback
41to B<cb>. The function EVP_PKEY_CTX_get_cb() returns the key or parameter
42generation callback.
43
44The function EVP_PKEY_CTX_get_keygen_info() returns parameters associated
45with the generation operation. If B<idx> is -1 the total number of
46parameters available is returned. Any non negative value returns the value of
47that parameter. EVP_PKEY_CTX_gen_keygen_info() with a non-negative value for
48B<idx> should only be called within the generation callback.
49
50If the callback returns 0 then the key generation operation is aborted and an
51error occurs. This might occur during a time consuming operation where
52a user clicks on a "cancel" button.
53
54The functions EVP_PKEY_CTX_set_app_data() and EVP_PKEY_CTX_get_app_data() set
55and retrieve an opaque pointer. This can be used to set some application
56defined value which can be retrieved in the callback: for example a handle
57which is used to update a "progress dialog".
58
59=head1 NOTES
60
61After the call to EVP_PKEY_keygen_init() or EVP_PKEY_paramgen_init() algorithm
62specific control operations can be performed to set any appropriate parameters
63for the operation.
64
65The functions EVP_PKEY_keygen() and EVP_PKEY_paramgen() can be called more than
66once on the same context if several operations are performed using the same
67parameters.
68
69The meaning of the parameters passed to the callback will depend on the
70algorithm and the specific implementation of the algorithm. Some might not
71give any useful information at all during key or parameter generation. Others
72might not even call the callback.
73
74The operation performed by key or parameter generation depends on the algorithm
75used. In some cases (e.g. EC with a supplied named curve) the "generation"
76option merely sets the appropriate fields in an EVP_PKEY structure.
77
78In OpenSSL an EVP_PKEY structure containing a private key also contains the
79public key components and parameters (if any). An OpenSSL private key is
80equivalent to what some libraries call a "key pair". A private key can be used
81in functions which require the use of a public key or parameters.
82
83=head1 RETURN VALUES
84
85EVP_PKEY_keygen_init(), EVP_PKEY_paramgen_init(), EVP_PKEY_keygen() and
86EVP_PKEY_paramgen() return 1 for success and 0 or a negative value for failure.
87In particular a return value of -2 indicates the operation is not supported by
88the public key algorithm.
89
90=head1 EXAMPLES
91
92Generate a 2048 bit RSA key:
93
94 #include <openssl/evp.h>
95 #include <openssl/rsa.h>
96
97 EVP_PKEY_CTX *ctx;
98 EVP_PKEY *pkey = NULL;
99 ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA, NULL);
100 if (!ctx)
101 /* Error occurred */
102 if (EVP_PKEY_keygen_init(ctx) <= 0)
103 /* Error */
104 if (EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, 2048) <= 0)
105 /* Error */
106
107 /* Generate key */
108 if (EVP_PKEY_keygen(ctx, &pkey) <= 0)
109 /* Error */
110
111Generate a key from a set of parameters:
112
113 #include <openssl/evp.h>
114 #include <openssl/rsa.h>
115
116 EVP_PKEY_CTX *ctx;
117 EVP_PKEY *pkey = NULL, *param;
118 /* Assumed param is set up already */
119 ctx = EVP_PKEY_CTX_new(param);
120 if (!ctx)
121 /* Error occurred */
122 if (EVP_PKEY_keygen_init(ctx) <= 0)
123 /* Error */
124
125 /* Generate key */
126 if (EVP_PKEY_keygen(ctx, &pkey) <= 0)
127 /* Error */
128
129Example of generation callback for OpenSSL public key implementations:
130
131 /* Application data is a BIO to output status to */
132
133 EVP_PKEY_CTX_set_app_data(ctx, status_bio);
134
135 static int
136 genpkey_cb(EVP_PKEY_CTX *ctx)
137 {
138 char c = '*';
139 BIO *b = EVP_PKEY_CTX_get_app_data(ctx);
140 int p;
141
142 p = EVP_PKEY_CTX_get_keygen_info(ctx, 0);
143 if (p == 0)
144 c='.';
145 if (p == 1)
146 c='+';
147 if (p == 2)
148 c='*';
149 if (p == 3)
150 c='\n';
151 BIO_write(b,&c,1);
152 (void)BIO_flush(b);
153 return 1;
154 }
155
156=head1 SEE ALSO
157
158L<EVP_PKEY_CTX_new(3)|EVP_PKEY_CTX_new(3)>,
159L<EVP_PKEY_encrypt(3)|EVP_PKEY_encrypt(3)>,
160L<EVP_PKEY_decrypt(3)|EVP_PKEY_decrypt(3)>,
161L<EVP_PKEY_sign(3)|EVP_PKEY_sign(3)>,
162L<EVP_PKEY_verify(3)|EVP_PKEY_verify(3)>,
163L<EVP_PKEY_verify_recover(3)|EVP_PKEY_verify_recover(3)>,
164L<EVP_PKEY_derive(3)|EVP_PKEY_derive(3)>
165
166=head1 HISTORY
167
168These functions were first added to OpenSSL 1.0.0.
169
170=cut