openssl-custom 2.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +7 -0
  2. data/BSDL +22 -0
  3. data/CONTRIBUTING.md +132 -0
  4. data/History.md +485 -0
  5. data/LICENSE.txt +56 -0
  6. data/README.md +66 -0
  7. data/ext/openssl/extconf.rb +190 -0
  8. data/ext/openssl/openssl_missing.c +106 -0
  9. data/ext/openssl/openssl_missing.h +257 -0
  10. data/ext/openssl/ossl.c +1282 -0
  11. data/ext/openssl/ossl.h +181 -0
  12. data/ext/openssl/ossl_asn1.c +1878 -0
  13. data/ext/openssl/ossl_asn1.h +62 -0
  14. data/ext/openssl/ossl_bio.c +42 -0
  15. data/ext/openssl/ossl_bio.h +16 -0
  16. data/ext/openssl/ossl_bn.c +1270 -0
  17. data/ext/openssl/ossl_bn.h +26 -0
  18. data/ext/openssl/ossl_cipher.c +1075 -0
  19. data/ext/openssl/ossl_cipher.h +20 -0
  20. data/ext/openssl/ossl_config.c +89 -0
  21. data/ext/openssl/ossl_config.h +19 -0
  22. data/ext/openssl/ossl_digest.c +425 -0
  23. data/ext/openssl/ossl_digest.h +20 -0
  24. data/ext/openssl/ossl_engine.c +567 -0
  25. data/ext/openssl/ossl_engine.h +19 -0
  26. data/ext/openssl/ossl_hmac.c +389 -0
  27. data/ext/openssl/ossl_hmac.h +18 -0
  28. data/ext/openssl/ossl_kdf.c +303 -0
  29. data/ext/openssl/ossl_kdf.h +6 -0
  30. data/ext/openssl/ossl_ns_spki.c +405 -0
  31. data/ext/openssl/ossl_ns_spki.h +19 -0
  32. data/ext/openssl/ossl_ocsp.c +2013 -0
  33. data/ext/openssl/ossl_ocsp.h +23 -0
  34. data/ext/openssl/ossl_pkcs12.c +257 -0
  35. data/ext/openssl/ossl_pkcs12.h +13 -0
  36. data/ext/openssl/ossl_pkcs7.c +1098 -0
  37. data/ext/openssl/ossl_pkcs7.h +36 -0
  38. data/ext/openssl/ossl_pkey.c +673 -0
  39. data/ext/openssl/ossl_pkey.h +241 -0
  40. data/ext/openssl/ossl_pkey_dh.c +650 -0
  41. data/ext/openssl/ossl_pkey_dsa.c +664 -0
  42. data/ext/openssl/ossl_pkey_ec.c +1827 -0
  43. data/ext/openssl/ossl_pkey_rsa.c +966 -0
  44. data/ext/openssl/ossl_rand.c +200 -0
  45. data/ext/openssl/ossl_rand.h +18 -0
  46. data/ext/openssl/ossl_ssl.c +3080 -0
  47. data/ext/openssl/ossl_ssl.h +36 -0
  48. data/ext/openssl/ossl_ssl_session.c +332 -0
  49. data/ext/openssl/ossl_ts.c +1524 -0
  50. data/ext/openssl/ossl_ts.h +16 -0
  51. data/ext/openssl/ossl_x509.c +262 -0
  52. data/ext/openssl/ossl_x509.h +115 -0
  53. data/ext/openssl/ossl_x509attr.c +324 -0
  54. data/ext/openssl/ossl_x509cert.c +846 -0
  55. data/ext/openssl/ossl_x509crl.c +542 -0
  56. data/ext/openssl/ossl_x509ext.c +491 -0
  57. data/ext/openssl/ossl_x509name.c +590 -0
  58. data/ext/openssl/ossl_x509req.c +441 -0
  59. data/ext/openssl/ossl_x509revoked.c +300 -0
  60. data/ext/openssl/ossl_x509store.c +902 -0
  61. data/ext/openssl/ruby_missing.h +24 -0
  62. data/lib/openssl/bn.rb +40 -0
  63. data/lib/openssl/buffering.rb +478 -0
  64. data/lib/openssl/cipher.rb +67 -0
  65. data/lib/openssl/config.rb +501 -0
  66. data/lib/openssl/digest.rb +73 -0
  67. data/lib/openssl/hmac.rb +13 -0
  68. data/lib/openssl/marshal.rb +30 -0
  69. data/lib/openssl/pkcs5.rb +22 -0
  70. data/lib/openssl/pkey.rb +42 -0
  71. data/lib/openssl/ssl.rb +542 -0
  72. data/lib/openssl/version.rb +5 -0
  73. data/lib/openssl/x509.rb +369 -0
  74. data/lib/openssl.rb +38 -0
  75. metadata +196 -0
