1gnutls_x509_privkey_generate2(3) gnutls gnutls_x509_privkey_generate2(3)
2
3
4
6 gnutls_x509_privkey_generate2 - API function
7
9 #include <gnutls/x509.h>
10
11 int gnutls_x509_privkey_generate2(gnutls_x509_privkey_t key,
12 gnutls_pk_algorithm_t algo, unsigned int bits, unsigned int flags,
13 const gnutls_keygen_data_st * data, unsigned data_size);
14
16 gnutls_x509_privkey_t key
17 a key
18
19 gnutls_pk_algorithm_t algo
20 is one of the algorithms in gnutls_pk_algorithm_t.
21
22 unsigned int bits
23 the size of the modulus
24
25 unsigned int flags
26 Must be zero or flags from gnutls_privkey_flags_t.
27
28 const gnutls_keygen_data_st * data
29 Allow specifying gnutls_keygen_data_st types such as the
30 seed to be used.
31
32 unsigned data_size
33 The number of data available.
34
36 This function will generate a random private key. Note that this func‐
37 tion must be called on an initialized private key.
38
39 The flag GNUTLS_PRIVKEY_FLAG_PROVABLE instructs the key generation
40 process to use algorithms like Shawe-Taylor (from FIPS PUB186-4) which
41 generate provable parameters out of a seed for RSA and DSA keys. On DSA
42 keys the PQG parameters are generated using the seed, while on RSA the
43 two primes. To specify an explicit seed (by default a random seed is
44 used), use the data with a GNUTLS_KEYGEN_SEED type.
45
46 Note that when generating an elliptic curve key, the curve can be sub‐
47 stituted in the place of the bits parameter using the
48 GNUTLS_CURVE_TO_BITS() macro.
49
50 To export the generated keys in memory or in files it is recommended to
51 use the PKCS8 form as it can handle all key types, and can store addi‐
52 tional parameters such as the seed, in case of provable RSA or DSA
53 keys. Generated keys can be exported in memory using
54 gnutls_privkey_export_x509(), and then with
55 gnutls_x509_privkey_export2_pkcs8().
56
57 If key generation is part of your application, avoid setting the number
58 of bits directly, and instead use gnutls_sec_param_to_pk_bits(). That
59 way the generated keys will adapt to the security levels of the under‐
60 lying GnuTLS library.
61
62 See also gnutls_privkey_generate2().
63
65 On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a negative
66 error value.
67
69 Report bugs to <bugs@gnutls.org>.
70 Home page: http://www.gnutls.org
71
72
74 Copyright © 2001-2018 Free Software Foundation, Inc., and others.
75 Copying and distribution of this file, with or without modification,
76 are permitted in any medium without royalty provided the copyright
77 notice and this notice are preserved.
78
80 The full documentation for gnutls is maintained as a Texinfo manual.
81 If the /usr/share/doc/gnutls/ directory does not contain the HTML form
82 visit
83
84 http://www.gnutls.org/manual/
85
86gnutls 3.6.5 gnutls_x509_privkey_generate2(3)