zig_example 0.3.2 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/ext/mkmf.rb +5 -2
  3. data/lib/zig_example/version.rb +1 -1
  4. metadata +3 -56
  5. data/ext/openssl/openssl_missing.c +0 -40
  6. data/ext/openssl/openssl_missing.h +0 -238
  7. data/ext/openssl/ossl.c +0 -1295
  8. data/ext/openssl/ossl.h +0 -201
  9. data/ext/openssl/ossl_asn1.c +0 -1891
  10. data/ext/openssl/ossl_asn1.h +0 -62
  11. data/ext/openssl/ossl_bio.c +0 -42
  12. data/ext/openssl/ossl_bio.h +0 -16
  13. data/ext/openssl/ossl_bn.c +0 -1344
  14. data/ext/openssl/ossl_bn.h +0 -26
  15. data/ext/openssl/ossl_cipher.c +0 -1074
  16. data/ext/openssl/ossl_cipher.h +0 -20
  17. data/ext/openssl/ossl_config.c +0 -460
  18. data/ext/openssl/ossl_config.h +0 -16
  19. data/ext/openssl/ossl_digest.c +0 -425
  20. data/ext/openssl/ossl_digest.h +0 -20
  21. data/ext/openssl/ossl_engine.c +0 -568
  22. data/ext/openssl/ossl_engine.h +0 -19
  23. data/ext/openssl/ossl_hmac.c +0 -310
  24. data/ext/openssl/ossl_hmac.h +0 -18
  25. data/ext/openssl/ossl_kdf.c +0 -311
  26. data/ext/openssl/ossl_kdf.h +0 -6
  27. data/ext/openssl/ossl_ns_spki.c +0 -405
  28. data/ext/openssl/ossl_ns_spki.h +0 -19
  29. data/ext/openssl/ossl_ocsp.c +0 -1965
  30. data/ext/openssl/ossl_ocsp.h +0 -23
  31. data/ext/openssl/ossl_pkcs12.c +0 -275
  32. data/ext/openssl/ossl_pkcs12.h +0 -13
  33. data/ext/openssl/ossl_pkcs7.c +0 -1081
  34. data/ext/openssl/ossl_pkcs7.h +0 -36
  35. data/ext/openssl/ossl_pkey.c +0 -1624
  36. data/ext/openssl/ossl_pkey.h +0 -204
  37. data/ext/openssl/ossl_pkey_dh.c +0 -440
  38. data/ext/openssl/ossl_pkey_dsa.c +0 -359
  39. data/ext/openssl/ossl_pkey_ec.c +0 -1655
  40. data/ext/openssl/ossl_pkey_rsa.c +0 -579
  41. data/ext/openssl/ossl_rand.c +0 -200
  42. data/ext/openssl/ossl_rand.h +0 -18
  43. data/ext/openssl/ossl_ssl.c +0 -3142
  44. data/ext/openssl/ossl_ssl.h +0 -36
  45. data/ext/openssl/ossl_ssl_session.c +0 -331
  46. data/ext/openssl/ossl_ts.c +0 -1539
  47. data/ext/openssl/ossl_ts.h +0 -16
  48. data/ext/openssl/ossl_x509.c +0 -256
  49. data/ext/openssl/ossl_x509.h +0 -115
  50. data/ext/openssl/ossl_x509attr.c +0 -324
  51. data/ext/openssl/ossl_x509cert.c +0 -1002
  52. data/ext/openssl/ossl_x509crl.c +0 -545
  53. data/ext/openssl/ossl_x509ext.c +0 -490
  54. data/ext/openssl/ossl_x509name.c +0 -597
  55. data/ext/openssl/ossl_x509req.c +0 -444
  56. data/ext/openssl/ossl_x509revoked.c +0 -300
  57. data/ext/openssl/ossl_x509store.c +0 -986
