motion-openssl 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +53 -0
  3. data/lib/OpenSSL/aes.h +149 -0
  4. data/lib/OpenSSL/asn1.h +1419 -0
  5. data/lib/OpenSSL/asn1_mac.h +579 -0
  6. data/lib/OpenSSL/asn1t.h +973 -0
  7. data/lib/OpenSSL/bio.h +879 -0
  8. data/lib/OpenSSL/blowfish.h +130 -0
  9. data/lib/OpenSSL/bn.h +939 -0
  10. data/lib/OpenSSL/buffer.h +125 -0
  11. data/lib/OpenSSL/camellia.h +132 -0
  12. data/lib/OpenSSL/cast.h +107 -0
  13. data/lib/OpenSSL/cmac.h +82 -0
  14. data/lib/OpenSSL/cms.h +555 -0
  15. data/lib/OpenSSL/comp.h +79 -0
  16. data/lib/OpenSSL/conf.h +267 -0
  17. data/lib/OpenSSL/conf_api.h +89 -0
  18. data/lib/OpenSSL/crypto.h +661 -0
  19. data/lib/OpenSSL/des.h +257 -0
  20. data/lib/OpenSSL/des_old.h +497 -0
  21. data/lib/OpenSSL/dh.h +392 -0
  22. data/lib/OpenSSL/dsa.h +332 -0
  23. data/lib/OpenSSL/dso.h +451 -0
  24. data/lib/OpenSSL/dtls1.h +272 -0
  25. data/lib/OpenSSL/e_os2.h +328 -0
  26. data/lib/OpenSSL/ebcdic.h +26 -0
  27. data/lib/OpenSSL/ec.h +1282 -0
  28. data/lib/OpenSSL/ecdh.h +134 -0
  29. data/lib/OpenSSL/ecdsa.h +335 -0
  30. data/lib/OpenSSL/engine.h +960 -0
  31. data/lib/OpenSSL/err.h +389 -0
  32. data/lib/OpenSSL/evp.h +1534 -0
  33. data/lib/OpenSSL/hmac.h +109 -0
  34. data/lib/OpenSSL/idea.h +105 -0
  35. data/lib/OpenSSL/krb5_asn.h +240 -0
  36. data/lib/OpenSSL/kssl.h +197 -0
  37. data/lib/OpenSSL/lhash.h +240 -0
  38. data/lib/OpenSSL/libcrypto-tvOS.a +0 -0
  39. data/lib/OpenSSL/libcrypto.a +0 -0
  40. data/lib/OpenSSL/libssl-tvOS.a +0 -0
  41. data/lib/OpenSSL/libssl.a +0 -0
  42. data/lib/OpenSSL/md4.h +119 -0
  43. data/lib/OpenSSL/md5.h +119 -0
  44. data/lib/OpenSSL/mdc2.h +94 -0
  45. data/lib/OpenSSL/modes.h +163 -0
  46. data/lib/OpenSSL/obj_mac.h +4194 -0
  47. data/lib/OpenSSL/objects.h +1143 -0
  48. data/lib/OpenSSL/ocsp.h +637 -0
  49. data/lib/OpenSSL/opensslconf.h +262 -0
  50. data/lib/OpenSSL/opensslv.h +97 -0
  51. data/lib/OpenSSL/ossl_typ.h +211 -0
  52. data/lib/OpenSSL/pem.h +615 -0
  53. data/lib/OpenSSL/pem2.h +70 -0
  54. data/lib/OpenSSL/pkcs12.h +342 -0
  55. data/lib/OpenSSL/pkcs7.h +481 -0
  56. data/lib/OpenSSL/pqueue.h +99 -0
  57. data/lib/OpenSSL/rand.h +150 -0
  58. data/lib/OpenSSL/rc2.h +103 -0
  59. data/lib/OpenSSL/rc4.h +88 -0
  60. data/lib/OpenSSL/ripemd.h +105 -0
  61. data/lib/OpenSSL/rsa.h +664 -0
  62. data/lib/OpenSSL/safestack.h +2672 -0
  63. data/lib/OpenSSL/seed.h +149 -0
  64. data/lib/OpenSSL/sha.h +214 -0
  65. data/lib/OpenSSL/srp.h +169 -0
  66. data/lib/OpenSSL/srtp.h +147 -0
  67. data/lib/OpenSSL/ssl.h +3168 -0
  68. data/lib/OpenSSL/ssl2.h +265 -0
  69. data/lib/OpenSSL/ssl23.h +84 -0
  70. data/lib/OpenSSL/ssl3.h +774 -0
  71. data/lib/OpenSSL/stack.h +107 -0
  72. data/lib/OpenSSL/symhacks.h +516 -0
  73. data/lib/OpenSSL/tls1.h +810 -0
  74. data/lib/OpenSSL/ts.h +862 -0
  75. data/lib/OpenSSL/txt_db.h +112 -0
  76. data/lib/OpenSSL/ui.h +415 -0
  77. data/lib/OpenSSL/ui_compat.h +88 -0
  78. data/lib/OpenSSL/whrlpool.h +41 -0
  79. data/lib/OpenSSL/x509.h +1327 -0
  80. data/lib/OpenSSL/x509_vfy.h +647 -0
  81. data/lib/OpenSSL/x509v3.h +1055 -0
  82. data/lib/motion-openssl.rb +8 -0
  83. data/lib/motion-openssl/hooks.rb +8 -0
  84. data/lib/motion-openssl/hooks/openssl.rb +20 -0
  85. data/lib/motion-openssl/version.rb +5 -0
  86. data/motion/openssl.rb +1 -0
  87. data/motion/openssl/random.rb +18 -0
  88. metadata +229 -0
