summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/libcrypto/doc/RC4.pod62
-rw-r--r--src/lib/libcrypto/doc/RIPEMD160.pod66
-rw-r--r--src/lib/libcrypto/doc/SHA1.pod71
-rw-r--r--src/lib/libcrypto/doc/bn.pod181
-rw-r--r--src/lib/libcrypto/doc/d2i_DHparams.pod26
-rw-r--r--src/lib/libcrypto/doc/d2i_DSAPublicKey.pod79
-rw-r--r--src/lib/libcrypto/doc/d2i_ECPKParameters.pod84
-rw-r--r--src/lib/libcrypto/doc/dh.pod79
-rw-r--r--src/lib/libcrypto/doc/dsa.pod114
-rw-r--r--src/lib/libcrypto/doc/ec.pod201
-rw-r--r--src/lib/libcrypto/doc/engine.pod599
-rw-r--r--src/lib/libcrypto/doc/lh_stats.pod60
-rw-r--r--src/lib/libcrypto/man/Makefile41
-rw-r--r--src/lib/libcrypto/man/RC4.379
-rw-r--r--src/lib/libcrypto/man/RIPEMD160.396
-rw-r--r--src/lib/libcrypto/man/SHA1.3102
-rw-r--r--src/lib/libcrypto/man/bn.3576
-rw-r--r--src/lib/libcrypto/man/d2i_DHparams.330
-rw-r--r--src/lib/libcrypto/man/d2i_DSAPublicKey.3159
-rw-r--r--src/lib/libcrypto/man/d2i_ECPKParameters.3188
-rw-r--r--src/lib/libcrypto/man/dh.3148
-rw-r--r--src/lib/libcrypto/man/dsa.3244
-rw-r--r--src/lib/libcrypto/man/ec.3710
-rw-r--r--src/lib/libcrypto/man/engine.31187
-rw-r--r--src/lib/libcrypto/man/lh_stats.383
25 files changed, 3615 insertions, 1650 deletions
diff --git a/src/lib/libcrypto/doc/RC4.pod b/src/lib/libcrypto/doc/RC4.pod
deleted file mode 100644
index b6d3a4342c..0000000000
--- a/src/lib/libcrypto/doc/RC4.pod
+++ /dev/null
@@ -1,62 +0,0 @@
1=pod
2
3=head1 NAME
4
5RC4_set_key, RC4 - RC4 encryption
6
7=head1 SYNOPSIS
8
9 #include <openssl/rc4.h>
10
11 void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data);
12
13 void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata,
14 unsigned char *outdata);
15
16=head1 DESCRIPTION
17
18This library implements the Alleged RC4 cipher, which is described for
19example in I<Applied Cryptography>. It is believed to be compatible
20with RC4[TM], a proprietary cipher of RSA Security Inc.
21
22RC4 is a stream cipher with variable key length. Typically, 128 bit
23(16 byte) keys are used for strong encryption, but shorter insecure
24key sizes have been widely used due to export restrictions.
25
26RC4 consists of a key setup phase and the actual encryption or
27decryption phase.
28
29RC4_set_key() sets up the B<RC4_KEY> B<key> using the B<len> bytes long
30key at B<data>.
31
32RC4() encrypts or decrypts the B<len> bytes of data at B<indata> using
33B<key> and places the result at B<outdata>. Repeated RC4() calls with
34the same B<key> yield a continuous key stream.
35
36Since RC4 is a stream cipher (the input is XORed with a pseudo-random
37key stream to produce the output), decryption uses the same function
38calls as encryption.
39
40Applications should use the higher level functions
41L<EVP_EncryptInit(3)|EVP_EncryptInit(3)>
42etc. instead of calling the RC4 functions directly.
43
44=head1 RETURN VALUES
45
46RC4_set_key() and RC4() do not return values.
47
48=head1 NOTE
49
50Certain conditions have to be observed to securely use stream ciphers.
51It is not permissible to perform multiple encryptions using the same
52key stream.
53
54=head1 SEE ALSO
55
56L<blowfish(3)|blowfish(3)>, L<des(3)|des(3)>, L<rc2(3)|rc2(3)>
57
58=head1 HISTORY
59
60RC4_set_key() and RC4() are available in all versions of SSLeay and OpenSSL.
61
62=cut
diff --git a/src/lib/libcrypto/doc/RIPEMD160.pod b/src/lib/libcrypto/doc/RIPEMD160.pod
deleted file mode 100644
index f66fb02ed2..0000000000
--- a/src/lib/libcrypto/doc/RIPEMD160.pod
+++ /dev/null
@@ -1,66 +0,0 @@
1=pod
2
3=head1 NAME
4
5RIPEMD160, RIPEMD160_Init, RIPEMD160_Update, RIPEMD160_Final -
6RIPEMD-160 hash function
7
8=head1 SYNOPSIS
9
10 #include <openssl/ripemd.h>
11
12 unsigned char *RIPEMD160(const unsigned char *d, unsigned long n,
13 unsigned char *md);
14
15 int RIPEMD160_Init(RIPEMD160_CTX *c);
16 int RIPEMD160_Update(RIPEMD_CTX *c, const void *data,
17 unsigned long len);
18 int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c);
19
20=head1 DESCRIPTION
21
22RIPEMD-160 is a cryptographic hash function with a
23160 bit output.
24
25RIPEMD160() computes the RIPEMD-160 message digest of the B<n>
26bytes at B<d> and places it in B<md> (which must have space for
27RIPEMD160_DIGEST_LENGTH == 20 bytes of output). If B<md> is NULL, the digest
28is placed in a static array.
29
30The following functions may be used if the message is not completely
31stored in memory:
32
33RIPEMD160_Init() initializes a B<RIPEMD160_CTX> structure.
34
35RIPEMD160_Update() can be called repeatedly with chunks of the message to
36be hashed (B<len> bytes at B<data>).
37
38RIPEMD160_Final() places the message digest in B<md>, which must have
39space for RIPEMD160_DIGEST_LENGTH == 20 bytes of output, and erases
40the B<RIPEMD160_CTX>.
41
42Applications should use the higher level functions
43L<EVP_DigestInit(3)|EVP_DigestInit(3)> etc. instead of calling the
44hash functions directly.
45
46=head1 RETURN VALUES
47
48RIPEMD160() returns a pointer to the hash value.
49
50RIPEMD160_Init(), RIPEMD160_Update() and RIPEMD160_Final() return 1 for
51success, 0 otherwise.
52
53=head1 CONFORMING TO
54
55ISO/IEC 10118-3 (draft) (??)
56
57=head1 SEE ALSO
58
59L<sha(3)|sha(3)>, L<hmac(3)|hmac(3)>, L<EVP_DigestInit(3)|EVP_DigestInit(3)>
60
61=head1 HISTORY
62
63RIPEMD160(), RIPEMD160_Init(), RIPEMD160_Update() and
64RIPEMD160_Final() are available since SSLeay 0.9.0.
65
66=cut
diff --git a/src/lib/libcrypto/doc/SHA1.pod b/src/lib/libcrypto/doc/SHA1.pod
deleted file mode 100644
index 9fffdf59e7..0000000000
--- a/src/lib/libcrypto/doc/SHA1.pod
+++ /dev/null
@@ -1,71 +0,0 @@
1=pod
2
3=head1 NAME
4
5SHA1, SHA1_Init, SHA1_Update, SHA1_Final - Secure Hash Algorithm
6
7=head1 SYNOPSIS
8
9 #include <openssl/sha.h>
10
11 unsigned char *SHA1(const unsigned char *d, unsigned long n,
12 unsigned char *md);
13
14 int SHA1_Init(SHA_CTX *c);
15 int SHA1_Update(SHA_CTX *c, const void *data,
16 unsigned long len);
17 int SHA1_Final(unsigned char *md, SHA_CTX *c);
18
19=head1 DESCRIPTION
20
21SHA-1 (Secure Hash Algorithm) is a cryptographic hash function with a
22160 bit output.
23
24SHA1() computes the SHA-1 message digest of the B<n>
25bytes at B<d> and places it in B<md> (which must have space for
26SHA_DIGEST_LENGTH == 20 bytes of output). If B<md> is NULL, the digest
27is placed in a static array.
28
29The following functions may be used if the message is not completely
30stored in memory:
31
32SHA1_Init() initializes a B<SHA_CTX> structure.
33
34SHA1_Update() can be called repeatedly with chunks of the message to
35be hashed (B<len> bytes at B<data>).
36
37SHA1_Final() places the message digest in B<md>, which must have space
38for SHA_DIGEST_LENGTH == 20 bytes of output, and erases the B<SHA_CTX>.
39
40Applications should use the higher level functions
41L<EVP_DigestInit(3)|EVP_DigestInit(3)>
42etc. instead of calling the hash functions directly.
43
44The predecessor of SHA-1, SHA, is also implemented, but it should be
45used only when backward compatibility is required.
46
47=head1 RETURN VALUES
48
49SHA1() returns a pointer to the hash value.
50
51SHA1_Init(), SHA1_Update() and SHA1_Final() return 1 for success, 0 otherwise.
52
53=head1 CONFORMING TO
54
55SHA: US Federal Information Processing Standard FIPS PUB 180 (Secure Hash
56Standard),
57SHA-1: US Federal Information Processing Standard FIPS PUB 180-1 (Secure Hash
58Standard),
59ANSI X9.30
60
61=head1 SEE ALSO
62
63L<ripemd(3)|ripemd(3)>, L<hmac(3)|hmac(3)>,
64L<EVP_DigestInit(3)|EVP_DigestInit(3)>
65
66=head1 HISTORY
67
68SHA1(), SHA1_Init(), SHA1_Update() and SHA1_Final() are available in all
69versions of SSLeay and OpenSSL.
70
71=cut
diff --git a/src/lib/libcrypto/doc/bn.pod b/src/lib/libcrypto/doc/bn.pod
deleted file mode 100644
index b3ad63320a..0000000000
--- a/src/lib/libcrypto/doc/bn.pod
+++ /dev/null
@@ -1,181 +0,0 @@
1=pod
2
3=head1 NAME
4
5bn - multiprecision integer arithmetics
6
7=head1 SYNOPSIS
8
9 #include <openssl/bn.h>
10
11 BIGNUM *BN_new(void);
12 void BN_free(BIGNUM *a);
13 void BN_init(BIGNUM *);
14 void BN_clear(BIGNUM *a);
15 void BN_clear_free(BIGNUM *a);
16
17 BN_CTX *BN_CTX_new(void);
18 void BN_CTX_init(BN_CTX *c);
19 void BN_CTX_free(BN_CTX *c);
20
21 BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);
22 BIGNUM *BN_dup(const BIGNUM *a);
23
24 BIGNUM *BN_swap(BIGNUM *a, BIGNUM *b);
25
26 int BN_num_bytes(const BIGNUM *a);
27 int BN_num_bits(const BIGNUM *a);
28 int BN_num_bits_word(BN_ULONG w);
29
30 void BN_set_negative(BIGNUM *a, int n);
31 int BN_is_negative(const BIGNUM *a);
32
33 int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
34 int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
35 int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
36 int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx);
37 int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *a, const BIGNUM *d,
38 BN_CTX *ctx);
39 int BN_mod(BIGNUM *rem, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
40 int BN_nnmod(BIGNUM *rem, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
41 int BN_mod_add(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m,
42 BN_CTX *ctx);
43 int BN_mod_sub(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m,
44 BN_CTX *ctx);
45 int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m,
46 BN_CTX *ctx);
47 int BN_mod_sqr(BIGNUM *ret, BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
48 int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BN_CTX *ctx);
49 int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
50 const BIGNUM *m, BN_CTX *ctx);
51 int BN_gcd(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
52
53 int BN_add_word(BIGNUM *a, BN_ULONG w);
54 int BN_sub_word(BIGNUM *a, BN_ULONG w);
55 int BN_mul_word(BIGNUM *a, BN_ULONG w);
56 BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);
57 BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);
58
59 int BN_cmp(BIGNUM *a, BIGNUM *b);
60 int BN_ucmp(BIGNUM *a, BIGNUM *b);
61 int BN_is_zero(BIGNUM *a);
62 int BN_is_one(BIGNUM *a);
63 int BN_is_word(BIGNUM *a, BN_ULONG w);
64 int BN_is_odd(BIGNUM *a);
65
66 int BN_zero(BIGNUM *a);
67 int BN_one(BIGNUM *a);
68 const BIGNUM *BN_value_one(void);
69 int BN_set_word(BIGNUM *a, unsigned long w);
70 unsigned long BN_get_word(BIGNUM *a);
71
72 int BN_rand(BIGNUM *rnd, int bits, int top, int bottom);
73 int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom);
74 int BN_rand_range(BIGNUM *rnd, BIGNUM *range);
75 int BN_pseudo_rand_range(BIGNUM *rnd, BIGNUM *range);
76
77 BIGNUM *BN_generate_prime(BIGNUM *ret, int bits,int safe, BIGNUM *add,
78 BIGNUM *rem, void (*callback)(int, int, void *), void *cb_arg);
79 int BN_is_prime(const BIGNUM *p, int nchecks,
80 void (*callback)(int, int, void *), BN_CTX *ctx, void *cb_arg);
81
82 int BN_set_bit(BIGNUM *a, int n);
83 int BN_clear_bit(BIGNUM *a, int n);
84 int BN_is_bit_set(const BIGNUM *a, int n);
85 int BN_mask_bits(BIGNUM *a, int n);
86 int BN_lshift(BIGNUM *r, const BIGNUM *a, int n);
87 int BN_lshift1(BIGNUM *r, BIGNUM *a);
88 int BN_rshift(BIGNUM *r, BIGNUM *a, int n);
89 int BN_rshift1(BIGNUM *r, BIGNUM *a);
90
91 int BN_bn2bin(const BIGNUM *a, unsigned char *to);
92 BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
93 char *BN_bn2hex(const BIGNUM *a);
94 char *BN_bn2dec(const BIGNUM *a);
95 int BN_hex2bn(BIGNUM **a, const char *str);
96 int BN_dec2bn(BIGNUM **a, const char *str);
97 int BN_print(BIO *fp, const BIGNUM *a);
98 int BN_print_fp(FILE *fp, const BIGNUM *a);
99 int BN_bn2mpi(const BIGNUM *a, unsigned char *to);
100 BIGNUM *BN_mpi2bn(unsigned char *s, int len, BIGNUM *ret);
101
102 BIGNUM *BN_mod_inverse(BIGNUM *r, BIGNUM *a, const BIGNUM *n,
103 BN_CTX *ctx);
104
105 BN_RECP_CTX *BN_RECP_CTX_new(void);
106 void BN_RECP_CTX_init(BN_RECP_CTX *recp);
107 void BN_RECP_CTX_free(BN_RECP_CTX *recp);
108 int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *m, BN_CTX *ctx);
109 int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *a, BIGNUM *b,
110 BN_RECP_CTX *recp, BN_CTX *ctx);
111
112 BN_MONT_CTX *BN_MONT_CTX_new(void);
113 void BN_MONT_CTX_init(BN_MONT_CTX *ctx);
114 void BN_MONT_CTX_free(BN_MONT_CTX *mont);
115 int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *m, BN_CTX *ctx);
116 BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from);
117 int BN_mod_mul_montgomery(BIGNUM *r, BIGNUM *a, BIGNUM *b,
118 BN_MONT_CTX *mont, BN_CTX *ctx);
119 int BN_from_montgomery(BIGNUM *r, BIGNUM *a, BN_MONT_CTX *mont,
120 BN_CTX *ctx);
121 int BN_to_montgomery(BIGNUM *r, BIGNUM *a, BN_MONT_CTX *mont,
122 BN_CTX *ctx);
123
124 BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai,
125 BIGNUM *mod);
126 void BN_BLINDING_free(BN_BLINDING *b);
127 int BN_BLINDING_update(BN_BLINDING *b,BN_CTX *ctx);
128 int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
129 int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
130 int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b,
131 BN_CTX *ctx);
132 int BN_BLINDING_invert_ex(BIGNUM *n,const BIGNUM *r,BN_BLINDING *b,
133 BN_CTX *ctx);
134 unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *);
135 void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long);
136 unsigned long BN_BLINDING_get_flags(const BN_BLINDING *);
137 void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long);
138 BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b,
139 const BIGNUM *e, BIGNUM *m, BN_CTX *ctx,
140 int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
141 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx),
142 BN_MONT_CTX *m_ctx);
143
144=head1 DESCRIPTION
145
146This library performs arithmetic operations on integers of arbitrary
147size. It was written for use in public key cryptography, such as RSA
148and Diffie-Hellman.
149
150It uses dynamic memory allocation for storing its data structures.
151That means that there is no limit on the size of the numbers
152manipulated by these functions, but return values must always be
153checked in case a memory allocation error has occurred.
154
155The basic object in this library is a B<BIGNUM>. It is used to hold a
156single large integer. This type should be considered opaque and fields
157should not be modified or accessed directly.
158
159The creation of B<BIGNUM> objects is described in L<BN_new(3)|BN_new(3)>;
160L<BN_add(3)|BN_add(3)> describes most of the arithmetic operations.
161Comparison is described in L<BN_cmp(3)|BN_cmp(3)>; L<BN_zero(3)|BN_zero(3)>
162describes certain assignments, L<BN_rand(3)|BN_rand(3)> the generation of
163random numbers, L<BN_generate_prime(3)|BN_generate_prime(3)> deals with prime
164numbers and L<BN_set_bit(3)|BN_set_bit(3)> with bit operations. The conversion
165of B<BIGNUM>s to external formats is described in L<BN_bn2bin(3)|BN_bn2bin(3)>.
166
167=head1 SEE ALSO
168
169L<bn_dump(3)|bn_dump(3)>, L<dh(3)|dh(3)>, L<err(3)|err(3)>,
170L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, L<BN_new(3)|BN_new(3)>,
171L<BN_CTX_new(3)|BN_CTX_new(3)>, L<BN_copy(3)|BN_copy(3)>,
172L<BN_swap(3)|BN_swap(3)>, L<BN_num_bytes(3)|BN_num_bytes(3)>,
173L<BN_add(3)|BN_add(3)>, L<BN_add_word(3)|BN_add_word(3)>,
174L<BN_cmp(3)|BN_cmp(3)>, L<BN_zero(3)|BN_zero(3)>, L<BN_rand(3)|BN_rand(3)>,
175L<BN_generate_prime(3)|BN_generate_prime(3)>, L<BN_set_bit(3)|BN_set_bit(3)>,
176L<BN_bn2bin(3)|BN_bn2bin(3)>, L<BN_mod_inverse(3)|BN_mod_inverse(3)>,
177L<BN_mod_mul_reciprocal(3)|BN_mod_mul_reciprocal(3)>,
178L<BN_mod_mul_montgomery(3)|BN_mod_mul_montgomery(3)>,
179L<BN_BLINDING_new(3)|BN_BLINDING_new(3)>
180
181=cut
diff --git a/src/lib/libcrypto/doc/d2i_DHparams.pod b/src/lib/libcrypto/doc/d2i_DHparams.pod
deleted file mode 100644
index 9f1aac9137..0000000000
--- a/src/lib/libcrypto/doc/d2i_DHparams.pod
+++ /dev/null
@@ -1,26 +0,0 @@
1=pod
2
3=head1 NAME
4
5d2i_DHparams, i2d_DHparams - PKCS#3 DH parameter functions.
6
7=head1 SYNOPSIS
8
9 #include <openssl/dh.h>
10
11 DH *d2i_DHparams(DH **a, unsigned char **pp, long length);
12 int i2d_DHparams(DH *a, unsigned char **pp);
13
14=head1 DESCRIPTION
15
16These functions decode and encode PKCS#3 DH parameters using the
17DHparameter structure described in PKCS#3.
18
19Othewise these behave in a similar way to d2i_X509() and i2d_X509()
20described in the L<d2i_X509(3)|d2i_X509(3)> manual page.
21
22=head1 SEE ALSO
23
24L<d2i_X509(3)|d2i_X509(3)>
25
26=cut
diff --git a/src/lib/libcrypto/doc/d2i_DSAPublicKey.pod b/src/lib/libcrypto/doc/d2i_DSAPublicKey.pod
deleted file mode 100644
index 10c49e3ad2..0000000000
--- a/src/lib/libcrypto/doc/d2i_DSAPublicKey.pod
+++ /dev/null
@@ -1,79 +0,0 @@
1=pod
2
3=head1 NAME
4
5d2i_DSAPublicKey, i2d_DSAPublicKey, d2i_DSAPrivateKey, i2d_DSAPrivateKey,
6d2i_DSA_PUBKEY, i2d_DSA_PUBKEY, d2i_DSAparams, i2d_DSAparams, d2i_DSA_SIG, i2d_DSA_SIG - DSA key encoding
7and parsing functions.
8
9=head1 SYNOPSIS
10
11 #include <openssl/dsa.h>
12 #include <openssl/x509.h>
13
14 DSA * d2i_DSAPublicKey(DSA **a, const unsigned char **pp, long length);
15
16 int i2d_DSAPublicKey(const DSA *a, unsigned char **pp);
17
18 DSA * d2i_DSA_PUBKEY(DSA **a, const unsigned char **pp, long length);
19
20 int i2d_DSA_PUBKEY(const DSA *a, unsigned char **pp);
21
22 DSA * d2i_DSAPrivateKey(DSA **a, const unsigned char **pp, long length);
23
24 int i2d_DSAPrivateKey(const DSA *a, unsigned char **pp);
25
26 DSA * d2i_DSAparams(DSA **a, const unsigned char **pp, long length);
27
28 int i2d_DSAparams(const DSA *a, unsigned char **pp);
29
30 DSA * d2i_DSA_SIG(DSA_SIG **a, const unsigned char **pp, long length);
31
32 int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp);
33
34=head1 DESCRIPTION
35
36d2i_DSAPublicKey() and i2d_DSAPublicKey() decode and encode the DSA public key
37components structure.
38
39d2i_DSA_PUBKEY() and i2d_DSA_PUBKEY() decode and encode an DSA public key using
40a SubjectPublicKeyInfo (certificate public key) structure.
41
42d2i_DSAPrivateKey(), i2d_DSAPrivateKey() decode and encode the DSA private key
43components.
44
45d2i_DSAparams(), i2d_DSAparams() decode and encode the DSA parameters using
46a B<Dss-Parms> structure as defined in RFC2459.
47
48d2i_DSA_SIG(), i2d_DSA_SIG() decode and encode a DSA signature using a
49B<Dss-Sig-Value> structure as defined in RFC2459.
50
51The usage of all of these functions is similar to the d2i_X509() and
52i2d_X509() described in the L<d2i_X509(3)|d2i_X509(3)> manual page.
53
54=head1 NOTES
55
56The B<DSA> structure passed to the private key encoding functions should have
57all the private key components present.
58
59The data encoded by the private key functions is unencrypted and therefore
60offers no private key security.
61
62The B<DSA_PUBKEY> functions should be used in preference to the B<DSAPublicKey>
63functions when encoding public keys because they use a standard format.
64
65The B<DSAPublicKey> functions use an non standard format the actual data encoded
66depends on the value of the B<write_params> field of the B<a> key parameter.
67If B<write_params> is zero then only the B<pub_key> field is encoded as an
68B<INTEGER>. If B<write_params> is 1 then a B<SEQUENCE> consisting of the
69B<p>, B<q>, B<g> and B<pub_key> respectively fields are encoded.
70
71The B<DSAPrivateKey> functions also use a non standard structure consisting
72consisting of a SEQUENCE containing the B<p>, B<q>, B<g> and B<pub_key> and
73B<priv_key> fields respectively.
74
75=head1 SEE ALSO
76
77L<d2i_X509(3)|d2i_X509(3)>
78
79=cut
diff --git a/src/lib/libcrypto/doc/d2i_ECPKParameters.pod b/src/lib/libcrypto/doc/d2i_ECPKParameters.pod
deleted file mode 100644
index 704b4ab352..0000000000
--- a/src/lib/libcrypto/doc/d2i_ECPKParameters.pod
+++ /dev/null
@@ -1,84 +0,0 @@
1=pod
2
3=head1 NAME
4
5d2i_ECPKParameters, i2d_ECPKParameters, d2i_ECPKParameters_bio, i2d_ECPKParameters_bio, d2i_ECPKParameters_fp, i2d_ECPKParameters_fp, ECPKParameters_print, ECPKParameters_print_fp - Functions for decoding and encoding ASN1 representations of elliptic curve entities
6
7=head1 SYNOPSIS
8
9 #include <openssl/ec.h>
10
11 EC_GROUP *d2i_ECPKParameters(EC_GROUP **px, const unsigned char **in, long len);
12 int i2d_ECPKParameters(const EC_GROUP *x, unsigned char **out);
13 #define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x)
14 #define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x)
15 #define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \
16 (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x))
17 #define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \
18 (unsigned char *)(x))
19 int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off);
20 int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off);
21
22
23=head1 DESCRIPTION
24
25The ECPKParameters encode and decode routines encode and parse the public parameters for an
26B<EC_GROUP> structure, which represents a curve.
27
28d2i_ECPKParameters() attempts to decode B<len> bytes at B<*in>. If
29successful a pointer to the B<EC_GROUP> structure is returned. If an error
30occurred then B<NULL> is returned. If B<px> is not B<NULL> then the
31returned structure is written to B<*px>. If B<*px> is not B<NULL>
32then it is assumed that B<*px> contains a valid B<EC_GROUP>
33structure and an attempt is made to reuse it. If the call is
34successful B<*in> is incremented to the byte following the
35parsed data.
36
37i2d_ECPKParameters() encodes the structure pointed to by B<x> into DER format.
38If B<out> is not B<NULL> is writes the DER encoded data to the buffer
39at B<*out>, and increments it to point after the data just written.
40If the return value is negative an error occurred, otherwise it
41returns the length of the encoded data.
42
43If B<*out> is B<NULL> memory will be allocated for a buffer and the encoded
44data written to it. In this case B<*out> is not incremented and it points to
45the start of the data just written.
46
47d2i_ECPKParameters_bio() is similar to d2i_ECPKParameters() except it attempts
48to parse data from BIO B<bp>.
49
50d2i_ECPKParameters_fp() is similar to d2i_ECPKParameters() except it attempts
51to parse data from FILE pointer B<fp>.
52
53i2d_ECPKParameters_bio() is similar to i2d_ECPKParameters() except it writes
54the encoding of the structure B<x> to BIO B<bp> and it
55returns 1 for success and 0 for failure.
56
57i2d_ECPKParameters_fp() is similar to i2d_ECPKParameters() except it writes
58the encoding of the structure B<x> to BIO B<bp> and it
59returns 1 for success and 0 for failure.
60
61These functions are very similar to the X509 functions described in L<d2i_X509(3)|d2i_X509(3)>,
62where further notes and examples are available.
63
64The ECPKParameters_print and ECPKParameters_print_fp functions print a human-readable output
65of the public parameters of the EC_GROUP to B<bp> or B<fp>. The output lines are indented by B<off> spaces.
66
67=head1 RETURN VALUES
68
69d2i_ECPKParameters(), d2i_ECPKParameters_bio() and d2i_ECPKParameters_fp() return a valid B<EC_GROUP> structure
70or B<NULL> if an error occurs.
71
72i2d_ECPKParameters() returns the number of bytes successfully encoded or a negative
73value if an error occurs.
74
75i2d_ECPKParameters_bio(), i2d_ECPKParameters_fp(), ECPKParameters_print and ECPKParameters_print_fp
76return 1 for success and 0 if an error occurs.
77
78=head1 SEE ALSO
79
80L<crypto(3)|crypto(3)>, L<ec(3)|ec(3)>, L<EC_GROUP_new(3)|EC_GROUP_new(3)>, L<EC_GROUP_copy(3)|EC_GROUP_copy(3)>,
81L<EC_POINT_new(3)|EC_POINT_new(3)>, L<EC_POINT_add(3)|EC_POINT_add(3)>, L<EC_KEY_new(3)|EC_KEY_new(3)>,
82L<EC_GFp_simple_method(3)|EC_GFp_simple_method(3)>, L<d2i_X509(3)|d2i_X509(3)>
83
84=cut
diff --git a/src/lib/libcrypto/doc/dh.pod b/src/lib/libcrypto/doc/dh.pod
deleted file mode 100644
index 5fb9890a77..0000000000
--- a/src/lib/libcrypto/doc/dh.pod
+++ /dev/null
@@ -1,79 +0,0 @@
1=pod
2
3=head1 NAME
4
5dh - Diffie-Hellman key agreement
6
7=head1 SYNOPSIS
8
9 #include <openssl/dh.h>
10 #include <openssl/engine.h>
11
12 DH * DH_new(void);
13 void DH_free(DH *dh);
14
15 int DH_size(const DH *dh);
16
17 DH * DH_generate_parameters(int prime_len, int generator,
18 void (*callback)(int, int, void *), void *cb_arg);
19 int DH_check(const DH *dh, int *codes);
20
21 int DH_generate_key(DH *dh);
22 int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh);
23
24 void DH_set_default_method(const DH_METHOD *meth);
25 const DH_METHOD *DH_get_default_method(void);
26 int DH_set_method(DH *dh, const DH_METHOD *meth);
27 DH *DH_new_method(ENGINE *engine);
28 const DH_METHOD *DH_OpenSSL(void);
29
30 int DH_get_ex_new_index(long argl, char *argp, int (*new_func)(),
31 int (*dup_func)(), void (*free_func)());
32 int DH_set_ex_data(DH *d, int idx, char *arg);
33 char *DH_get_ex_data(DH *d, int idx);
34
35 DH * d2i_DHparams(DH **a, unsigned char **pp, long length);
36 int i2d_DHparams(const DH *a, unsigned char **pp);
37
38 int DHparams_print_fp(FILE *fp, const DH *x);
39 int DHparams_print(BIO *bp, const DH *x);
40
41=head1 DESCRIPTION
42
43These functions implement the Diffie-Hellman key agreement protocol. The
44generation of shared DH parameters is described in
45L<DH_generate_parameters(3)|DH_generate_parameters(3)>;
46L<DH_generate_key(3)|DH_generate_key(3)> describes how to perform a key
47agreement.
48
49The B<DH> structure consists of several BIGNUM components.
50
51 struct
52 {
53 BIGNUM *p; // prime number (shared)
54 BIGNUM *g; // generator of Z_p (shared)
55 BIGNUM *priv_key; // private DH value x
56 BIGNUM *pub_key; // public DH value g^x
57 // ...
58 };
59 DH
60
61Note that DH keys may use non-standard B<DH_METHOD> implementations,
62either directly or by the use of B<ENGINE> modules. In some cases (eg. an
63ENGINE providing support for hardware-embedded keys), these BIGNUM values
64will not be used by the implementation or may be used for alternative data
65storage. For this reason, applications should generally avoid using DH
66structure elements directly and instead use API functions to query or
67modify keys.
68
69=head1 SEE ALSO
70
71L<dhparam(1)|dhparam(1)>, L<bn(3)|bn(3)>, L<dsa(3)|dsa(3)>, L<err(3)|err(3)>,
72L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, L<engine(3)|engine(3)>,
73L<DH_set_method(3)|DH_set_method(3)>, L<DH_new(3)|DH_new(3)>,
74L<DH_get_ex_new_index(3)|DH_get_ex_new_index(3)>,
75L<DH_generate_parameters(3)|DH_generate_parameters(3)>,
76L<DH_compute_key(3)|DH_compute_key(3)>, L<d2i_DHparams(3)|d2i_DHparams(3)>,
77L<RSA_print(3)|RSA_print(3)>
78
79=cut
diff --git a/src/lib/libcrypto/doc/dsa.pod b/src/lib/libcrypto/doc/dsa.pod
deleted file mode 100644
index da07d2b930..0000000000
--- a/src/lib/libcrypto/doc/dsa.pod
+++ /dev/null
@@ -1,114 +0,0 @@
1=pod
2
3=head1 NAME
4
5dsa - Digital Signature Algorithm
6
7=head1 SYNOPSIS
8
9 #include <openssl/dsa.h>
10 #include <openssl/engine.h>
11
12 DSA * DSA_new(void);
13 void DSA_free(DSA *dsa);
14
15 int DSA_size(const DSA *dsa);
16
17 DSA * DSA_generate_parameters(int bits, unsigned char *seed,
18 int seed_len, int *counter_ret, unsigned long *h_ret,
19 void (*callback)(int, int, void *), void *cb_arg);
20
21 DH * DSA_dup_DH(const DSA *r);
22
23 int DSA_generate_key(DSA *dsa);
24
25 int DSA_sign(int dummy, const unsigned char *dgst, int len,
26 unsigned char *sigret, unsigned int *siglen, DSA *dsa);
27 int DSA_sign_setup(DSA *dsa, BN_CTX *ctx, BIGNUM **kinvp,
28 BIGNUM **rp);
29 int DSA_verify(int dummy, const unsigned char *dgst, int len,
30 const unsigned char *sigbuf, int siglen, DSA *dsa);
31
32 void DSA_set_default_method(const DSA_METHOD *meth);
33 const DSA_METHOD *DSA_get_default_method(void);
34 int DSA_set_method(DSA *dsa, const DSA_METHOD *meth);
35 DSA *DSA_new_method(ENGINE *engine);
36 const DSA_METHOD *DSA_OpenSSL(void);
37
38 int DSA_get_ex_new_index(long argl, char *argp, int (*new_func)(),
39 int (*dup_func)(), void (*free_func)());
40 int DSA_set_ex_data(DSA *d, int idx, char *arg);
41 char *DSA_get_ex_data(DSA *d, int idx);
42
43 DSA_SIG *DSA_SIG_new(void);
44 void DSA_SIG_free(DSA_SIG *a);
45 int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp);
46 DSA_SIG *d2i_DSA_SIG(DSA_SIG **v, unsigned char **pp, long length);
47
48 DSA_SIG *DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa);
49 int DSA_do_verify(const unsigned char *dgst, int dgst_len,
50 DSA_SIG *sig, DSA *dsa);
51
52 DSA * d2i_DSAPublicKey(DSA **a, unsigned char **pp, long length);
53 DSA * d2i_DSAPrivateKey(DSA **a, unsigned char **pp, long length);
54 DSA * d2i_DSAparams(DSA **a, unsigned char **pp, long length);
55 int i2d_DSAPublicKey(const DSA *a, unsigned char **pp);
56 int i2d_DSAPrivateKey(const DSA *a, unsigned char **pp);
57 int i2d_DSAparams(const DSA *a,unsigned char **pp);
58
59 int DSAparams_print(BIO *bp, const DSA *x);
60 int DSAparams_print_fp(FILE *fp, const DSA *x);
61 int DSA_print(BIO *bp, const DSA *x, int off);
62 int DSA_print_fp(FILE *bp, const DSA *x, int off);
63
64=head1 DESCRIPTION
65
66These functions implement the Digital Signature Algorithm (DSA). The
67generation of shared DSA parameters is described in
68L<DSA_generate_parameters(3)|DSA_generate_parameters(3)>;
69L<DSA_generate_key(3)|DSA_generate_key(3)> describes how to
70generate a signature key. Signature generation and verification are
71described in L<DSA_sign(3)|DSA_sign(3)>.
72
73The B<DSA> structure consists of several BIGNUM components.
74
75 struct
76 {
77 BIGNUM *p; // prime number (public)
78 BIGNUM *q; // 160-bit subprime, q | p-1 (public)
79 BIGNUM *g; // generator of subgroup (public)
80 BIGNUM *priv_key; // private key x
81 BIGNUM *pub_key; // public key y = g^x
82 // ...
83 }
84 DSA;
85
86In public keys, B<priv_key> is NULL.
87
88Note that DSA keys may use non-standard B<DSA_METHOD> implementations,
89either directly or by the use of B<ENGINE> modules. In some cases (eg. an
90ENGINE providing support for hardware-embedded keys), these BIGNUM values
91will not be used by the implementation or may be used for alternative data
92storage. For this reason, applications should generally avoid using DSA
93structure elements directly and instead use API functions to query or
94modify keys.
95
96=head1 CONFORMING TO
97
98US Federal Information Processing Standard FIPS 186 (Digital Signature
99Standard, DSS), ANSI X9.30
100
101=head1 SEE ALSO
102
103L<bn(3)|bn(3)>, L<dh(3)|dh(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>,
104L<rsa(3)|rsa(3)>, L<sha(3)|sha(3)>, L<engine(3)|engine(3)>,
105L<DSA_new(3)|DSA_new(3)>,
106L<DSA_size(3)|DSA_size(3)>,
107L<DSA_generate_parameters(3)|DSA_generate_parameters(3)>,
108L<DSA_dup_DH(3)|DSA_dup_DH(3)>,
109L<DSA_generate_key(3)|DSA_generate_key(3)>,
110L<DSA_sign(3)|DSA_sign(3)>, L<DSA_set_method(3)|DSA_set_method(3)>,
111L<DSA_get_ex_new_index(3)|DSA_get_ex_new_index(3)>,
112L<RSA_print(3)|RSA_print(3)>
113
114=cut
diff --git a/src/lib/libcrypto/doc/ec.pod b/src/lib/libcrypto/doc/ec.pod
deleted file mode 100644
index 891948e4f6..0000000000
--- a/src/lib/libcrypto/doc/ec.pod
+++ /dev/null
@@ -1,201 +0,0 @@
1=pod
2
3=head1 NAME
4
5ec - Elliptic Curve functions
6
7=head1 SYNOPSIS
8
9 #include <openssl/ec.h>
10 #include <openssl/bn.h>
11
12 const EC_METHOD *EC_GFp_simple_method(void);
13 const EC_METHOD *EC_GFp_mont_method(void);
14 const EC_METHOD *EC_GFp_nist_method(void);
15 const EC_METHOD *EC_GFp_nistp224_method(void);
16 const EC_METHOD *EC_GFp_nistp256_method(void);
17 const EC_METHOD *EC_GFp_nistp521_method(void);
18
19 const EC_METHOD *EC_GF2m_simple_method(void);
20
21 EC_GROUP *EC_GROUP_new(const EC_METHOD *meth);
22 void EC_GROUP_free(EC_GROUP *group);
23 void EC_GROUP_clear_free(EC_GROUP *group);
24 int EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src);
25 EC_GROUP *EC_GROUP_dup(const EC_GROUP *src);
26 const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group);
27 int EC_METHOD_get_field_type(const EC_METHOD *meth);
28 int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor);
29 const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group);
30 int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx);
31 int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx);
32 void EC_GROUP_set_curve_name(EC_GROUP *group, int nid);
33 int EC_GROUP_get_curve_name(const EC_GROUP *group);
34 void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag);
35 int EC_GROUP_get_asn1_flag(const EC_GROUP *group);
36 void EC_GROUP_set_point_conversion_form(EC_GROUP *group, point_conversion_form_t form);
37 point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *);
38 unsigned char *EC_GROUP_get0_seed(const EC_GROUP *x);
39 size_t EC_GROUP_get_seed_len(const EC_GROUP *);
40 size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len);
41 int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
42 int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
43 int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
44 int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
45 int EC_GROUP_get_degree(const EC_GROUP *group);
46 int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx);
47 int EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx);
48 int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx);
49 EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
50 EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
51 EC_GROUP *EC_GROUP_new_by_curve_name(int nid);
52
53 size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems);
54
55 EC_POINT *EC_POINT_new(const EC_GROUP *group);
56 void EC_POINT_free(EC_POINT *point);
57 void EC_POINT_clear_free(EC_POINT *point);
58 int EC_POINT_copy(EC_POINT *dst, const EC_POINT *src);
59 EC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group);
60 const EC_METHOD *EC_POINT_method_of(const EC_POINT *point);
61 int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point);
62 int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
63 const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx);
64 int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group,
65 const EC_POINT *p, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx);
66 int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
67 const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx);
68 int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
69 const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
70 int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
71 const BIGNUM *x, int y_bit, BN_CTX *ctx);
72 int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,
73 const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx);
74 int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,
75 const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
76 int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,
77 const BIGNUM *x, int y_bit, BN_CTX *ctx);
78 size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p,
79 point_conversion_form_t form,
80 unsigned char *buf, size_t len, BN_CTX *ctx);
81 int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p,
82 const unsigned char *buf, size_t len, BN_CTX *ctx);
83 BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *,
84 point_conversion_form_t form, BIGNUM *, BN_CTX *);
85 EC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *,
86 EC_POINT *, BN_CTX *);
87 char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *,
88 point_conversion_form_t form, BN_CTX *);
89 EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *,
90 EC_POINT *, BN_CTX *);
91
92 int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx);
93 int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx);
94 int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx);
95 int EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p);
96 int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx);
97 int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx);
98 int EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx);
99 int EC_POINTs_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx);
100 int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, size_t num, const EC_POINT *p[], const BIGNUM *m[], BN_CTX *ctx);
101 int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx);
102 int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx);
103 int EC_GROUP_have_precompute_mult(const EC_GROUP *group);
104
105 int EC_GROUP_get_basis_type(const EC_GROUP *);
106 int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k);
107 int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1,
108 unsigned int *k2, unsigned int *k3);
109 EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len);
110 int i2d_ECPKParameters(const EC_GROUP *, unsigned char **out);
111 #define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x)
112 #define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x)
113 #define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \
114 (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x))
115 #define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \
116 (unsigned char *)(x))
117 int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off);
118 int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off);
119
120 EC_KEY *EC_KEY_new(void);
121 int EC_KEY_get_flags(const EC_KEY *key);
122 void EC_KEY_set_flags(EC_KEY *key, int flags);
123 void EC_KEY_clear_flags(EC_KEY *key, int flags);
124 EC_KEY *EC_KEY_new_by_curve_name(int nid);
125 void EC_KEY_free(EC_KEY *key);
126 EC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src);
127 EC_KEY *EC_KEY_dup(const EC_KEY *src);
128 int EC_KEY_up_ref(EC_KEY *key);
129 const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key);
130 int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group);
131 const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key);
132 int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv);
133 const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key);
134 int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub);
135 unsigned EC_KEY_get_enc_flags(const EC_KEY *key);
136 void EC_KEY_set_enc_flags(EC_KEY *eckey, unsigned int flags);
137 point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key);
138 void EC_KEY_set_conv_form(EC_KEY *eckey, point_conversion_form_t cform);
139 void *EC_KEY_get_key_method_data(EC_KEY *key,
140 void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *));
141 void EC_KEY_insert_key_method_data(EC_KEY *key, void *data,
142 void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *));
143 void EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag);
144 int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx);
145 int EC_KEY_generate_key(EC_KEY *key);
146 int EC_KEY_check_key(const EC_KEY *key);
147 int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, BIGNUM *y);
148
149 EC_KEY *d2i_ECPrivateKey(EC_KEY **key, const unsigned char **in, long len);
150 int i2d_ECPrivateKey(EC_KEY *key, unsigned char **out);
151
152 EC_KEY *d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len);
153 int i2d_ECParameters(EC_KEY *key, unsigned char **out);
154
155 EC_KEY *o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len);
156 int i2o_ECPublicKey(EC_KEY *key, unsigned char **out);
157 int ECParameters_print(BIO *bp, const EC_KEY *key);
158 int EC_KEY_print(BIO *bp, const EC_KEY *key, int off);
159 int ECParameters_print_fp(FILE *fp, const EC_KEY *key);
160 int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off);
161 EC_KEY *ECParameters_dup(EC_KEY *key);
162 #define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \
163 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, EVP_PKEY_OP_PARAMGEN, \
164 EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL)
165
166
167=head1 DESCRIPTION
168
169This library provides an extensive set of functions for performing operations on elliptic curves over finite fields.
170In general an elliptic curve is one with an equation of the form:
171
172y^2 = x^3 + ax + b
173
174An B<EC_GROUP> structure is used to represent the definition of an elliptic curve. Points on a curve are stored using an
175B<EC_POINT> structure. An B<EC_KEY> is used to hold a private/public key pair, where a private key is simply a BIGNUM and a
176public key is a point on a curve (represented by an B<EC_POINT>).
177
178The library contains a number of alternative implementations of the different functions. Each implementation is optimised
179for different scenarios. No matter which implementation is being used, the interface remains the same. The library
180handles calling the correct implementation when an interface function is invoked. An implementation is represented by
181an B<EC_METHOD> structure.
182
183The creation and destruction of B<EC_GROUP> objects is described in L<EC_GROUP_new(3)|EC_GROUP_new(3)>. Functions for
184manipulating B<EC_GROUP> objects are described in L<EC_GROUP_copy(3)|EC_GROUP_copy(3)>.
185
186Functions for creating, destroying and manipulating B<EC_POINT> objects are explained in L<EC_POINT_new(3)|EC_POINT_new(3)>,
187whilst functions for performing mathematical operations and tests on B<EC_POINTs> are coverd in L<EC_POINT_add(3)|EC_POINT_add(3)>.
188
189For working with private and public keys refer to L<EC_KEY_new(3)|EC_KEY_new(3)>. Implementations are covered in
190L<EC_GFp_simple_method(3)|EC_GFp_simple_method(3)>.
191
192For information on encoding and decoding curve parameters to and from ASN1 see L<d2i_ECPKParameters(3)|d2i_ECPKParameters(3)>.
193
194=head1 SEE ALSO
195
196L<crypto(3)|crypto(3)>, L<EC_GROUP_new(3)|EC_GROUP_new(3)>, L<EC_GROUP_copy(3)|EC_GROUP_copy(3)>,
197L<EC_POINT_new(3)|EC_POINT_new(3)>, L<EC_POINT_add(3)|EC_POINT_add(3)>, L<EC_KEY_new(3)|EC_KEY_new(3)>,
198L<EC_GFp_simple_method(3)|EC_GFp_simple_method(3)>, L<d2i_ECPKParameters(3)|d2i_ECPKParameters(3)>
199
200
201=cut
diff --git a/src/lib/libcrypto/doc/engine.pod b/src/lib/libcrypto/doc/engine.pod
deleted file mode 100644
index 31035af398..0000000000
--- a/src/lib/libcrypto/doc/engine.pod
+++ /dev/null
@@ -1,599 +0,0 @@
1=pod
2
3=head1 NAME
4
5ENGINE_add, ENGINE_by_id, ENGINE_finish, ENGINE_get_first,
6ENGINE_get_last, ENGINE_get_next, ENGINE_get_prev,
7ENGINE_init, ENGINE_load_builtin_engines, ENGINE_remove
8- ENGINE cryptographic module support
9
10=head1 SYNOPSIS
11
12 #include <openssl/engine.h>
13
14 ENGINE *ENGINE_get_first(void);
15 ENGINE *ENGINE_get_last(void);
16 ENGINE *ENGINE_get_next(ENGINE *e);
17 ENGINE *ENGINE_get_prev(ENGINE *e);
18
19 int ENGINE_add(ENGINE *e);
20 int ENGINE_remove(ENGINE *e);
21
22 ENGINE *ENGINE_by_id(const char *id);
23
24 int ENGINE_init(ENGINE *e);
25 int ENGINE_finish(ENGINE *e);
26
27 void ENGINE_load_openssl(void);
28 void ENGINE_load_dynamic(void);
29 void ENGINE_load_cryptodev(void);
30 void ENGINE_load_builtin_engines(void);
31
32 void ENGINE_cleanup(void);
33
34 ENGINE *ENGINE_get_default_RSA(void);
35 ENGINE *ENGINE_get_default_DSA(void);
36 ENGINE *ENGINE_get_default_ECDH(void);
37 ENGINE *ENGINE_get_default_ECDSA(void);
38 ENGINE *ENGINE_get_default_DH(void);
39 ENGINE *ENGINE_get_default_RAND(void);
40 ENGINE *ENGINE_get_cipher_engine(int nid);
41 ENGINE *ENGINE_get_digest_engine(int nid);
42
43 int ENGINE_set_default_RSA(ENGINE *e);
44 int ENGINE_set_default_DSA(ENGINE *e);
45 int ENGINE_set_default_ECDH(ENGINE *e);
46 int ENGINE_set_default_ECDSA(ENGINE *e);
47 int ENGINE_set_default_DH(ENGINE *e);
48 int ENGINE_set_default_RAND(ENGINE *e);
49 int ENGINE_set_default_ciphers(ENGINE *e);
50 int ENGINE_set_default_digests(ENGINE *e);
51 int ENGINE_set_default_string(ENGINE *e, const char *list);
52
53 int ENGINE_set_default(ENGINE *e, unsigned int flags);
54
55 unsigned int ENGINE_get_table_flags(void);
56 void ENGINE_set_table_flags(unsigned int flags);
57
58 int ENGINE_register_RSA(ENGINE *e);
59 void ENGINE_unregister_RSA(ENGINE *e);
60 void ENGINE_register_all_RSA(void);
61 int ENGINE_register_DSA(ENGINE *e);
62 void ENGINE_unregister_DSA(ENGINE *e);
63 void ENGINE_register_all_DSA(void);
64 int ENGINE_register_ECDH(ENGINE *e);
65 void ENGINE_unregister_ECDH(ENGINE *e);
66 void ENGINE_register_all_ECDH(void);
67 int ENGINE_register_ECDSA(ENGINE *e);
68 void ENGINE_unregister_ECDSA(ENGINE *e);
69 void ENGINE_register_all_ECDSA(void);
70 int ENGINE_register_DH(ENGINE *e);
71 void ENGINE_unregister_DH(ENGINE *e);
72 void ENGINE_register_all_DH(void);
73 int ENGINE_register_RAND(ENGINE *e);
74 void ENGINE_unregister_RAND(ENGINE *e);
75 void ENGINE_register_all_RAND(void);
76 int ENGINE_register_STORE(ENGINE *e);
77 void ENGINE_unregister_STORE(ENGINE *e);
78 void ENGINE_register_all_STORE(void);
79 int ENGINE_register_ciphers(ENGINE *e);
80 void ENGINE_unregister_ciphers(ENGINE *e);
81 void ENGINE_register_all_ciphers(void);
82 int ENGINE_register_digests(ENGINE *e);
83 void ENGINE_unregister_digests(ENGINE *e);
84 void ENGINE_register_all_digests(void);
85 int ENGINE_register_complete(ENGINE *e);
86 int ENGINE_register_all_complete(void);
87
88 int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void));
89 int ENGINE_cmd_is_executable(ENGINE *e, int cmd);
90 int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name,
91 long i, void *p, void (*f)(void), int cmd_optional);
92 int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg,
93 int cmd_optional);
94
95 int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg);
96 void *ENGINE_get_ex_data(const ENGINE *e, int idx);
97
98 int ENGINE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
99 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
100
101 ENGINE *ENGINE_new(void);
102 int ENGINE_free(ENGINE *e);
103 int ENGINE_up_ref(ENGINE *e);
104
105 int ENGINE_set_id(ENGINE *e, const char *id);
106 int ENGINE_set_name(ENGINE *e, const char *name);
107 int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth);
108 int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth);
109 int ENGINE_set_ECDH(ENGINE *e, const ECDH_METHOD *dh_meth);
110 int ENGINE_set_ECDSA(ENGINE *e, const ECDSA_METHOD *dh_meth);
111 int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth);
112 int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth);
113 int ENGINE_set_STORE(ENGINE *e, const STORE_METHOD *rand_meth);
114 int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f);
115 int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f);
116 int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f);
117 int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f);
118 int ENGINE_set_load_privkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpriv_f);
119 int ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f);
120 int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f);
121 int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f);
122 int ENGINE_set_flags(ENGINE *e, int flags);
123 int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns);
124
125 const char *ENGINE_get_id(const ENGINE *e);
126 const char *ENGINE_get_name(const ENGINE *e);
127 const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e);
128 const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e);
129 const ECDH_METHOD *ENGINE_get_ECDH(const ENGINE *e);
130 const ECDSA_METHOD *ENGINE_get_ECDSA(const ENGINE *e);
131 const DH_METHOD *ENGINE_get_DH(const ENGINE *e);
132 const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e);
133 const STORE_METHOD *ENGINE_get_STORE(const ENGINE *e);
134 ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e);
135 ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e);
136 ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e);
137 ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const ENGINE *e);
138 ENGINE_LOAD_KEY_PTR ENGINE_get_load_privkey_function(const ENGINE *e);
139 ENGINE_LOAD_KEY_PTR ENGINE_get_load_pubkey_function(const ENGINE *e);
140 ENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e);
141 ENGINE_DIGESTS_PTR ENGINE_get_digests(const ENGINE *e);
142 const EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid);
143 const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid);
144 int ENGINE_get_flags(const ENGINE *e);
145 const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e);
146
147 EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id,
148 UI_METHOD *ui_method, void *callback_data);
149 EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id,
150 UI_METHOD *ui_method, void *callback_data);
151
152 void ENGINE_add_conf_module(void);
153
154=head1 DESCRIPTION
155
156These functions create, manipulate, and use cryptographic modules in the
157form of B<ENGINE> objects. These objects act as containers for
158implementations of cryptographic algorithms, and support a
159reference-counted mechanism to allow them to be dynamically loaded in and
160out of the running application.
161
162The cryptographic functionality that can be provided by an B<ENGINE>
163implementation includes the following abstractions;
164
165 RSA_METHOD - for providing alternative RSA implementations
166 DSA_METHOD, DH_METHOD, RAND_METHOD, ECDH_METHOD, ECDSA_METHOD,
167 STORE_METHOD - similarly for other OpenSSL APIs
168 EVP_CIPHER - potentially multiple cipher algorithms (indexed by 'nid')
169 EVP_DIGEST - potentially multiple hash algorithms (indexed by 'nid')
170 key-loading - loading public and/or private EVP_PKEY keys
171
172=head2 Reference counting and handles
173
174Due to the modular nature of the ENGINE API, pointers to ENGINEs need to be
175treated as handles - ie. not only as pointers, but also as references to
176the underlying ENGINE object. Ie. one should obtain a new reference when
177making copies of an ENGINE pointer if the copies will be used (and
178released) independently.
179
180ENGINE objects have two levels of reference-counting to match the way in
181which the objects are used. At the most basic level, each ENGINE pointer is
182inherently a B<structural> reference - a structural reference is required
183to use the pointer value at all, as this kind of reference is a guarantee
184that the structure can not be deallocated until the reference is released.
185
186However, a structural reference provides no guarantee that the ENGINE is
187initialised and able to use any of its cryptographic
188implementations. Indeed it's quite possible that most ENGINEs will not
189initialise at all in typical environments, as ENGINEs are typically used to
190support specialised hardware. To use an ENGINE's functionality, you need a
191B<functional> reference. This kind of reference can be considered a
192specialised form of structural reference, because each functional reference
193implicitly contains a structural reference as well - however to avoid
194difficult-to-find programming bugs, it is recommended to treat the two
195kinds of reference independently. If you have a functional reference to an
196ENGINE, you have a guarantee that the ENGINE has been initialised ready to
197perform cryptographic operations and will remain uninitialised
198until after you have released your reference.
199
200I<Structural references>
201
202This basic type of reference is used for instantiating new ENGINEs,
203iterating across OpenSSL's internal linked-list of loaded
204ENGINEs, reading information about an ENGINE, etc. Essentially a structural
205reference is sufficient if you only need to query or manipulate the data of
206an ENGINE implementation rather than use its functionality.
207
208The ENGINE_new() function returns a structural reference to a new (empty)
209ENGINE object. There are other ENGINE API functions that return structural
210references such as; ENGINE_by_id(), ENGINE_get_first(), ENGINE_get_last(),
211ENGINE_get_next(), ENGINE_get_prev(). All structural references should be
212released by a corresponding to call to the ENGINE_free() function - the
213ENGINE object itself will only actually be cleaned up and deallocated when
214the last structural reference is released.
215
216It should also be noted that many ENGINE API function calls that accept a
217structural reference will internally obtain another reference - typically
218this happens whenever the supplied ENGINE will be needed by OpenSSL after
219the function has returned. Eg. the function to add a new ENGINE to
220OpenSSL's internal list is ENGINE_add() - if this function returns success,
221then OpenSSL will have stored a new structural reference internally so the
222caller is still responsible for freeing their own reference with
223ENGINE_free() when they are finished with it. In a similar way, some
224functions will automatically release the structural reference passed to it
225if part of the function's job is to do so. Eg. the ENGINE_get_next() and
226ENGINE_get_prev() functions are used for iterating across the internal
227ENGINE list - they will return a new structural reference to the next (or
228previous) ENGINE in the list or NULL if at the end (or beginning) of the
229list, but in either case the structural reference passed to the function is
230released on behalf of the caller.
231
232To clarify a particular function's handling of references, one should
233always consult that function's documentation "man" page, or failing that
234the openssl/engine.h header file includes some hints.
235
236I<Functional references>
237
238As mentioned, functional references exist when the cryptographic
239functionality of an ENGINE is required to be available. A functional
240reference can be obtained in one of two ways; from an existing structural
241reference to the required ENGINE, or by asking OpenSSL for the default
242operational ENGINE for a given cryptographic purpose.
243
244To obtain a functional reference from an existing structural reference,
245call the ENGINE_init() function. This returns zero if the ENGINE was not
246already operational and couldn't be successfully initialised (eg. lack of
247system drivers, no special hardware attached, etc), otherwise it will
248return non-zero to indicate that the ENGINE is now operational and will
249have allocated a new B<functional> reference to the ENGINE. All functional
250references are released by calling ENGINE_finish() (which removes the
251implicit structural reference as well).
252
253The second way to get a functional reference is by asking OpenSSL for a
254default implementation for a given task, eg. by ENGINE_get_default_RSA(),
255ENGINE_get_default_cipher_engine(), etc. These are discussed in the next
256section, though they are not usually required by application programmers as
257they are used automatically when creating and using the relevant
258algorithm-specific types in OpenSSL, such as RSA, DSA, EVP_CIPHER_CTX, etc.
259
260=head2 Default implementations
261
262For each supported abstraction, the ENGINE code maintains an internal table
263of state to control which implementations are available for a given
264abstraction and which should be used by default. These implementations are
265registered in the tables and indexed by an 'nid' value, because
266abstractions like EVP_CIPHER and EVP_DIGEST support many distinct
267algorithms and modes, and ENGINEs can support arbitrarily many of them.
268In the case of other abstractions like RSA, DSA, etc, there is only one
269"algorithm" so all implementations implicitly register using the same 'nid'
270index.
271
272When a default ENGINE is requested for a given abstraction/algorithm/mode, (eg.
273when calling RSA_new_method(NULL)), a "get_default" call will be made to the
274ENGINE subsystem to process the corresponding state table and return a
275functional reference to an initialised ENGINE whose implementation should be
276used. If no ENGINE should (or can) be used, it will return NULL and the caller
277will operate with a NULL ENGINE handle - this usually equates to using the
278conventional software implementation. In the latter case, OpenSSL will from
279then on behave the way it used to before the ENGINE API existed.
280
281Each state table has a flag to note whether it has processed this
282"get_default" query since the table was last modified, because to process
283this question it must iterate across all the registered ENGINEs in the
284table trying to initialise each of them in turn, in case one of them is
285operational. If it returns a functional reference to an ENGINE, it will
286also cache another reference to speed up processing future queries (without
287needing to iterate across the table). Likewise, it will cache a NULL
288response if no ENGINE was available so that future queries won't repeat the
289same iteration unless the state table changes. This behaviour can also be
290changed; if the ENGINE_TABLE_FLAG_NOINIT flag is set (using
291ENGINE_set_table_flags()), no attempted initialisations will take place,
292instead the only way for the state table to return a non-NULL ENGINE to the
293"get_default" query will be if one is expressly set in the table. Eg.
294ENGINE_set_default_RSA() does the same job as ENGINE_register_RSA() except
295that it also sets the state table's cached response for the "get_default"
296query. In the case of abstractions like EVP_CIPHER, where implementations are
297indexed by 'nid', these flags and cached-responses are distinct for each 'nid'
298value.
299
300=head2 Application requirements
301
302This section will explain the basic things an application programmer should
303support to make the most useful elements of the ENGINE functionality
304available to the user. The first thing to consider is whether the
305programmer wishes to make alternative ENGINE modules available to the
306application and user. OpenSSL maintains an internal linked list of
307"visible" ENGINEs from which it has to operate - at start-up, this list is
308empty and in fact if an application does not call any ENGINE API calls and
309it uses static linking against openssl, then the resulting application
310binary will not contain any alternative ENGINE code at all. So the first
311consideration is whether any/all available ENGINE implementations should be
312made visible to OpenSSL - this is controlled by calling the various "load"
313functions, eg.
314
315 /* Make ALL ENGINE implementations bundled with OpenSSL available */
316 ENGINE_load_builtin_engines();
317
318Note that ENGINE_load_dynamic(void) is a placeholder and does not enable
319dynamic engine loading support.
320
321Having called any of these functions, ENGINE objects would have been
322dynamically allocated and populated with these implementations and linked
323into OpenSSL's internal linked list. At this point it is important to
324mention an important API function;
325
326 void ENGINE_cleanup(void);
327
328If no ENGINE API functions are called at all in an application, then there
329are no inherent memory leaks to worry about from the ENGINE functionality,
330however if any ENGINEs are loaded, even if they are never registered or
331used, it is necessary to use the ENGINE_cleanup() function to
332correspondingly cleanup before program exit, if the caller wishes to avoid
333memory leaks. This mechanism uses an internal callback registration table
334so that any ENGINE API functionality that knows it requires cleanup can
335register its cleanup details to be called during ENGINE_cleanup(). This
336approach allows ENGINE_cleanup() to clean up after any ENGINE functionality
337at all that your program uses, yet doesn't automatically create linker
338dependencies to all possible ENGINE functionality - only the cleanup
339callbacks required by the functionality you do use will be required by the
340linker.
341
342The fact that ENGINEs are made visible to OpenSSL (and thus are linked into
343the program and loaded into memory at run-time) does not mean they are
344"registered" or called into use by OpenSSL automatically - that behaviour
345is something for the application to control. Some applications
346will want to allow the user to specify exactly which ENGINE they want used
347if any is to be used at all. Others may prefer to load all support and have
348OpenSSL automatically use at run-time any ENGINE that is able to
349successfully initialise - ie. to assume that this corresponds to
350acceleration hardware attached to the machine or some such thing. There are
351probably numerous other ways in which applications may prefer to handle
352things, so we will simply illustrate the consequences as they apply to a
353couple of simple cases and leave developers to consider these and the
354source code to openssl's builtin utilities as guides.
355
356I<Using a specific ENGINE implementation>
357
358Here we'll assume an application has been configured by its user or admin
359to want to use the "ACME" ENGINE if it is available in the version of
360OpenSSL the application was compiled with. If it is available, it should be
361used by default for all RSA, DSA, and symmetric cipher operation, otherwise
362OpenSSL should use its builtin software as per usual. The following code
363illustrates how to approach this;
364
365 ENGINE *e;
366 const char *engine_id = "ACME";
367 ENGINE_load_builtin_engines();
368 e = ENGINE_by_id(engine_id);
369 if (!e)
370 /* the engine isn't available */
371 return;
372 if (!ENGINE_init(e)) {
373 /* the engine couldn't initialise, release 'e' */
374 ENGINE_free(e);
375 return;
376 }
377 if (!ENGINE_set_default_RSA(e))
378 /* This should only happen when 'e' can't initialise, but the previous
379 * statement suggests it did. */
380 abort();
381 ENGINE_set_default_DSA(e);
382 ENGINE_set_default_ciphers(e);
383 /* Release the functional reference from ENGINE_init() */
384 ENGINE_finish(e);
385 /* Release the structural reference from ENGINE_by_id() */
386 ENGINE_free(e);
387
388I<Automatically using builtin ENGINE implementations>
389
390Here we'll assume we want to load and register all ENGINE implementations
391bundled with OpenSSL, such that for any cryptographic algorithm required by
392OpenSSL - if there is an ENGINE that implements it and can be initialise,
393it should be used. The following code illustrates how this can work;
394
395 /* Load all bundled ENGINEs into memory and make them visible */
396 ENGINE_load_builtin_engines();
397 /* Register all of them for every algorithm they collectively implement */
398 ENGINE_register_all_complete();
399
400That's all that's required. Eg. the next time OpenSSL tries to set up an
401RSA key, any bundled ENGINEs that implement RSA_METHOD will be passed to
402ENGINE_init() and if any of those succeed, that ENGINE will be set as the
403default for RSA use from then on.
404
405=head2 Advanced configuration support
406
407There is a mechanism supported by the ENGINE framework that allows each
408ENGINE implementation to define an arbitrary set of configuration
409"commands" and expose them to OpenSSL and any applications based on
410OpenSSL. This mechanism is entirely based on the use of name-value pairs
411and assumes ASCII input (no unicode or UTF for now!), so it is ideal if
412applications want to provide a transparent way for users to provide
413arbitrary configuration "directives" directly to such ENGINEs. It is also
414possible for the application to dynamically interrogate the loaded ENGINE
415implementations for the names, descriptions, and input flags of their
416available "control commands", providing a more flexible configuration
417scheme. However, if the user is expected to know which ENGINE device he/she
418is using (in the case of specialised hardware, this goes without saying)
419then applications may not need to concern themselves with discovering the
420supported control commands and simply prefer to pass settings into ENGINEs
421exactly as they are provided by the user.
422
423Before illustrating how control commands work, it is worth mentioning what
424they are typically used for. Broadly speaking there are two uses for
425control commands; the first is to provide the necessary details to the
426implementation (which may know nothing at all specific to the host system)
427so that it can be initialised for use. This could include the path to any
428driver or config files it needs to load, required network addresses,
429smart-card identifiers, passwords to initialise protected devices,
430logging information, etc etc. This class of commands typically needs to be
431passed to an ENGINE B<before> attempting to initialise it, ie. before
432calling ENGINE_init(). The other class of commands consist of settings or
433operations that tweak certain behaviour or cause certain operations to take
434place, and these commands may work either before or after ENGINE_init(), or
435in some cases both. ENGINE implementations should provide indications of
436this in the descriptions attached to builtin control commands and/or in
437external product documentation.
438
439I<Issuing control commands to an ENGINE>
440
441Let's illustrate by example; a function for which the caller supplies the
442name of the ENGINE it wishes to use, a table of string-pairs for use before
443initialisation, and another table for use after initialisation. Note that
444the string-pairs used for control commands consist of a command "name"
445followed by the command "parameter" - the parameter could be NULL in some
446cases but the name can not. This function should initialise the ENGINE
447(issuing the "pre" commands beforehand and the "post" commands afterwards)
448and set it as the default for everything except RAND and then return a
449boolean success or failure.
450
451 int
452 generic_load_engine_fn(const char *engine_id,
453 const char **pre_cmds, int pre_num,
454 const char **post_cmds, int post_num)
455 {
456 ENGINE *e = ENGINE_by_id(engine_id);
457
458 if (!e)
459 return 0;
460 while (pre_num--) {
461 if (!ENGINE_ctrl_cmd_string(e,
462 pre_cmds[0], pre_cmds[1], 0)) {
463 fprintf(stderr,
464 "Failed command (%s - %s:%s)\n",
465 engine_id, pre_cmds[0],
466 pre_cmds[1] ? pre_cmds[1] : "(NULL)");
467 ENGINE_free(e);
468 return 0;
469 }
470 pre_cmds += 2;
471 }
472 if (!ENGINE_init(e)) {
473 fprintf(stderr, "Failed initialisation\n");
474 ENGINE_free(e);
475 return 0;
476 }
477 /*
478 * ENGINE_init() returned a functional reference,
479 * so free the structural reference from
480 * ENGINE_by_id().
481 */
482 ENGINE_free(e);
483 while (post_num--) {
484 if (!ENGINE_ctrl_cmd_string(e,
485 post_cmds[0], post_cmds[1], 0)) {
486 fprintf(stderr,
487 "Failed command (%s - %s:%s)\n",
488 engine_id, post_cmds[0],
489 post_cmds[1] ? post_cmds[1] : "(NULL)");
490 ENGINE_finish(e);
491 return 0;
492 }
493 post_cmds += 2;
494 }
495 ENGINE_set_default(e, ENGINE_METHOD_ALL & ~ENGINE_METHOD_RAND);
496 /* Success */
497 return 1;
498}
499
500Note that ENGINE_ctrl_cmd_string() accepts a boolean argument that can
501relax the semantics of the function - if set non-zero it will only return
502failure if the ENGINE supported the given command name but failed while
503executing it, if the ENGINE doesn't support the command name it will simply
504return success without doing anything. In this case we assume the user is
505only supplying commands specific to the given ENGINE so we set this to
506FALSE.
507
508I<Discovering supported control commands>
509
510It is possible to discover at run-time the names, numerical-ids, descriptions
511and input parameters of the control commands supported by an ENGINE using a
512structural reference. Note that some control commands are defined by OpenSSL
513itself and it will intercept and handle these control commands on behalf of the
514ENGINE, ie. the ENGINE's ctrl() handler is not used for the control command.
515openssl/engine.h defines an index, ENGINE_CMD_BASE, that all control commands
516implemented by ENGINEs should be numbered from. Any command value lower than
517this symbol is considered a "generic" command is handled directly by the
518OpenSSL core routines.
519
520It is using these "core" control commands that one can discover the control
521commands implemented by a given ENGINE, specifically the commands;
522
523 #define ENGINE_HAS_CTRL_FUNCTION 10
524 #define ENGINE_CTRL_GET_FIRST_CMD_TYPE 11
525 #define ENGINE_CTRL_GET_NEXT_CMD_TYPE 12
526 #define ENGINE_CTRL_GET_CMD_FROM_NAME 13
527 #define ENGINE_CTRL_GET_NAME_LEN_FROM_CMD 14
528 #define ENGINE_CTRL_GET_NAME_FROM_CMD 15
529 #define ENGINE_CTRL_GET_DESC_LEN_FROM_CMD 16
530 #define ENGINE_CTRL_GET_DESC_FROM_CMD 17
531 #define ENGINE_CTRL_GET_CMD_FLAGS 18
532
533Whilst these commands are automatically processed by the OpenSSL framework code,
534they use various properties exposed by each ENGINE to process these
535queries. An ENGINE has 3 properties it exposes that can affect how this behaves;
536it can supply a ctrl() handler, it can specify ENGINE_FLAGS_MANUAL_CMD_CTRL in
537the ENGINE's flags, and it can expose an array of control command descriptions.
538If an ENGINE specifies the ENGINE_FLAGS_MANUAL_CMD_CTRL flag, then it will
539simply pass all these "core" control commands directly to the ENGINE's ctrl()
540handler (and thus, it must have supplied one), so it is up to the ENGINE to
541reply to these "discovery" commands itself. If that flag is not set, then the
542OpenSSL framework code will work with the following rules;
543
544 if no ctrl() handler supplied;
545 ENGINE_HAS_CTRL_FUNCTION returns FALSE (zero),
546 all other commands fail.
547 if a ctrl() handler was supplied but no array of control commands;
548 ENGINE_HAS_CTRL_FUNCTION returns TRUE,
549 all other commands fail.
550 if a ctrl() handler and array of control commands was supplied;
551 ENGINE_HAS_CTRL_FUNCTION returns TRUE,
552 all other commands proceed processing ...
553
554If the ENGINE's array of control commands is empty then all other commands will
555fail, otherwise; ENGINE_CTRL_GET_FIRST_CMD_TYPE returns the identifier of
556the first command supported by the ENGINE, ENGINE_GET_NEXT_CMD_TYPE takes the
557identifier of a command supported by the ENGINE and returns the next command
558identifier or fails if there are no more, ENGINE_CMD_FROM_NAME takes a string
559name for a command and returns the corresponding identifier or fails if no such
560command name exists, and the remaining commands take a command identifier and
561return properties of the corresponding commands. All except
562ENGINE_CTRL_GET_FLAGS return the string length of a command name or description,
563or populate a supplied character buffer with a copy of the command name or
564description. ENGINE_CTRL_GET_FLAGS returns a bitwise-OR'd mask of the following
565possible values;
566
567 #define ENGINE_CMD_FLAG_NUMERIC (unsigned int)0x0001
568 #define ENGINE_CMD_FLAG_STRING (unsigned int)0x0002
569 #define ENGINE_CMD_FLAG_NO_INPUT (unsigned int)0x0004
570 #define ENGINE_CMD_FLAG_INTERNAL (unsigned int)0x0008
571
572If the ENGINE_CMD_FLAG_INTERNAL flag is set, then any other flags are purely
573informational to the caller - this flag will prevent the command being usable
574for any higher-level ENGINE functions such as ENGINE_ctrl_cmd_string().
575"INTERNAL" commands are not intended to be exposed to text-based configuration
576by applications, administrations, users, etc. These can support arbitrary
577operations via ENGINE_ctrl(), including passing to and/or from the control
578commands data of any arbitrary type. These commands are supported in the
579discovery mechanisms simply allow applications to determine if an ENGINE
580supports certain specific commands it might want to use (eg. application "foo"
581might query various ENGINEs to see if they implement "FOO_GET_VENDOR_LOGO_GIF" -
582and ENGINE could therefore decide whether or not to support this "foo"-specific
583extension).
584
585=head2 Future developments
586
587The ENGINE API and internal architecture is currently being reviewed. Slated for
588possible release in 0.9.8 is support for transparent loading of "dynamic"
589ENGINEs (built as self-contained shared-libraries). This would allow ENGINE
590implementations to be provided independently of OpenSSL libraries and/or
591OpenSSL-based applications, and would also remove any requirement for
592applications to explicitly use the "dynamic" ENGINE to bind to shared-library
593implementations.
594
595=head1 SEE ALSO
596
597L<rsa(3)|rsa(3)>, L<dsa(3)|dsa(3)>, L<dh(3)|dh(3)>, L<rand(3)|rand(3)>
598
599=cut
diff --git a/src/lib/libcrypto/doc/lh_stats.pod b/src/lib/libcrypto/doc/lh_stats.pod
deleted file mode 100644
index 15f97b5545..0000000000
--- a/src/lib/libcrypto/doc/lh_stats.pod
+++ /dev/null
@@ -1,60 +0,0 @@
1=pod
2
3=head1 NAME
4
5lh_stats, lh_node_stats, lh_node_usage_stats, lh_stats_bio,
6lh_node_stats_bio, lh_node_usage_stats_bio - LHASH statistics
7
8=head1 SYNOPSIS
9
10 #include <openssl/lhash.h>
11
12 void lh_stats(LHASH *table, FILE *out);
13 void lh_node_stats(LHASH *table, FILE *out);
14 void lh_node_usage_stats(LHASH *table, FILE *out);
15
16 void lh_stats_bio(LHASH *table, BIO *out);
17 void lh_node_stats_bio(LHASH *table, BIO *out);
18 void lh_node_usage_stats_bio(LHASH *table, BIO *out);
19
20=head1 DESCRIPTION
21
22The B<LHASH> structure records statistics about most aspects of
23accessing the hash table. This is mostly a legacy of Eric Young
24writing this library for the reasons of implementing what looked like
25a nice algorithm rather than for a particular software product.
26
27lh_stats() prints out statistics on the size of the hash table, how
28many entries are in it, and the number and result of calls to the
29routines in this library.
30
31lh_node_stats() prints the number of entries for each 'bucket' in the
32hash table.
33
34lh_node_usage_stats() prints out a short summary of the state of the
35hash table. It prints the 'load' and the 'actual load'. The load is
36the average number of data items per 'bucket' in the hash table. The
37'actual load' is the average number of items per 'bucket', but only
38for buckets which contain entries. So the 'actual load' is the
39average number of searches that will need to find an item in the hash
40table, while the 'load' is the average number that will be done to
41record a miss.
42
43lh_stats_bio(), lh_node_stats_bio() and lh_node_usage_stats_bio()
44are the same as the above, except that the output goes to a B<BIO>.
45
46=head1 RETURN VALUES
47
48These functions do not return values.
49
50=head1 SEE ALSO
51
52L<bio(3)|bio(3)>, L<lh_new(3)|lh_new(3)>
53
54=head1 HISTORY
55
56These functions are available in all versions of SSLeay and OpenSSL.
57
58This manpage is derived from the SSLeay documentation.
59
60=cut
diff --git a/src/lib/libcrypto/man/Makefile b/src/lib/libcrypto/man/Makefile
index 7819029ff6..81840a0b29 100644
--- a/src/lib/libcrypto/man/Makefile
+++ b/src/lib/libcrypto/man/Makefile
@@ -1,9 +1,7 @@
1# $OpenBSD: Makefile,v 1.47 2016/11/04 18:07:23 beck Exp $ 1# $OpenBSD: Makefile,v 1.48 2016/11/05 13:36:33 schwarze Exp $
2 2
3.include <bsd.own.mk> # for NOMAN 3.include <bsd.own.mk> # for NOMAN
4 4
5POD2MAN=pod2man --official --release="OpenBSD ${OSREV}" --center=OpenSSL
6
7.ifndef NOMAN 5.ifndef NOMAN
8MAN= \ 6MAN= \
9 ASN1_OBJECT_new.3 \ 7 ASN1_OBJECT_new.3 \
@@ -138,6 +136,8 @@ MAN= \
138 RAND_cleanup.3 \ 136 RAND_cleanup.3 \
139 RAND_load_file.3 \ 137 RAND_load_file.3 \
140 RAND_set_rand_method.3 \ 138 RAND_set_rand_method.3 \
139 RC4.3 \
140 RIPEMD160.3 \
141 RSA_blinding_on.3 \ 141 RSA_blinding_on.3 \
142 RSA_check_key.3 \ 142 RSA_check_key.3 \
143 RSA_generate_key.3 \ 143 RSA_generate_key.3 \
@@ -151,6 +151,7 @@ MAN= \
151 RSA_sign.3 \ 151 RSA_sign.3 \
152 RSA_sign_ASN1_OCTET_STRING.3 \ 152 RSA_sign_ASN1_OCTET_STRING.3 \
153 RSA_size.3 \ 153 RSA_size.3 \
154 SHA1.3 \
154 SMIME_read_PKCS7.3 \ 155 SMIME_read_PKCS7.3 \
155 SMIME_write_PKCS7.3 \ 156 SMIME_write_PKCS7.3 \
156 UI_new.3 \ 157 UI_new.3 \
@@ -166,9 +167,13 @@ MAN= \
166 X509_VERIFY_PARAM_set_flags.3 \ 167 X509_VERIFY_PARAM_set_flags.3 \
167 X509_new.3 \ 168 X509_new.3 \
168 X509_verify_cert.3 \ 169 X509_verify_cert.3 \
170 bn.3 \
169 bn_dump.3 \ 171 bn_dump.3 \
170 crypto.3 \ 172 crypto.3 \
171 d2i_ASN1_OBJECT.3 \ 173 d2i_ASN1_OBJECT.3 \
174 d2i_DHparams.3 \
175 d2i_DSAPublicKey.3 \
176 d2i_ECPKParameters.3 \
172 d2i_PKCS8PrivateKey_bio.3 \ 177 d2i_PKCS8PrivateKey_bio.3 \
173 d2i_RSAPublicKey.3 \ 178 d2i_RSAPublicKey.3 \
174 d2i_X509.3 \ 179 d2i_X509.3 \
@@ -178,27 +183,16 @@ MAN= \
178 d2i_X509_REQ.3 \ 183 d2i_X509_REQ.3 \
179 d2i_X509_SIG.3 \ 184 d2i_X509_SIG.3 \
180 des_read_pw.3 \ 185 des_read_pw.3 \
181 evp.3 \
182 i2d_PKCS7_bio_stream.3 \
183 lh_new.3 \
184 rsa.3 \
185 x509.3
186
187GENMAN= \
188 RC4.3 \
189 RIPEMD160.3 \
190 SHA1.3 \
191 bn.3 \
192 d2i_DHparams.3 \
193 d2i_DSAPublicKey.3 \
194 d2i_ECPKParameters.3 \
195 dh.3 \ 186 dh.3 \
196 dsa.3 \ 187 dsa.3 \
197 ec.3 \ 188 ec.3 \
198 engine.3 \ 189 engine.3 \
190 evp.3 \
191 i2d_PKCS7_bio_stream.3 \
192 lh_new.3 \
199 lh_stats.3 \ 193 lh_stats.3 \
200 194 rsa.3 \
201MAN+= ${GENMAN} 195 x509.3
202 196
203.include <bsd.man.mk> 197.include <bsd.man.mk>
204.else 198.else
@@ -206,16 +200,7 @@ maninstall:
206 200
207.endif 201.endif
208 202
209.PATH: ${.CURDIR}/../doc
210.SUFFIXES: .pod .1 .3 .7
211.for sect in 1 3 7
212.pod.${sect}:
213 @echo '${POD2MAN} --section=${sect} --name=${*:U} $< > $@'
214 @${POD2MAN} --section=${sect} --name=${*:U} $< > $@.tmp && mv $@.tmp $@
215.endfor
216
217.include <bsd.obj.mk> 203.include <bsd.obj.mk>
218.include <bsd.subdir.mk> 204.include <bsd.subdir.mk>
219 205
220clean cleandir: 206clean cleandir:
221 rm -f ${GENMAN}
diff --git a/src/lib/libcrypto/man/RC4.3 b/src/lib/libcrypto/man/RC4.3
new file mode 100644
index 0000000000..2c631c36be
--- /dev/null
+++ b/src/lib/libcrypto/man/RC4.3
@@ -0,0 +1,79 @@
1.Dd $Mdocdate: November 5 2016 $
2.Dt RC4 3
3.Os
4.Sh NAME
5.Nm RC4_set_key ,
6.Nm RC4
7.Nd RC4 encryption
8.Sh SYNOPSIS
9.In openssl/rc4.h
10.Ft void
11.Fo RC4_set_key
12.Fa "RC4_KEY *key"
13.Fa "int len"
14.Fa "const unsigned char *data"
15.Fc
16.Ft void
17.Fo RC4
18.Fa "RC4_KEY *key"
19.Fa "unsigned long len"
20.Fa "const unsigned char *indata"
21.Fa "unsigned char *outdata"
22.Fc
23.Sh DESCRIPTION
24This library implements the alleged RC4 cipher, which is described for
25example in
26.%B Applied Cryptography .
27It is believed to be compatible with RC4[TM], a proprietary cipher of
28RSA Security Inc.
29.Pp
30RC4 is a stream cipher with variable key length.
31Typically, 128 bit (16 byte) keys are used for strong encryption, but
32shorter insecure key sizes have been widely used due to export
33restrictions.
34.Pp
35RC4 consists of a key setup phase and the actual encryption or
36decryption phase.
37.Pp
38.Fn RC4_set_key
39sets up the
40.Vt RC4_KEY
41.Fa key
42using the
43.Fa len
44bytes long key at
45.Fa data .
46.Pp
47.Fn RC4
48encrypts or decrypts the
49.Fa len
50bytes of data at
51.Fa indata
52using
53.Fa key
54and places the result at
55.Fa outdata .
56Repeated
57.Fn RC4
58calls with the same
59.Fa key
60yield a continuous key stream.
61.Pp
62Since RC4 is a stream cipher (the input is XOR'ed with a pseudo-random
63key stream to produce the output), decryption uses the same function
64calls as encryption.
65.Sh RETURN VALUES
66.Fn RC4_set_key
67and
68.Fn RC4
69do not return values.
70.Sh SEE ALSO
71.Xr blowfish 3 ,
72.Xr EVP_EncryptInit 3
73.Sh HISTORY
74.Fn RC4_set_key
75and
76.Fn RC4
77are available in all versions of SSLeay and OpenSSL.
78.Sh BUGS
79This cipher is broken and should no longer be used.
diff --git a/src/lib/libcrypto/man/RIPEMD160.3 b/src/lib/libcrypto/man/RIPEMD160.3
new file mode 100644
index 0000000000..57cff8a9e4
--- /dev/null
+++ b/src/lib/libcrypto/man/RIPEMD160.3
@@ -0,0 +1,96 @@
1.Dd $Mdocdate: November 5 2016 $
2.Dt RIPEMD160 3
3.Os
4.Sh NAME
5.Nm RIPEMD160 ,
6.Nm RIPEMD160_Init ,
7.Nm RIPEMD160_Update ,
8.Nm RIPEMD160_Final
9.Nd RIPEMD-160 hash function
10.Sh SYNOPSIS
11.In openssl/ripemd.h
12.Ft unsigned char *
13.Fo RIPEMD160
14.Fa "const unsigned char *d"
15.Fa "unsigned long n"
16.Fa "unsigned char *md"
17.Fc
18.Ft int
19.Fo RIPEMD160_Init
20.Fa "RIPEMD160_CTX *c"
21.Fc
22.Ft int
23.Fo RIPEMD160_Update
24.Fa "RIPEMD_CTX *c"
25.Fa "const void *data"
26.Fa "unsigned long len"
27.Fc
28.Ft int
29.Fo RIPEMD160_Final
30.Fa "unsigned char *md"
31.Fa "RIPEMD160_CTX *c"
32.Fc
33.Sh DESCRIPTION
34RIPEMD-160 is a cryptographic hash function with a 160 bit output.
35.Pp
36.Fn RIPEMD160
37computes the RIPEMD-160 message digest of the
38.Fa n
39bytes at
40.Fa d
41and places it in
42.Fa md ,
43which must have space for
44.Dv RIPEMD160_DIGEST_LENGTH
45== 20 bytes of output.
46If
47.Fa md
48is
49.Dv NULL ,
50the digest is placed in a static array.
51.Pp
52The following functions may be used if the message is not completely
53stored in memory:
54.Pp
55.Fn RIPEMD160_Init
56initializes a
57.Vt RIPEMD160_CTX
58structure.
59.Pp
60.Fn RIPEMD160_Update
61can be called repeatedly with chunks of the message to be hashed
62.Pq Fa len No bytes at Fa data .
63.Pp
64.Fn RIPEMD160_Final
65places the message digest in
66.Fa md ,
67which must have space for
68.Dv RIPEMD160_DIGEST_LENGTH
69== 20 bytes of output,
70and erases the
71.Vt RIPEMD160_CTX .
72.Pp
73Applications should use the higher level functions
74.Xr EVP_DigestInit 3
75etc. instead of calling the hash functions directly.
76.Sh RETURN VALUES
77.Fn RIPEMD160
78returns a pointer to the hash value.
79.Pp
80.Fn RIPEMD160_Init ,
81.Fn RIPEMD160_Update ,
82and
83.Fn RIPEMD160_Final
84return 1 for success or 0 otherwise.
85.Sh SEE ALSO
86.Xr EVP_DigestInit 3 ,
87.Xr HMAC 3
88.Sh STANDARDS
89ISO/IEC 10118-3 (draft) (??)
90.Sh HISTORY
91.Fn RIPEMD160 ,
92.Fn RIPEMD160_Init ,
93.Fn RIPEMD160_Update ,
94and
95.Fn RIPEMD160_Final
96are available since SSLeay 0.9.0.
diff --git a/src/lib/libcrypto/man/SHA1.3 b/src/lib/libcrypto/man/SHA1.3
new file mode 100644
index 0000000000..c873a8cbb7
--- /dev/null
+++ b/src/lib/libcrypto/man/SHA1.3
@@ -0,0 +1,102 @@
1.Dd $Mdocdate: November 5 2016 $
2.Dt SHA1 3
3.Os
4.Sh NAME
5.Nm SHA1 ,
6.Nm SHA1_Init ,
7.Nm SHA1_Update ,
8.Nm SHA1_Final
9.Nd Secure Hash Algorithm
10.Sh SYNOPSIS
11.In openssl/sha.h
12.Ft unsigned char *
13.Fo SHA1
14.Fa "const unsigned char *d"
15.Fa "unsigned long n"
16.Fa "unsigned char *md"
17.Fc
18.Ft int
19.Fo SHA1_Init
20.Fa "SHA_CTX *c"
21.Fc
22.Ft int
23.Fo SHA1_Update
24.Fa "SHA_CTX *c"
25.Fa "const void *data"
26.Fa "unsigned long len"
27.Fc
28.Ft int
29.Fo SHA1_Final
30.Fa "unsigned char *md"
31.Fa "SHA_CTX *c"
32.Fc
33.Sh DESCRIPTION
34SHA-1 (Secure Hash Algorithm) is a cryptographic hash function with a
35160 bit output.
36.Pp
37.Fn SHA1
38computes the SHA-1 message digest of the
39.Fa n
40bytes at
41.Fa d
42and places it in
43.Fa md ,
44which must have space for
45.Dv SHA_DIGEST_LENGTH
46== 20 bytes of output.
47If
48.Fa md
49is
50.Dv NULL ,
51the digest is placed in a static array.
52.Pp
53The following functions may be used if the message is not completely
54stored in memory:
55.Pp
56.Fn SHA1_Init
57initializes a
58.Vt SHA_CTX
59structure.
60.Pp
61.Fn SHA1_Update
62can be called repeatedly with chunks of the message to be hashed
63.Pq Fa len No bytes at Fa data .
64.Pp
65.Fn SHA1_Final
66places the message digest in
67.Fa md ,
68which must have space for
69.Dv SHA_DIGEST_LENGTH
70== 20 bytes of output, and erases the
71.Vt SHA_CTX .
72.Pp
73Applications should use the higher level functions
74.Xr EVP_DigestInit 3
75etc. instead of calling the hash functions directly.
76.Pp
77The predecessor of SHA-1, SHA, is also implemented, but it should be
78used only when backward compatibility is required.
79.Sh RETURN VALUES
80.Fn SHA1
81returns a pointer to the hash value.
82.Pp
83.Fn SHA1_Init ,
84.Fn SHA1_Update ,
85and
86.Fn SHA1_Final
87return 1 for success or 0 otherwise.
88.Sh SEE ALSO
89.Xr EVP_DigestInit 3 ,
90.Xr HMAC 3 ,
91.Xr RIPEMD160 3
92.Sh STANDARDS
93SHA: US Federal Information Processing Standard FIPS PUB 180 (Secure
94Hash Standard), SHA-1: US Federal Information Processing Standard FIPS
95PUB 180-1 (Secure Hash Standard), ANSI X9.30
96.Sh HISTORY
97.Fn SHA1 ,
98.Fn SHA1_Init ,
99.Fn SHA1_Update ,
100and
101.Fn SHA1_Final
102are available in all versions of SSLeay and OpenSSL.
diff --git a/src/lib/libcrypto/man/bn.3 b/src/lib/libcrypto/man/bn.3
new file mode 100644
index 0000000000..6406be1663
--- /dev/null
+++ b/src/lib/libcrypto/man/bn.3
@@ -0,0 +1,576 @@
1.Dd $Mdocdate: November 5 2016 $
2.Dt BN 3
3.Os
4.Sh NAME
5.Nm bn
6.Nd multiprecision integer arithmetics
7.Sh SYNOPSIS
8.In openssl/bn.h
9.Ft BIGNUM *
10.Fn BN_new void
11.Ft void
12.Fo BN_free
13.Fa "BIGNUM *a"
14.Fc
15.Ft void
16.Fo BN_init
17.Fa "BIGNUM *"
18.Fc
19.Ft void
20.Fo BN_clear
21.Fa "BIGNUM *a"
22.Fc
23.Ft void
24.Fo BN_clear_free
25.Fa "BIGNUM *a"
26.Fc
27.Ft BN_CTX *
28.Fn BN_CTX_new void
29.Ft void
30.Fo BN_CTX_init
31.Fa "BN_CTX *c"
32.Fc
33.Ft void
34.Fo BN_CTX_free
35.Fa "BN_CTX *c"
36.Fc
37.Ft BIGNUM *
38.Fo BN_copy
39.Fa "BIGNUM *a"
40.Fa "const BIGNUM *b"
41.Fc
42.Ft BIGNUM *
43.Fo BN_dup
44.Fa "const BIGNUM *a"
45.Fc
46.Ft BIGNUM *
47.Fo BN_swap
48.Fa "BIGNUM *a"
49.Fa "BIGNUM *b"
50.Fc
51.Ft int
52.Fo BN_num_bytes
53.Fa "const BIGNUM *a"
54.Fc
55.Ft int
56.Fo BN_num_bits
57.Fa "const BIGNUM *a"
58.Fc
59.Ft int
60.Fo BN_num_bits_word
61.Fa "BN_ULONG w"
62.Fc
63.Ft void
64.Fo BN_set_negative
65.Fa "BIGNUM *a"
66.Fa "int n"
67.Fc
68.Ft int
69.Fo BN_is_negative
70.Fa "const BIGNUM *a"
71.Fc
72.Ft int
73.Fo BN_add
74.Fa "BIGNUM *r"
75.Fa "const BIGNUM *a"
76.Fa "const BIGNUM *b"
77.Fc
78.Ft int
79.Fo BN_sub
80.Fa "BIGNUM *r"
81.Fa "const BIGNUM *a"
82.Fa "const BIGNUM *b"
83.Fc
84.Ft int
85.Fo BN_mul
86.Fa "BIGNUM *r"
87.Fa "BIGNUM *a"
88.Fa "BIGNUM *b"
89.Fa "BN_CTX *ctx"
90.Fc
91.Ft int
92.Fo BN_sqr
93.Fa "BIGNUM *r"
94.Fa "BIGNUM *a"
95.Fa "BN_CTX *ctx"
96.Fc
97.Ft int
98.Fo BN_div
99.Fa "BIGNUM *dv"
100.Fa "BIGNUM *rem"
101.Fa "const BIGNUM *a"
102.Fa "const BIGNUM *d"
103.Fa "BN_CTX *ctx"
104.Fc
105.Ft int
106.Fo BN_mod
107.Fa "BIGNUM *rem"
108.Fa "const BIGNUM *a"
109.Fa "const BIGNUM *m"
110.Fa "BN_CTX *ctx"
111.Fc
112.Ft int
113.Fo BN_nnmod
114.Fa "BIGNUM *rem"
115.Fa "const BIGNUM *a"
116.Fa "const BIGNUM *m"
117.Fa "BN_CTX *ctx"
118.Fc
119.Ft int
120.Fo BN_mod_add
121.Fa "BIGNUM *ret"
122.Fa "BIGNUM *a"
123.Fa "BIGNUM *b"
124.Fa "const BIGNUM *m"
125.Fa "BN_CTX *ctx"
126.Fc
127.Ft int
128.Fo BN_mod_sub
129.Fa "BIGNUM *ret"
130.Fa "BIGNUM *a"
131.Fa "BIGNUM *b"
132.Fa "const BIGNUM *m"
133.Fa "BN_CTX *ctx"
134.Fc
135.Ft int
136.Fo BN_mod_mul
137.Fa "BIGNUM *ret"
138.Fa "BIGNUM *a"
139.Fa "BIGNUM *b"
140.Fa "const BIGNUM *m"
141.Fa "BN_CTX *ctx"
142.Fc
143.Ft int
144.Fo BN_mod_sqr
145.Fa "BIGNUM *ret"
146.Fa "BIGNUM *a"
147.Fa "const BIGNUM *m"
148.Fa "BN_CTX *ctx"
149.Fc
150.Ft int
151.Fo BN_exp
152.Fa "BIGNUM *r"
153.Fa "BIGNUM *a"
154.Fa "BIGNUM *p"
155.Fa "BN_CTX *ctx"
156.Fc
157.Ft int
158.Fo BN_mod_exp
159.Fa "BIGNUM *r"
160.Fa "BIGNUM *a"
161.Fa "const BIGNUM *p"
162.Fa "const BIGNUM *m"
163.Fa "BN_CTX *ctx"
164.Fc
165.Ft int
166.Fo BN_gcd
167.Fa "BIGNUM *r"
168.Fa "BIGNUM *a"
169.Fa "BIGNUM *b"
170.Fa "BN_CTX *ctx"
171.Fc
172.Ft int
173.Fo BN_add_word
174.Fa "BIGNUM *a"
175.Fa "BN_ULONG w"
176.Fc
177.Ft int
178.Fo BN_sub_word
179.Fa "BIGNUM *a"
180.Fa "BN_ULONG w"
181.Fc
182.Ft int
183.Fo BN_mul_word
184.Fa "BIGNUM *a"
185.Fa "BN_ULONG w"
186.Fc
187.Ft BN_ULONG
188.Fo BN_div_word
189.Fa "BIGNUM *a"
190.Fa "BN_ULONG w"
191.Fc
192.Ft BN_ULONG
193.Fo BN_mod_word
194.Fa "const BIGNUM *a"
195.Fa "BN_ULONG w"
196.Fc
197.Ft int
198.Fo BN_cmp
199.Fa "BIGNUM *a"
200.Fa "BIGNUM *b"
201.Fc
202.Ft int
203.Fo BN_ucmp
204.Fa "BIGNUM *a"
205.Fa "BIGNUM *b"
206.Fc
207.Ft int
208.Fo BN_is_zero
209.Fa "BIGNUM *a"
210.Fc
211.Ft int
212.Fo BN_is_one
213.Fa "BIGNUM *a"
214.Fc
215.Ft int
216.Fo BN_is_word
217.Fa "BIGNUM *a"
218.Fa "BN_ULONG w"
219.Fc
220.Ft int
221.Fo BN_is_odd
222.Fa "BIGNUM *a"
223.Fc
224.Ft int
225.Fo BN_zero
226.Fa "BIGNUM *a"
227.Fc
228.Ft int
229.Fo BN_one
230.Fa "BIGNUM *a"
231.Fc
232.Ft const BIGNUM *
233.Fn BN_value_one void
234.Ft int
235.Fo BN_set_word
236.Fa "BIGNUM *a"
237.Fa "unsigned long w"
238.Fc
239.Ft unsigned long
240.Fo BN_get_word
241.Fa "BIGNUM *a"
242.Fc
243.Ft int
244.Fo BN_rand
245.Fa "BIGNUM *rnd"
246.Fa "int bits"
247.Fa "int top"
248.Fa "int bottom"
249.Fc
250.Ft int
251.Fo BN_pseudo_rand
252.Fa "BIGNUM *rnd"
253.Fa "int bits"
254.Fa "int top"
255.Fa "int bottom"
256.Fc
257.Ft int
258.Fo BN_rand_range
259.Fa "BIGNUM *rnd"
260.Fa "BIGNUM *range"
261.Fc
262.Ft int
263.Fo BN_pseudo_rand_range
264.Fa "BIGNUM *rnd"
265.Fa "BIGNUM *range"
266.Fc
267.Ft BIGNUM *
268.Fo BN_generate_prime
269.Fa "BIGNUM *ret"
270.Fa "int bits"
271.Fa "int safe"
272.Fa "BIGNUM *add"
273.Fa "BIGNUM *rem"
274.Fa "void (*callback)(int, int, void *)"
275.Fa "void *cb_arg"
276.Fc
277.Ft int
278.Fo BN_is_prime
279.Fa "const BIGNUM *p"
280.Fa "int nchecks"
281.Fa "void (*callback)(int, int, void *)"
282.Fa "BN_CTX *ctx"
283.Fa "void *cb_arg"
284.Fc
285.Ft int
286.Fo BN_set_bit
287.Fa "BIGNUM *a"
288.Fa "int n"
289.Fc
290.Ft int
291.Fo BN_clear_bit
292.Fa "BIGNUM *a"
293.Fa "int n"
294.Fc
295.Ft int
296.Fo BN_is_bit_set
297.Fa "const BIGNUM *a"
298.Fa "int n"
299.Fc
300.Ft int
301.Fo BN_mask_bits
302.Fa "BIGNUM *a"
303.Fa "int n"
304.Fc
305.Ft int
306.Fo BN_lshift
307.Fa "BIGNUM *r"
308.Fa "const BIGNUM *a"
309.Fa "int n"
310.Fc
311.Ft int
312.Fo BN_lshift1
313.Fa "BIGNUM *r"
314.Fa "BIGNUM *a"
315.Fc
316.Ft int
317.Fo BN_rshift
318.Fa "BIGNUM *r"
319.Fa "BIGNUM *a"
320.Fa "int n"
321.Fc
322.Ft int
323.Fo BN_rshift1
324.Fa "BIGNUM *r"
325.Fa "BIGNUM *a"
326.Fc
327.Ft int
328.Fo BN_bn2bin
329.Fa "const BIGNUM *a"
330.Fa "unsigned char *to"
331.Fc
332.Ft BIGNUM *
333.Fo BN_bin2bn
334.Fa "const unsigned char *s"
335.Fa "int len"
336.Fa "BIGNUM *ret"
337.Fc
338.Ft char *
339.Fo BN_bn2hex
340.Fa "const BIGNUM *a"
341.Fc
342.Ft char *
343.Fo BN_bn2dec
344.Fa "const BIGNUM *a"
345.Fc
346.Ft int
347.Fo BN_hex2bn
348.Fa "BIGNUM **a"
349.Fa "const char *str"
350.Fc
351.Ft int
352.Fo BN_dec2bn
353.Fa "BIGNUM **a"
354.Fa "const char *str"
355.Fc
356.Ft int
357.Fo BN_print
358.Fa "BIO *fp"
359.Fa "const BIGNUM *a"
360.Fc
361.Ft int
362.Fo BN_print_fp
363.Fa "FILE *fp"
364.Fa "const BIGNUM *a"
365.Fc
366.Ft int
367.Fo BN_bn2mpi
368.Fa "const BIGNUM *a"
369.Fa "unsigned char *to"
370.Fc
371.Ft BIGNUM *
372.Fo BN_mpi2bn
373.Fa "unsigned char *s"
374.Fa "int len"
375.Fa "BIGNUM *ret"
376.Fc
377.Ft BIGNUM *
378.Fo BN_mod_inverse
379.Fa "BIGNUM *r"
380.Fa "BIGNUM *a"
381.Fa "const BIGNUM *n"
382.Fa "BN_CTX *ctx"
383.Fc
384.Ft BN_RECP_CTX *
385.Fn BN_RECP_CTX_new void
386.Ft void
387.Fo BN_RECP_CTX_init
388.Fa "BN_RECP_CTX *recp"
389.Fc
390.Ft void
391.Fo BN_RECP_CTX_free
392.Fa "BN_RECP_CTX *recp"
393.Fc
394.Ft int
395.Fo BN_RECP_CTX_set
396.Fa "BN_RECP_CTX *recp"
397.Fa "const BIGNUM *m"
398.Fa "BN_CTX *ctx"
399.Fc
400.Ft int
401.Fo BN_mod_mul_reciprocal
402.Fa "BIGNUM *r"
403.Fa "BIGNUM *a"
404.Fa "BIGNUM *b"
405.Fa "BN_RECP_CTX *recp"
406.Fa "BN_CTX *ctx"
407.Fc
408.Ft BN_MONT_CTX *
409.Fn BN_MONT_CTX_new void
410.Ft void
411.Fo BN_MONT_CTX_init
412.Fa "BN_MONT_CTX *ctx"
413.Fc
414.Ft void
415.Fo BN_MONT_CTX_free
416.Fa "BN_MONT_CTX *mont"
417.Fc
418.Ft int
419.Fo BN_MONT_CTX_set
420.Fa "BN_MONT_CTX *mont"
421.Fa "const BIGNUM *m"
422.Fa "BN_CTX *ctx"
423.Fc
424.Ft BN_MONT_CTX *
425.Fo BN_MONT_CTX_copy
426.Fa "BN_MONT_CTX *to"
427.Fa "BN_MONT_CTX *from"
428.Fc
429.Ft int
430.Fo BN_mod_mul_montgomery
431.Fa "BIGNUM *r"
432.Fa "BIGNUM *a"
433.Fa "BIGNUM *b"
434.Fa "BN_MONT_CTX *mont"
435.Fa "BN_CTX *ctx"
436.Fc
437.Ft int
438.Fo BN_from_montgomery
439.Fa "BIGNUM *r"
440.Fa "BIGNUM *a"
441.Fa "BN_MONT_CTX *mont"
442.Fa "BN_CTX *ctx"
443.Fc
444.Ft int
445.Fo BN_to_montgomery
446.Fa "BIGNUM *r"
447.Fa "BIGNUM *a"
448.Fa "BN_MONT_CTX *mont"
449.Fa "BN_CTX *ctx"
450.Fc
451.Ft BN_BLINDING *
452.Fo BN_BLINDING_new
453.Fa "const BIGNUM *A"
454.Fa "const BIGNUM *Ai"
455.Fa "BIGNUM *mod"
456.Fc
457.Ft void
458.Fo BN_BLINDING_free
459.Fa "BN_BLINDING *b"
460.Fc
461.Ft int
462.Fo BN_BLINDING_update
463.Fa "BN_BLINDING *b"
464.Fa "BN_CTX *ctx"
465.Fc
466.Ft int
467.Fo BN_BLINDING_convert
468.Fa "BIGNUM *n"
469.Fa "BN_BLINDING *b"
470.Fa "BN_CTX *ctx"
471.Fc
472.Ft int
473.Fo BN_BLINDING_invert
474.Fa "BIGNUM *n"
475.Fa "BN_BLINDING *b"
476.Fa "BN_CTX *ctx"
477.Fc
478.Ft int
479.Fo BN_BLINDING_convert_ex
480.Fa "BIGNUM *n"
481.Fa "BIGNUM *r"
482.Fa "BN_BLINDING *b"
483.Fa "BN_CTX *ctx"
484.Fc
485.Ft int
486.Fo BN_BLINDING_invert_ex
487.Fa "BIGNUM *n"
488.Fa "const BIGNUM *r"
489.Fa "BN_BLINDING *b"
490.Fa "BN_CTX *ctx"
491.Fc
492.Ft unsigned long
493.Fo BN_BLINDING_get_thread_id
494.Fa "const BN_BLINDING *"
495.Fc
496.Ft void
497.Fo BN_BLINDING_set_thread_id
498.Fa "BN_BLINDING *"
499.Fa "unsigned long"
500.Fc
501.Ft unsigned long
502.Fo BN_BLINDING_get_flags
503.Fa "const BN_BLINDING *"
504.Fc
505.Ft void
506.Fo BN_BLINDING_set_flags
507.Fa "BN_BLINDING *"
508.Fa "unsigned long"
509.Fc
510.Ft BN_BLINDING *
511.Fo BN_BLINDING_create_param
512.Fa "BN_BLINDING *b"
513.Fa "const BIGNUM *e"
514.Fa "BIGNUM *m"
515.Fa "BN_CTX *ctx"
516.Fa "int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)"
517.Fa "BN_MONT_CTX *m_ctx"
518.Fc
519.Sh DESCRIPTION
520This library performs arithmetic operations on integers of arbitrary size.
521It was written for use in public key cryptography, such as RSA and
522Diffie-Hellman.
523.Pp
524It uses dynamic memory allocation for storing its data structures.
525That means that there is no limit on the size of the numbers manipulated
526by these functions, but return values must always be checked in case a
527memory allocation error has occurred.
528.Pp
529The basic object in this library is a
530.Vt BIGNUM .
531It is used to hold a single large integer.
532This type should be considered opaque and fields should not be modified
533or accessed directly.
534.Pp
535The creation of
536.Vt BIGNUM
537objects is described in
538.Xr BN_new 3 ;
539.Xr BN_add 3
540describes most of the arithmetic operations.
541Comparison is described in
542.Xr BN_cmp 3 ;
543.Xr BN_zero 3
544describes certain assignments,
545.Xr BN_rand 3
546the generation of random numbers,
547.Xr BN_generate_prime 3
548deals with prime numbers and
549.Xr BN_set_bit 3
550with bit operations.
551The conversion of
552.Vt BIGNUM Ns s
553to external formats is described in
554.Xr BN_bn2bin 3 .
555.Sh SEE ALSO
556.Xr BN_add 3 ,
557.Xr BN_add_word 3 ,
558.Xr BN_BLINDING_new 3 ,
559.Xr BN_bn2bin 3 ,
560.Xr BN_cmp 3 ,
561.Xr BN_copy 3 ,
562.Xr BN_CTX_new 3 ,
563.Xr bn_dump 3 ,
564.Xr BN_generate_prime 3 ,
565.Xr BN_mod_inverse 3 ,
566.Xr BN_mod_mul_montgomery 3 ,
567.Xr BN_mod_mul_reciprocal 3 ,
568.Xr BN_new 3 ,
569.Xr BN_num_bytes 3 ,
570.Xr BN_rand 3 ,
571.Xr BN_set_bit 3 ,
572.Xr BN_swap 3 ,
573.Xr BN_zero 3 ,
574.Xr dh 3 ,
575.Xr ERR 3 ,
576.Xr rsa 3
diff --git a/src/lib/libcrypto/man/d2i_DHparams.3 b/src/lib/libcrypto/man/d2i_DHparams.3
new file mode 100644
index 0000000000..73aec0269b
--- /dev/null
+++ b/src/lib/libcrypto/man/d2i_DHparams.3
@@ -0,0 +1,30 @@
1.Dd $Mdocdate: November 5 2016 $
2.Dt D2I_DHPARAMS 3
3.Os
4.Sh NAME
5.Nm d2i_DHparams ,
6.Nm i2d_DHparams
7.Nd PKCS#3 DH parameter functions
8.Sh SYNOPSIS
9.In openssl/dh.h
10.Ft DH *
11.Fo d2i_DHparams
12.Fa "DH **a"
13.Fa "unsigned char **pp"
14.Fa "long length"
15.Fc
16.Ft int
17.Fo i2d_DHparams
18.Fa "DH *a"
19.Fa "unsigned char **pp"
20.Fc
21.Sh DESCRIPTION
22These functions decode and encode PKCS#3 DH parameters using the
23DHparameter structure described in PKCS#3.
24.Pp
25Otherwise these behave in a way similar to
26.Xr d2i_X509 3
27and
28.Xr i2d_X509 3 .
29.Sh SEE ALSO
30.Xr d2i_X509 3
diff --git a/src/lib/libcrypto/man/d2i_DSAPublicKey.3 b/src/lib/libcrypto/man/d2i_DSAPublicKey.3
new file mode 100644
index 0000000000..aff5d0f814
--- /dev/null
+++ b/src/lib/libcrypto/man/d2i_DSAPublicKey.3
@@ -0,0 +1,159 @@
1.Dd $Mdocdate: November 5 2016 $
2.Dt D2I_DSAPUBLICKEY 3
3.Os
4.Sh NAME
5.Nm d2i_DSAPublicKey ,
6.Nm i2d_DSAPublicKey ,
7.Nm d2i_DSAPrivateKey ,
8.Nm i2d_DSAPrivateKey ,
9.Nm d2i_DSA_PUBKEY ,
10.Nm i2d_DSA_PUBKEY ,
11.Nm d2i_DSAparams ,
12.Nm i2d_DSAparams ,
13.Nm d2i_DSA_SIG ,
14.Nm i2d_DSA_SIG
15.Nd DSA key encoding and parsing functions
16.Sh SYNOPSIS
17.In openssl/dsa.h
18.In openssl/x509.h
19.Ft DSA *
20.Fo d2i_DSAPublicKey
21.Fa "DSA **a"
22.Fa "const unsigned char **pp"
23.Fa "long length"
24.Fc
25.Ft int
26.Fo i2d_DSAPublicKey
27.Fa "const DSA *a"
28.Fa "unsigned char **pp"
29.Fc
30.Ft DSA *
31.Fo d2i_DSA_PUBKEY
32.Fa "DSA **a"
33.Fa "const unsigned char **pp"
34.Fa "long length"
35.Fc
36.Ft int
37.Fo i2d_DSA_PUBKEY
38.Fa "const DSA *a"
39.Fa "unsigned char **pp"
40.Fc
41.Ft DSA *
42.Fo d2i_DSAPrivateKey
43.Fa "DSA **a"
44.Fa "const unsigned char **pp"
45.Fa "long length"
46.Fc
47.Ft int
48.Fo i2d_DSAPrivateKey
49.Fa "const DSA *a"
50.Fa "unsigned char **pp"
51.Fc
52.Ft DSA *
53.Fo d2i_DSAparams
54.Fa "DSA **a"
55.Fa "const unsigned char **pp"
56.Fa "long length"
57.Fc
58.Ft int
59.Fo i2d_DSAparams
60.Fa "const DSA *a"
61.Fa "unsigned char **pp"
62.Fc
63.Ft DSA *
64.Fo d2i_DSA_SIG
65.Fa "DSA_SIG **a"
66.Fa "const unsigned char **pp"
67.Fa "long length"
68.Fc
69.Ft int
70.Fo i2d_DSA_SIG
71.Fa "const DSA_SIG *a"
72.Fa "unsigned char **pp"
73.Fc
74.Sh DESCRIPTION
75.Fn d2i_DSAPublicKey
76and
77.Fn i2d_DSAPublicKey
78decode and encode the DSA public key components structure.
79.Pp
80.Fn d2i_DSA_PUBKEY
81and
82.Fn i2d_DSA_PUBKEY
83decode and encode a DSA public key using a SubjectPublicKeyInfo
84(certificate public key) structure.
85.Pp
86.Fn d2i_DSAPrivateKey
87and
88.Fn i2d_DSAPrivateKey
89decode and encode the DSA private key components.
90.Pp
91.Fn d2i_DSAparams
92and
93.Fn i2d_DSAparams
94decode and encode the DSA parameters using a
95.Sy Dss-Parms
96structure as defined in RFC2459.
97.Pp
98.Fn d2i_DSA_SIG
99and
100.Fn i2d_DSA_SIG
101decode and encode a DSA signature using a
102.Sy Dss-Sig-Value
103structure as defined in RFC2459.
104.Pp
105The usage of all of these functions is similar to
106.Xr d2i_X509 3
107and
108.Xr i2d_X509 3 .
109.Pp
110The
111.Vt DSA
112structure passed to the private key encoding functions should have all
113the private key components present.
114.Pp
115The data encoded by the private key functions is unencrypted and
116therefore offers no private key security.
117.Pp
118The
119.Fn *_DSA_PUBKEY
120functions should be used in preference to the
121.Fn *_DSAPublicKey
122functions when encoding public keys because they use a standard format.
123.Pp
124The
125.Fn *_DSAPublicKey
126functions use an non-standard format.
127The actual data encoded depends on the value of
128.Fa a->write_params .
129If
130.Fa a->write_params
131is zero, then only the
132.Fa a->pub_key
133field is encoded as an
134.Sy INTEGER .
135If
136.Fa a->write_params
137is 1, then a
138.Sy SEQUENCE
139consisting of the
140.Fa a->p ,
141.Fa a->q ,
142.Fa a->g ,
143and
144.Fa a->pub_key
145fields is encoded.
146.Pp
147The
148.Fn *_DSAPrivateKey
149functions also use a non-standard structure consisting consisting of a
150SEQUENCE containing the
151.Fa a->p ,
152.Fa a->q ,
153.Fa a->g ,
154.Fa a->pub_key ,
155and
156.Fa a->priv_key
157fields.
158.Sh SEE ALSO
159.Xr d2i_X509 3
diff --git a/src/lib/libcrypto/man/d2i_ECPKParameters.3 b/src/lib/libcrypto/man/d2i_ECPKParameters.3
new file mode 100644
index 0000000000..71d84b95c9
--- /dev/null
+++ b/src/lib/libcrypto/man/d2i_ECPKParameters.3
@@ -0,0 +1,188 @@
1.Dd $Mdocdate: November 5 2016 $
2.Dt D2I_ECPKPARAMETERS 3
3.Os
4.Sh NAME
5.Nm d2i_ECPKParameters ,
6.Nm i2d_ECPKParameters ,
7.Nm d2i_ECPKParameters_bio ,
8.Nm i2d_ECPKParameters_bio ,
9.Nm d2i_ECPKParameters_fp ,
10.Nm i2d_ECPKParameters_fp ,
11.Nm ECPKParameters_print ,
12.Nm ECPKParameters_print_fp
13.Nd decode and encode ASN.1 representations of elliptic curve entities
14.Sh SYNOPSIS
15.In openssl/ec.h
16.Ft EC_GROUP *
17.Fo d2i_ECPKParameters
18.Fa "EC_GROUP **px"
19.Fa "const unsigned char **in"
20.Fa "long len"
21.Fc
22.Ft int
23.Fo i2d_ECPKParameters
24.Fa "const EC_GROUP *x"
25.Fa "unsigned char **out"
26.Fc
27.Fd #define d2i_ECPKParameters_bio(bp,x)\
28 ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x)
29.Fd #define i2d_ECPKParameters_bio(bp,x)\
30 ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x)
31.Fd #define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL,\
32 (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x))
33.Fd #define i2d_ECPKParameters_fp(fp,x)\
34 ASN1_i2d_fp(i2d_ECPKParameters,(fp), (unsigned char *)(x))
35.Ft int
36.Fo ECPKParameters_print
37.Fa "BIO *bp"
38.Fa "const EC_GROUP *x"
39.Fa "int off"
40.Fc
41.Ft int
42.Fo ECPKParameters_print_fp
43.Fa "FILE *fp"
44.Fa "const EC_GROUP *x"
45.Fa "int off"
46.Fc
47.Sh DESCRIPTION
48The ECPKParameters encode and decode routines encode and parse the
49public parameters for an
50.Vt EC_GROUP
51structure, which represents a curve.
52.Pp
53.Fn d2i_ECPKParameters
54attempts to decode
55.Fa len
56bytes at
57.Pf * Fa in .
58If successful, a pointer to the
59.Vt EC_GROUP
60structure is returned.
61If an error occurred, then
62.Dv NULL
63is returned.
64If
65.Fa px
66is not
67.Dv NULL ,
68then the returned structure is written to
69.Pf * Fa px .
70If
71.Pf * Fa px
72is not
73.Dv NULL ,
74then it is assumed that
75.Pf * Fa px
76contains a valid
77.Vt EC_GROUP
78structure and an attempt is made to reuse it.
79If the call is successful,
80.Pf * Fa in
81is incremented to the byte following the parsed data.
82.Pp
83.Fn i2d_ECPKParameters
84encodes the structure pointed to by
85.Fa x
86into DER format.
87If
88.Fa out
89is not
90.Dv NULL ,
91is writes the DER encoded data to the buffer at
92.Pf * Fa out
93and increments it to point after the data just written.
94If the return value is negative, an error occurred, otherwise it returns
95the length of the encoded data.
96.Pp
97If
98.Pf * Fa out
99is
100.Dv NULL ,
101memory will be allocated for a buffer and the encoded data written to it.
102In this case
103.Pf * Fa out
104is not incremented, and it points to the start of the data just written.
105.Pp
106.Fn d2i_ECPKParameters_bio
107is similar to
108.Fn d2i_ECPKParameters
109except it attempts to parse data from
110.Vt BIO
111.Fa bp .
112.Pp
113.Fn d2i_ECPKParameters_fp
114is similar to
115.Fn d2i_ECPKParameters
116except it attempts to parse data from the
117.Vt FILE
118pointer
119.Fa fp .
120.Pp
121.Fn i2d_ECPKParameters_bio
122is similar to
123.Fn i2d_ECPKParameters
124except it writes the encoding of the structure
125.Fa x
126to
127.Vt BIO
128.Fa bp
129and it returns 1 for success or 0 for failure.
130.Pp
131.Fn i2d_ECPKParameters_fp
132is similar to
133.Fn i2d_ECPKParameters
134except it writes the encoding of the structure
135.Fa x
136to
137.Vt BIO
138.Sy bp
139and it returns 1 for success or 0 for failure.
140.Pp
141These functions are very similar to the X.509 functions described in
142.Xr d2i_X509 3 ,
143where further notes and examples are available.
144.Pp
145The
146.Fn ECPKParameters_print
147and
148.Fn ECPKParameters_print_fp
149functions print human-readable output of the public parameters of the
150.Vt EC_GROUP
151to
152.Fa bp
153or
154.Fa fp .
155The output lines are indented by
156.Fa off
157spaces.
158.Sh RETURN VALUES
159.Fn d2i_ECPKParameters ,
160.Fn d2i_ECPKParameters_bio ,
161and
162.Fn d2i_ECPKParameters_fp
163return a valid
164.Vt EC_GROUP
165structure or
166.Dv NULL
167if an error occurs.
168.Pp
169.Fn i2d_ECPKParameters
170returns the number of bytes successfully encoded or a negative value if
171an error occurs.
172.Pp
173.Fn i2d_ECPKParameters_bio ,
174.Fn i2d_ECPKParameters_fp ,
175.Fn ECPKParameters_print ,
176and
177.Fn ECPKParameters_print_fp
178return 1 for success or 0 if an error occurs.
179.Sh SEE ALSO
180.Xr crypto 3 ,
181.Xr d2i_X509 3 ,
182.Xr ec 3 ,
183.Xr EC_GFp_simple_method 3 ,
184.Xr EC_GROUP_copy 3 ,
185.Xr EC_GROUP_new 3 ,
186.Xr EC_KEY_new 3 ,
187.Xr EC_POINT_add 3 ,
188.Xr EC_POINT_new 3
diff --git a/src/lib/libcrypto/man/dh.3 b/src/lib/libcrypto/man/dh.3
new file mode 100644
index 0000000000..2a8f172e2b
--- /dev/null
+++ b/src/lib/libcrypto/man/dh.3
@@ -0,0 +1,148 @@
1.Dd $Mdocdate: November 5 2016 $
2.Dt DH 3
3.Os
4.Sh NAME
5.Nm dh
6.Nd Diffie-Hellman key agreement
7.Sh SYNOPSIS
8.In openssl/dh.h
9.In openssl/engine.h
10.Ft DH *
11.Fn DH_new void
12.Ft void
13.Fo DH_free
14.Fa "DH *dh"
15.Fc
16.Ft int
17.Fo DH_size
18.Fa "const DH *dh"
19.Fc
20.Ft DH *
21.Fo DH_generate_parameters
22.Fa "int prime_len"
23.Fa "int generator"
24.Fa "void (*callback)(int, int, void *)"
25.Fa "void *cb_arg"
26.Fc
27.Ft int
28.Fo DH_check
29.Fa "const DH *dh"
30.Fa "int *codes"
31.Fc
32.Ft int
33.Fo DH_generate_key
34.Fa "DH *dh"
35.Fc
36.Ft int
37.Fo DH_compute_key
38.Fa "unsigned char *key"
39.Fa "BIGNUM *pub_key"
40.Fa "DH *dh"
41.Fc
42.Ft void
43.Fo DH_set_default_method
44.Fa "const DH_METHOD *meth"
45.Fc
46.Ft const DH_METHOD *
47.Fn DH_get_default_method void
48.Ft int
49.Fo DH_set_method
50.Fa "DH *dh"
51.Fa "const DH_METHOD *meth"
52.Fc
53.Ft DH *
54.Fo DH_new_method
55.Fa "ENGINE *engine"
56.Fc
57.Ft const DH_METHOD *
58.Fn DH_OpenSSL void
59.Ft int
60.Fo DH_get_ex_new_index
61.Fa "long argl"
62.Fa "char *argp"
63.Fa "int (*new_func)()"
64.Fa "int (*dup_func)()"
65.Fa "void (*free_func)()"
66.Fc
67.Ft int
68.Fo DH_set_ex_data
69.Fa "DH *d"
70.Fa "int idx"
71.Fa "char *arg"
72.Fc
73.Ft char *
74.Fo DH_get_ex_data
75.Fa "DH *d"
76.Fa "int idx"
77.Fc
78.Ft DH *
79.Fo d2i_DHparams
80.Fa "DH **a"
81.Fa "unsigned char **pp"
82.Fa "long length"
83.Fc
84.Ft int
85.Fo i2d_DHparams
86.Fa "const DH *a"
87.Fa "unsigned char **pp"
88.Fc
89.Ft int
90.Fo DHparams_print_fp
91.Fa "FILE *fp"
92.Fa "const DH *x"
93.Fc
94.Ft int
95.Fo DHparams_print
96.Fa "BIO *bp"
97.Fa "const DH *x"
98.Fc
99.Sh DESCRIPTION
100These functions implement the Diffie-Hellman key agreement protocol.
101The generation of shared DH parameters is described in
102.Xr DH_generate_parameters 3 ;
103.Xr DH_generate_key 3
104describes how to perform a key agreement.
105.Pp
106The
107.Vt DH
108structure consists of several
109.Vt BIGNUM
110components.
111.Bd -literal
112typedef struct {
113 BIGNUM *p; // prime number (shared)
114 BIGNUM *g; // generator of Z_p (shared)
115 BIGNUM *priv_key; // private DH value x
116 BIGNUM *pub_key; // public DH value g^x
117 // ...
118} DH;
119.Ed
120.Pp
121Note that DH keys may use non-standard
122.Vt DH_METHOD
123implementations, either directly or by the use of
124.Vt ENGINE
125modules.
126In some cases (eg. an
127.Vt ENGINE
128providing support for hardware-embedded keys), these
129.Vt BIGNUM
130values will not be used by the implementation or may be used for
131alternative data storage.
132For this reason, applications should generally avoid using
133.Vt DH
134structure elements directly and instead use API functions to query
135or modify keys.
136.Sh SEE ALSO
137.Xr bn 3 ,
138.Xr d2i_DHparams 3 ,
139.Xr DH_compute_key 3 ,
140.Xr DH_generate_parameters 3 ,
141.Xr DH_get_ex_new_index 3 ,
142.Xr DH_new 3 ,
143.Xr DH_set_method 3 ,
144.Xr dsa 3 ,
145.Xr engine 3 ,
146.Xr ERR 3 ,
147.Xr rsa 3 ,
148.Xr RSA_print 3
diff --git a/src/lib/libcrypto/man/dsa.3 b/src/lib/libcrypto/man/dsa.3
new file mode 100644
index 0000000000..b374f18d27
--- /dev/null
+++ b/src/lib/libcrypto/man/dsa.3
@@ -0,0 +1,244 @@
1.Dd $Mdocdate: November 5 2016 $
2.Dt DSA 3
3.Os
4.Sh NAME
5.Nm dsa
6.Nd Digital Signature Algorithm
7.Sh SYNOPSIS
8.In openssl/dsa.h
9.In openssl/engine.h
10.Ft DSA *
11.Fn DSA_new void
12.Ft void
13.Fo DSA_free
14.Fa "DSA *dsa"
15.Fc
16.Ft int
17.Fo DSA_size
18.Fa "const DSA *dsa"
19.Fc
20.Ft DSA *
21.Fo DSA_generate_parameters
22.Fa "int bits"
23.Fa "unsigned char *seed"
24.Fa "int seed_len"
25.Fa "int *counter_ret"
26.Fa "unsigned long *h_ret"
27.Fa "void (*callback)(int, int, void *)"
28.Fa "void *cb_arg"
29.Fc
30.Ft DH *
31.Fo DSA_dup_DH
32.Fa "const DSA *r"
33.Fc
34.Ft int
35.Fo DSA_generate_key
36.Fa "DSA *dsa"
37.Fc
38.Ft int
39.Fo DSA_sign
40.Fa "int dummy"
41.Fa "const unsigned char *dgst"
42.Fa "int len"
43.Fa "unsigned char *sigret"
44.Fa "unsigned int *siglen"
45.Fa "DSA *dsa"
46.Fc
47.Ft int
48.Fo DSA_sign_setup
49.Fa "DSA *dsa"
50.Fa "BN_CTX *ctx"
51.Fa "BIGNUM **kinvp"
52.Fa "BIGNUM **rp"
53.Fc
54.Ft int
55.Fo DSA_verify
56.Fa "int dummy"
57.Fa "const unsigned char *dgst"
58.Fa "int len"
59.Fa "const unsigned char *sigbuf"
60.Fa "int siglen"
61.Fa "DSA *dsa"
62.Fc
63.Ft void
64.Fo DSA_set_default_method
65.Fa "const DSA_METHOD *meth"
66.Fc
67.Ft const DSA_METHOD *
68.Fn DSA_get_default_method void
69.Ft int
70.Fo DSA_set_method
71.Fa "DSA *dsa"
72.Fa "const DSA_METHOD *meth"
73.Fc
74.Ft DSA *
75.Fo DSA_new_method
76.Fa "ENGINE *engine"
77.Fc
78.Ft const DSA_METHOD *
79.Fn DSA_OpenSSL void
80.Ft int
81.Fo DSA_get_ex_new_index
82.Fa "long argl"
83.Fa "char *argp"
84.Fa "int (*new_func)()"
85.Fa "int (*dup_func)()"
86.Fa "void (*free_func)()"
87.Fc
88.Ft int
89.Fo DSA_set_ex_data
90.Fa "DSA *d"
91.Fa "int idx"
92.Fa "char *arg"
93.Fc
94.Ft char *
95.Fo DSA_get_ex_data
96.Fa "DSA *d"
97.Fa "int idx"
98.Fc
99.Ft DSA_SIG *
100.Fn DSA_SIG_new void
101.Ft void
102.Fo DSA_SIG_free
103.Fa "DSA_SIG *a"
104.Fc
105.Ft int
106.Fo i2d_DSA_SIG
107.Fa "const DSA_SIG *a"
108.Fa "unsigned char **pp"
109.Fc
110.Ft DSA_SIG *
111.Fo d2i_DSA_SIG
112.Fa "DSA_SIG **v"
113.Fa "unsigned char **pp"
114.Fa "long length"
115.Fc
116.Ft DSA_SIG *
117.Fo DSA_do_sign
118.Fa "const unsigned char *dgst"
119.Fa "int dlen"
120.Fa "DSA *dsa"
121.Fc
122.Ft int
123.Fo DSA_do_verify
124.Fa "const unsigned char *dgst"
125.Fa "int dgst_len"
126.Fa "DSA_SIG *sig"
127.Fa "DSA *dsa"
128.Fc
129.Ft DSA *
130.Fo d2i_DSAPublicKey
131.Fa "DSA **a"
132.Fa "unsigned char **pp"
133.Fa "long length"
134.Fc
135.Ft DSA *
136.Fo d2i_DSAPrivateKey
137.Fa "DSA **a"
138.Fa "unsigned char **pp"
139.Fa "long length"
140.Fc
141.Ft DSA *
142.Fo d2i_DSAparams
143.Fa "DSA **a"
144.Fa "unsigned char **pp"
145.Fa "long length"
146.Fc
147.Ft int
148.Fo i2d_DSAPublicKey
149.Fa "const DSA *a"
150.Fa "unsigned char **pp"
151.Fc
152.Ft int
153.Fo i2d_DSAPrivateKey
154.Fa "const DSA *a"
155.Fa "unsigned char **pp"
156.Fc
157.Ft int
158.Fo i2d_DSAparams
159.Fa "const DSA *a"
160.Fa "unsigned char **pp"
161.Fc
162.Ft int
163.Fo DSAparams_print
164.Fa "BIO *bp"
165.Fa "const DSA *x"
166.Fc
167.Ft int
168.Fo DSAparams_print_fp
169.Fa "FILE *fp"
170.Fa "const DSA *x"
171.Fc
172.Ft int
173.Fo DSA_print
174.Fa "BIO *bp"
175.Fa "const DSA *x"
176.Fa "int off"
177.Fc
178.Ft int
179.Fo DSA_print_fp
180.Fa "FILE *bp"
181.Fa "const DSA *x"
182.Fa "int off"
183.Fc
184.Sh DESCRIPTION
185These functions implement the Digital Signature Algorithm (DSA).
186The generation of shared DSA parameters is described in
187.Xr DSA_generate_parameters 3 ;
188.Xr DSA_generate_key 3
189describes how to generate a signature key.
190Signature generation and verification are described in
191.Xr DSA_sign 3 .
192.Pp
193The
194.Vt DSA
195structure consists of several BIGNUM components.
196.Bd -literal
197typedef struct {
198 BIGNUM *p; // prime number (public)
199 BIGNUM *q; // 160-bit subprime, q | p-1 (public)
200 BIGNUM *g; // generator of subgroup (public)
201 BIGNUM *priv_key; // private key x
202 BIGNUM *pub_key; // public key y = g^x
203 // ...
204} DSA;
205.Ed
206.Pp
207In public keys,
208.Fa priv_key
209is
210.Dv NULL .
211.Pp
212Note that DSA keys may use non-standard
213.Vt DSA_METHOD
214implementations, either directly or by the use of
215.Vt ENGINE
216modules.
217In some cases (eg. an
218.Vt ENGINE
219providing support for hardware-embedded keys), these
220.Vt BIGNUM
221values will not be used by the implementation or may be used for
222alternative data storage.
223For this reason, applications should generally avoid using
224.Vt DSA
225structure elements directly and instead use API functions to query
226or modify keys.
227.Sh SEE ALSO
228.Xr bn 3 ,
229.Xr dh 3 ,
230.Xr DSA_dup_DH 3 ,
231.Xr DSA_generate_key 3 ,
232.Xr DSA_generate_parameters 3 ,
233.Xr DSA_get_ex_new_index 3 ,
234.Xr DSA_new 3 ,
235.Xr DSA_set_method 3 ,
236.Xr DSA_sign 3 ,
237.Xr DSA_size 3 ,
238.Xr engine 3 ,
239.Xr err 3 ,
240.Xr rsa 3 ,
241.Xr RSA_print 3
242.Sh STANDARDS
243US Federal Information Processing Standard FIPS 186 (Digital Signature
244Standard, DSS), ANSI X9.30
diff --git a/src/lib/libcrypto/man/ec.3 b/src/lib/libcrypto/man/ec.3
new file mode 100644
index 0000000000..3ecdd5dd8d
--- /dev/null
+++ b/src/lib/libcrypto/man/ec.3
@@ -0,0 +1,710 @@
1.Dd $Mdocdate: November 5 2016 $
2.Dt EC 3
3.Os
4.Sh NAME
5.Nm ec
6.Nd Elliptic Curve functions
7.Sh SYNOPSIS
8.In openssl/ec.h
9.In openssl/bn.h
10.Ft const EC_METHOD *
11.Fn EC_GFp_simple_method void
12.Ft const EC_METHOD *
13.Fn EC_GFp_mont_method void
14.Ft const EC_METHOD *
15.Fn EC_GFp_nist_method void
16.Ft const EC_METHOD *
17.Fn EC_GFp_nistp224_method void
18.Ft const EC_METHOD *
19.Fn EC_GFp_nistp256_method void
20.Ft const EC_METHOD *
21.Fn EC_GFp_nistp521_method void
22.Ft const EC_METHOD *
23.Fn EC_GF2m_simple_method void
24.Ft EC_GROUP *
25.Fo EC_GROUP_new
26.Fa "const EC_METHOD *meth"
27.Fc
28.Ft void
29.Fo EC_GROUP_free
30.Fa "EC_GROUP *group"
31.Fc
32.Ft void
33.Fo EC_GROUP_clear_free
34.Fa "EC_GROUP *group"
35.Fc
36.Ft int
37.Fo EC_GROUP_copy
38.Fa "EC_GROUP *dst"
39.Fa "const EC_GROUP *src"
40.Fc
41.Ft EC_GROUP *
42.Fo EC_GROUP_dup
43.Fa "const EC_GROUP *src"
44.Fc
45.Ft const EC_METHOD *
46.Fo EC_GROUP_method_of
47.Fa "const EC_GROUP *group"
48.Fc
49.Ft int
50.Fo EC_METHOD_get_field_type
51.Fa "const EC_METHOD *meth"
52.Fc
53.Ft int
54.Fo EC_GROUP_set_generator
55.Fa "EC_GROUP *group"
56.Fa "const EC_POINT *generator"
57.Fa "const BIGNUM *order"
58.Fa "const BIGNUM *cofactor"
59.Fc
60.Ft const EC_POINT *
61.Fo EC_GROUP_get0_generator
62.Fa "const EC_GROUP *group"
63.Fc
64.Ft int
65.Fo EC_GROUP_get_order
66.Fa "const EC_GROUP *group"
67.Fa "BIGNUM *order"
68.Fa "BN_CTX *ctx"
69.Fc
70.Ft int
71.Fo EC_GROUP_get_cofactor
72.Fa "const EC_GROUP *group"
73.Fa "BIGNUM *cofactor"
74.Fa "BN_CTX *ctx"
75.Fc
76.Ft void
77.Fo EC_GROUP_set_curve_name
78.Fa "EC_GROUP *group"
79.Fa "int nid"
80.Fc
81.Ft int
82.Fo EC_GROUP_get_curve_name
83.Fa "const EC_GROUP *group"
84.Fc
85.Ft void
86.Fo EC_GROUP_set_asn1_flag
87.Fa "EC_GROUP *group"
88.Fa "int flag"
89.Fc
90.Ft int
91.Fo EC_GROUP_get_asn1_flag
92.Fa "const EC_GROUP *group"
93.Fc
94.Ft void
95.Fo EC_GROUP_set_point_conversion_form
96.Fa "EC_GROUP *group"
97.Fa "point_conversion_form_t form"
98.Fc
99.Ft point_conversion_form_t
100.Fo EC_GROUP_get_point_conversion_form
101.Fa "const EC_GROUP *"
102.Fc
103.Ft unsigned char *
104.Fo EC_GROUP_get0_seed
105.Fa "const EC_GROUP *x"
106.Fc
107.Ft size_t
108.Fo EC_GROUP_get_seed_len
109.Fa "const EC_GROUP *"
110.Fc
111.Ft size_t
112.Fo EC_GROUP_set_seed
113.Fa "EC_GROUP *"
114.Fa "const unsigned char *"
115.Fa "size_t len"
116.Fc
117.Ft int
118.Fo EC_GROUP_set_curve_GFp
119.Fa "EC_GROUP *group"
120.Fa "const BIGNUM *p"
121.Fa "const BIGNUM *a"
122.Fa "const BIGNUM *b"
123.Fa "BN_CTX *ctx"
124.Fc
125.Ft int
126.Fo EC_GROUP_get_curve_GFp
127.Fa "const EC_GROUP *group"
128.Fa "BIGNUM *p"
129.Fa "BIGNUM *a"
130.Fa "BIGNUM *b"
131.Fa "BN_CTX *ctx"
132.Fc
133.Ft int
134.Fo EC_GROUP_set_curve_GF2m
135.Fa "EC_GROUP *group"
136.Fa "const BIGNUM *p"
137.Fa "const BIGNUM *a"
138.Fa "const BIGNUM *b"
139.Fa "BN_CTX *ctx"
140.Fc
141.Ft int
142.Fo EC_GROUP_get_curve_GF2m
143.Fa "const EC_GROUP *group"
144.Fa "BIGNUM *p"
145.Fa "BIGNUM *a"
146.Fa "BIGNUM *b"
147.Fa "BN_CTX *ctx"
148.Fc
149.Ft int
150.Fo EC_GROUP_get_degree
151.Fa "const EC_GROUP *group"
152.Fc
153.Ft int
154.Fo EC_GROUP_check
155.Fa "const EC_GROUP *group"
156.Fa "BN_CTX *ctx"
157.Fc
158.Ft int
159.Fo EC_GROUP_check_discriminant
160.Fa "const EC_GROUP *group"
161.Fa "BN_CTX *ctx"
162.Fc
163.Ft int
164.Fo EC_GROUP_cmp
165.Fa "const EC_GROUP *a"
166.Fa "const EC_GROUP *b"
167.Fa "BN_CTX *ctx"
168.Fc
169.Ft EC_GROUP *
170.Fo EC_GROUP_new_curve_GFp
171.Fa "const BIGNUM *p"
172.Fa "const BIGNUM *a"
173.Fa "const BIGNUM *b"
174.Fa "BN_CTX *ctx"
175.Fc
176.Ft EC_GROUP *
177.Fo EC_GROUP_new_curve_GF2m
178.Fa "const BIGNUM *p"
179.Fa "const BIGNUM *a"
180.Fa "const BIGNUM *b"
181.Fa "BN_CTX *ctx"
182.Fc
183.Ft EC_GROUP *
184.Fo EC_GROUP_new_by_curve_name
185.Fa "int nid"
186.Fc
187.Ft size_t
188.Fo EC_get_builtin_curves
189.Fa "EC_builtin_curve *r"
190.Fa "size_t nitems"
191.Fc
192.Ft EC_POINT *
193.Fo EC_POINT_new
194.Fa "const EC_GROUP *group"
195.Fc
196.Ft void
197.Fo EC_POINT_free
198.Fa "EC_POINT *point"
199.Fc
200.Ft void
201.Fo EC_POINT_clear_free
202.Fa "EC_POINT *point"
203.Fc
204.Ft int
205.Fo EC_POINT_copy
206.Fa "EC_POINT *dst"
207.Fa "const EC_POINT *src"
208.Fc
209.Ft EC_POINT *
210.Fo EC_POINT_dup
211.Fa "const EC_POINT *src"
212.Fa "const EC_GROUP *group"
213.Fc
214.Ft const EC_METHOD *
215.Fo EC_POINT_method_of
216.Fa "const EC_POINT *point"
217.Fc
218.Ft int
219.Fo EC_POINT_set_to_infinity
220.Fa "const EC_GROUP *group"
221.Fa "EC_POINT *point"
222.Fc
223.Ft int
224.Fo EC_POINT_set_Jprojective_coordinates_GFp
225.Fa "const EC_GROUP *group"
226.Fa "EC_POINT *p"
227.Fa "const BIGNUM *x"
228.Fa "const BIGNUM *y"
229.Fa "const BIGNUM *z"
230.Fa "BN_CTX *ctx"
231.Fc
232.Ft int
233.Fo EC_POINT_get_Jprojective_coordinates_GFp
234.Fa "const EC_GROUP *group"
235.Fa "const EC_POINT *p"
236.Fa "BIGNUM *x"
237.Fa "BIGNUM *y"
238.Fa "BIGNUM *z"
239.Fa "BN_CTX *ctx"
240.Fc
241.Ft int
242.Fo EC_POINT_set_affine_coordinates_GFp
243.Fa "const EC_GROUP *group"
244.Fa "EC_POINT *p"
245.Fa "const BIGNUM *x"
246.Fa "const BIGNUM *y"
247.Fa "BN_CTX *ctx"
248.Fc
249.Ft int
250.Fo EC_POINT_get_affine_coordinates_GFp
251.Fa "const EC_GROUP *group"
252.Fa "const EC_POINT *p"
253.Fa "BIGNUM *x"
254.Fa "BIGNUM *y"
255.Fa "BN_CTX *ctx"
256.Fc
257.Ft int
258.Fo EC_POINT_set_compressed_coordinates_GFp
259.Fa "const EC_GROUP *group"
260.Fa "EC_POINT *p"
261.Fa "const BIGNUM *x"
262.Fa "int y_bit"
263.Fa "BN_CTX *ctx"
264.Fc
265.Ft int
266.Fo EC_POINT_set_affine_coordinates_GF2m
267.Fa "const EC_GROUP *group"
268.Fa "EC_POINT *p"
269.Fa "const BIGNUM *x"
270.Fa "const BIGNUM *y"
271.Fa "BN_CTX *ctx"
272.Fc
273.Ft int
274.Fo EC_POINT_get_affine_coordinates_GF2m
275.Fa "const EC_GROUP *group"
276.Fa "const EC_POINT *p"
277.Fa "BIGNUM *x"
278.Fa "BIGNUM *y"
279.Fa "BN_CTX *ctx"
280.Fc
281.Ft int
282.Fo EC_POINT_set_compressed_coordinates_GF2m
283.Fa "const EC_GROUP *group"
284.Fa "EC_POINT *p"
285.Fa "const BIGNUM *x"
286.Fa "int y_bit"
287.Fa "BN_CTX *ctx"
288.Fc
289.Ft size_t
290.Fo EC_POINT_point2oct
291.Fa "const EC_GROUP *group"
292.Fa "const EC_POINT *p"
293.Fa "point_conversion_form_t form"
294.Fa "unsigned char *buf"
295.Fa "size_t len"
296.Fa "BN_CTX *ctx"
297.Fc
298.Ft int
299.Fo EC_POINT_oct2point
300.Fa "const EC_GROUP *group"
301.Fa "EC_POINT *p"
302.Fa "const unsigned char *buf"
303.Fa "size_t len"
304.Fa "BN_CTX *ctx"
305.Fc
306.Ft BIGNUM *
307.Fo EC_POINT_point2bn
308.Fa "const EC_GROUP *"
309.Fa "const EC_POINT *"
310.Fa "point_conversion_form_t form"
311.Fa "BIGNUM *"
312.Fa "BN_CTX *"
313.Fc
314.Ft EC_POINT *
315.Fo EC_POINT_bn2point
316.Fa "const EC_GROUP *"
317.Fa "const BIGNUM *"
318.Fa "EC_POINT *"
319.Fa "BN_CTX *"
320.Fc
321.Ft char *
322.Fo EC_POINT_point2hex
323.Fa "const EC_GROUP *"
324.Fa "const EC_POINT *"
325.Fa "point_conversion_form_t form"
326.Fa "BN_CTX *"
327.Fc
328.Ft EC_POINT *
329.Fo EC_POINT_hex2point
330.Fa "const EC_GROUP *"
331.Fa "const char *"
332.Fa "EC_POINT *"
333.Fa "BN_CTX *"
334.Fc
335.Ft int
336.Fo EC_POINT_add
337.Fa "const EC_GROUP *group"
338.Fa "EC_POINT *r"
339.Fa "const EC_POINT *a"
340.Fa "const EC_POINT *b"
341.Fa "BN_CTX *ctx"
342.Fc
343.Ft int
344.Fo EC_POINT_dbl
345.Fa "const EC_GROUP *group"
346.Fa "EC_POINT *r"
347.Fa "const EC_POINT *a"
348.Fa "BN_CTX *ctx"
349.Fc
350.Ft int
351.Fo EC_POINT_invert
352.Fa "const EC_GROUP *group"
353.Fa "EC_POINT *a"
354.Fa "BN_CTX *ctx"
355.Fc
356.Ft int
357.Fo EC_POINT_is_at_infinity
358.Fa "const EC_GROUP *group"
359.Fa "const EC_POINT *p"
360.Fc
361.Ft int
362.Fo EC_POINT_is_on_curve
363.Fa "const EC_GROUP *group"
364.Fa "const EC_POINT *point"
365.Fa "BN_CTX *ctx"
366.Fc
367.Ft int
368.Fo EC_POINT_cmp
369.Fa "const EC_GROUP *group"
370.Fa "const EC_POINT *a"
371.Fa "const EC_POINT *b"
372.Fa "BN_CTX *ctx"
373.Fc
374.Ft int
375.Fo EC_POINT_make_affine
376.Fa "const EC_GROUP *group"
377.Fa "EC_POINT *point"
378.Fa "BN_CTX *ctx"
379.Fc
380.Ft int
381.Fo EC_POINTs_make_affine
382.Fa "const EC_GROUP *group"
383.Fa "size_t num"
384.Fa "EC_POINT *points[]"
385.Fa "BN_CTX *ctx"
386.Fc
387.Ft int
388.Fo EC_POINTs_mul
389.Fa "const EC_GROUP *group"
390.Fa "EC_POINT *r"
391.Fa "const BIGNUM *n"
392.Fa "size_t num"
393.Fa "const EC_POINT *p[]"
394.Fa "const BIGNUM *m[]"
395.Fa "BN_CTX *ctx"
396.Fc
397.Ft int
398.Fo EC_POINT_mul
399.Fa "const EC_GROUP *group"
400.Fa "EC_POINT *r"
401.Fa "const BIGNUM *n"
402.Fa "const EC_POINT *q"
403.Fa "const BIGNUM *m"
404.Fa "BN_CTX *ctx"
405.Fc
406.Ft int
407.Fo EC_GROUP_precompute_mult
408.Fa "EC_GROUP *group"
409.Fa "BN_CTX *ctx"
410.Fc
411.Ft int
412.Fo EC_GROUP_have_precompute_mult
413.Fa "const EC_GROUP *group"
414.Fc
415.Ft int
416.Fo EC_GROUP_get_basis_type
417.Fa "const EC_GROUP *"
418.Fc
419.Ft int
420.Fo EC_GROUP_get_trinomial_basis
421.Fa "const EC_GROUP *"
422.Fa "unsigned int *k"
423.Fc
424.Ft int
425.Fo EC_GROUP_get_pentanomial_basis
426.Fa "const EC_GROUP *"
427.Fa "unsigned int *k1"
428.Fa "unsigned int *k2"
429.Fa "unsigned int *k3"
430.Fc
431.Ft EC_GROUP *
432.Fo d2i_ECPKParameters
433.Fa "EC_GROUP **"
434.Fa "const unsigned char **in"
435.Fa "long len"
436.Fc
437.Ft int
438.Fo i2d_ECPKParameters
439.Fa "const EC_GROUP *"
440.Fa "unsigned char **out"
441.Fc
442.Fd #define d2i_ECPKParameters_bio(bp,x)\
443 ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x)
444.Fd #define i2d_ECPKParameters_bio(bp,x)\
445 ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x)
446.Fd #define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL,\
447 (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x))
448.Fd #define i2d_ECPKParameters_fp(fp,x)\
449 ASN1_i2d_fp(i2d_ECPKParameters,(fp), (unsigned char *)(x))
450.Ft int
451.Fo ECPKParameters_print
452.Fa "BIO *bp"
453.Fa "const EC_GROUP *x"
454.Fa "int off"
455.Fc
456.Ft int
457.Fo ECPKParameters_print_fp
458.Fa "FILE *fp"
459.Fa "const EC_GROUP *x"
460.Fa "int off"
461.Fc
462.Ft EC_KEY *
463.Fn EC_KEY_new void
464.Ft int
465.Fo EC_KEY_get_flags
466.Fa "const EC_KEY *key"
467.Fc
468.Ft void
469.Fo EC_KEY_set_flags
470.Fa "EC_KEY *key"
471.Fa "int flags"
472.Fc
473.Ft void
474.Fo EC_KEY_clear_flags
475.Fa "EC_KEY *key"
476.Fa "int flags"
477.Fc
478.Ft EC_KEY *
479.Fo EC_KEY_new_by_curve_name
480.Fa "int nid"
481.Fc
482.Ft void
483.Fo EC_KEY_free
484.Fa "EC_KEY *key"
485.Fc
486.Ft EC_KEY *
487.Fo EC_KEY_copy
488.Fa "EC_KEY *dst"
489.Fa "const EC_KEY *src"
490.Fc
491.Ft EC_KEY *
492.Fo EC_KEY_dup
493.Fa "const EC_KEY *src"
494.Fc
495.Ft int
496.Fo EC_KEY_up_ref
497.Fa "EC_KEY *key"
498.Fc
499.Ft const EC_GROUP *
500.Fo EC_KEY_get0_group
501.Fa "const EC_KEY *key"
502.Fc
503.Ft int
504.Fo EC_KEY_set_group
505.Fa "EC_KEY *key"
506.Fa "const EC_GROUP *group"
507.Fc
508.Ft const BIGNUM *
509.Fo EC_KEY_get0_private_key
510.Fa "const EC_KEY *key"
511.Fc
512.Ft int
513.Fo EC_KEY_set_private_key
514.Fa "EC_KEY *key"
515.Fa "const BIGNUM *prv"
516.Fc
517.Ft const EC_POINT *
518.Fo EC_KEY_get0_public_key
519.Fa "const EC_KEY *key"
520.Fc
521.Ft int
522.Fo EC_KEY_set_public_key
523.Fa "EC_KEY *key"
524.Fa "const EC_POINT *pub"
525.Fc
526.Ft unsigned
527.Fo EC_KEY_get_enc_flags
528.Fa "const EC_KEY *key"
529.Fc
530.Ft void
531.Fo EC_KEY_set_enc_flags
532.Fa "EC_KEY *eckey"
533.Fa "unsigned int flags"
534.Fc
535.Ft point_conversion_form_t
536.Fo EC_KEY_get_conv_form
537.Fa "const EC_KEY *key"
538.Fc
539.Ft void
540.Fo EC_KEY_set_conv_form
541.Fa "EC_KEY *eckey"
542.Fa "point_conversion_form_t cform"
543.Fc
544.Ft void *
545.Fo EC_KEY_get_key_method_data
546.Fa "EC_KEY *key"
547.Fa "void *(*dup_func)(void *)"
548.Fa "void (*free_func)(void *)"
549.Fa "void (*clear_free_func)(void *)"
550.Fc
551.Ft void
552.Fo EC_KEY_insert_key_method_data
553.Fa "EC_KEY *key"
554.Fa "void *data"
555.Fa "void *(*dup_func)(void *)"
556.Fa "void (*free_func)(void *)"
557.Fa "void (*clear_free_func)(void *)"
558.Fc
559.Ft void
560.Fo EC_KEY_set_asn1_flag
561.Fa "EC_KEY *eckey"
562.Fa "int asn1_flag"
563.Fc
564.Ft int
565.Fo EC_KEY_precompute_mult
566.Fa "EC_KEY *key"
567.Fa "BN_CTX *ctx"
568.Fc
569.Ft int
570.Fo EC_KEY_generate_key
571.Fa "EC_KEY *key"
572.Fc
573.Ft int
574.Fo EC_KEY_check_key
575.Fa "const EC_KEY *key"
576.Fc
577.Ft int
578.Fo EC_KEY_set_public_key_affine_coordinates
579.Fa "EC_KEY *key"
580.Fa "BIGNUM *x"
581.Fa "BIGNUM *y"
582.Fc
583.Ft EC_KEY *
584.Fo d2i_ECPrivateKey
585.Fa "EC_KEY **key"
586.Fa "const unsigned char **in"
587.Fa "long len"
588.Fc
589.Ft int
590.Fo i2d_ECPrivateKey
591.Fa "EC_KEY *key"
592.Fa "unsigned char **out"
593.Fc
594.Ft EC_KEY *
595.Fo d2i_ECParameters
596.Fa "EC_KEY **key"
597.Fa "const unsigned char **in"
598.Fa "long len"
599.Fc
600.Ft int
601.Fo i2d_ECParameters
602.Fa "EC_KEY *key"
603.Fa "unsigned char **out"
604.Fc
605.Ft EC_KEY *
606.Fo o2i_ECPublicKey
607.Fa "EC_KEY **key"
608.Fa "const unsigned char **in"
609.Fa "long len"
610.Fc
611.Ft int
612.Fo i2o_ECPublicKey
613.Fa "EC_KEY *key"
614.Fa "unsigned char **out"
615.Fc
616.Ft int
617.Fo ECParameters_print
618.Fa "BIO *bp"
619.Fa "const EC_KEY *key"
620.Fc
621.Ft int
622.Fo EC_KEY_print
623.Fa "BIO *bp"
624.Fa "const EC_KEY *key"
625.Fa "int off"
626.Fc
627.Ft int
628.Fo ECParameters_print_fp
629.Fa "FILE *fp"
630.Fa "const EC_KEY *key"
631.Fc
632.Ft int
633.Fo EC_KEY_print_fp
634.Fa "FILE *fp"
635.Fa "const EC_KEY *key"
636.Fa "int off"
637.Fc
638.Ft EC_KEY *
639.Fo ECParameters_dup
640.Fa "EC_KEY *key"
641.Fc
642.Fd #define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid)\
643 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, EVP_PKEY_OP_PARAMGEN,\
644 EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL)
645.Sh DESCRIPTION
646This library provides an extensive set of functions for performing
647operations on elliptic curves over finite fields.
648In general an elliptic curve is one with an equation of the form:
649.Pp
650.Dl y^2 = x^3 + ax + b
651.Pp
652An
653.Vt EC_GROUP
654structure is used to represent the definition of an elliptic curve.
655Points on a curve are stored using an
656.Vt EC_POINT
657structure.
658An
659.Vt EC_KEY
660is used to hold a private/public key pair, where a private key is simply a
661.Vt BIGNUM
662and a public key is a point on a curve represented by an
663.Vt EC_POINT .
664.Pp
665The library contains a number of alternative implementations of the
666different functions.
667Each implementation is optimised for different scenarios.
668No matter which implementation is being used, the interface remains the
669same.
670The library handles calling the correct implementation when an interface
671function is invoked.
672An implementation is represented by an
673.Vt EC_METHOD
674structure.
675.Pp
676The creation and destruction of
677.Vt EC_GROUP
678objects is described in
679.Xr EC_GROUP_new 3 .
680Functions for manipulating
681.Vt EC_GROUP
682objects are described in
683.Xr EC_GROUP_copy 3 .
684.Pp
685Functions for creating, destroying and manipulating
686.Vt EC_POINT
687objects are explained in
688.Xr EC_POINT_new 3 ,
689whilst functions for performing mathematical operations and tests on
690.Vt EC_POINT Ns s
691are coverd in
692.Xr EC_POINT_add 3 .
693.Pp
694For working with private and public keys refer to
695.Xr EC_KEY_new 3 .
696Implementations are covered in
697.Xr EC_GFp_simple_method 3 .
698.Pp
699For information on encoding and decoding curve parameters to and
700from ASN.1 see
701.Xr d2i_ECPKParameters 3 .
702.Sh SEE ALSO
703.Xr crypto 3 ,
704.Xr d2i_ECPKParameters 3 ,
705.Xr EC_GFp_simple_method 3 ,
706.Xr EC_GROUP_copy 3 ,
707.Xr EC_GROUP_new 3 ,
708.Xr EC_KEY_new 3 ,
709.Xr EC_POINT_add 3 ,
710.Xr EC_POINT_new 3
diff --git a/src/lib/libcrypto/man/engine.3 b/src/lib/libcrypto/man/engine.3
new file mode 100644
index 0000000000..3624fa76e4
--- /dev/null
+++ b/src/lib/libcrypto/man/engine.3
@@ -0,0 +1,1187 @@
1.Dd $Mdocdate: November 5 2016 $
2.Dt ENGINE 3
3.Os
4.Sh NAME
5.Nm ENGINE_add ,
6.Nm ENGINE_by_id ,
7.Nm ENGINE_finish ,
8.Nm ENGINE_get_first ,
9.Nm ENGINE_get_last ,
10.Nm ENGINE_get_next ,
11.Nm ENGINE_get_prev ,
12.Nm ENGINE_init ,
13.Nm ENGINE_load_builtin_engines ,
14.Nm ENGINE_remove
15.Nd ENGINE cryptographic module support
16.Sh SYNOPSIS
17.In openssl/engine.h
18.Ft ENGINE *
19.Fn ENGINE_get_first void
20.Ft ENGINE *
21.Fn ENGINE_get_last void
22.Ft ENGINE *
23.Fo ENGINE_get_next
24.Fa "ENGINE *e"
25.Fc
26.Ft ENGINE *
27.Fo ENGINE_get_prev
28.Fa "ENGINE *e"
29.Fc
30.Ft int
31.Fo ENGINE_add
32.Fa "ENGINE *e"
33.Fc
34.Ft int
35.Fo ENGINE_remove
36.Fa "ENGINE *e"
37.Fc
38.Ft ENGINE *
39.Fo ENGINE_by_id
40.Fa "const char *id"
41.Fc
42.Ft int
43.Fo ENGINE_init
44.Fa "ENGINE *e"
45.Fc
46.Ft int
47.Fo ENGINE_finish
48.Fa "ENGINE *e"
49.Fc
50.Ft void
51.Fn ENGINE_load_openssl void
52.Ft void
53.Fn ENGINE_load_dynamic void
54.Ft void
55.Fn ENGINE_load_cryptodev void
56.Ft void
57.Fn ENGINE_load_builtin_engines void
58.Ft void
59.Fn ENGINE_cleanup void
60.Ft ENGINE *
61.Fn ENGINE_get_default_RSA void
62.Ft ENGINE *
63.Fn ENGINE_get_default_DSA void
64.Ft ENGINE *
65.Fn ENGINE_get_default_ECDH void
66.Ft ENGINE *
67.Fn ENGINE_get_default_ECDSA void
68.Ft ENGINE *
69.Fn ENGINE_get_default_DH void
70.Ft ENGINE *
71.Fn ENGINE_get_default_RAND void
72.Ft ENGINE *
73.Fo ENGINE_get_cipher_engine
74.Fa "int nid"
75.Fc
76.Ft ENGINE *
77.Fo ENGINE_get_digest_engine
78.Fa "int nid"
79.Fc
80.Ft int
81.Fo ENGINE_set_default_RSA
82.Fa "ENGINE *e"
83.Fc
84.Ft int
85.Fo ENGINE_set_default_DSA
86.Fa "ENGINE *e"
87.Fc
88.Ft int
89.Fo ENGINE_set_default_ECDH
90.Fa "ENGINE *e"
91.Fc
92.Ft int
93.Fo ENGINE_set_default_ECDSA
94.Fa "ENGINE *e"
95.Fc
96.Ft int
97.Fo ENGINE_set_default_DH
98.Fa "ENGINE *e"
99.Fc
100.Ft int
101.Fo ENGINE_set_default_RAND
102.Fa "ENGINE *e"
103.Fc
104.Ft int
105.Fo ENGINE_set_default_ciphers
106.Fa "ENGINE *e"
107.Fc
108.Ft int
109.Fo ENGINE_set_default_digests
110.Fa "ENGINE *e"
111.Fc
112.Ft int
113.Fo ENGINE_set_default_string
114.Fa "ENGINE *e"
115.Fa "const char *list"
116.Fc
117.Ft int
118.Fo ENGINE_set_default
119.Fa "ENGINE *e"
120.Fa "unsigned int flags"
121.Fc
122.Ft unsigned int
123.Fn ENGINE_get_table_flags void
124.Ft void
125.Fo ENGINE_set_table_flags
126.Fa "unsigned int flags"
127.Fc
128.Ft int
129.Fo ENGINE_register_RSA
130.Fa "ENGINE *e"
131.Fc
132.Ft void
133.Fo ENGINE_unregister_RSA
134.Fa "ENGINE *e"
135.Fc
136.Ft void
137.Fn ENGINE_register_all_RSA void
138.Ft int
139.Fo ENGINE_register_DSA
140.Fa "ENGINE *e"
141.Fc
142.Ft void
143.Fo ENGINE_unregister_DSA
144.Fa "ENGINE *e"
145.Fc
146.Ft void
147.Fn ENGINE_register_all_DSA void
148.Ft int
149.Fo ENGINE_register_ECDH
150.Fa "ENGINE *e"
151.Fc
152.Ft void
153.Fo ENGINE_unregister_ECDH
154.Fa "ENGINE *e"
155.Fc
156.Ft void
157.Fn ENGINE_register_all_ECDH void
158.Ft int
159.Fo ENGINE_register_ECDSA
160.Fa "ENGINE *e"
161.Fc
162.Ft void
163.Fo ENGINE_unregister_ECDSA
164.Fa "ENGINE *e"
165.Fc
166.Ft void
167.Fn ENGINE_register_all_ECDSA void
168.Ft int
169.Fo ENGINE_register_DH
170.Fa "ENGINE *e"
171.Fc
172.Ft void
173.Fo ENGINE_unregister_DH
174.Fa "ENGINE *e"
175.Fc
176.Ft void
177.Fn ENGINE_register_all_DH void
178.Ft int
179.Fo ENGINE_register_RAND
180.Fa "ENGINE *e"
181.Fc
182.Ft void
183.Fo ENGINE_unregister_RAND
184.Fa "ENGINE *e"
185.Fc
186.Ft void
187.Fn ENGINE_register_all_RAND void
188.Ft int
189.Fo ENGINE_register_STORE
190.Fa "ENGINE *e"
191.Fc
192.Ft void
193.Fo ENGINE_unregister_STORE
194.Fa "ENGINE *e"
195.Fc
196.Ft void
197.Fn ENGINE_register_all_STORE void
198.Ft int
199.Fo ENGINE_register_ciphers
200.Fa "ENGINE *e"
201.Fc
202.Ft void
203.Fo ENGINE_unregister_ciphers
204.Fa "ENGINE *e"
205.Fc
206.Ft void
207.Fn ENGINE_register_all_ciphers void
208.Ft int
209.Fo ENGINE_register_digests
210.Fa "ENGINE *e"
211.Fc
212.Ft void
213.Fo ENGINE_unregister_digests
214.Fa "ENGINE *e"
215.Fc
216.Ft void
217.Fn ENGINE_register_all_digests void
218.Ft int
219.Fo ENGINE_register_complete
220.Fa "ENGINE *e"
221.Fc
222.Ft int
223.Fn ENGINE_register_all_complete void
224.Ft int
225.Fo ENGINE_ctrl
226.Fa "ENGINE *e"
227.Fa "int cmd"
228.Fa "long i"
229.Fa "void *p"
230.Fa "void (*f)(void)"
231.Fc
232.Ft int
233.Fo ENGINE_cmd_is_executable
234.Fa "ENGINE *e"
235.Fa "int cmd"
236.Fc
237.Ft int
238.Fo ENGINE_ctrl_cmd
239.Fa "ENGINE *e"
240.Fa "const char *cmd_name"
241.Fa "long i"
242.Fa "void *p"
243.Fa "void (*f)(void)"
244.Fa "int cmd_optional"
245.Fc
246.Ft int
247.Fo ENGINE_ctrl_cmd_string
248.Fa "ENGINE *e"
249.Fa "const char *cmd_name"
250.Fa "const char *arg"
251.Fa "int cmd_optional"
252.Fc
253.Ft int
254.Fo ENGINE_set_ex_data
255.Fa "ENGINE *e"
256.Fa "int idx"
257.Fa "void *arg"
258.Fc
259.Ft void *
260.Fo ENGINE_get_ex_data
261.Fa "const ENGINE *e"
262.Fa "int idx"
263.Fc
264.Ft int
265.Fo ENGINE_get_ex_new_index
266.Fa "long argl"
267.Fa "void *argp"
268.Fa "CRYPTO_EX_new *new_func"
269.Fa "CRYPTO_EX_dup *dup_func"
270.Fa "CRYPTO_EX_free *free_func"
271.Fc
272.Ft ENGINE *
273.Fn ENGINE_new void
274.Ft int
275.Fo ENGINE_free
276.Fa "ENGINE *e"
277.Fc
278.Ft int
279.Fo ENGINE_up_ref
280.Fa "ENGINE *e"
281.Fc
282.Ft int
283.Fo ENGINE_set_id
284.Fa "ENGINE *e"
285.Fa "const char *id"
286.Fc
287.Ft int
288.Fo ENGINE_set_name
289.Fa "ENGINE *e"
290.Fa "const char *name"
291.Fc
292.Ft int
293.Fo ENGINE_set_RSA
294.Fa "ENGINE *e"
295.Fa "const RSA_METHOD *rsa_meth"
296.Fc
297.Ft int
298.Fo ENGINE_set_DSA
299.Fa "ENGINE *e"
300.Fa "const DSA_METHOD *dsa_meth"
301.Fc
302.Ft int
303.Fo ENGINE_set_ECDH
304.Fa "ENGINE *e"
305.Fa "const ECDH_METHOD *dh_meth"
306.Fc
307.Ft int
308.Fo ENGINE_set_ECDSA
309.Fa "ENGINE *e"
310.Fa "const ECDSA_METHOD *dh_meth"
311.Fc
312.Ft int
313.Fo ENGINE_set_DH
314.Fa "ENGINE *e"
315.Fa "const DH_METHOD *dh_meth"
316.Fc
317.Ft int
318.Fo ENGINE_set_RAND
319.Fa "ENGINE *e"
320.Fa "const RAND_METHOD *rand_meth"
321.Fc
322.Ft int
323.Fo ENGINE_set_STORE
324.Fa "ENGINE *e"
325.Fa "const STORE_METHOD *rand_meth"
326.Fc
327.Ft int
328.Fo ENGINE_set_destroy_function
329.Fa "ENGINE *e"
330.Fa "ENGINE_GEN_INT_FUNC_PTR destroy_f"
331.Fc
332.Ft int
333.Fo ENGINE_set_init_function
334.Fa "ENGINE *e"
335.Fa "ENGINE_GEN_INT_FUNC_PTR init_f"
336.Fc
337.Ft int
338.Fo ENGINE_set_finish_function
339.Fa "ENGINE *e"
340.Fa "ENGINE_GEN_INT_FUNC_PTR finish_f"
341.Fc
342.Ft int
343.Fo ENGINE_set_ctrl_function
344.Fa "ENGINE *e"
345.Fa "ENGINE_CTRL_FUNC_PTR ctrl_f"
346.Fc
347.Ft int
348.Fo ENGINE_set_load_privkey_function
349.Fa "ENGINE *e"
350.Fa "ENGINE_LOAD_KEY_PTR loadpriv_f"
351.Fc
352.Ft int
353.Fo ENGINE_set_load_pubkey_function
354.Fa "ENGINE *e"
355.Fa "ENGINE_LOAD_KEY_PTR loadpub_f"
356.Fc
357.Ft int
358.Fo ENGINE_set_ciphers
359.Fa "ENGINE *e"
360.Fa "ENGINE_CIPHERS_PTR f"
361.Fc
362.Ft int
363.Fo ENGINE_set_digests
364.Fa "ENGINE *e"
365.Fa "ENGINE_DIGESTS_PTR f"
366.Fc
367.Ft int
368.Fo ENGINE_set_flags
369.Fa "ENGINE *e"
370.Fa "int flags"
371.Fc
372.Ft int
373.Fo ENGINE_set_cmd_defns
374.Fa "ENGINE *e"
375.Fa "const ENGINE_CMD_DEFN *defns"
376.Fc
377.Ft const char *
378.Fo ENGINE_get_id
379.Fa "const ENGINE *e"
380.Fc
381.Ft const char *
382.Fo ENGINE_get_name
383.Fa "const ENGINE *e"
384.Fc
385.Ft const RSA_METHOD *
386.Fo ENGINE_get_RSA
387.Fa "const ENGINE *e"
388.Fc
389.Ft const DSA_METHOD *
390.Fo ENGINE_get_DSA
391.Fa "const ENGINE *e"
392.Fc
393.Ft const ECDH_METHOD *
394.Fo ENGINE_get_ECDH
395.Fa "const ENGINE *e"
396.Fc
397.Ft const ECDSA_METHOD *
398.Fo ENGINE_get_ECDSA
399.Fa "const ENGINE *e"
400.Fc
401.Ft const DH_METHOD *
402.Fo ENGINE_get_DH
403.Fa "const ENGINE *e"
404.Fc
405.Ft const RAND_METHOD *
406.Fo ENGINE_get_RAND
407.Fa "const ENGINE *e"
408.Fc
409.Ft const STORE_METHOD *
410.Fo ENGINE_get_STORE
411.Fa "const ENGINE *e"
412.Fc
413.Ft ENGINE_GEN_INT_FUNC_PTR
414.Fo ENGINE_get_destroy_function
415.Fa "const ENGINE *e"
416.Fc
417.Ft ENGINE_GEN_INT_FUNC_PTR
418.Fo ENGINE_get_init_function
419.Fa "const ENGINE *e"
420.Fc
421.Ft ENGINE_GEN_INT_FUNC_PTR
422.Fo ENGINE_get_finish_function
423.Fa "const ENGINE *e"
424.Fc
425.Ft ENGINE_CTRL_FUNC_PTR
426.Fo ENGINE_get_ctrl_function
427.Fa "const ENGINE *e"
428.Fc
429.Ft ENGINE_LOAD_KEY_PTR
430.Fo ENGINE_get_load_privkey_function
431.Fa "const ENGINE *e"
432.Fc
433.Ft ENGINE_LOAD_KEY_PTR
434.Fo ENGINE_get_load_pubkey_function
435.Fa "const ENGINE *e"
436.Fc
437.Ft ENGINE_CIPHERS_PTR
438.Fo ENGINE_get_ciphers
439.Fa "const ENGINE *e"
440.Fc
441.Ft ENGINE_DIGESTS_PTR
442.Fo ENGINE_get_digests
443.Fa "const ENGINE *e"
444.Fc
445.Ft const EVP_CIPHER *
446.Fo ENGINE_get_cipher
447.Fa "ENGINE *e"
448.Fa "int nid"
449.Fc
450.Ft const EVP_MD *
451.Fo ENGINE_get_digest
452.Fa "ENGINE *e"
453.Fa "int nid"
454.Fc
455.Ft int
456.Fo ENGINE_get_flags
457.Fa "const ENGINE *e"
458.Fc
459.Ft const ENGINE_CMD_DEFN *
460.Fo ENGINE_get_cmd_defns
461.Fa "const ENGINE *e"
462.Fc
463.Ft EVP_PKEY *
464.Fo ENGINE_load_private_key
465.Fa "ENGINE *e"
466.Fa "const char *key_id"
467.Fa "UI_METHOD *ui_method"
468.Fa "void *callback_data"
469.Fc
470.Ft EVP_PKEY *
471.Fo ENGINE_load_public_key
472.Fa "ENGINE *e"
473.Fa "const char *key_id"
474.Fa "UI_METHOD *ui_method"
475.Fa "void *callback_data"
476.Fc
477.Ft void
478.Fn ENGINE_add_conf_module void
479.Sh DESCRIPTION
480These functions create, manipulate, and use cryptographic modules
481in the form of
482.Vt ENGINE
483objects.
484These objects act as containers for implementations of cryptographic
485algorithms, and support a reference-counted mechanism to allow them to
486be dynamically loaded in and out of the running application.
487.Pp
488The cryptographic functionality that can be provided by an
489.Vt ENGINE
490implementation includes the following abstractions:
491.Pp
492.Bl -bullet -compact
493.It
494.Vt RSA_METHOD :
495for providing alternative RSA implementations
496.It
497.Vt DSA_METHOD , DH_METHOD , RAND_METHOD , ECDH_METHOD ,
498.Vt ECDSA_METHOD , STORE_METHOD :
499similarly for other OpenSSL APIs
500.It
501.Vt EVP_CIPHER :
502potentially multiple cipher algorithms (indexed by 'nid')
503.It
504.Vt EVP_DIGEST :
505potentially multiple hash algorithms (indexed by 'nid')
506.It
507key-loading: loading public and/or private EVP_PKEY keys
508.El
509.Ss Reference counting and handles
510Due to the modular nature of the
511.Nm engine
512API, pointers to
513.Vt ENGINE Ns s
514need to be treated as handles - ie. not only as pointers, but also
515as references to the underlying
516.Vt ENGINE
517object.
518One should obtain a new reference when making copies of an
519.Vt ENGINE
520pointer if the copies will be used (and released) independently.
521.Pp
522.Vt ENGINE
523objects have two levels of reference-counting to match the way in
524which the objects are used.
525At the most basic level, each
526.Vt ENGINE
527pointer is inherently a
528.Sy structural
529reference - a structural reference is required to use the pointer value
530at all, as this kind of reference is a guarantee that the structure can
531not be deallocated until the reference is released.
532.Pp
533However, a structural reference provides no guarantee that the
534.Vt ENGINE
535is initialised and able to use any of its cryptographic implementations.
536Indeed it's quite possible that most
537.Vt ENGINE Ns s
538will not initialise at all in typical environments, as
539.Vt ENGINE Ns s
540are typically used to support specialised hardware.
541To use an
542.Vt ENGINE Ap s
543functionality, you need a
544.Sy functional
545reference.
546This kind of reference can be considered a specialised form of
547structural reference, because each functional reference implicitly
548contains a structural reference as well - however to avoid
549difficult-to-find programming bugs, it is recommended to treat the two
550kinds of reference independently.
551If you have a functional reference to an
552.Vt ENGINE ,
553you have a guarantee that the
554.Vt ENGINE
555has been initialised ready to perform cryptographic operations and
556will remain uninitialised until after you have released your
557reference.
558.Pp
559.Em Structural references
560.Pp
561This basic type of reference is used for instantiating new
562.Vt ENGINE Ns s,
563iterating across OpenSSL's internal linked-list of loaded
564.Vt ENGINE Ns s,
565reading information about an
566.Vt ENGINE ,
567etc.
568Essentially a structural reference is sufficient if you only need to
569query or manipulate the data of an
570.Vt ENGINE
571implementation rather than use its functionality.
572.Pp
573The
574.Fn ENGINE_new
575function returns a structural reference to a new (empty)
576.Vt ENGINE
577object.
578There are other
579.Nm engine
580API functions that return structural references such as
581.Fn ENGINE_by_id ,
582.Fn ENGINE_get_first ,
583.Fn ENGINE_get_last ,
584.Fn ENGINE_get_next ,
585and
586.Fn ENGINE_get_prev .
587All structural references should be released by a corresponding call
588to the
589.Fn ENGINE_free
590function.
591The
592.Vt ENGINE
593object itself will only actually be cleaned up and deallocated when
594the last structural reference is released.
595.Pp
596It should also be noted that many
597.Nm engine
598API function calls that accept a structural reference will internally
599obtain another reference.
600Typically this happens whenever the supplied
601.Vt ENGINE
602will be needed by OpenSSL after the function has returned.
603For example, the function to add a new
604.Vt ENGINE
605to OpenSSL's internal list is
606.Fn ENGINE_add .
607If this function returns success, OpenSSL will have stored a new
608structural reference internally so the caller is still responsible for
609freeing their own reference with
610.Fn ENGINE_free
611when they are finished with it.
612In a similar way, some functions will automatically release the
613structural reference passed to it if part of the function's job is
614to do so.
615For example, the
616.Fn ENGINE_get_next
617and
618.Fn ENGINE_get_prev
619functions are used for iterating across the internal
620.Vt ENGINE
621list.
622They
623will return a new structural reference to the next (or previous)
624.Vt ENGINE
625in the list or
626.Dv NULL
627if at the end (or beginning) of the list, but in either case the
628structural reference passed to the function is released on behalf
629of the caller.
630.Pp
631To clarify a particular function's handling of references, one should
632always consult that function's manual page, or failing that the
633.In openssl/engine.h
634header file includes some hints.
635.Pp
636.Em Functional references
637.Pp
638As mentioned, functional references exist when the cryptographic
639functionality of an
640.Vt ENGINE
641is required to be available.
642A functional reference can be obtained in one of two ways; from an
643existing structural reference to the required
644.Vt ENGINE ,
645or by asking OpenSSL for the default operational
646.Vt ENGINE
647for a given cryptographic purpose.
648.Pp
649To obtain a functional reference from an existing structural reference,
650call the
651.Fn ENGINE_init
652function.
653This returns zero if the
654.Vt ENGINE
655was not already operational and couldn't be successfully initialised
656(eg. lack of system drivers, no special hardware attached, etc.),
657otherwise it will return non-zero to indicate that the
658.Vt ENGINE
659is now operational and will have allocated a new
660.Sy functional
661reference to the
662.Vt ENGINE .
663All functional references are released by calling
664.Fn ENGINE_finish ,
665which removes the implicit structural reference as well.
666.Pp
667The second way to get a functional reference is by asking OpenSSL for a
668default implementation for a given task, eg.
669by
670.Fn ENGINE_get_default_RSA ,
671.Fn ENGINE_get_default_cipher_engine ,
672etc.
673These are discussed in the next section, though they are not usually
674required by application programmers as they are used automatically when
675creating and using the relevant algorithm-specific types in OpenSSL,
676such as RSA, DSA, EVP_CIPHER_CTX, etc.
677.Ss Default implementations
678For each supported abstraction, the
679.Nm engine
680code maintains an internal table of state to control which
681implementations are available for a given abstraction and which
682should be used by default.
683These implementations are registered in the tables and indexed by an
684.Fa nid
685value, because abstractions like
686.Vt EVP_CIPHER
687and
688.Vt EVP_DIGEST
689support many distinct algorithms and modes, and
690.Vt ENGINE Ns s
691can support arbitrarily many of them.
692In the case of other abstractions like RSA, DSA, etc., there is
693only one "algorithm" so all implementations implicitly register
694using the same
695.Fa nid
696index.
697.Pp
698When a default
699.Vt ENGINE
700is requested for a given abstraction/algorithm/mode, (eg. when
701calling
702.Fn RSA_new_method NULL ) ,
703a "get_default" call will be made to the
704.Nm engine
705subsystem to process the corresponding state table and return
706a functional reference to an initialised
707.Vt ENGINE
708whose implementation should be used.
709If no
710.Vt ENGINE
711should (or can) be used, it will return
712.Dv NULL
713and the caller will operate with a
714.Dv NULL
715.Vt ENGINE
716handle.
717This usually equates to using the conventional software implementation.
718In the latter case, OpenSSL will from then on behave the way it used to
719before the
720.Nm engine
721API existed.
722.Pp
723Each state table has a flag to note whether it has processed this
724"get_default" query since the table was last modified, because to
725process this question it must iterate across all the registered
726.Vt ENGINE Ns s
727in the table trying to initialise each of them in turn, in case one of
728them is operational.
729If it returns a functional reference to an
730.Vt ENGINE ,
731it will also cache another reference to speed up processing future
732queries (without needing to iterate across the table).
733Likewise, it will cache a
734.Dv NULL
735response if no
736.Vt ENGINE
737was available so that future queries won't repeat the same iteration
738unless the state table changes.
739This behaviour can also be changed; if the
740.Dv ENGINE_TABLE_FLAG_NOINIT
741flag is set (using
742.Fn ENGINE_set_table_flags ) ,
743no attempted initialisations will take place, instead the only way for
744the state table to return a
745.Pf non- Dv NULL
746.Vt ENGINE
747to the "get_default" query will be if one is expressly set in the table.
748For example,
749.Fn ENGINE_set_default_RSA
750does the same job as
751.Fn ENGINE_register_RSA
752except that it also sets the state table's cached response for the
753"get_default" query.
754In the case of abstractions like
755.Vt EVP_CIPHER ,
756where implementations are indexed by
757.Fa nid ,
758these flags and cached-responses are distinct for each
759.Fa nid
760value.
761.Ss Application requirements
762This section will explain the basic things an application programmer
763should support to make the most useful elements of the
764.Nm engine
765functionality available to the user.
766The first thing to consider is whether the programmer wishes to make
767alternative
768.Vt ENGINE
769modules available to the application and user.
770OpenSSL maintains an internal linked list of "visible"
771.Vt ENGINE Ns s
772from which it has to operate.
773At start-up, this list is empty, and in fact if an application does
774not call any
775.Nm engine
776API calls and it uses static
777linking against openssl, then the resulting application binary will
778not contain any alternative
779.Nm engine
780code at all.
781So the first consideration is whether any/all available
782.Vt ENGINE
783implementations should be made visible to OpenSSL.
784This is controlled by calling the various "load" functions, eg.
785.Fn ENGINE_load_builtin_engines
786to make all
787.Vt ENGINE
788implementations bundled with OpenSSL available.
789.Pp
790Note that
791.Fn ENGINE_load_dynamic
792is a placeholder and does not enable dynamic engine loading support.
793.Pp
794Having called any of these functions,
795.Vt ENGINE
796objects would have been dynamically allocated and populated with
797these implementations and linked into OpenSSL's internal linked
798list.
799.Pp
800If no
801.Nm engine
802API functions are called at all in an application, then there are
803no inherent memory leaks to worry about from the
804.Nm engine
805functionality, however if any
806.Vt ENGINE Ns s
807are loaded, even if they are never registered or used, it is necessary
808to use the
809.Fn ENGINE_cleanup
810function to correspondingly cleanup before program exit, if the caller
811wishes to avoid memory leaks.
812This mechanism uses an internal callback registration table so that any
813.Nm engine
814API functionality that knows it requires cleanup can register its
815cleanup details to be called during
816.Fn ENGINE_cleanup .
817This approach allows
818.Fn ENGINE_cleanup
819to clean up after any
820.Nm engine
821functionality at all that your program uses, yet doesn't automatically
822create linker dependencies to all possible
823.Nm engine
824functionality - only the cleanup callbacks required by the functionality
825you do use will be required by the linker.
826.Pp
827The fact that
828.Vt ENGINE Ns s
829are made visible to OpenSSL (and thus are linked into the program
830and loaded into memory at run-time) does not mean they are "registered"
831or called into use by OpenSSL automatically - that behaviour is
832something for the application to control.
833Some applications will want to allow the user to specify exactly which
834.Vt ENGINE
835they want used if any is to be used at all.
836Others may prefer to load all support and have OpenSSL automatically use
837at run-time any
838.Vt ENGINE
839that is able to successfully initialised - ie. to assume that this
840corresponds to acceleration hardware attached to the machine or
841some such thing.
842There are probably numerous other ways in which applications may prefer
843to handle things, so we will simply illustrate the consequences as they
844apply to a couple of simple cases and leave developers to consider these
845and the source code to openssl's builtin utilities as guides.
846.Pp
847.Em Using a specific ENGINE implementation
848.Pp
849Here we'll assume an application has been configured by its user or
850admin to want to use the "ACME"
851.Vt ENGINE
852if it is available in the version of OpenSSL the application was
853compiled with.
854If it is available, it should be used by default for all RSA, DSA, and
855symmetric cipher operation, otherwise OpenSSL should use its builtin
856software as usual.
857The following code illustrates how to approach this:
858.Bd -literal
859ENGINE *e;
860const char *engine_id = "ACME";
861ENGINE_load_builtin_engines();
862e = ENGINE_by_id(engine_id);
863if (!e)
864 /* the engine isn't available */
865 return;
866if (!ENGINE_init(e)) {
867 /* the engine couldn't initialise, release 'e' */
868 ENGINE_free(e);
869 return;
870}
871if (!ENGINE_set_default_RSA(e))
872 /* This should only happen when 'e' can't initialise, but the previous
873 * statement suggests it did. */
874 abort();
875ENGINE_set_default_DSA(e);
876ENGINE_set_default_ciphers(e);
877/* Release the functional reference from ENGINE_init() */
878ENGINE_finish(e);
879/* Release the structural reference from ENGINE_by_id() */
880ENGINE_free(e);
881.Ed
882.Pp
883.Em Automatically using builtin ENGINE implementations
884.Pp
885Here we'll assume we want to load and register all
886.Vt ENGINE
887implementations bundled with OpenSSL, such that for any cryptographic
888algorithm required by OpenSSL - if there is an
889.Vt ENGINE
890that implements it and can be initialise, it should be used.
891The following code illustrates how this can work;
892.Bd -literal
893/* Load all bundled ENGINEs into memory and make them visible */
894ENGINE_load_builtin_engines();
895/* Register all of them for every algorithm they collectively implement */
896ENGINE_register_all_complete();
897.Ed
898.Pp
899That's all that's required.
900For example, the next time OpenSSL tries to set up an RSA key, any bundled
901.Vt ENGINE Ns s
902that implement
903.Vt RSA_METHOD
904will be passed to
905.Fn ENGINE_init
906and if any of those succeed, that
907.Vt ENGINE
908will be set as the default for RSA use from then on.
909.Ss Advanced configuration support
910There is a mechanism supported by the
911.Nm engine
912framework that allows each
913.Vt ENGINE
914implementation to define an arbitrary set of configuration
915"commands" and expose them to OpenSSL and any applications based on
916OpenSSL.
917This mechanism is entirely based on the use of name-value pairs
918and assumes ASCII input (no unicode or UTF for now!), so it is ideal if
919applications want to provide a transparent way for users to provide
920arbitrary configuration "directives" directly to such
921.Vt ENGINE Ns s.
922It is also possible for the application to dynamically interrogate the
923loaded
924.Vt ENGINE
925implementations for the names, descriptions, and input flags of
926their available "control commands", providing a more flexible
927configuration scheme.
928However, if the user is expected to know which
929.Vt ENGINE
930device he/she is using (in the case of specialised hardware, this
931goes without saying) then applications may not need to concern
932themselves with discovering the supported control commands and
933simply prefer to pass settings into
934.Vt ENGINE s
935exactly as they are provided by the user.
936.Pp
937Before illustrating how control commands work, it is worth mentioning
938what they are typically used for.
939Broadly speaking there are two uses for control commands; the first is
940to provide the necessary details to the implementation (which may know
941nothing at all specific to the host system) so that it can be
942initialised for use.
943This could include the path to any driver or config files it needs to
944load, required network addresses, smart-card identifiers, passwords to
945initialise protected devices, logging information, etc etc.
946This class of commands typically needs to be passed to an
947.Vt ENGINE
948.Sy before
949attempting to initialise it, ie. before calling
950.Fn ENGINE_init .
951The other class of commands consist of settings or operations that tweak
952certain behaviour or cause certain operations to take place, and these
953commands may work either before or after
954.Fn ENGINE_init ,
955or in some cases both.
956.Vt ENGINE
957implementations should provide indications of this in the descriptions
958attached to builtin control commands and/or in external product
959documentation.
960.Pp
961.Em Issuing control commands to an ENGINE
962.Pp
963Let's illustrate by example; a function for which the caller supplies
964the name of the
965.Vt ENGINE
966it wishes to use, a table of string-pairs for use before initialisation,
967and another table for use after initialisation.
968Note that the string-pairs used for control commands consist of a
969command "name" followed by the command "parameter" - the parameter
970could be
971.Dv NULL
972in some cases but the name can not.
973This function should initialise the
974.Vt ENGINE
975(issuing the "pre" commands beforehand and the "post" commands
976afterwards) and set it as the default for everything except RAND
977and then return a boolean success or failure.
978.Bd -literal
979int
980generic_load_engine_fn(const char *engine_id,
981 const char **pre_cmds, int pre_num,
982 const char **post_cmds, int post_num)
983{
984 ENGINE *e = ENGINE_by_id(engine_id);
985
986 if (!e)
987 return 0;
988 while (pre_num--) {
989 if (!ENGINE_ctrl_cmd_string(e,
990 pre_cmds[0], pre_cmds[1], 0)) {
991 fprintf(stderr,
992 "Failed command (%s - %s:%s)\en",
993 engine_id, pre_cmds[0],
994 pre_cmds[1] ? pre_cmds[1] : "(NULL)");
995 ENGINE_free(e);
996 return 0;
997 }
998 pre_cmds += 2;
999 }
1000 if (!ENGINE_init(e)) {
1001 fprintf(stderr, "Failed initialisation\en");
1002 ENGINE_free(e);
1003 return 0;
1004 }
1005 /*
1006 * ENGINE_init() returned a functional reference,
1007 * so free the structural reference from
1008 * ENGINE_by_id().
1009 */
1010 ENGINE_free(e);
1011 while (post_num--) {
1012 if (!ENGINE_ctrl_cmd_string(e,
1013 post_cmds[0], post_cmds[1], 0)) {
1014 fprintf(stderr,
1015 "Failed command (%s - %s:%s)\en",
1016 engine_id, post_cmds[0],
1017 post_cmds[1] ? post_cmds[1] : "(NULL)");
1018 ENGINE_finish(e);
1019 return 0;
1020 }
1021 post_cmds += 2;
1022 }
1023 ENGINE_set_default(e, ENGINE_METHOD_ALL & ~ENGINE_METHOD_RAND);
1024 /* Success */
1025 return 1;
1026}
1027.Ed
1028.Pp
1029Note that
1030.Fn ENGINE_ctrl_cmd_string
1031accepts a boolean argument that can relax the semantics of the function.
1032If set to non-zero it will only return failure if the
1033.Vt ENGINE
1034supported the given command name but failed while executing it, if the
1035.Vt ENGINE
1036doesn't support the command name it will simply return success without
1037doing anything.
1038In this case we assume the user is only supplying commands specific to
1039the given
1040.Vt ENGINE
1041so we set this to FALSE.
1042.Pp
1043.Em Discovering supported control commands
1044.Pp
1045It is possible to discover at run-time the names, numerical-ids,
1046descriptions and input parameters of the control commands supported by an
1047.Vt ENGINE
1048using a structural reference.
1049Note that some control commands are defined by OpenSSL itself and it
1050will intercept and handle these control commands on behalf of the
1051.Vt ENGINE ,
1052ie. the
1053.Vt ENGINE Ap s
1054ctrl() handler is not used for the control command.
1055.In openssl/engine.h
1056defines an index,
1057.Dv ENGINE_CMD_BASE ,
1058that all control commands implemented by
1059.Vt ENGINE Ns s
1060should be numbered from.
1061Any command value lower than this symbol is considered a "generic"
1062command is handled directly by the OpenSSL core routines.
1063.Pp
1064It is using these "core" control commands that one can discover the
1065control commands implemented by a given
1066.Vt ENGINE ,
1067specifically the commands:
1068.Bd -literal
1069#define ENGINE_HAS_CTRL_FUNCTION 10
1070#define ENGINE_CTRL_GET_FIRST_CMD_TYPE 11
1071#define ENGINE_CTRL_GET_NEXT_CMD_TYPE 12
1072#define ENGINE_CTRL_GET_CMD_FROM_NAME 13
1073#define ENGINE_CTRL_GET_NAME_LEN_FROM_CMD 14
1074#define ENGINE_CTRL_GET_NAME_FROM_CMD 15
1075#define ENGINE_CTRL_GET_DESC_LEN_FROM_CMD 16
1076#define ENGINE_CTRL_GET_DESC_FROM_CMD 17
1077#define ENGINE_CTRL_GET_CMD_FLAGS 18
1078.Ed
1079.Pp
1080Whilst these commands are automatically processed by the OpenSSL
1081framework code, they use various properties exposed by each
1082.Vt ENGINE
1083to process these queries.
1084An
1085.Vt ENGINE
1086has 3 properties it exposes that can affect how this behaves;
1087it can supply a ctrl() handler, it can specify
1088.Dv ENGINE_FLAGS_MANUAL_CMD_CTRL
1089in the
1090.Vt ENGINE Ap s
1091flags, and it can expose an array of control command descriptions.
1092If an
1093.Vt ENGINE
1094specifies the
1095.Dv ENGINE_FLAGS_MANUAL_CMD_CTRL
1096flag, then it will simply pass all these "core" control commands
1097directly to the
1098.Vt ENGINE Ap s
1099ctrl() handler (and thus, it must have supplied one), so it is up
1100to the
1101.Vt ENGINE
1102to reply to these "discovery" commands itself.
1103If that flag is not set, then the OpenSSL framework code will work with
1104the following rules;
1105.Bl -tag -width Ds
1106.It If no ctrl() handler is supplied:
1107.Dv ENGINE_HAS_CTRL_FUNCTION
1108returns FALSE (zero), all other commands fail.
1109.It If a ctrl() handler was supplied but no array of control commands:
1110.Dv ENGINE_HAS_CTRL_FUNCTION
1111returns TRUE, all other commands fail.
1112.It If a ctrl() handler and array of control commands was supplied:
1113.Dv ENGINE_HAS_CTRL_FUNCTION
1114returns TRUE, all other commands proceed processing...
1115.El
1116.Pp
1117If the
1118.Vt ENGINE Ns s
1119array of control commands is empty, then all other commands will fail.
1120Otherwise
1121.Dv ENGINE_CTRL_GET_FIRST_CMD_TYPE
1122returns the identifier of the first command supported by the
1123.Vt ENGINE ,
1124.Dv ENGINE_GET_NEXT_CMD_TYPE
1125takes the identifier of a command supported by the
1126.Vt ENGINE
1127and returns the next command identifier or fails if there are no more,
1128.Dv ENGINE_CMD_FROM_NAME
1129takes a string name for a command and returns the corresponding
1130identifier or fails if no such command name exists, and the remaining
1131commands take a command identifier and return properties of the
1132corresponding commands.
1133All except
1134.Dv ENGINE_CTRL_GET_FLAGS
1135return the string length of a command name or description, or
1136populate a supplied character buffer with a copy of the command
1137name or description.
1138.Dv ENGINE_CTRL_GET_FLAGS
1139returns a bitwise-OR'd mask of the following possible values:
1140.Bd -literal
1141#define ENGINE_CMD_FLAG_NUMERIC (unsigned int)0x0001
1142#define ENGINE_CMD_FLAG_STRING (unsigned int)0x0002
1143#define ENGINE_CMD_FLAG_NO_INPUT (unsigned int)0x0004
1144#define ENGINE_CMD_FLAG_INTERNAL (unsigned int)0x0008
1145.Ed
1146.Pp
1147If the
1148.Dv ENGINE_CMD_FLAG_INTERNAL
1149flag is set, then any other flags are purely informational to the caller.
1150This flag will prevent the command being usable for any higher-level
1151.Vt ENGINE
1152functions such as
1153.Fn ENGINE_ctrl_cmd_string .
1154"INTERNAL" commands are not intended to be exposed to text-based
1155configuration by applications, administrations, users, etc.
1156These can support arbitrary operations via
1157.Fn ENGINE_ctrl ,
1158including passing to and/or from the control commands data of any
1159arbitrary type.
1160These commands are supported in the discovery mechanisms simply allow
1161applications to determine if an
1162.Vt ENGINE
1163supports certain specific commands it might want to use (eg.
1164application "foo" might query various
1165.Vt ENGINE Ns s
1166to see if they implement "FOO_GET_VENDOR_LOGO_GIF" - and
1167.Vt ENGINE
1168could therefore decide whether or not to support this "foo"-specific
1169extension).
1170.Ss Future developments
1171The
1172.Nm engine
1173API and internal architecture is currently being reviewed.
1174Slated for possible release in 0.9.8 is support for transparent loading
1175of "dynamic"
1176.Vt ENGINE Ns s (built as self-contained shared libraries).
1177This would allow
1178.Vt ENGINE
1179implementations to be provided independently of
1180OpenSSL libraries and/or OpenSSL-based applications, and would also
1181remove any requirement for applications to explicitly use the "dynamic"
1182.Vt ENGINE
1183to bind to shared-library implementations.
1184.Sh SEE ALSO
1185.Xr dh 3 ,
1186.Xr dsa 3 ,
1187.Xr rsa 3
diff --git a/src/lib/libcrypto/man/lh_stats.3 b/src/lib/libcrypto/man/lh_stats.3
new file mode 100644
index 0000000000..b56bb81979
--- /dev/null
+++ b/src/lib/libcrypto/man/lh_stats.3
@@ -0,0 +1,83 @@
1.Dd $Mdocdate: November 5 2016 $
2.Dt LH_STATS 3
3.Os
4.Sh NAME
5.Nm lh_stats ,
6.Nm lh_node_stats ,
7.Nm lh_node_usage_stats ,
8.Nm lh_stats_bio ,
9.Nm lh_node_stats_bio ,
10.Nm lh_node_usage_stats_bio
11.Nd LHASH statistics
12.Sh SYNOPSIS
13.In openssl/lhash.h
14.Ft void
15.Fo lh_stats
16.Fa "LHASH *table"
17.Fa "FILE *out"
18.Fc
19.Ft void
20.Fo lh_node_stats
21.Fa "LHASH *table"
22.Fa "FILE *out"
23.Fc
24.Ft void
25.Fo lh_node_usage_stats
26.Fa "LHASH *table"
27.Fa "FILE *out"
28.Fc
29.Ft void
30.Fo lh_stats_bio
31.Fa "LHASH *table"
32.Fa "BIO *out"
33.Fc
34.Ft void
35.Fo lh_node_stats_bio
36.Fa "LHASH *table"
37.Fa "BIO *out"
38.Fc
39.Ft void
40.Fo lh_node_usage_stats_bio
41.Fa "LHASH *table"
42.Fa "BIO *out"
43.Fc
44.Sh DESCRIPTION
45The
46.Vt LHASH
47structure records statistics about most aspects of accessing the hash
48table.
49.Pp
50.Fn lh_stats
51prints out statistics on the size of the hash table, how many entries
52are in it, and the number and result of calls to the routines in this
53library.
54.Pp
55.Fn lh_node_stats
56prints the number of entries for each 'bucket' in the hash table.
57.Pp
58.Fn lh_node_usage_stats
59prints out a short summary of the state of the hash table.
60It prints the 'load' and the 'actual load'.
61The load is the average number of data items per 'bucket' in the hash
62table.
63The 'actual load' is the average number of items per 'bucket', but only
64for buckets which contain entries.
65So the 'actual load' is the average number of searches that will need to
66find an item in the hash table, while the 'load' is the average number
67that will be done to record a miss.
68.Pp
69.Fn lh_stats_bio ,
70.Fn lh_node_stats_bio ,
71and
72.Fn lh_node_usage_stats_bio
73are the same as the above, except that the output goes to a
74.Vt BIO .
75.Sh RETURN VALUES
76These functions do not return values.
77.Sh SEE ALSO
78.Xr bio 3 ,
79.Xr lh_new 3
80.Sh HISTORY
81These functions are available in all versions of SSLeay and OpenSSL.
82.Sh AUTHORS
83.An Eric Young