zig_example 0.3.2 → 0.3.3.1
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.
- checksums.yaml +4 -4
- data/ext/mkmf.rb +6 -1
- data/lib/zig_example/version.rb +1 -1
- metadata +2 -55
- data/ext/openssl/openssl_missing.c +0 -40
- data/ext/openssl/openssl_missing.h +0 -238
- data/ext/openssl/ossl.c +0 -1295
- data/ext/openssl/ossl.h +0 -201
- data/ext/openssl/ossl_asn1.c +0 -1891
- data/ext/openssl/ossl_asn1.h +0 -62
- data/ext/openssl/ossl_bio.c +0 -42
- data/ext/openssl/ossl_bio.h +0 -16
- data/ext/openssl/ossl_bn.c +0 -1344
- data/ext/openssl/ossl_bn.h +0 -26
- data/ext/openssl/ossl_cipher.c +0 -1074
- data/ext/openssl/ossl_cipher.h +0 -20
- data/ext/openssl/ossl_config.c +0 -460
- data/ext/openssl/ossl_config.h +0 -16
- data/ext/openssl/ossl_digest.c +0 -425
- data/ext/openssl/ossl_digest.h +0 -20
- data/ext/openssl/ossl_engine.c +0 -568
- data/ext/openssl/ossl_engine.h +0 -19
- data/ext/openssl/ossl_hmac.c +0 -310
- data/ext/openssl/ossl_hmac.h +0 -18
- data/ext/openssl/ossl_kdf.c +0 -311
- data/ext/openssl/ossl_kdf.h +0 -6
- data/ext/openssl/ossl_ns_spki.c +0 -405
- data/ext/openssl/ossl_ns_spki.h +0 -19
- data/ext/openssl/ossl_ocsp.c +0 -1965
- data/ext/openssl/ossl_ocsp.h +0 -23
- data/ext/openssl/ossl_pkcs12.c +0 -275
- data/ext/openssl/ossl_pkcs12.h +0 -13
- data/ext/openssl/ossl_pkcs7.c +0 -1081
- data/ext/openssl/ossl_pkcs7.h +0 -36
- data/ext/openssl/ossl_pkey.c +0 -1624
- data/ext/openssl/ossl_pkey.h +0 -204
- data/ext/openssl/ossl_pkey_dh.c +0 -440
- data/ext/openssl/ossl_pkey_dsa.c +0 -359
- data/ext/openssl/ossl_pkey_ec.c +0 -1655
- data/ext/openssl/ossl_pkey_rsa.c +0 -579
- data/ext/openssl/ossl_rand.c +0 -200
- data/ext/openssl/ossl_rand.h +0 -18
- data/ext/openssl/ossl_ssl.c +0 -3142
- data/ext/openssl/ossl_ssl.h +0 -36
- data/ext/openssl/ossl_ssl_session.c +0 -331
- data/ext/openssl/ossl_ts.c +0 -1539
- data/ext/openssl/ossl_ts.h +0 -16
- data/ext/openssl/ossl_x509.c +0 -256
- data/ext/openssl/ossl_x509.h +0 -115
- data/ext/openssl/ossl_x509attr.c +0 -324
- data/ext/openssl/ossl_x509cert.c +0 -1002
- data/ext/openssl/ossl_x509crl.c +0 -545
- data/ext/openssl/ossl_x509ext.c +0 -490
- data/ext/openssl/ossl_x509name.c +0 -597
- data/ext/openssl/ossl_x509req.c +0 -444
- data/ext/openssl/ossl_x509revoked.c +0 -300
- data/ext/openssl/ossl_x509store.c +0 -986
@@ -1,300 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* 'OpenSSL for Ruby' project
|
3
|
-
* Copyright (C) 2001-2002 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
|
-
#include "ossl.h"
|
11
|
-
|
12
|
-
#define NewX509Rev(klass) \
|
13
|
-
TypedData_Wrap_Struct((klass), &ossl_x509rev_type, 0)
|
14
|
-
#define SetX509Rev(obj, rev) do { \
|
15
|
-
if (!(rev)) { \
|
16
|
-
ossl_raise(rb_eRuntimeError, "REV wasn't initialized!"); \
|
17
|
-
} \
|
18
|
-
RTYPEDDATA_DATA(obj) = (rev); \
|
19
|
-
} while (0)
|
20
|
-
#define GetX509Rev(obj, rev) do { \
|
21
|
-
TypedData_Get_Struct((obj), X509_REVOKED, &ossl_x509rev_type, (rev)); \
|
22
|
-
if (!(rev)) { \
|
23
|
-
ossl_raise(rb_eRuntimeError, "REV wasn't initialized!"); \
|
24
|
-
} \
|
25
|
-
} while (0)
|
26
|
-
|
27
|
-
/*
|
28
|
-
* Classes
|
29
|
-
*/
|
30
|
-
VALUE cX509Rev;
|
31
|
-
VALUE eX509RevError;
|
32
|
-
|
33
|
-
static void
|
34
|
-
ossl_x509rev_free(void *ptr)
|
35
|
-
{
|
36
|
-
X509_REVOKED_free(ptr);
|
37
|
-
}
|
38
|
-
|
39
|
-
static const rb_data_type_t ossl_x509rev_type = {
|
40
|
-
"OpenSSL/X509/REV",
|
41
|
-
{
|
42
|
-
0, ossl_x509rev_free,
|
43
|
-
},
|
44
|
-
0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
|
45
|
-
};
|
46
|
-
|
47
|
-
/*
|
48
|
-
* PUBLIC
|
49
|
-
*/
|
50
|
-
VALUE
|
51
|
-
ossl_x509revoked_new(X509_REVOKED *rev)
|
52
|
-
{
|
53
|
-
X509_REVOKED *new;
|
54
|
-
VALUE obj;
|
55
|
-
|
56
|
-
obj = NewX509Rev(cX509Rev);
|
57
|
-
if (!rev) {
|
58
|
-
new = X509_REVOKED_new();
|
59
|
-
} else {
|
60
|
-
new = X509_REVOKED_dup(rev);
|
61
|
-
}
|
62
|
-
if (!new) {
|
63
|
-
ossl_raise(eX509RevError, NULL);
|
64
|
-
}
|
65
|
-
SetX509Rev(obj, new);
|
66
|
-
|
67
|
-
return obj;
|
68
|
-
}
|
69
|
-
|
70
|
-
X509_REVOKED *
|
71
|
-
DupX509RevokedPtr(VALUE obj)
|
72
|
-
{
|
73
|
-
X509_REVOKED *rev, *new;
|
74
|
-
|
75
|
-
GetX509Rev(obj, rev);
|
76
|
-
if (!(new = X509_REVOKED_dup(rev))) {
|
77
|
-
ossl_raise(eX509RevError, NULL);
|
78
|
-
}
|
79
|
-
|
80
|
-
return new;
|
81
|
-
}
|
82
|
-
|
83
|
-
/*
|
84
|
-
* PRIVATE
|
85
|
-
*/
|
86
|
-
static VALUE
|
87
|
-
ossl_x509revoked_alloc(VALUE klass)
|
88
|
-
{
|
89
|
-
X509_REVOKED *rev;
|
90
|
-
VALUE obj;
|
91
|
-
|
92
|
-
obj = NewX509Rev(klass);
|
93
|
-
if (!(rev = X509_REVOKED_new())) {
|
94
|
-
ossl_raise(eX509RevError, NULL);
|
95
|
-
}
|
96
|
-
SetX509Rev(obj, rev);
|
97
|
-
|
98
|
-
return obj;
|
99
|
-
}
|
100
|
-
|
101
|
-
static VALUE
|
102
|
-
ossl_x509revoked_initialize(int argc, VALUE *argv, VALUE self)
|
103
|
-
{
|
104
|
-
/* EMPTY */
|
105
|
-
return self;
|
106
|
-
}
|
107
|
-
|
108
|
-
static VALUE
|
109
|
-
ossl_x509revoked_initialize_copy(VALUE self, VALUE other)
|
110
|
-
{
|
111
|
-
X509_REVOKED *rev, *rev_other, *rev_new;
|
112
|
-
|
113
|
-
rb_check_frozen(self);
|
114
|
-
GetX509Rev(self, rev);
|
115
|
-
GetX509Rev(other, rev_other);
|
116
|
-
|
117
|
-
rev_new = X509_REVOKED_dup(rev_other);
|
118
|
-
if (!rev_new)
|
119
|
-
ossl_raise(eX509RevError, "X509_REVOKED_dup");
|
120
|
-
|
121
|
-
SetX509Rev(self, rev_new);
|
122
|
-
X509_REVOKED_free(rev);
|
123
|
-
|
124
|
-
return self;
|
125
|
-
}
|
126
|
-
|
127
|
-
static VALUE
|
128
|
-
ossl_x509revoked_get_serial(VALUE self)
|
129
|
-
{
|
130
|
-
X509_REVOKED *rev;
|
131
|
-
|
132
|
-
GetX509Rev(self, rev);
|
133
|
-
|
134
|
-
return asn1integer_to_num(X509_REVOKED_get0_serialNumber(rev));
|
135
|
-
}
|
136
|
-
|
137
|
-
static VALUE
|
138
|
-
ossl_x509revoked_set_serial(VALUE self, VALUE num)
|
139
|
-
{
|
140
|
-
X509_REVOKED *rev;
|
141
|
-
ASN1_INTEGER *asn1int;
|
142
|
-
|
143
|
-
GetX509Rev(self, rev);
|
144
|
-
asn1int = num_to_asn1integer(num, NULL);
|
145
|
-
if (!X509_REVOKED_set_serialNumber(rev, asn1int)) {
|
146
|
-
ASN1_INTEGER_free(asn1int);
|
147
|
-
ossl_raise(eX509RevError, "X509_REVOKED_set_serialNumber");
|
148
|
-
}
|
149
|
-
ASN1_INTEGER_free(asn1int);
|
150
|
-
|
151
|
-
return num;
|
152
|
-
}
|
153
|
-
|
154
|
-
static VALUE
|
155
|
-
ossl_x509revoked_get_time(VALUE self)
|
156
|
-
{
|
157
|
-
X509_REVOKED *rev;
|
158
|
-
const ASN1_TIME *time;
|
159
|
-
|
160
|
-
GetX509Rev(self, rev);
|
161
|
-
time = X509_REVOKED_get0_revocationDate(rev);
|
162
|
-
if (!time)
|
163
|
-
return Qnil;
|
164
|
-
|
165
|
-
return asn1time_to_time(time);
|
166
|
-
}
|
167
|
-
|
168
|
-
static VALUE
|
169
|
-
ossl_x509revoked_set_time(VALUE self, VALUE time)
|
170
|
-
{
|
171
|
-
X509_REVOKED *rev;
|
172
|
-
ASN1_TIME *asn1time;
|
173
|
-
|
174
|
-
GetX509Rev(self, rev);
|
175
|
-
asn1time = ossl_x509_time_adjust(NULL, time);
|
176
|
-
if (!X509_REVOKED_set_revocationDate(rev, asn1time)) {
|
177
|
-
ASN1_TIME_free(asn1time);
|
178
|
-
ossl_raise(eX509RevError, "X509_REVOKED_set_revocationDate");
|
179
|
-
}
|
180
|
-
ASN1_TIME_free(asn1time);
|
181
|
-
|
182
|
-
return time;
|
183
|
-
}
|
184
|
-
/*
|
185
|
-
* Gets X509v3 extensions as array of X509Ext objects
|
186
|
-
*/
|
187
|
-
static VALUE
|
188
|
-
ossl_x509revoked_get_extensions(VALUE self)
|
189
|
-
{
|
190
|
-
X509_REVOKED *rev;
|
191
|
-
int count, i;
|
192
|
-
X509_EXTENSION *ext;
|
193
|
-
VALUE ary;
|
194
|
-
|
195
|
-
GetX509Rev(self, rev);
|
196
|
-
count = X509_REVOKED_get_ext_count(rev);
|
197
|
-
if (count < 0) {
|
198
|
-
OSSL_Debug("count < 0???");
|
199
|
-
return rb_ary_new();
|
200
|
-
}
|
201
|
-
ary = rb_ary_new2(count);
|
202
|
-
for (i=0; i<count; i++) {
|
203
|
-
ext = X509_REVOKED_get_ext(rev, i);
|
204
|
-
rb_ary_push(ary, ossl_x509ext_new(ext));
|
205
|
-
}
|
206
|
-
|
207
|
-
return ary;
|
208
|
-
}
|
209
|
-
|
210
|
-
/*
|
211
|
-
* Sets X509_EXTENSIONs
|
212
|
-
*/
|
213
|
-
static VALUE
|
214
|
-
ossl_x509revoked_set_extensions(VALUE self, VALUE ary)
|
215
|
-
{
|
216
|
-
X509_REVOKED *rev;
|
217
|
-
X509_EXTENSION *ext;
|
218
|
-
long i;
|
219
|
-
VALUE item;
|
220
|
-
|
221
|
-
Check_Type(ary, T_ARRAY);
|
222
|
-
for (i=0; i<RARRAY_LEN(ary); i++) {
|
223
|
-
OSSL_Check_Kind(RARRAY_AREF(ary, i), cX509Ext);
|
224
|
-
}
|
225
|
-
GetX509Rev(self, rev);
|
226
|
-
for (i = X509_REVOKED_get_ext_count(rev); i > 0; i--)
|
227
|
-
X509_EXTENSION_free(X509_REVOKED_delete_ext(rev, 0));
|
228
|
-
for (i=0; i<RARRAY_LEN(ary); i++) {
|
229
|
-
item = RARRAY_AREF(ary, i);
|
230
|
-
ext = GetX509ExtPtr(item);
|
231
|
-
if(!X509_REVOKED_add_ext(rev, ext, -1)) {
|
232
|
-
ossl_raise(eX509RevError, "X509_REVOKED_add_ext");
|
233
|
-
}
|
234
|
-
}
|
235
|
-
|
236
|
-
return ary;
|
237
|
-
}
|
238
|
-
|
239
|
-
static VALUE
|
240
|
-
ossl_x509revoked_add_extension(VALUE self, VALUE ext)
|
241
|
-
{
|
242
|
-
X509_REVOKED *rev;
|
243
|
-
|
244
|
-
GetX509Rev(self, rev);
|
245
|
-
if (!X509_REVOKED_add_ext(rev, GetX509ExtPtr(ext), -1)) {
|
246
|
-
ossl_raise(eX509RevError, NULL);
|
247
|
-
}
|
248
|
-
|
249
|
-
return ext;
|
250
|
-
}
|
251
|
-
|
252
|
-
static VALUE
|
253
|
-
ossl_x509revoked_to_der(VALUE self)
|
254
|
-
{
|
255
|
-
X509_REVOKED *rev;
|
256
|
-
VALUE str;
|
257
|
-
int len;
|
258
|
-
unsigned char *p;
|
259
|
-
|
260
|
-
GetX509Rev(self, rev);
|
261
|
-
len = i2d_X509_REVOKED(rev, NULL);
|
262
|
-
if (len <= 0)
|
263
|
-
ossl_raise(eX509RevError, "i2d_X509_REVOKED");
|
264
|
-
str = rb_str_new(NULL, len);
|
265
|
-
p = (unsigned char *)RSTRING_PTR(str);
|
266
|
-
if (i2d_X509_REVOKED(rev, &p) <= 0)
|
267
|
-
ossl_raise(eX509RevError, "i2d_X509_REVOKED");
|
268
|
-
ossl_str_adjust(str, p);
|
269
|
-
return str;
|
270
|
-
}
|
271
|
-
|
272
|
-
/*
|
273
|
-
* INIT
|
274
|
-
*/
|
275
|
-
void
|
276
|
-
Init_ossl_x509revoked(void)
|
277
|
-
{
|
278
|
-
#if 0
|
279
|
-
mOSSL = rb_define_module("OpenSSL");
|
280
|
-
eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
|
281
|
-
mX509 = rb_define_module_under(mOSSL, "X509");
|
282
|
-
#endif
|
283
|
-
|
284
|
-
eX509RevError = rb_define_class_under(mX509, "RevokedError", eOSSLError);
|
285
|
-
|
286
|
-
cX509Rev = rb_define_class_under(mX509, "Revoked", rb_cObject);
|
287
|
-
|
288
|
-
rb_define_alloc_func(cX509Rev, ossl_x509revoked_alloc);
|
289
|
-
rb_define_method(cX509Rev, "initialize", ossl_x509revoked_initialize, -1);
|
290
|
-
rb_define_method(cX509Rev, "initialize_copy", ossl_x509revoked_initialize_copy, 1);
|
291
|
-
|
292
|
-
rb_define_method(cX509Rev, "serial", ossl_x509revoked_get_serial, 0);
|
293
|
-
rb_define_method(cX509Rev, "serial=", ossl_x509revoked_set_serial, 1);
|
294
|
-
rb_define_method(cX509Rev, "time", ossl_x509revoked_get_time, 0);
|
295
|
-
rb_define_method(cX509Rev, "time=", ossl_x509revoked_set_time, 1);
|
296
|
-
rb_define_method(cX509Rev, "extensions", ossl_x509revoked_get_extensions, 0);
|
297
|
-
rb_define_method(cX509Rev, "extensions=", ossl_x509revoked_set_extensions, 1);
|
298
|
-
rb_define_method(cX509Rev, "add_extension", ossl_x509revoked_add_extension, 1);
|
299
|
-
rb_define_method(cX509Rev, "to_der", ossl_x509revoked_to_der, 0);
|
300
|
-
}
|