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
data/ext/openssl/ossl_ssl.h
DELETED
@@ -1,36 +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
|
-
#if !defined(_OSSL_SSL_H_)
|
11
|
-
#define _OSSL_SSL_H_
|
12
|
-
|
13
|
-
#define GetSSL(obj, ssl) do { \
|
14
|
-
TypedData_Get_Struct((obj), SSL, &ossl_ssl_type, (ssl)); \
|
15
|
-
if (!(ssl)) { \
|
16
|
-
ossl_raise(rb_eRuntimeError, "SSL is not initialized"); \
|
17
|
-
} \
|
18
|
-
} while (0)
|
19
|
-
|
20
|
-
#define GetSSLSession(obj, sess) do { \
|
21
|
-
TypedData_Get_Struct((obj), SSL_SESSION, &ossl_ssl_session_type, (sess)); \
|
22
|
-
if (!(sess)) { \
|
23
|
-
ossl_raise(rb_eRuntimeError, "SSL Session wasn't initialized."); \
|
24
|
-
} \
|
25
|
-
} while (0)
|
26
|
-
|
27
|
-
extern const rb_data_type_t ossl_ssl_type;
|
28
|
-
extern const rb_data_type_t ossl_ssl_session_type;
|
29
|
-
extern VALUE mSSL;
|
30
|
-
extern VALUE cSSLSocket;
|
31
|
-
extern VALUE cSSLSession;
|
32
|
-
|
33
|
-
void Init_ossl_ssl(void);
|
34
|
-
void Init_ossl_ssl_session(void);
|
35
|
-
|
36
|
-
#endif /* _OSSL_SSL_H_ */
|
@@ -1,331 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright (C) 2004-2007 Technorama Ltd. <oss-ruby@technorama.net>
|
3
|
-
*/
|
4
|
-
|
5
|
-
#include "ossl.h"
|
6
|
-
|
7
|
-
#ifndef OPENSSL_NO_SOCK
|
8
|
-
VALUE cSSLSession;
|
9
|
-
static VALUE eSSLSession;
|
10
|
-
|
11
|
-
static void
|
12
|
-
ossl_ssl_session_free(void *ptr)
|
13
|
-
{
|
14
|
-
SSL_SESSION_free(ptr);
|
15
|
-
}
|
16
|
-
|
17
|
-
const rb_data_type_t ossl_ssl_session_type = {
|
18
|
-
"OpenSSL/SSL/Session",
|
19
|
-
{
|
20
|
-
0, ossl_ssl_session_free,
|
21
|
-
},
|
22
|
-
0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
|
23
|
-
};
|
24
|
-
|
25
|
-
static VALUE ossl_ssl_session_alloc(VALUE klass)
|
26
|
-
{
|
27
|
-
return TypedData_Wrap_Struct(klass, &ossl_ssl_session_type, NULL);
|
28
|
-
}
|
29
|
-
|
30
|
-
/*
|
31
|
-
* call-seq:
|
32
|
-
* Session.new(ssl_socket) -> Session
|
33
|
-
* Session.new(string) -> Session
|
34
|
-
*
|
35
|
-
* Creates a new Session object from an instance of SSLSocket or DER/PEM encoded
|
36
|
-
* String.
|
37
|
-
*/
|
38
|
-
static VALUE
|
39
|
-
ossl_ssl_session_initialize(VALUE self, VALUE arg1)
|
40
|
-
{
|
41
|
-
SSL_SESSION *ctx;
|
42
|
-
|
43
|
-
if (RTYPEDDATA_DATA(self))
|
44
|
-
ossl_raise(eSSLSession, "SSL Session already initialized");
|
45
|
-
|
46
|
-
if (rb_obj_is_instance_of(arg1, cSSLSocket)) {
|
47
|
-
SSL *ssl;
|
48
|
-
|
49
|
-
GetSSL(arg1, ssl);
|
50
|
-
|
51
|
-
if ((ctx = SSL_get1_session(ssl)) == NULL)
|
52
|
-
ossl_raise(eSSLSession, "no session available");
|
53
|
-
}
|
54
|
-
else {
|
55
|
-
BIO *in = ossl_obj2bio(&arg1);
|
56
|
-
|
57
|
-
ctx = d2i_SSL_SESSION_bio(in, NULL);
|
58
|
-
if (!ctx) {
|
59
|
-
OSSL_BIO_reset(in);
|
60
|
-
ctx = PEM_read_bio_SSL_SESSION(in, NULL, NULL, NULL);
|
61
|
-
}
|
62
|
-
BIO_free(in);
|
63
|
-
if (!ctx)
|
64
|
-
ossl_raise(rb_eArgError, "unknown type");
|
65
|
-
}
|
66
|
-
|
67
|
-
RTYPEDDATA_DATA(self) = ctx;
|
68
|
-
|
69
|
-
return self;
|
70
|
-
}
|
71
|
-
|
72
|
-
static VALUE
|
73
|
-
ossl_ssl_session_initialize_copy(VALUE self, VALUE other)
|
74
|
-
{
|
75
|
-
SSL_SESSION *sess, *sess_other, *sess_new;
|
76
|
-
|
77
|
-
rb_check_frozen(self);
|
78
|
-
sess = RTYPEDDATA_DATA(self); /* XXX */
|
79
|
-
GetSSLSession(other, sess_other);
|
80
|
-
|
81
|
-
sess_new = ASN1_dup((i2d_of_void *)i2d_SSL_SESSION, (d2i_of_void *)d2i_SSL_SESSION,
|
82
|
-
(char *)sess_other);
|
83
|
-
if (!sess_new)
|
84
|
-
ossl_raise(eSSLSession, "ASN1_dup");
|
85
|
-
|
86
|
-
RTYPEDDATA_DATA(self) = sess_new;
|
87
|
-
SSL_SESSION_free(sess);
|
88
|
-
|
89
|
-
return self;
|
90
|
-
}
|
91
|
-
|
92
|
-
static int
|
93
|
-
ossl_SSL_SESSION_cmp(const SSL_SESSION *a, const SSL_SESSION *b)
|
94
|
-
{
|
95
|
-
unsigned int a_len;
|
96
|
-
const unsigned char *a_sid = SSL_SESSION_get_id(a, &a_len);
|
97
|
-
unsigned int b_len;
|
98
|
-
const unsigned char *b_sid = SSL_SESSION_get_id(b, &b_len);
|
99
|
-
|
100
|
-
if (SSL_SESSION_get_protocol_version(a) != SSL_SESSION_get_protocol_version(b))
|
101
|
-
return 1;
|
102
|
-
if (a_len != b_len)
|
103
|
-
return 1;
|
104
|
-
|
105
|
-
return CRYPTO_memcmp(a_sid, b_sid, a_len);
|
106
|
-
}
|
107
|
-
|
108
|
-
/*
|
109
|
-
* call-seq:
|
110
|
-
* session1 == session2 -> boolean
|
111
|
-
*
|
112
|
-
* Returns +true+ if the two Session is the same, +false+ if not.
|
113
|
-
*/
|
114
|
-
static VALUE ossl_ssl_session_eq(VALUE val1, VALUE val2)
|
115
|
-
{
|
116
|
-
SSL_SESSION *ctx1, *ctx2;
|
117
|
-
|
118
|
-
GetSSLSession(val1, ctx1);
|
119
|
-
GetSSLSession(val2, ctx2);
|
120
|
-
|
121
|
-
switch (ossl_SSL_SESSION_cmp(ctx1, ctx2)) {
|
122
|
-
case 0: return Qtrue;
|
123
|
-
default: return Qfalse;
|
124
|
-
}
|
125
|
-
}
|
126
|
-
|
127
|
-
/*
|
128
|
-
* call-seq:
|
129
|
-
* session.time -> Time
|
130
|
-
*
|
131
|
-
* Returns the time at which the session was established.
|
132
|
-
*/
|
133
|
-
static VALUE
|
134
|
-
ossl_ssl_session_get_time(VALUE self)
|
135
|
-
{
|
136
|
-
SSL_SESSION *ctx;
|
137
|
-
long t;
|
138
|
-
|
139
|
-
GetSSLSession(self, ctx);
|
140
|
-
t = SSL_SESSION_get_time(ctx);
|
141
|
-
if (t == 0)
|
142
|
-
return Qnil;
|
143
|
-
|
144
|
-
return rb_funcall(rb_cTime, rb_intern("at"), 1, LONG2NUM(t));
|
145
|
-
}
|
146
|
-
|
147
|
-
/*
|
148
|
-
* call-seq:
|
149
|
-
* session.timeout -> Integer
|
150
|
-
*
|
151
|
-
* Returns the timeout value set for the session, in seconds from the
|
152
|
-
* established time.
|
153
|
-
*
|
154
|
-
*/
|
155
|
-
static VALUE
|
156
|
-
ossl_ssl_session_get_timeout(VALUE self)
|
157
|
-
{
|
158
|
-
SSL_SESSION *ctx;
|
159
|
-
long t;
|
160
|
-
|
161
|
-
GetSSLSession(self, ctx);
|
162
|
-
t = SSL_SESSION_get_timeout(ctx);
|
163
|
-
|
164
|
-
return LONG2NUM(t);
|
165
|
-
}
|
166
|
-
|
167
|
-
/*
|
168
|
-
* call-seq:
|
169
|
-
* session.time = time
|
170
|
-
* session.time = integer
|
171
|
-
*
|
172
|
-
* Sets start time of the session. Time resolution is in seconds.
|
173
|
-
*
|
174
|
-
*/
|
175
|
-
static VALUE ossl_ssl_session_set_time(VALUE self, VALUE time_v)
|
176
|
-
{
|
177
|
-
SSL_SESSION *ctx;
|
178
|
-
long t;
|
179
|
-
|
180
|
-
GetSSLSession(self, ctx);
|
181
|
-
if (rb_obj_is_instance_of(time_v, rb_cTime)) {
|
182
|
-
time_v = rb_funcall(time_v, rb_intern("to_i"), 0);
|
183
|
-
}
|
184
|
-
t = NUM2LONG(time_v);
|
185
|
-
SSL_SESSION_set_time(ctx, t);
|
186
|
-
return ossl_ssl_session_get_time(self);
|
187
|
-
}
|
188
|
-
|
189
|
-
/*
|
190
|
-
* call-seq:
|
191
|
-
* session.timeout = integer
|
192
|
-
*
|
193
|
-
* Sets how long until the session expires in seconds.
|
194
|
-
*/
|
195
|
-
static VALUE ossl_ssl_session_set_timeout(VALUE self, VALUE time_v)
|
196
|
-
{
|
197
|
-
SSL_SESSION *ctx;
|
198
|
-
long t;
|
199
|
-
|
200
|
-
GetSSLSession(self, ctx);
|
201
|
-
t = NUM2LONG(time_v);
|
202
|
-
SSL_SESSION_set_timeout(ctx, t);
|
203
|
-
return ossl_ssl_session_get_timeout(self);
|
204
|
-
}
|
205
|
-
|
206
|
-
/*
|
207
|
-
* call-seq:
|
208
|
-
* session.id -> String
|
209
|
-
*
|
210
|
-
* Returns the Session ID.
|
211
|
-
*/
|
212
|
-
static VALUE ossl_ssl_session_get_id(VALUE self)
|
213
|
-
{
|
214
|
-
SSL_SESSION *ctx;
|
215
|
-
const unsigned char *p = NULL;
|
216
|
-
unsigned int i = 0;
|
217
|
-
|
218
|
-
GetSSLSession(self, ctx);
|
219
|
-
|
220
|
-
p = SSL_SESSION_get_id(ctx, &i);
|
221
|
-
|
222
|
-
return rb_str_new((const char *) p, i);
|
223
|
-
}
|
224
|
-
|
225
|
-
/*
|
226
|
-
* call-seq:
|
227
|
-
* session.to_der -> String
|
228
|
-
*
|
229
|
-
* Returns an ASN1 encoded String that contains the Session object.
|
230
|
-
*/
|
231
|
-
static VALUE ossl_ssl_session_to_der(VALUE self)
|
232
|
-
{
|
233
|
-
SSL_SESSION *ctx;
|
234
|
-
unsigned char *p;
|
235
|
-
int len;
|
236
|
-
VALUE str;
|
237
|
-
|
238
|
-
GetSSLSession(self, ctx);
|
239
|
-
len = i2d_SSL_SESSION(ctx, NULL);
|
240
|
-
if (len <= 0) {
|
241
|
-
ossl_raise(eSSLSession, "i2d_SSL_SESSION");
|
242
|
-
}
|
243
|
-
|
244
|
-
str = rb_str_new(0, len);
|
245
|
-
p = (unsigned char *)RSTRING_PTR(str);
|
246
|
-
i2d_SSL_SESSION(ctx, &p);
|
247
|
-
ossl_str_adjust(str, p);
|
248
|
-
return str;
|
249
|
-
}
|
250
|
-
|
251
|
-
/*
|
252
|
-
* call-seq:
|
253
|
-
* session.to_pem -> String
|
254
|
-
*
|
255
|
-
* Returns a PEM encoded String that contains the Session object.
|
256
|
-
*/
|
257
|
-
static VALUE ossl_ssl_session_to_pem(VALUE self)
|
258
|
-
{
|
259
|
-
SSL_SESSION *ctx;
|
260
|
-
BIO *out;
|
261
|
-
|
262
|
-
GetSSLSession(self, ctx);
|
263
|
-
|
264
|
-
if (!(out = BIO_new(BIO_s_mem()))) {
|
265
|
-
ossl_raise(eSSLSession, "BIO_s_mem()");
|
266
|
-
}
|
267
|
-
|
268
|
-
if (!PEM_write_bio_SSL_SESSION(out, ctx)) {
|
269
|
-
BIO_free(out);
|
270
|
-
ossl_raise(eSSLSession, "SSL_SESSION_print()");
|
271
|
-
}
|
272
|
-
|
273
|
-
|
274
|
-
return ossl_membio2str(out);
|
275
|
-
}
|
276
|
-
|
277
|
-
|
278
|
-
/*
|
279
|
-
* call-seq:
|
280
|
-
* session.to_text -> String
|
281
|
-
*
|
282
|
-
* Shows everything in the Session object. This is for diagnostic purposes.
|
283
|
-
*/
|
284
|
-
static VALUE ossl_ssl_session_to_text(VALUE self)
|
285
|
-
{
|
286
|
-
SSL_SESSION *ctx;
|
287
|
-
BIO *out;
|
288
|
-
|
289
|
-
GetSSLSession(self, ctx);
|
290
|
-
|
291
|
-
if (!(out = BIO_new(BIO_s_mem()))) {
|
292
|
-
ossl_raise(eSSLSession, "BIO_s_mem()");
|
293
|
-
}
|
294
|
-
|
295
|
-
if (!SSL_SESSION_print(out, ctx)) {
|
296
|
-
BIO_free(out);
|
297
|
-
ossl_raise(eSSLSession, "SSL_SESSION_print()");
|
298
|
-
}
|
299
|
-
|
300
|
-
return ossl_membio2str(out);
|
301
|
-
}
|
302
|
-
|
303
|
-
#endif /* !defined(OPENSSL_NO_SOCK) */
|
304
|
-
|
305
|
-
void Init_ossl_ssl_session(void)
|
306
|
-
{
|
307
|
-
#if 0
|
308
|
-
mOSSL = rb_define_module("OpenSSL");
|
309
|
-
mSSL = rb_define_module_under(mOSSL, "SSL");
|
310
|
-
eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
|
311
|
-
#endif
|
312
|
-
#ifndef OPENSSL_NO_SOCK
|
313
|
-
cSSLSession = rb_define_class_under(mSSL, "Session", rb_cObject);
|
314
|
-
eSSLSession = rb_define_class_under(cSSLSession, "SessionError", eOSSLError);
|
315
|
-
|
316
|
-
rb_define_alloc_func(cSSLSession, ossl_ssl_session_alloc);
|
317
|
-
rb_define_method(cSSLSession, "initialize", ossl_ssl_session_initialize, 1);
|
318
|
-
rb_define_method(cSSLSession, "initialize_copy", ossl_ssl_session_initialize_copy, 1);
|
319
|
-
|
320
|
-
rb_define_method(cSSLSession, "==", ossl_ssl_session_eq, 1);
|
321
|
-
|
322
|
-
rb_define_method(cSSLSession, "time", ossl_ssl_session_get_time, 0);
|
323
|
-
rb_define_method(cSSLSession, "time=", ossl_ssl_session_set_time, 1);
|
324
|
-
rb_define_method(cSSLSession, "timeout", ossl_ssl_session_get_timeout, 0);
|
325
|
-
rb_define_method(cSSLSession, "timeout=", ossl_ssl_session_set_timeout, 1);
|
326
|
-
rb_define_method(cSSLSession, "id", ossl_ssl_session_get_id, 0);
|
327
|
-
rb_define_method(cSSLSession, "to_der", ossl_ssl_session_to_der, 0);
|
328
|
-
rb_define_method(cSSLSession, "to_pem", ossl_ssl_session_to_pem, 0);
|
329
|
-
rb_define_method(cSSLSession, "to_text", ossl_ssl_session_to_text, 0);
|
330
|
-
#endif /* !defined(OPENSSL_NO_SOCK) */
|
331
|
-
}
|