openssl-custom 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/BSDL +22 -0
- data/CONTRIBUTING.md +132 -0
- data/History.md +485 -0
- data/LICENSE.txt +56 -0
- data/README.md +66 -0
- data/ext/openssl/extconf.rb +190 -0
- data/ext/openssl/openssl_missing.c +106 -0
- data/ext/openssl/openssl_missing.h +257 -0
- data/ext/openssl/ossl.c +1282 -0
- data/ext/openssl/ossl.h +181 -0
- data/ext/openssl/ossl_asn1.c +1878 -0
- data/ext/openssl/ossl_asn1.h +62 -0
- data/ext/openssl/ossl_bio.c +42 -0
- data/ext/openssl/ossl_bio.h +16 -0
- data/ext/openssl/ossl_bn.c +1270 -0
- data/ext/openssl/ossl_bn.h +26 -0
- data/ext/openssl/ossl_cipher.c +1075 -0
- data/ext/openssl/ossl_cipher.h +20 -0
- data/ext/openssl/ossl_config.c +89 -0
- data/ext/openssl/ossl_config.h +19 -0
- data/ext/openssl/ossl_digest.c +425 -0
- data/ext/openssl/ossl_digest.h +20 -0
- data/ext/openssl/ossl_engine.c +567 -0
- data/ext/openssl/ossl_engine.h +19 -0
- data/ext/openssl/ossl_hmac.c +389 -0
- data/ext/openssl/ossl_hmac.h +18 -0
- data/ext/openssl/ossl_kdf.c +303 -0
- data/ext/openssl/ossl_kdf.h +6 -0
- data/ext/openssl/ossl_ns_spki.c +405 -0
- data/ext/openssl/ossl_ns_spki.h +19 -0
- data/ext/openssl/ossl_ocsp.c +2013 -0
- data/ext/openssl/ossl_ocsp.h +23 -0
- data/ext/openssl/ossl_pkcs12.c +257 -0
- data/ext/openssl/ossl_pkcs12.h +13 -0
- data/ext/openssl/ossl_pkcs7.c +1098 -0
- data/ext/openssl/ossl_pkcs7.h +36 -0
- data/ext/openssl/ossl_pkey.c +673 -0
- data/ext/openssl/ossl_pkey.h +241 -0
- data/ext/openssl/ossl_pkey_dh.c +650 -0
- data/ext/openssl/ossl_pkey_dsa.c +664 -0
- data/ext/openssl/ossl_pkey_ec.c +1827 -0
- data/ext/openssl/ossl_pkey_rsa.c +966 -0
- data/ext/openssl/ossl_rand.c +200 -0
- data/ext/openssl/ossl_rand.h +18 -0
- data/ext/openssl/ossl_ssl.c +3080 -0
- data/ext/openssl/ossl_ssl.h +36 -0
- data/ext/openssl/ossl_ssl_session.c +332 -0
- data/ext/openssl/ossl_ts.c +1524 -0
- data/ext/openssl/ossl_ts.h +16 -0
- data/ext/openssl/ossl_x509.c +262 -0
- data/ext/openssl/ossl_x509.h +115 -0
- data/ext/openssl/ossl_x509attr.c +324 -0
- data/ext/openssl/ossl_x509cert.c +846 -0
- data/ext/openssl/ossl_x509crl.c +542 -0
- data/ext/openssl/ossl_x509ext.c +491 -0
- data/ext/openssl/ossl_x509name.c +590 -0
- data/ext/openssl/ossl_x509req.c +441 -0
- data/ext/openssl/ossl_x509revoked.c +300 -0
- data/ext/openssl/ossl_x509store.c +902 -0
- data/ext/openssl/ruby_missing.h +24 -0
- data/lib/openssl/bn.rb +40 -0
- data/lib/openssl/buffering.rb +478 -0
- data/lib/openssl/cipher.rb +67 -0
- data/lib/openssl/config.rb +501 -0
- data/lib/openssl/digest.rb +73 -0
- data/lib/openssl/hmac.rb +13 -0
- data/lib/openssl/marshal.rb +30 -0
- data/lib/openssl/pkcs5.rb +22 -0
- data/lib/openssl/pkey.rb +42 -0
- data/lib/openssl/ssl.rb +542 -0
- data/lib/openssl/version.rb +5 -0
- data/lib/openssl/x509.rb +369 -0
- data/lib/openssl.rb +38 -0
- metadata +196 -0
data/ext/openssl/ossl.h
ADDED
@@ -0,0 +1,181 @@
|
|
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_H_)
|
11
|
+
#define _OSSL_H_
|
12
|
+
|
13
|
+
#include RUBY_EXTCONF_H
|
14
|
+
|
15
|
+
#include <assert.h>
|
16
|
+
#include <ruby.h>
|
17
|
+
#include <errno.h>
|
18
|
+
#include <ruby/io.h>
|
19
|
+
#include <ruby/thread.h>
|
20
|
+
#include <openssl/opensslv.h>
|
21
|
+
#include <openssl/err.h>
|
22
|
+
#include <openssl/asn1.h>
|
23
|
+
#include <openssl/x509v3.h>
|
24
|
+
#include <openssl/ssl.h>
|
25
|
+
#include <openssl/pkcs12.h>
|
26
|
+
#include <openssl/pkcs7.h>
|
27
|
+
#include <openssl/hmac.h>
|
28
|
+
#include <openssl/rand.h>
|
29
|
+
#include <openssl/conf.h>
|
30
|
+
#ifndef OPENSSL_NO_TS
|
31
|
+
#include <openssl/ts.h>
|
32
|
+
#endif
|
33
|
+
#include <openssl/crypto.h>
|
34
|
+
#if !defined(OPENSSL_NO_ENGINE)
|
35
|
+
# include <openssl/engine.h>
|
36
|
+
#endif
|
37
|
+
#if !defined(OPENSSL_NO_OCSP)
|
38
|
+
# include <openssl/ocsp.h>
|
39
|
+
#endif
|
40
|
+
#include <openssl/bn.h>
|
41
|
+
#include <openssl/rsa.h>
|
42
|
+
#include <openssl/dsa.h>
|
43
|
+
#include <openssl/evp.h>
|
44
|
+
#include <openssl/dh.h>
|
45
|
+
|
46
|
+
/*
|
47
|
+
* Common Module
|
48
|
+
*/
|
49
|
+
extern VALUE mOSSL;
|
50
|
+
|
51
|
+
/*
|
52
|
+
* Common Error Class
|
53
|
+
*/
|
54
|
+
extern VALUE eOSSLError;
|
55
|
+
|
56
|
+
/*
|
57
|
+
* CheckTypes
|
58
|
+
*/
|
59
|
+
#define OSSL_Check_Kind(obj, klass) do {\
|
60
|
+
if (!rb_obj_is_kind_of((obj), (klass))) {\
|
61
|
+
ossl_raise(rb_eTypeError, "wrong argument (%"PRIsVALUE")! (Expected kind of %"PRIsVALUE")",\
|
62
|
+
rb_obj_class(obj), (klass));\
|
63
|
+
}\
|
64
|
+
} while (0)
|
65
|
+
|
66
|
+
/*
|
67
|
+
* Type conversions
|
68
|
+
*/
|
69
|
+
#if !defined(NUM2UINT64T) /* in case Ruby starts to provide */
|
70
|
+
# if SIZEOF_LONG == 8
|
71
|
+
# define NUM2UINT64T(x) ((uint64_t)NUM2ULONG(x))
|
72
|
+
# elif defined(HAVE_LONG_LONG) && SIZEOF_LONG_LONG == 8
|
73
|
+
# define NUM2UINT64T(x) ((uint64_t)NUM2ULL(x))
|
74
|
+
# else
|
75
|
+
# error "unknown platform; no 64-bit width integer"
|
76
|
+
# endif
|
77
|
+
#endif
|
78
|
+
|
79
|
+
/*
|
80
|
+
* Data Conversion
|
81
|
+
*/
|
82
|
+
STACK_OF(X509) *ossl_x509_ary2sk(VALUE);
|
83
|
+
STACK_OF(X509) *ossl_protect_x509_ary2sk(VALUE,int*);
|
84
|
+
VALUE ossl_x509_sk2ary(const STACK_OF(X509) *certs);
|
85
|
+
VALUE ossl_x509crl_sk2ary(const STACK_OF(X509_CRL) *crl);
|
86
|
+
VALUE ossl_x509name_sk2ary(const STACK_OF(X509_NAME) *names);
|
87
|
+
VALUE ossl_buf2str(char *buf, int len);
|
88
|
+
VALUE ossl_str_new(const char *, long, int *);
|
89
|
+
#define ossl_str_adjust(str, p) \
|
90
|
+
do{\
|
91
|
+
long newlen = (long)((p) - (unsigned char*)RSTRING_PTR(str));\
|
92
|
+
assert(newlen <= RSTRING_LEN(str));\
|
93
|
+
rb_str_set_len((str), newlen);\
|
94
|
+
}while(0)
|
95
|
+
/*
|
96
|
+
* Convert binary string to hex string. The caller is responsible for
|
97
|
+
* ensuring out has (2 * len) bytes of capacity.
|
98
|
+
*/
|
99
|
+
void ossl_bin2hex(unsigned char *in, char *out, size_t len);
|
100
|
+
|
101
|
+
/*
|
102
|
+
* Our default PEM callback
|
103
|
+
*/
|
104
|
+
/* Convert the argument to String and validate the length. Note this may raise. */
|
105
|
+
VALUE ossl_pem_passwd_value(VALUE);
|
106
|
+
/* Can be casted to pem_password_cb. If a password (String) is passed as the
|
107
|
+
* "arbitrary data" (typically the last parameter of PEM_{read,write}_
|
108
|
+
* functions), uses the value. If not, but a block is given, yields to it.
|
109
|
+
* If not either, fallbacks to PEM_def_callback() which reads from stdin. */
|
110
|
+
int ossl_pem_passwd_cb(char *, int, int, void *);
|
111
|
+
|
112
|
+
/*
|
113
|
+
* Clear BIO* with this in PEM/DER fallback scenarios to avoid decoding
|
114
|
+
* errors piling up in OpenSSL::Errors
|
115
|
+
*/
|
116
|
+
#define OSSL_BIO_reset(bio) do { \
|
117
|
+
(void)BIO_reset((bio)); \
|
118
|
+
ossl_clear_error(); \
|
119
|
+
} while (0)
|
120
|
+
|
121
|
+
/*
|
122
|
+
* ERRor messages
|
123
|
+
*/
|
124
|
+
NORETURN(void ossl_raise(VALUE, const char *, ...));
|
125
|
+
/* Clear OpenSSL error queue. If dOSSL is set, rb_warn() them. */
|
126
|
+
void ossl_clear_error(void);
|
127
|
+
|
128
|
+
/*
|
129
|
+
* String to DER String
|
130
|
+
*/
|
131
|
+
VALUE ossl_to_der(VALUE);
|
132
|
+
VALUE ossl_to_der_if_possible(VALUE);
|
133
|
+
|
134
|
+
/*
|
135
|
+
* Debug
|
136
|
+
*/
|
137
|
+
extern VALUE dOSSL;
|
138
|
+
|
139
|
+
#if defined(HAVE_VA_ARGS_MACRO)
|
140
|
+
#define OSSL_Debug(...) do { \
|
141
|
+
if (dOSSL == Qtrue) { \
|
142
|
+
fprintf(stderr, "OSSL_DEBUG: "); \
|
143
|
+
fprintf(stderr, __VA_ARGS__); \
|
144
|
+
fprintf(stderr, " [%s:%d]\n", __FILE__, __LINE__); \
|
145
|
+
} \
|
146
|
+
} while (0)
|
147
|
+
|
148
|
+
#else
|
149
|
+
void ossl_debug(const char *, ...);
|
150
|
+
#define OSSL_Debug ossl_debug
|
151
|
+
#endif
|
152
|
+
|
153
|
+
/*
|
154
|
+
* Include all parts
|
155
|
+
*/
|
156
|
+
#include "openssl_missing.h"
|
157
|
+
#include "ruby_missing.h"
|
158
|
+
#include "ossl_asn1.h"
|
159
|
+
#include "ossl_bio.h"
|
160
|
+
#include "ossl_bn.h"
|
161
|
+
#include "ossl_cipher.h"
|
162
|
+
#include "ossl_config.h"
|
163
|
+
#include "ossl_digest.h"
|
164
|
+
#include "ossl_hmac.h"
|
165
|
+
#include "ossl_ns_spki.h"
|
166
|
+
#include "ossl_ocsp.h"
|
167
|
+
#include "ossl_pkcs12.h"
|
168
|
+
#include "ossl_pkcs7.h"
|
169
|
+
#include "ossl_pkey.h"
|
170
|
+
#include "ossl_rand.h"
|
171
|
+
#include "ossl_ssl.h"
|
172
|
+
#ifndef OPENSSL_NO_TS
|
173
|
+
#include "ossl_ts.h"
|
174
|
+
#endif
|
175
|
+
#include "ossl_x509.h"
|
176
|
+
#include "ossl_engine.h"
|
177
|
+
#include "ossl_kdf.h"
|
178
|
+
|
179
|
+
void Init_openssl(void);
|
180
|
+
|
181
|
+
#endif /* _OSSL_H_ */
|