@@ -1,23 +0,0 @@
1
- /*
2
- * 'OpenSSL for Ruby' project
3
- * Copyright (C) 2003 Michal Rokos <m.rokos@sh.cvut.cz>
4
- * Copyright (C) 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
5
- * All rights reserved.
6
- */
7
- /*
8
- * This program is licensed under the same licence as Ruby.
9
- * (See the file 'LICENCE'.)
10
- */
11
- #if !defined(_OSSL_OCSP_H_)
12
- #define _OSSL_OCSP_H_
13
-
14
- #if !defined(OPENSSL_NO_OCSP)
15
- extern VALUE mOCSP;
16
- extern VALUE cOCSPReq;
17
- extern VALUE cOCSPRes;
18
- extern VALUE cOCSPBasicRes;
19
- #endif
20
-
21
- void Init_ossl_ocsp(void);
22
-
23
- #endif /* _OSSL_OCSP_H_ */
@@ -1,275 +0,0 @@
1
- /*
2
- * This program is licensed under the same licence as Ruby.
3
- * (See the file 'LICENCE'.)
4
- */
5
- #include "ossl.h"
6
-
7
- #define NewPKCS12(klass) \
8
- TypedData_Wrap_Struct((klass), &ossl_pkcs12_type, 0)
9
-
10
- #define SetPKCS12(obj, p12) do { \
11
- if(!(p12)) ossl_raise(rb_eRuntimeError, "PKCS12 wasn't initialized."); \
12
- RTYPEDDATA_DATA(obj) = (p12); \
13
- } while (0)
14
-
15
- #define GetPKCS12(obj, p12) do { \
16
- TypedData_Get_Struct((obj), PKCS12, &ossl_pkcs12_type, (p12)); \
17
- if(!(p12)) ossl_raise(rb_eRuntimeError, "PKCS12 wasn't initialized."); \
18
- } while (0)
19
-
20
- #define ossl_pkcs12_set_key(o,v) rb_iv_set((o), "@key", (v))
21
- #define ossl_pkcs12_set_cert(o,v) rb_iv_set((o), "@certificate", (v))
22
- #define ossl_pkcs12_set_ca_certs(o,v) rb_iv_set((o), "@ca_certs", (v))
23
- #define ossl_pkcs12_get_key(o) rb_iv_get((o), "@key")
24
- #define ossl_pkcs12_get_cert(o) rb_iv_get((o), "@certificate")
25
- #define ossl_pkcs12_get_ca_certs(o) rb_iv_get((o), "@ca_certs")
26
-
27
- /*
28
- * Classes
29
- */
30
- VALUE cPKCS12;
31
- VALUE ePKCS12Error;
32
-
33
- /*
34
- * Private
35
- */
36
- static void
37
- ossl_pkcs12_free(void *ptr)
38
- {
39
- PKCS12_free(ptr);
40
- }
41
-
42
- static const rb_data_type_t ossl_pkcs12_type = {
43
- "OpenSSL/PKCS12",
44
- {
45
- 0, ossl_pkcs12_free,
46
- },
47
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
48
- };
49
-
50
- static VALUE
51
- ossl_pkcs12_s_allocate(VALUE klass)
52
- {
53
- PKCS12 *p12;
54
- VALUE obj;
55
-
56
- obj = NewPKCS12(klass);
57
- if(!(p12 = PKCS12_new())) ossl_raise(ePKCS12Error, NULL);
58
- SetPKCS12(obj, p12);
59
-
60
- return obj;
61
- }
62
-
63
- static VALUE
64
- ossl_pkcs12_initialize_copy(VALUE self, VALUE other)
65
- {
66
- PKCS12 *p12, *p12_old, *p12_new;
67
-
68
- rb_check_frozen(self);
69
- GetPKCS12(self, p12_old);
70
- GetPKCS12(other, p12);
71
-
72
- p12_new = ASN1_dup((i2d_of_void *)i2d_PKCS12, (d2i_of_void *)d2i_PKCS12, (char *)p12);
73
- if (!p12_new)
74
- ossl_raise(ePKCS12Error, "ASN1_dup");
75
-
76
- SetPKCS12(self, p12_new);
77
- PKCS12_free(p12_old);
78
-
79
- return self;
80
- }
81
-
82
- /*
83
- * call-seq:
84
- * PKCS12.create(pass, name, key, cert [, ca, [, key_pbe [, cert_pbe [, key_iter [, mac_iter [, keytype]]]]]])
85
- *
86
- * === Parameters
87
- * * _pass_ - string
88
- * * _name_ - A string describing the key.
89
- * * _key_ - Any PKey.
90
- * * _cert_ - A X509::Certificate.
91
- * * The public_key portion of the certificate must contain a valid public key.
92
- * * The not_before and not_after fields must be filled in.
93
- * * _ca_ - An optional array of X509::Certificate's.
94
- * * _key_pbe_ - string
95
- * * _cert_pbe_ - string
96
- * * _key_iter_ - integer
97
- * * _mac_iter_ - integer
98
- * * _keytype_ - An integer representing an MSIE specific extension.
99
- *
100
- * Any optional arguments may be supplied as +nil+ to preserve the OpenSSL defaults.
101
- *
102
- * See the OpenSSL documentation for PKCS12_create().
103
- */
104
- static VALUE
105
- ossl_pkcs12_s_create(int argc, VALUE *argv, VALUE self)
106
- {
107
- VALUE pass, name, pkey, cert, ca, key_nid, cert_nid, key_iter, mac_iter, keytype;
108
- VALUE obj;
109
- char *passphrase, *friendlyname;
110
- EVP_PKEY *key;
111
- X509 *x509;
112
- STACK_OF(X509) *x509s;
113
- int nkey = 0, ncert = 0, kiter = 0, miter = 0, ktype = 0;
114
- PKCS12 *p12;
115
-
116
- rb_scan_args(argc, argv, "46", &pass, &name, &pkey, &cert, &ca, &key_nid, &cert_nid, &key_iter, &mac_iter, &keytype);
117
- passphrase = NIL_P(pass) ? NULL : StringValueCStr(pass);
118
- friendlyname = NIL_P(name) ? NULL : StringValueCStr(name);
119
- key = GetPKeyPtr(pkey);
120
- x509 = GetX509CertPtr(cert);
121
- /* TODO: make a VALUE to nid function */
122
- if (!NIL_P(key_nid)) {
123
- if ((nkey = OBJ_txt2nid(StringValueCStr(key_nid))) == NID_undef)
124
- ossl_raise(rb_eArgError, "Unknown PBE algorithm %"PRIsVALUE, key_nid);
125
- }
126
- if (!NIL_P(cert_nid)) {
127
- if ((ncert = OBJ_txt2nid(StringValueCStr(cert_nid))) == NID_undef)
128
- ossl_raise(rb_eArgError, "Unknown PBE algorithm %"PRIsVALUE, cert_nid);
129
- }
130
- if (!NIL_P(key_iter))
131
- kiter = NUM2INT(key_iter);
132
- if (!NIL_P(mac_iter))
133
- miter = NUM2INT(mac_iter);
134
- if (!NIL_P(keytype))
135
- ktype = NUM2INT(keytype);
136
-
137
- obj = NewPKCS12(cPKCS12);
138
- x509s = NIL_P(ca) ? NULL : ossl_x509_ary2sk(ca);
139
- p12 = PKCS12_create(passphrase, friendlyname, key, x509, x509s,
140
- nkey, ncert, kiter, miter, ktype);
141
- sk_X509_pop_free(x509s, X509_free);
142
- if(!p12) ossl_raise(ePKCS12Error, NULL);
143
- SetPKCS12(obj, p12);
144
-
145
- ossl_pkcs12_set_key(obj, pkey);
146
- ossl_pkcs12_set_cert(obj, cert);
147
- ossl_pkcs12_set_ca_certs(obj, ca);
148
-
149
- return obj;
150
- }
151
-
152
- static VALUE
153
- ossl_pkey_new_i(VALUE arg)
154
- {
155
- return ossl_pkey_new((EVP_PKEY *)arg);
156
- }
157
-
158
- static VALUE
159
- ossl_x509_new_i(VALUE arg)
160
- {
161
- return ossl_x509_new((X509 *)arg);
162
- }
163
-
164
- static VALUE
165
- ossl_x509_sk2ary_i(VALUE arg)
166
- {
167
- return ossl_x509_sk2ary((STACK_OF(X509) *)arg);
168
- }
169
-
170
- /*
171
- * call-seq:
172
- * PKCS12.new -> pkcs12
173
- * PKCS12.new(str) -> pkcs12
174
- * PKCS12.new(str, pass) -> pkcs12
175
- *
176
- * === Parameters
177
- * * _str_ - Must be a DER encoded PKCS12 string.
178
- * * _pass_ - string
179
- */
180
- static VALUE
181
- ossl_pkcs12_initialize(int argc, VALUE *argv, VALUE self)
182
- {
183
- BIO *in;
184
- VALUE arg, pass, pkey, cert, ca;
185
- char *passphrase;
186
- EVP_PKEY *key;
187
- X509 *x509;
188
- STACK_OF(X509) *x509s = NULL;
189
- int st = 0;
190
- PKCS12 *pkcs = DATA_PTR(self);
191
-
192
- if(rb_scan_args(argc, argv, "02", &arg, &pass) == 0) return self;
193
- passphrase = NIL_P(pass) ? NULL : StringValueCStr(pass);
194
- in = ossl_obj2bio(&arg);
195
- d2i_PKCS12_bio(in, &pkcs);
196
- DATA_PTR(self) = pkcs;
197
- BIO_free(in);
198
-
199
- pkey = cert = ca = Qnil;
200
- /* OpenSSL's bug; PKCS12_parse() puts errors even if it succeeds.
201
- * Fixed in OpenSSL 1.0.0t, 1.0.1p, 1.0.2d */
202
- ERR_set_mark();
203
- if(!PKCS12_parse(pkcs, passphrase, &key, &x509, &x509s))
204
- ossl_raise(ePKCS12Error, "PKCS12_parse");
205
- ERR_pop_to_mark();
206
- if (key) {
207
- pkey = rb_protect(ossl_pkey_new_i, (VALUE)key, &st);
208
- if (st) goto err;
209
- }
210
- if (x509) {
211
- cert = rb_protect(ossl_x509_new_i, (VALUE)x509, &st);
212
- if (st) goto err;
213
- }
214
- if (x509s) {
215
- ca = rb_protect(ossl_x509_sk2ary_i, (VALUE)x509s, &st);
216
- if (st) goto err;
217
- }
218
-
219
- err:
220
- X509_free(x509);
221
- sk_X509_pop_free(x509s, X509_free);
222
- ossl_pkcs12_set_key(self, pkey);
223
- ossl_pkcs12_set_cert(self, cert);
224
- ossl_pkcs12_set_ca_certs(self, ca);
225
- if(st) rb_jump_tag(st);
226
-
227
- return self;
228
- }
229
-
230
- static VALUE
231
- ossl_pkcs12_to_der(VALUE self)
232
- {
233
- PKCS12 *p12;
234
- VALUE str;
235
- long len;
236
- unsigned char *p;
237
-
238
- GetPKCS12(self, p12);
239
- if((len = i2d_PKCS12(p12, NULL)) <= 0)
240
- ossl_raise(ePKCS12Error, NULL);
241
- str = rb_str_new(0, len);
242
- p = (unsigned char *)RSTRING_PTR(str);
243
- if(i2d_PKCS12(p12, &p) <= 0)
244
- ossl_raise(ePKCS12Error, NULL);
245
- ossl_str_adjust(str, p);
246
-
247
- return str;
248
- }
249
-
250
- void
251
- Init_ossl_pkcs12(void)
252
- {
253
- #undef rb_intern
254
- #if 0
255
- mOSSL = rb_define_module("OpenSSL");
256
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
257
- #endif
258
-
259
- /*
260
- * Defines a file format commonly used to store private keys with
261
- * accompanying public key certificates, protected with a password-based
262
- * symmetric key.
263
- */
264
- cPKCS12 = rb_define_class_under(mOSSL, "PKCS12", rb_cObject);
265
- ePKCS12Error = rb_define_class_under(cPKCS12, "PKCS12Error", eOSSLError);
266
- rb_define_singleton_method(cPKCS12, "create", ossl_pkcs12_s_create, -1);
267
-
268
- rb_define_alloc_func(cPKCS12, ossl_pkcs12_s_allocate);
269
- rb_define_method(cPKCS12, "initialize_copy", ossl_pkcs12_initialize_copy, 1);
270
- rb_attr(cPKCS12, rb_intern("key"), 1, 0, Qfalse);
271
- rb_attr(cPKCS12, rb_intern("certificate"), 1, 0, Qfalse);
272
- rb_attr(cPKCS12, rb_intern("ca_certs"), 1, 0, Qfalse);
273
- rb_define_method(cPKCS12, "initialize", ossl_pkcs12_initialize, -1);
274
- rb_define_method(cPKCS12, "to_der", ossl_pkcs12_to_der, 0);
275
- }
@@ -1,13 +0,0 @@
1
- /*
2
- * This program is licensed under the same licence as Ruby.
3
- * (See the file 'LICENCE'.)
4
- */
5
- #if !defined(_OSSL_PKCS12_H_)
6
- #define _OSSL_PKCS12_H_
7
-
8
- extern VALUE cPKCS12;
9
- extern VALUE ePKCS12Error;
10
-
11
- void Init_ossl_pkcs12(void);
12
-
13
- #endif /* _OSSL_PKCS12_H_ */