@@ -0,0 +1,241 @@
1
+ /*
2
+ * 'OpenSSL for Ruby' project
3
+ * Copyright (C) 2001 Michal Rokos <m.rokos@sh.cvut.cz>
4
+ * All rights reserved.
5
+ */
6
+ /*
7
+ * This program is licensed under the same licence as Ruby.
8
+ * (See the file 'LICENCE'.)
9
+ */
10
+ #if !defined(_OSSL_PKEY_H_)
11
+ #define _OSSL_PKEY_H_
12
+
13
+ extern VALUE mPKey;
14
+ extern VALUE cPKey;
15
+ extern VALUE ePKeyError;
16
+ extern const rb_data_type_t ossl_evp_pkey_type;
17
+
18
+ #define OSSL_PKEY_SET_PRIVATE(obj) rb_iv_set((obj), "private", Qtrue)
19
+ #define OSSL_PKEY_SET_PUBLIC(obj) rb_iv_set((obj), "private", Qfalse)
20
+ #define OSSL_PKEY_IS_PRIVATE(obj) (rb_iv_get((obj), "private") == Qtrue)
21
+
22
+ #define NewPKey(klass) \
23
+ TypedData_Wrap_Struct((klass), &ossl_evp_pkey_type, 0)
24
+ #define SetPKey(obj, pkey) do { \
25
+ if (!(pkey)) { \
26
+ rb_raise(rb_eRuntimeError, "PKEY wasn't initialized!"); \
27
+ } \
28
+ RTYPEDDATA_DATA(obj) = (pkey); \
29
+ OSSL_PKEY_SET_PUBLIC(obj); \
30
+ } while (0)
31
+ #define GetPKey(obj, pkey) do {\
32
+ TypedData_Get_Struct((obj), EVP_PKEY, &ossl_evp_pkey_type, (pkey)); \
33
+ if (!(pkey)) { \
34
+ rb_raise(rb_eRuntimeError, "PKEY wasn't initialized!");\
35
+ } \
36
+ } while (0)
37
+
38
+ struct ossl_generate_cb_arg {
39
+ int yield;
40
+ int interrupted;
41
+ int state;
42
+ };
43
+ int ossl_generate_cb_2(int p, int n, BN_GENCB *cb);
44
+ void ossl_generate_cb_stop(void *ptr);
45
+
46
+ VALUE ossl_pkey_new(EVP_PKEY *);
47
+ void ossl_pkey_check_public_key(const EVP_PKEY *);
48
+ EVP_PKEY *GetPKeyPtr(VALUE);
49
+ EVP_PKEY *DupPKeyPtr(VALUE);
50
+ EVP_PKEY *GetPrivPKeyPtr(VALUE);
51
+ void Init_ossl_pkey(void);
52
+
53
+ /*
54
+ * RSA
55
+ */
56
+ extern VALUE cRSA;
57
+ extern VALUE eRSAError;
58
+
59
+ VALUE ossl_rsa_new(EVP_PKEY *);
60
+ void Init_ossl_rsa(void);
61
+
62
+ /*
63
+ * DSA
64
+ */
65
+ extern VALUE cDSA;
66
+ extern VALUE eDSAError;
67
+
68
+ VALUE ossl_dsa_new(EVP_PKEY *);
69
+ void Init_ossl_dsa(void);
70
+
71
+ /*
72
+ * DH
73
+ */
74
+ extern VALUE cDH;
75
+ extern VALUE eDHError;
76
+
77
+ VALUE ossl_dh_new(EVP_PKEY *);
78
+ void Init_ossl_dh(void);
79
+
80
+ /*
81
+ * EC
82
+ */
83
+ extern VALUE cEC;
84
+ extern VALUE eECError;
85
+ extern VALUE cEC_GROUP;
86
+ extern VALUE eEC_GROUP;
87
+ extern VALUE cEC_POINT;
88
+ extern VALUE eEC_POINT;
89
+ VALUE ossl_ec_new(EVP_PKEY *);
90
+ void Init_ossl_ec(void);
91
+
92
+ #define OSSL_PKEY_BN_DEF_GETTER0(_keytype, _type, _name, _get) \
93
+ /* \
94
+ * call-seq: \
95
+ * _keytype##.##_name -> aBN \
96
+ */ \
97
+ static VALUE ossl_##_keytype##_get_##_name(VALUE self) \
98
+ { \
99
+ _type *obj; \
100
+ const BIGNUM *bn; \
101
+ \
102
+ Get##_type(self, obj); \
103
+ _get; \
104
+ if (bn == NULL) \
105
+ return Qnil; \
106
+ return ossl_bn_new(bn); \
107
+ }
108
+
109
+ #define OSSL_PKEY_BN_DEF_GETTER3(_keytype, _type, _group, a1, a2, a3) \
110
+ OSSL_PKEY_BN_DEF_GETTER0(_keytype, _type, a1, \
111
+ _type##_get0_##_group(obj, &bn, NULL, NULL)) \
112
+ OSSL_PKEY_BN_DEF_GETTER0(_keytype, _type, a2, \
113
+ _type##_get0_##_group(obj, NULL, &bn, NULL)) \
114
+ OSSL_PKEY_BN_DEF_GETTER0(_keytype, _type, a3, \
115
+ _type##_get0_##_group(obj, NULL, NULL, &bn))
116
+
117
+ #define OSSL_PKEY_BN_DEF_GETTER2(_keytype, _type, _group, a1, a2) \
118
+ OSSL_PKEY_BN_DEF_GETTER0(_keytype, _type, a1, \
119
+ _type##_get0_##_group(obj, &bn, NULL)) \
120
+ OSSL_PKEY_BN_DEF_GETTER0(_keytype, _type, a2, \
121
+ _type##_get0_##_group(obj, NULL, &bn))
122
+
123
+ #define OSSL_PKEY_BN_DEF_SETTER3(_keytype, _type, _group, a1, a2, a3) \
124
+ /* \
125
+ * call-seq: \
126
+ * _keytype##.set_##_group(a1, a2, a3) -> self \
127
+ */ \
128
+ static VALUE ossl_##_keytype##_set_##_group(VALUE self, VALUE v1, VALUE v2, VALUE v3) \
129
+ { \
130
+ _type *obj; \
131
+ BIGNUM *bn1 = NULL, *orig_bn1 = NIL_P(v1) ? NULL : GetBNPtr(v1);\
132
+ BIGNUM *bn2 = NULL, *orig_bn2 = NIL_P(v2) ? NULL : GetBNPtr(v2);\
133
+ BIGNUM *bn3 = NULL, *orig_bn3 = NIL_P(v3) ? NULL : GetBNPtr(v3);\
134
+ \
135
+ Get##_type(self, obj); \
136
+ if ((orig_bn1 && !(bn1 = BN_dup(orig_bn1))) || \
137
+ (orig_bn2 && !(bn2 = BN_dup(orig_bn2))) || \
138
+ (orig_bn3 && !(bn3 = BN_dup(orig_bn3)))) { \
139
+ BN_clear_free(bn1); \
140
+ BN_clear_free(bn2); \
141
+ BN_clear_free(bn3); \
142
+ ossl_raise(eBNError, NULL); \
143
+ } \
144
+ \
145
+ if (!_type##_set0_##_group(obj, bn1, bn2, bn3)) { \
146
+ BN_clear_free(bn1); \
147
+ BN_clear_free(bn2); \
148
+ BN_clear_free(bn3); \
149
+ ossl_raise(ePKeyError, #_type"_set0_"#_group); \
150
+ } \
151
+ return self; \
152
+ }
153
+
154
+ #define OSSL_PKEY_BN_DEF_SETTER2(_keytype, _type, _group, a1, a2) \
155
+ /* \
156
+ * call-seq: \
157
+ * _keytype##.set_##_group(a1, a2) -> self \
158
+ */ \
159
+ static VALUE ossl_##_keytype##_set_##_group(VALUE self, VALUE v1, VALUE v2) \
160
+ { \
161
+ _type *obj; \
162
+ BIGNUM *bn1 = NULL, *orig_bn1 = NIL_P(v1) ? NULL : GetBNPtr(v1);\
163
+ BIGNUM *bn2 = NULL, *orig_bn2 = NIL_P(v2) ? NULL : GetBNPtr(v2);\
164
+ \
165
+ Get##_type(self, obj); \
166
+ if ((orig_bn1 && !(bn1 = BN_dup(orig_bn1))) || \
167
+ (orig_bn2 && !(bn2 = BN_dup(orig_bn2)))) { \
168
+ BN_clear_free(bn1); \
169
+ BN_clear_free(bn2); \
170
+ ossl_raise(eBNError, NULL); \
171
+ } \
172
+ \
173
+ if (!_type##_set0_##_group(obj, bn1, bn2)) { \
174
+ BN_clear_free(bn1); \
175
+ BN_clear_free(bn2); \
176
+ ossl_raise(ePKeyError, #_type"_set0_"#_group); \
177
+ } \
178
+ return self; \
179
+ }
180
+
181
+ #define OSSL_PKEY_BN_DEF_SETTER_OLD(_keytype, _type, _group, _name) \
182
+ /* \
183
+ * call-seq: \
184
+ * _keytype##.##_name = bn -> bn \
185
+ */ \
186
+ static VALUE ossl_##_keytype##_set_##_name(VALUE self, VALUE bignum) \
187
+ { \
188
+ _type *obj; \
189
+ BIGNUM *bn; \
190
+ \
191
+ rb_warning("#"#_name"= is deprecated; use #set_"#_group); \
192
+ Get##_type(self, obj); \
193
+ if (NIL_P(bignum)) { \
194
+ BN_clear_free(obj->_name); \
195
+ obj->_name = NULL; \
196
+ return Qnil; \
197
+ } \
198
+ \
199
+ bn = GetBNPtr(bignum); \
200
+ if (obj->_name == NULL) \
201
+ obj->_name = BN_new(); \
202
+ if (obj->_name == NULL) \
203
+ ossl_raise(eBNError, NULL); \
204
+ if (BN_copy(obj->_name, bn) == NULL) \
205
+ ossl_raise(eBNError, NULL); \
206
+ return bignum; \
207
+ }
208
+
209
+ #if defined(HAVE_OPAQUE_OPENSSL) /* OpenSSL 1.1.0 */
210
+ #define OSSL_PKEY_BN_DEF3(_keytype, _type, _group, a1, a2, a3) \
211
+ OSSL_PKEY_BN_DEF_GETTER3(_keytype, _type, _group, a1, a2, a3) \
212
+ OSSL_PKEY_BN_DEF_SETTER3(_keytype, _type, _group, a1, a2, a3)
213
+
214
+ #define OSSL_PKEY_BN_DEF2(_keytype, _type, _group, a1, a2) \
215
+ OSSL_PKEY_BN_DEF_GETTER2(_keytype, _type, _group, a1, a2) \
216
+ OSSL_PKEY_BN_DEF_SETTER2(_keytype, _type, _group, a1, a2)
217
+
218
+ #define DEF_OSSL_PKEY_BN(class, keytype, name) \
219
+ rb_define_method((class), #name, ossl_##keytype##_get_##name, 0)
220
+
221
+ #else
222
+ #define OSSL_PKEY_BN_DEF3(_keytype, _type, _group, a1, a2, a3) \
223
+ OSSL_PKEY_BN_DEF_GETTER3(_keytype, _type, _group, a1, a2, a3) \
224
+ OSSL_PKEY_BN_DEF_SETTER3(_keytype, _type, _group, a1, a2, a3) \
225
+ OSSL_PKEY_BN_DEF_SETTER_OLD(_keytype, _type, _group, a1) \
226
+ OSSL_PKEY_BN_DEF_SETTER_OLD(_keytype, _type, _group, a2) \
227
+ OSSL_PKEY_BN_DEF_SETTER_OLD(_keytype, _type, _group, a3)
228
+
229
+ #define OSSL_PKEY_BN_DEF2(_keytype, _type, _group, a1, a2) \
230
+ OSSL_PKEY_BN_DEF_GETTER2(_keytype, _type, _group, a1, a2) \
231
+ OSSL_PKEY_BN_DEF_SETTER2(_keytype, _type, _group, a1, a2) \
232
+ OSSL_PKEY_BN_DEF_SETTER_OLD(_keytype, _type, _group, a1) \
233
+ OSSL_PKEY_BN_DEF_SETTER_OLD(_keytype, _type, _group, a2)
234
+
235
+ #define DEF_OSSL_PKEY_BN(class, keytype, name) do { \
236
+ rb_define_method((class), #name, ossl_##keytype##_get_##name, 0);\
237
+ rb_define_method((class), #name "=", ossl_##keytype##_set_##name, 1);\
238
+ } while (0)
239
+ #endif /* HAVE_OPAQUE_OPENSSL */
240
+
241
+ #endif /* _OSSL_PKEY_H_ */