@@ -0,0 +1,392 @@
1
+ /* crypto/dh/dh.h */
2
+ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3
+ * All rights reserved.
4
+ *
5
+ * This package is an SSL implementation written
6
+ * by Eric Young (eay@cryptsoft.com).
7
+ * The implementation was written so as to conform with Netscapes SSL.
8
+ *
9
+ * This library is free for commercial and non-commercial use as long as
10
+ * the following conditions are aheared to. The following conditions
11
+ * apply to all code found in this distribution, be it the RC4, RSA,
12
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13
+ * included with this distribution is covered by the same copyright terms
14
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15
+ *
16
+ * Copyright remains Eric Young's, and as such any Copyright notices in
17
+ * the code are not to be removed.
18
+ * If this package is used in a product, Eric Young should be given attribution
19
+ * as the author of the parts of the library used.
20
+ * This can be in the form of a textual message at program startup or
21
+ * in documentation (online or textual) provided with the package.
22
+ *
23
+ * Redistribution and use in source and binary forms, with or without
24
+ * modification, are permitted provided that the following conditions
25
+ * are met:
26
+ * 1. Redistributions of source code must retain the copyright
27
+ * notice, this list of conditions and the following disclaimer.
28
+ * 2. Redistributions in binary form must reproduce the above copyright
29
+ * notice, this list of conditions and the following disclaimer in the
30
+ * documentation and/or other materials provided with the distribution.
31
+ * 3. All advertising materials mentioning features or use of this software
32
+ * must display the following acknowledgement:
33
+ * "This product includes cryptographic software written by
34
+ * Eric Young (eay@cryptsoft.com)"
35
+ * The word 'cryptographic' can be left out if the rouines from the library
36
+ * being used are not cryptographic related :-).
37
+ * 4. If you include any Windows specific code (or a derivative thereof) from
38
+ * the apps directory (application code) you must include an acknowledgement:
39
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40
+ *
41
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51
+ * SUCH DAMAGE.
52
+ *
53
+ * The licence and distribution terms for any publically available version or
54
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
55
+ * copied and put under another distribution licence
56
+ * [including the GNU Public Licence.]
57
+ */
58
+
59
+ #ifndef HEADER_DH_H
60
+ # define HEADER_DH_H
61
+
62
+ # include <openssl/e_os2.h>
63
+
64
+ # ifdef OPENSSL_NO_DH
65
+ # error DH is disabled.
66
+ # endif
67
+
68
+ # ifndef OPENSSL_NO_BIO
69
+ # include <openssl/bio.h>
70
+ # endif
71
+ # include <openssl/ossl_typ.h>
72
+ # ifndef OPENSSL_NO_DEPRECATED
73
+ # include <openssl/bn.h>
74
+ # endif
75
+
76
+ # ifndef OPENSSL_DH_MAX_MODULUS_BITS
77
+ # define OPENSSL_DH_MAX_MODULUS_BITS 10000
78
+ # endif
79
+
80
+ # define DH_FLAG_CACHE_MONT_P 0x01
81
+
82
+ /*
83
+ * new with 0.9.7h; the built-in DH
84
+ * implementation now uses constant time
85
+ * modular exponentiation for secret exponents
86
+ * by default. This flag causes the
87
+ * faster variable sliding window method to
88
+ * be used for all exponents.
89
+ */
90
+ # define DH_FLAG_NO_EXP_CONSTTIME 0x02
91
+
92
+ /*
93
+ * If this flag is set the DH method is FIPS compliant and can be used in
94
+ * FIPS mode. This is set in the validated module method. If an application
95
+ * sets this flag in its own methods it is its reposibility to ensure the
96
+ * result is compliant.
97
+ */
98
+
99
+ # define DH_FLAG_FIPS_METHOD 0x0400
100
+
101
+ /*
102
+ * If this flag is set the operations normally disabled in FIPS mode are
103
+ * permitted it is then the applications responsibility to ensure that the
104
+ * usage is compliant.
105
+ */
106
+
107
+ # define DH_FLAG_NON_FIPS_ALLOW 0x0400
108
+
109
+ #ifdef __cplusplus
110
+ extern "C" {
111
+ #endif
112
+
113
+ /* Already defined in ossl_typ.h */
114
+ /* typedef struct dh_st DH; */
115
+ /* typedef struct dh_method DH_METHOD; */
116
+
117
+ struct dh_method {
118
+ const char *name;
119
+ /* Methods here */
120
+ int (*generate_key) (DH *dh);
121
+ int (*compute_key) (unsigned char *key, const BIGNUM *pub_key, DH *dh);
122
+ /* Can be null */
123
+ int (*bn_mod_exp) (const DH *dh, BIGNUM *r, const BIGNUM *a,
124
+ const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
125
+ BN_MONT_CTX *m_ctx);
126
+ int (*init) (DH *dh);
127
+ int (*finish) (DH *dh);
128
+ int flags;
129
+ char *app_data;
130
+ /* If this is non-NULL, it will be used to generate parameters */
131
+ int (*generate_params) (DH *dh, int prime_len, int generator,
132
+ BN_GENCB *cb);
133
+ };
134
+
135
+ struct dh_st {
136
+ /*
137
+ * This first argument is used to pick up errors when a DH is passed
138
+ * instead of a EVP_PKEY
139
+ */
140
+ int pad;
141
+ int version;
142
+ BIGNUM *p;
143
+ BIGNUM *g;
144
+ long length; /* optional */
145
+ BIGNUM *pub_key; /* g^x % p */
146
+ BIGNUM *priv_key; /* x */
147
+ int flags;
148
+ BN_MONT_CTX *method_mont_p;
149
+ /* Place holders if we want to do X9.42 DH */
150
+ BIGNUM *q;
151
+ BIGNUM *j;
152
+ unsigned char *seed;
153
+ int seedlen;
154
+ BIGNUM *counter;
155
+ int references;
156
+ CRYPTO_EX_DATA ex_data;
157
+ const DH_METHOD *meth;
158
+ ENGINE *engine;
159
+ };
160
+
161
+ # define DH_GENERATOR_2 2
162
+ /* #define DH_GENERATOR_3 3 */
163
+ # define DH_GENERATOR_5 5
164
+
165
+ /* DH_check error codes */
166
+ # define DH_CHECK_P_NOT_PRIME 0x01
167
+ # define DH_CHECK_P_NOT_SAFE_PRIME 0x02
168
+ # define DH_UNABLE_TO_CHECK_GENERATOR 0x04
169
+ # define DH_NOT_SUITABLE_GENERATOR 0x08
170
+ # define DH_CHECK_Q_NOT_PRIME 0x10
171
+ # define DH_CHECK_INVALID_Q_VALUE 0x20
172
+ # define DH_CHECK_INVALID_J_VALUE 0x40
173
+
174
+ /* DH_check_pub_key error codes */
175
+ # define DH_CHECK_PUBKEY_TOO_SMALL 0x01
176
+ # define DH_CHECK_PUBKEY_TOO_LARGE 0x02
177
+
178
+ /*
179
+ * primes p where (p-1)/2 is prime too are called "safe"; we define this for
180
+ * backward compatibility:
181
+ */
182
+ # define DH_CHECK_P_NOT_STRONG_PRIME DH_CHECK_P_NOT_SAFE_PRIME
183
+
184
+ # define d2i_DHparams_fp(fp,x) (DH *)ASN1_d2i_fp((char *(*)())DH_new, \
185
+ (char *(*)())d2i_DHparams,(fp),(unsigned char **)(x))
186
+ # define i2d_DHparams_fp(fp,x) ASN1_i2d_fp(i2d_DHparams,(fp), \
187
+ (unsigned char *)(x))
188
+ # define d2i_DHparams_bio(bp,x) ASN1_d2i_bio_of(DH,DH_new,d2i_DHparams,bp,x)
189
+ # define i2d_DHparams_bio(bp,x) ASN1_i2d_bio_of_const(DH,i2d_DHparams,bp,x)
190
+
191
+ DH *DHparams_dup(DH *);
192
+
193
+ const DH_METHOD *DH_OpenSSL(void);
194
+
195
+ void DH_set_default_method(const DH_METHOD *meth);
196
+ const DH_METHOD *DH_get_default_method(void);
197
+ int DH_set_method(DH *dh, const DH_METHOD *meth);
198
+ DH *DH_new_method(ENGINE *engine);
199
+
200
+ DH *DH_new(void);
201
+ void DH_free(DH *dh);
202
+ int DH_up_ref(DH *dh);
203
+ int DH_size(const DH *dh);
204
+ int DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
205
+ CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
206
+ int DH_set_ex_data(DH *d, int idx, void *arg);
207
+ void *DH_get_ex_data(DH *d, int idx);
208
+
209
+ /* Deprecated version */
210
+ # ifndef OPENSSL_NO_DEPRECATED
211
+ DH *DH_generate_parameters(int prime_len, int generator,
212
+ void (*callback) (int, int, void *), void *cb_arg);
213
+ # endif /* !defined(OPENSSL_NO_DEPRECATED) */
214
+
215
+ /* New version */
216
+ int DH_generate_parameters_ex(DH *dh, int prime_len, int generator,
217
+ BN_GENCB *cb);
218
+
219
+ int DH_check(const DH *dh, int *codes);
220
+ int DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *codes);
221
+ int DH_generate_key(DH *dh);
222
+ int DH_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh);
223
+ int DH_compute_key_padded(unsigned char *key, const BIGNUM *pub_key, DH *dh);
224
+ DH *d2i_DHparams(DH **a, const unsigned char **pp, long length);
225
+ int i2d_DHparams(const DH *a, unsigned char **pp);
226
+ DH *d2i_DHxparams(DH **a, const unsigned char **pp, long length);
227
+ int i2d_DHxparams(const DH *a, unsigned char **pp);
228
+ # ifndef OPENSSL_NO_FP_API
229
+ int DHparams_print_fp(FILE *fp, const DH *x);
230
+ # endif
231
+ # ifndef OPENSSL_NO_BIO
232
+ int DHparams_print(BIO *bp, const DH *x);
233
+ # else
234
+ int DHparams_print(char *bp, const DH *x);
235
+ # endif
236
+
237
+ /* RFC 5114 parameters */
238
+ DH *DH_get_1024_160(void);
239
+ DH *DH_get_2048_224(void);
240
+ DH *DH_get_2048_256(void);
241
+
242
+ /* RFC2631 KDF */
243
+ int DH_KDF_X9_42(unsigned char *out, size_t outlen,
244
+ const unsigned char *Z, size_t Zlen,
245
+ ASN1_OBJECT *key_oid,
246
+ const unsigned char *ukm, size_t ukmlen, const EVP_MD *md);
247
+
248
+ # define EVP_PKEY_CTX_set_dh_paramgen_prime_len(ctx, len) \
249
+ EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \
250
+ EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN, len, NULL)
251
+
252
+ # define EVP_PKEY_CTX_set_dh_paramgen_subprime_len(ctx, len) \
253
+ EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \
254
+ EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN, len, NULL)
255
+
256
+ # define EVP_PKEY_CTX_set_dh_paramgen_type(ctx, typ) \
257
+ EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \
258
+ EVP_PKEY_CTRL_DH_PARAMGEN_TYPE, typ, NULL)
259
+
260
+ # define EVP_PKEY_CTX_set_dh_paramgen_generator(ctx, gen) \
261
+ EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \
262
+ EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR, gen, NULL)
263
+
264
+ # define EVP_PKEY_CTX_set_dh_rfc5114(ctx, gen) \
265
+ EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_PARAMGEN, \
266
+ EVP_PKEY_CTRL_DH_RFC5114, gen, NULL)
267
+
268
+ # define EVP_PKEY_CTX_set_dhx_rfc5114(ctx, gen) \
269
+ EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_PARAMGEN, \
270
+ EVP_PKEY_CTRL_DH_RFC5114, gen, NULL)
271
+
272
+ # define EVP_PKEY_CTX_set_dh_kdf_type(ctx, kdf) \
273
+ EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
274
+ EVP_PKEY_OP_DERIVE, \
275
+ EVP_PKEY_CTRL_DH_KDF_TYPE, kdf, NULL)
276
+
277
+ # define EVP_PKEY_CTX_get_dh_kdf_type(ctx) \
278
+ EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
279
+ EVP_PKEY_OP_DERIVE, \
280
+ EVP_PKEY_CTRL_DH_KDF_TYPE, -2, NULL)
281
+
282
+ # define EVP_PKEY_CTX_set0_dh_kdf_oid(ctx, oid) \
283
+ EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
284
+ EVP_PKEY_OP_DERIVE, \
285
+ EVP_PKEY_CTRL_DH_KDF_OID, 0, (void *)oid)
286
+
287
+ # define EVP_PKEY_CTX_get0_dh_kdf_oid(ctx, poid) \
288
+ EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
289
+ EVP_PKEY_OP_DERIVE, \
290
+ EVP_PKEY_CTRL_GET_DH_KDF_OID, 0, (void *)poid)
291
+
292
+ # define EVP_PKEY_CTX_set_dh_kdf_md(ctx, md) \
293
+ EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
294
+ EVP_PKEY_OP_DERIVE, \
295
+ EVP_PKEY_CTRL_DH_KDF_MD, 0, (void *)md)
296
+
297
+ # define EVP_PKEY_CTX_get_dh_kdf_md(ctx, pmd) \
298
+ EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
299
+ EVP_PKEY_OP_DERIVE, \
300
+ EVP_PKEY_CTRL_GET_DH_KDF_MD, 0, (void *)pmd)
301
+
302
+ # define EVP_PKEY_CTX_set_dh_kdf_outlen(ctx, len) \
303
+ EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
304
+ EVP_PKEY_OP_DERIVE, \
305
+ EVP_PKEY_CTRL_DH_KDF_OUTLEN, len, NULL)
306
+
307
+ # define EVP_PKEY_CTX_get_dh_kdf_outlen(ctx, plen) \
308
+ EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
309
+ EVP_PKEY_OP_DERIVE, \
310
+ EVP_PKEY_CTRL_GET_DH_KDF_OUTLEN, 0, (void *)plen)
311
+
312
+ # define EVP_PKEY_CTX_set0_dh_kdf_ukm(ctx, p, plen) \
313
+ EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
314
+ EVP_PKEY_OP_DERIVE, \
315
+ EVP_PKEY_CTRL_DH_KDF_UKM, plen, (void *)p)
316
+
317
+ # define EVP_PKEY_CTX_get0_dh_kdf_ukm(ctx, p) \
318
+ EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \
319
+ EVP_PKEY_OP_DERIVE, \
320
+ EVP_PKEY_CTRL_GET_DH_KDF_UKM, 0, (void *)p)
321
+
322
+ # define EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN (EVP_PKEY_ALG_CTRL + 1)
323
+ # define EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR (EVP_PKEY_ALG_CTRL + 2)
324
+ # define EVP_PKEY_CTRL_DH_RFC5114 (EVP_PKEY_ALG_CTRL + 3)
325
+ # define EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN (EVP_PKEY_ALG_CTRL + 4)
326
+ # define EVP_PKEY_CTRL_DH_PARAMGEN_TYPE (EVP_PKEY_ALG_CTRL + 5)
327
+ # define EVP_PKEY_CTRL_DH_KDF_TYPE (EVP_PKEY_ALG_CTRL + 6)
328
+ # define EVP_PKEY_CTRL_DH_KDF_MD (EVP_PKEY_ALG_CTRL + 7)
329
+ # define EVP_PKEY_CTRL_GET_DH_KDF_MD (EVP_PKEY_ALG_CTRL + 8)
330
+ # define EVP_PKEY_CTRL_DH_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 9)
331
+ # define EVP_PKEY_CTRL_GET_DH_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 10)
332
+ # define EVP_PKEY_CTRL_DH_KDF_UKM (EVP_PKEY_ALG_CTRL + 11)
333
+ # define EVP_PKEY_CTRL_GET_DH_KDF_UKM (EVP_PKEY_ALG_CTRL + 12)
334
+ # define EVP_PKEY_CTRL_DH_KDF_OID (EVP_PKEY_ALG_CTRL + 13)
335
+ # define EVP_PKEY_CTRL_GET_DH_KDF_OID (EVP_PKEY_ALG_CTRL + 14)
336
+
337
+ /* KDF types */
338
+ # define EVP_PKEY_DH_KDF_NONE 1
339
+ # define EVP_PKEY_DH_KDF_X9_42 2
340
+
341
+ /* BEGIN ERROR CODES */
342
+ /*
343
+ * The following lines are auto generated by the script mkerr.pl. Any changes
344
+ * made after this point may be overwritten when the script is next run.
345
+ */
346
+ void ERR_load_DH_strings(void);
347
+
348
+ /* Error codes for the DH functions. */
349
+
350
+ /* Function codes. */
351
+ # define DH_F_COMPUTE_KEY 102
352
+ # define DH_F_DHPARAMS_PRINT_FP 101
353
+ # define DH_F_DH_BUILTIN_GENPARAMS 106
354
+ # define DH_F_DH_CMS_DECRYPT 117
355
+ # define DH_F_DH_CMS_SET_PEERKEY 118
356
+ # define DH_F_DH_CMS_SET_SHARED_INFO 119
357
+ # define DH_F_DH_COMPUTE_KEY 114
358
+ # define DH_F_DH_GENERATE_KEY 115
359
+ # define DH_F_DH_GENERATE_PARAMETERS_EX 116
360
+ # define DH_F_DH_NEW_METHOD 105
361
+ # define DH_F_DH_PARAM_DECODE 107
362
+ # define DH_F_DH_PRIV_DECODE 110
363
+ # define DH_F_DH_PRIV_ENCODE 111
364
+ # define DH_F_DH_PUB_DECODE 108
365
+ # define DH_F_DH_PUB_ENCODE 109
366
+ # define DH_F_DO_DH_PRINT 100
367
+ # define DH_F_GENERATE_KEY 103
368
+ # define DH_F_GENERATE_PARAMETERS 104
369
+ # define DH_F_PKEY_DH_DERIVE 112
370
+ # define DH_F_PKEY_DH_KEYGEN 113
371
+
372
+ /* Reason codes. */
373
+ # define DH_R_BAD_GENERATOR 101
374
+ # define DH_R_BN_DECODE_ERROR 109
375
+ # define DH_R_BN_ERROR 106
376
+ # define DH_R_DECODE_ERROR 104
377
+ # define DH_R_INVALID_PUBKEY 102
378
+ # define DH_R_KDF_PARAMETER_ERROR 112
379
+ # define DH_R_KEYS_NOT_SET 108
380
+ # define DH_R_KEY_SIZE_TOO_SMALL 110
381
+ # define DH_R_MODULUS_TOO_LARGE 103
382
+ # define DH_R_NON_FIPS_METHOD 111
383
+ # define DH_R_NO_PARAMETERS_SET 107
384
+ # define DH_R_NO_PRIVATE_VALUE 100
385
+ # define DH_R_PARAMETER_ENCODING_ERROR 105
386
+ # define DH_R_PEER_KEY_ERROR 113
387
+ # define DH_R_SHARED_INFO_ERROR 114
388
+
389
+ #ifdef __cplusplus
390
+ }
391
+ #endif
392
+ #endif
@@ -0,0 +1,332 @@
1
+ /* crypto/dsa/dsa.h */
2
+ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3
+ * All rights reserved.
4
+ *
5
+ * This package is an SSL implementation written
6
+ * by Eric Young (eay@cryptsoft.com).
7
+ * The implementation was written so as to conform with Netscapes SSL.
8
+ *
9
+ * This library is free for commercial and non-commercial use as long as
10
+ * the following conditions are aheared to. The following conditions
11
+ * apply to all code found in this distribution, be it the RC4, RSA,
12
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13
+ * included with this distribution is covered by the same copyright terms
14
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15
+ *
16
+ * Copyright remains Eric Young's, and as such any Copyright notices in
17
+ * the code are not to be removed.
18
+ * If this package is used in a product, Eric Young should be given attribution
19
+ * as the author of the parts of the library used.
20
+ * This can be in the form of a textual message at program startup or
21
+ * in documentation (online or textual) provided with the package.
22
+ *
23
+ * Redistribution and use in source and binary forms, with or without
24
+ * modification, are permitted provided that the following conditions
25
+ * are met:
26
+ * 1. Redistributions of source code must retain the copyright
27
+ * notice, this list of conditions and the following disclaimer.
28
+ * 2. Redistributions in binary form must reproduce the above copyright
29
+ * notice, this list of conditions and the following disclaimer in the
30
+ * documentation and/or other materials provided with the distribution.
31
+ * 3. All advertising materials mentioning features or use of this software
32
+ * must display the following acknowledgement:
33
+ * "This product includes cryptographic software written by
34
+ * Eric Young (eay@cryptsoft.com)"
35
+ * The word 'cryptographic' can be left out if the rouines from the library
36
+ * being used are not cryptographic related :-).
37
+ * 4. If you include any Windows specific code (or a derivative thereof) from
38
+ * the apps directory (application code) you must include an acknowledgement:
39
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40
+ *
41
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51
+ * SUCH DAMAGE.
52
+ *
53
+ * The licence and distribution terms for any publically available version or
54
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
55
+ * copied and put under another distribution licence
56
+ * [including the GNU Public Licence.]
57
+ */
58
+
59
+ /*
60
+ * The DSS routines are based on patches supplied by
61
+ * Steven Schoch <schoch@sheba.arc.nasa.gov>. He basically did the
62
+ * work and I have just tweaked them a little to fit into my
63
+ * stylistic vision for SSLeay :-) */
64
+
65
+ #ifndef HEADER_DSA_H
66
+ # define HEADER_DSA_H
67
+
68
+ # include <openssl/e_os2.h>
69
+
70
+ # ifdef OPENSSL_NO_DSA
71
+ # error DSA is disabled.
72
+ # endif
73
+
74
+ # ifndef OPENSSL_NO_BIO
75
+ # include <openssl/bio.h>
76
+ # endif
77
+ # include <openssl/crypto.h>
78
+ # include <openssl/ossl_typ.h>
79
+
80
+ # ifndef OPENSSL_NO_DEPRECATED
81
+ # include <openssl/bn.h>
82
+ # ifndef OPENSSL_NO_DH
83
+ # include <openssl/dh.h>
84
+ # endif
85
+ # endif
86
+
87
+ # ifndef OPENSSL_DSA_MAX_MODULUS_BITS
88
+ # define OPENSSL_DSA_MAX_MODULUS_BITS 10000
89
+ # endif
90
+
91
+ # define DSA_FLAG_CACHE_MONT_P 0x01
92
+ /*
93
+ * new with 0.9.7h; the built-in DSA implementation now uses constant time
94
+ * modular exponentiation for secret exponents by default. This flag causes
95
+ * the faster variable sliding window method to be used for all exponents.
96
+ */
97
+ # define DSA_FLAG_NO_EXP_CONSTTIME 0x02
98
+
99
+ /*
100
+ * If this flag is set the DSA method is FIPS compliant and can be used in
101
+ * FIPS mode. This is set in the validated module method. If an application
102
+ * sets this flag in its own methods it is its reposibility to ensure the
103
+ * result is compliant.
104
+ */
105
+
106
+ # define DSA_FLAG_FIPS_METHOD 0x0400
107
+
108
+ /*
109
+ * If this flag is set the operations normally disabled in FIPS mode are
110
+ * permitted it is then the applications responsibility to ensure that the
111
+ * usage is compliant.
112
+ */
113
+
114
+ # define DSA_FLAG_NON_FIPS_ALLOW 0x0400
115
+
116
+ #ifdef __cplusplus
117
+ extern "C" {
118
+ #endif
119
+
120
+ /* Already defined in ossl_typ.h */
121
+ /* typedef struct dsa_st DSA; */
122
+ /* typedef struct dsa_method DSA_METHOD; */
123
+
124
+ typedef struct DSA_SIG_st {
125
+ BIGNUM *r;
126
+ BIGNUM *s;
127
+ } DSA_SIG;
128
+
129
+ struct dsa_method {
130
+ const char *name;
131
+ DSA_SIG *(*dsa_do_sign) (const unsigned char *dgst, int dlen, DSA *dsa);
132
+ int (*dsa_sign_setup) (DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
133
+ BIGNUM **rp);
134
+ int (*dsa_do_verify) (const unsigned char *dgst, int dgst_len,
135
+ DSA_SIG *sig, DSA *dsa);
136
+ int (*dsa_mod_exp) (DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1,
137
+ BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx,
138
+ BN_MONT_CTX *in_mont);
139
+ /* Can be null */
140
+ int (*bn_mod_exp) (DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
141
+ const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
142
+ int (*init) (DSA *dsa);
143
+ int (*finish) (DSA *dsa);
144
+ int flags;
145
+ char *app_data;
146
+ /* If this is non-NULL, it is used to generate DSA parameters */
147
+ int (*dsa_paramgen) (DSA *dsa, int bits,
148
+ const unsigned char *seed, int seed_len,
149
+ int *counter_ret, unsigned long *h_ret,
150
+ BN_GENCB *cb);
151
+ /* If this is non-NULL, it is used to generate DSA keys */
152
+ int (*dsa_keygen) (DSA *dsa);
153
+ };
154
+
155
+ struct dsa_st {
156
+ /*
157
+ * This first variable is used to pick up errors where a DSA is passed
158
+ * instead of of a EVP_PKEY
159
+ */
160
+ int pad;
161
+ long version;
162
+ int write_params;
163
+ BIGNUM *p;
164
+ BIGNUM *q; /* == 20 */
165
+ BIGNUM *g;
166
+ BIGNUM *pub_key; /* y public key */
167
+ BIGNUM *priv_key; /* x private key */
168
+ BIGNUM *kinv; /* Signing pre-calc */
169
+ BIGNUM *r; /* Signing pre-calc */
170
+ int flags;
171
+ /* Normally used to cache montgomery values */
172
+ BN_MONT_CTX *method_mont_p;
173
+ int references;
174
+ CRYPTO_EX_DATA ex_data;
175
+ const DSA_METHOD *meth;
176
+ /* functional reference if 'meth' is ENGINE-provided */
177
+ ENGINE *engine;
178
+ };
179
+
180
+ # define d2i_DSAparams_fp(fp,x) (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \
181
+ (char *(*)())d2i_DSAparams,(fp),(unsigned char **)(x))
182
+ # define i2d_DSAparams_fp(fp,x) ASN1_i2d_fp(i2d_DSAparams,(fp), \
183
+ (unsigned char *)(x))
184
+ # define d2i_DSAparams_bio(bp,x) ASN1_d2i_bio_of(DSA,DSA_new,d2i_DSAparams,bp,x)
185
+ # define i2d_DSAparams_bio(bp,x) ASN1_i2d_bio_of_const(DSA,i2d_DSAparams,bp,x)
186
+
187
+ DSA *DSAparams_dup(DSA *x);
188
+ DSA_SIG *DSA_SIG_new(void);
189
+ void DSA_SIG_free(DSA_SIG *a);
190
+ int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp);
191
+ DSA_SIG *d2i_DSA_SIG(DSA_SIG **v, const unsigned char **pp, long length);
192
+
193
+ DSA_SIG *DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa);
194
+ int DSA_do_verify(const unsigned char *dgst, int dgst_len,
195
+ DSA_SIG *sig, DSA *dsa);
196
+
197
+ const DSA_METHOD *DSA_OpenSSL(void);
198
+
199
+ void DSA_set_default_method(const DSA_METHOD *);
200
+ const DSA_METHOD *DSA_get_default_method(void);
201
+ int DSA_set_method(DSA *dsa, const DSA_METHOD *);
202
+
203
+ DSA *DSA_new(void);
204
+ DSA *DSA_new_method(ENGINE *engine);
205
+ void DSA_free(DSA *r);
206
+ /* "up" the DSA object's reference count */
207
+ int DSA_up_ref(DSA *r);
208
+ int DSA_size(const DSA *);
209
+ /* next 4 return -1 on error */
210
+ int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp);
211
+ int DSA_sign(int type, const unsigned char *dgst, int dlen,
212
+ unsigned char *sig, unsigned int *siglen, DSA *dsa);
213
+ int DSA_verify(int type, const unsigned char *dgst, int dgst_len,
214
+ const unsigned char *sigbuf, int siglen, DSA *dsa);
215
+ int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
216
+ CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
217
+ int DSA_set_ex_data(DSA *d, int idx, void *arg);
218
+ void *DSA_get_ex_data(DSA *d, int idx);
219
+
220
+ DSA *d2i_DSAPublicKey(DSA **a, const unsigned char **pp, long length);
221
+ DSA *d2i_DSAPrivateKey(DSA **a, const unsigned char **pp, long length);
222
+ DSA *d2i_DSAparams(DSA **a, const unsigned char **pp, long length);
223
+
224
+ /* Deprecated version */
225
+ # ifndef OPENSSL_NO_DEPRECATED
226
+ DSA *DSA_generate_parameters(int bits,
227
+ unsigned char *seed, int seed_len,
228
+ int *counter_ret, unsigned long *h_ret, void
229
+ (*callback) (int, int, void *), void *cb_arg);
230
+ # endif /* !defined(OPENSSL_NO_DEPRECATED) */
231
+
232
+ /* New version */
233
+ int DSA_generate_parameters_ex(DSA *dsa, int bits,
234
+ const unsigned char *seed, int seed_len,
235
+ int *counter_ret, unsigned long *h_ret,
236
+ BN_GENCB *cb);
237
+
238
+ int DSA_generate_key(DSA *a);
239
+ int i2d_DSAPublicKey(const DSA *a, unsigned char **pp);
240
+ int i2d_DSAPrivateKey(const DSA *a, unsigned char **pp);
241
+ int i2d_DSAparams(const DSA *a, unsigned char **pp);
242
+
243
+ # ifndef OPENSSL_NO_BIO
244
+ int DSAparams_print(BIO *bp, const DSA *x);
245
+ int DSA_print(BIO *bp, const DSA *x, int off);
246
+ # endif
247
+ # ifndef OPENSSL_NO_FP_API
248
+ int DSAparams_print_fp(FILE *fp, const DSA *x);
249
+ int DSA_print_fp(FILE *bp, const DSA *x, int off);
250
+ # endif
251
+
252
+ # define DSS_prime_checks 50
253
+ /*
254
+ * Primality test according to FIPS PUB 186[-1], Appendix 2.1: 50 rounds of
255
+ * Rabin-Miller
256
+ */
257
+ # define DSA_is_prime(n, callback, cb_arg) \
258
+ BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg)
259
+
260
+ # ifndef OPENSSL_NO_DH
261
+ /*
262
+ * Convert DSA structure (key or just parameters) into DH structure (be
263
+ * careful to avoid small subgroup attacks when using this!)
264
+ */
265
+ DH *DSA_dup_DH(const DSA *r);
266
+ # endif
267
+
268
+ # define EVP_PKEY_CTX_set_dsa_paramgen_bits(ctx, nbits) \
269
+ EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, \
270
+ EVP_PKEY_CTRL_DSA_PARAMGEN_BITS, nbits, NULL)
271
+
272
+ # define EVP_PKEY_CTRL_DSA_PARAMGEN_BITS (EVP_PKEY_ALG_CTRL + 1)
273
+ # define EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS (EVP_PKEY_ALG_CTRL + 2)
274
+ # define EVP_PKEY_CTRL_DSA_PARAMGEN_MD (EVP_PKEY_ALG_CTRL + 3)
275
+
276
+ /* BEGIN ERROR CODES */
277
+ /*
278
+ * The following lines are auto generated by the script mkerr.pl. Any changes
279
+ * made after this point may be overwritten when the script is next run.
280
+ */
281
+ void ERR_load_DSA_strings(void);
282
+
283
+ /* Error codes for the DSA functions. */
284
+
285
+ /* Function codes. */
286
+ # define DSA_F_D2I_DSA_SIG 110
287
+ # define DSA_F_DO_DSA_PRINT 104
288
+ # define DSA_F_DSAPARAMS_PRINT 100
289
+ # define DSA_F_DSAPARAMS_PRINT_FP 101
290
+ # define DSA_F_DSA_BUILTIN_PARAMGEN2 126
291
+ # define DSA_F_DSA_DO_SIGN 112
292
+ # define DSA_F_DSA_DO_VERIFY 113
293
+ # define DSA_F_DSA_GENERATE_KEY 124
294
+ # define DSA_F_DSA_GENERATE_PARAMETERS_EX 123
295
+ # define DSA_F_DSA_NEW_METHOD 103
296
+ # define DSA_F_DSA_PARAM_DECODE 119
297
+ # define DSA_F_DSA_PRINT_FP 105
298
+ # define DSA_F_DSA_PRIV_DECODE 115
299
+ # define DSA_F_DSA_PRIV_ENCODE 116
300
+ # define DSA_F_DSA_PUB_DECODE 117
301
+ # define DSA_F_DSA_PUB_ENCODE 118
302
+ # define DSA_F_DSA_SIGN 106
303
+ # define DSA_F_DSA_SIGN_SETUP 107
304
+ # define DSA_F_DSA_SIG_NEW 109
305
+ # define DSA_F_DSA_SIG_PRINT 125
306
+ # define DSA_F_DSA_VERIFY 108
307
+ # define DSA_F_I2D_DSA_SIG 111
308
+ # define DSA_F_OLD_DSA_PRIV_DECODE 122
309
+ # define DSA_F_PKEY_DSA_CTRL 120
310
+ # define DSA_F_PKEY_DSA_KEYGEN 121
311
+ # define DSA_F_SIG_CB 114
312
+
313
+ /* Reason codes. */
314
+ # define DSA_R_BAD_Q_VALUE 102
315
+ # define DSA_R_BN_DECODE_ERROR 108
316
+ # define DSA_R_BN_ERROR 109
317
+ # define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100
318
+ # define DSA_R_DECODE_ERROR 104
319
+ # define DSA_R_INVALID_DIGEST_TYPE 106
320
+ # define DSA_R_INVALID_PARAMETERS 112
321
+ # define DSA_R_MISSING_PARAMETERS 101
322
+ # define DSA_R_MODULUS_TOO_LARGE 103
323
+ # define DSA_R_NEED_NEW_SETUP_VALUES 110
324
+ # define DSA_R_NON_FIPS_DSA_METHOD 111
325
+ # define DSA_R_NO_PARAMETERS_SET 107
326
+ # define DSA_R_PARAMETER_ENCODING_ERROR 105
327
+ # define DSA_R_Q_NOT_PRIME 113
328
+
329
+ #ifdef __cplusplus
330
+ }
331
+ #endif
332
+ #endif