rubysl-openssl 2.10 → 2.11
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 +5 -5
- data/ext/rubysl/openssl/deprecation.rb +7 -3
- data/ext/rubysl/openssl/extconf.rb +148 -103
- data/ext/rubysl/openssl/openssl_missing.c +94 -275
- data/ext/rubysl/openssl/openssl_missing.h +167 -98
- data/ext/rubysl/openssl/ossl.c +266 -212
- data/ext/rubysl/openssl/ossl.h +27 -89
- data/ext/rubysl/openssl/ossl_asn1.c +157 -221
- data/ext/rubysl/openssl/ossl_asn1.h +11 -3
- data/ext/rubysl/openssl/ossl_bio.c +10 -40
- data/ext/rubysl/openssl/ossl_bio.h +1 -2
- data/ext/rubysl/openssl/ossl_bn.c +144 -100
- data/ext/rubysl/openssl/ossl_bn.h +3 -1
- data/ext/rubysl/openssl/ossl_cipher.c +270 -195
- data/ext/rubysl/openssl/ossl_config.c +7 -1
- data/ext/rubysl/openssl/ossl_config.h +0 -1
- data/ext/rubysl/openssl/ossl_digest.c +40 -29
- data/ext/rubysl/openssl/ossl_engine.c +23 -62
- data/ext/rubysl/openssl/ossl_hmac.c +82 -55
- data/ext/rubysl/openssl/ossl_ns_spki.c +22 -22
- data/ext/rubysl/openssl/ossl_ocsp.c +894 -144
- data/ext/rubysl/openssl/ossl_ocsp.h +1 -1
- data/ext/rubysl/openssl/ossl_pkcs12.c +47 -19
- data/ext/rubysl/openssl/ossl_pkcs5.c +7 -15
- data/ext/rubysl/openssl/ossl_pkcs7.c +38 -15
- data/ext/rubysl/openssl/ossl_pkey.c +151 -99
- data/ext/rubysl/openssl/ossl_pkey.h +123 -29
- data/ext/rubysl/openssl/ossl_pkey_dh.c +143 -92
- data/ext/rubysl/openssl/ossl_pkey_dsa.c +149 -104
- data/ext/rubysl/openssl/ossl_pkey_ec.c +646 -524
- data/ext/rubysl/openssl/ossl_pkey_rsa.c +180 -121
- data/ext/rubysl/openssl/ossl_rand.c +25 -21
- data/ext/rubysl/openssl/ossl_ssl.c +795 -413
- data/ext/rubysl/openssl/ossl_ssl.h +3 -0
- data/ext/rubysl/openssl/ossl_ssl_session.c +83 -77
- data/ext/rubysl/openssl/ossl_version.h +1 -1
- data/ext/rubysl/openssl/ossl_x509.c +92 -8
- data/ext/rubysl/openssl/ossl_x509.h +14 -5
- data/ext/rubysl/openssl/ossl_x509attr.c +77 -41
- data/ext/rubysl/openssl/ossl_x509cert.c +45 -46
- data/ext/rubysl/openssl/ossl_x509crl.c +51 -57
- data/ext/rubysl/openssl/ossl_x509ext.c +39 -33
- data/ext/rubysl/openssl/ossl_x509name.c +68 -45
- data/ext/rubysl/openssl/ossl_x509req.c +32 -38
- data/ext/rubysl/openssl/ossl_x509revoked.c +43 -9
- data/ext/rubysl/openssl/ossl_x509store.c +309 -104
- data/ext/rubysl/openssl/ruby_missing.h +8 -6
- data/lib/openssl/buffering.rb +11 -5
- data/lib/openssl/cipher.rb +23 -15
- data/lib/openssl/digest.rb +7 -10
- data/lib/openssl/pkey.rb +15 -8
- data/lib/openssl/ssl.rb +81 -105
- data/lib/rubysl/openssl.rb +1 -4
- data/lib/rubysl/openssl/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c8e134279ec9b3fb382410f085056f03b7452528e35e767659db710fd831e9e0
|
4
|
+
data.tar.gz: f49ad76beb97edc9466f440b7a51a34da5b3a38cbe4c240b4ec67b29aeeced3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00272e14585bb278bcc37c42c1de138fbb4f1075329cd831b64c9749c0b39f89b93fafb0940369fd2238649a3bade8dc604ace72684e541bb41ac442c64f21a2
|
7
|
+
data.tar.gz: '089dd3bf4adfa74f51a6566e3c55d8c24bbc7dd64f4e0bb6e9443d6e497743af84a5a7847618d83c2495fc022cedc9347649675a0c1371462598cfe354af7ae6'
|
@@ -3,7 +3,7 @@ module OpenSSL
|
|
3
3
|
def self.deprecated_warning_flag
|
4
4
|
unless flag = (@deprecated_warning_flag ||= nil)
|
5
5
|
if try_compile("", flag = "-Werror=deprecated-declarations")
|
6
|
-
if with_config("broken-apple-openssl")
|
6
|
+
if /darwin/ =~ RUBY_PLATFORM and with_config("broken-apple-openssl")
|
7
7
|
flag = "-Wno-deprecated-declarations"
|
8
8
|
end
|
9
9
|
$warnflags << " #{flag}"
|
@@ -16,7 +16,11 @@ module OpenSSL
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.check_func(func, header)
|
19
|
-
have_func(func, header, deprecated_warning_flag)
|
20
|
-
|
19
|
+
have_func(func, header, deprecated_warning_flag)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.check_func_or_macro(func, header)
|
23
|
+
check_func(func, header) or
|
24
|
+
have_macro(func, header) && $defs.push("-DHAVE_#{func.upcase}")
|
21
25
|
end
|
22
26
|
end
|
@@ -19,144 +19,189 @@ dir_config("kerberos")
|
|
19
19
|
|
20
20
|
Logging::message "=== OpenSSL for Ruby configurator ===\n"
|
21
21
|
|
22
|
+
# Add -Werror=deprecated-declarations to $warnflags if available
|
23
|
+
OpenSSL.deprecated_warning_flag
|
24
|
+
|
22
25
|
##
|
23
26
|
# Adds -DOSSL_DEBUG for compilation and some more targets when GCC is used
|
24
27
|
# To turn it on, use: --with-debug or --enable-debug
|
25
28
|
#
|
26
29
|
if with_config("debug") or enable_config("debug")
|
27
|
-
$defs.push("-DOSSL_DEBUG")
|
30
|
+
$defs.push("-DOSSL_DEBUG")
|
28
31
|
end
|
29
32
|
|
30
33
|
Logging::message "=== Checking for system dependent stuff... ===\n"
|
31
34
|
have_library("nsl", "t_open")
|
32
35
|
have_library("socket", "socket")
|
33
|
-
|
34
|
-
|
35
|
-
Logging::message "=== Checking for required stuff... ===\n"
|
36
|
-
if $mingw
|
37
|
-
have_library("wsock32")
|
38
|
-
have_library("gdi32")
|
36
|
+
if $mswin || $mingw
|
37
|
+
have_library("ws2_32")
|
39
38
|
end
|
40
39
|
|
40
|
+
Logging::message "=== Checking for required stuff... ===\n"
|
41
41
|
result = pkg_config("openssl") && have_header("openssl/ssl.h")
|
42
42
|
|
43
|
+
def find_openssl_library
|
44
|
+
if $mswin || $mingw
|
45
|
+
# required for static OpenSSL libraries
|
46
|
+
have_library("gdi32") # OpenSSL <= 1.0.2 (for RAND_screen())
|
47
|
+
have_library("crypt32")
|
48
|
+
end
|
49
|
+
|
50
|
+
return false unless have_header("openssl/ssl.h")
|
51
|
+
|
52
|
+
ret = have_library("crypto", "CRYPTO_malloc") &&
|
53
|
+
have_library("ssl", "SSL_new")
|
54
|
+
return ret if ret
|
55
|
+
|
56
|
+
if $mswin
|
57
|
+
# OpenSSL >= 1.1.0: libcrypto.lib and libssl.lib.
|
58
|
+
if have_library("libcrypto", "CRYPTO_malloc") &&
|
59
|
+
have_library("libssl", "SSL_new")
|
60
|
+
return true
|
61
|
+
end
|
62
|
+
|
63
|
+
# OpenSSL <= 1.0.2: libeay32.lib and ssleay32.lib.
|
64
|
+
if have_library("libeay32", "CRYPTO_malloc") &&
|
65
|
+
have_library("ssleay32", "SSL_new")
|
66
|
+
return true
|
67
|
+
end
|
68
|
+
|
69
|
+
# LibreSSL: libcrypto-##.lib and libssl-##.lib, where ## is the ABI version
|
70
|
+
# number. We have to find the version number out by scanning libpath.
|
71
|
+
libpath = $LIBPATH.dup
|
72
|
+
libpath |= ENV["LIB"].split(File::PATH_SEPARATOR)
|
73
|
+
libpath.map! { |d| d.tr(File::ALT_SEPARATOR, File::SEPARATOR) }
|
74
|
+
|
75
|
+
ret = [
|
76
|
+
["crypto", "CRYPTO_malloc"],
|
77
|
+
["ssl", "SSL_new"]
|
78
|
+
].all? do |base, func|
|
79
|
+
result = false
|
80
|
+
libs = ["lib#{base}-[0-9][0-9]", "lib#{base}-[0-9][0-9][0-9]"]
|
81
|
+
libs = Dir.glob(libs.map{|l| libpath.map{|d| File.join(d, l + ".*")}}.flatten).map{|path| File.basename(path, ".*")}.uniq
|
82
|
+
libs.each do |lib|
|
83
|
+
result = have_library(lib, func)
|
84
|
+
break if result
|
85
|
+
end
|
86
|
+
result
|
87
|
+
end
|
88
|
+
return ret if ret
|
89
|
+
end
|
90
|
+
return false
|
91
|
+
end
|
92
|
+
|
43
93
|
unless result
|
44
|
-
|
45
|
-
result &&= %w[crypto libeay32].any? {|lib| have_library(lib, "OpenSSL_add_all_digests")}
|
46
|
-
result &&= %w[ssl ssleay32].any? {|lib| have_library(lib, "SSL_library_init")}
|
47
|
-
unless result
|
94
|
+
unless find_openssl_library
|
48
95
|
Logging::message "=== Checking for required stuff failed. ===\n"
|
49
96
|
Logging::message "Makefile wasn't created. Fix the errors above.\n"
|
50
97
|
exit 1
|
51
98
|
end
|
52
99
|
end
|
53
100
|
|
54
|
-
|
55
|
-
|
101
|
+
result = checking_for("OpenSSL version is 0.9.8 or later") {
|
102
|
+
try_static_assert("OPENSSL_VERSION_NUMBER >= 0x00908000L", "openssl/opensslv.h")
|
103
|
+
}
|
104
|
+
unless result
|
105
|
+
raise "OpenSSL 0.9.8 or later required."
|
56
106
|
end
|
57
|
-
|
107
|
+
|
108
|
+
if /darwin/ =~ RUBY_PLATFORM and !OpenSSL.check_func("SSL_library_init()", "openssl/ssl.h")
|
58
109
|
Logging::message "You may be using a version of OpenSSL or SSL provided by Apple.\nIf you encounter issues, please use another SSL library. (e.g. using `configure --with-openssl-dir=/path/to/openssl')"
|
59
110
|
end
|
60
111
|
|
61
112
|
Logging::message "=== Checking for OpenSSL features... ===\n"
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
have_func("BN_mod_sub")
|
67
|
-
have_func("BN_pseudo_rand_range")
|
68
|
-
have_func("BN_rand_range")
|
69
|
-
have_func("CONF_get1_default_config_file")
|
70
|
-
have_func("EVP_CIPHER_CTX_copy")
|
71
|
-
have_func("EVP_CIPHER_CTX_set_padding")
|
72
|
-
have_func("EVP_CipherFinal_ex")
|
73
|
-
have_func("EVP_CipherInit_ex")
|
74
|
-
have_func("EVP_DigestFinal_ex")
|
75
|
-
have_func("EVP_DigestInit_ex")
|
76
|
-
have_func("EVP_MD_CTX_cleanup")
|
77
|
-
have_func("EVP_MD_CTX_create")
|
78
|
-
have_func("EVP_MD_CTX_destroy")
|
79
|
-
have_func("EVP_MD_CTX_init")
|
80
|
-
have_func("HMAC_CTX_cleanup")
|
81
|
-
have_func("HMAC_CTX_copy")
|
82
|
-
have_func("HMAC_CTX_init")
|
83
|
-
have_func("PEM_def_callback")
|
84
|
-
have_func("PKCS5_PBKDF2_HMAC")
|
85
|
-
have_func("PKCS5_PBKDF2_HMAC_SHA1")
|
86
|
-
have_func("RAND_egd")
|
87
|
-
have_func("X509V3_set_nconf")
|
88
|
-
have_func("X509V3_EXT_nconf_nid")
|
89
|
-
have_func("X509_CRL_add0_revoked")
|
90
|
-
have_func("X509_CRL_set_issuer_name")
|
91
|
-
have_func("X509_CRL_set_version")
|
92
|
-
have_func("X509_CRL_sort")
|
93
|
-
have_func("X509_NAME_hash_old")
|
94
|
-
have_func("X509_STORE_get_ex_data")
|
95
|
-
have_func("X509_STORE_set_ex_data")
|
96
|
-
have_func("OBJ_NAME_do_all_sorted")
|
97
|
-
have_func("SSL_SESSION_get_id")
|
98
|
-
have_func("SSL_SESSION_cmp")
|
99
|
-
have_func("OPENSSL_cleanse")
|
113
|
+
# compile options
|
114
|
+
|
115
|
+
# SSLv2 and SSLv3 may be removed in future versions of OpenSSL, and even macros
|
116
|
+
# like OPENSSL_NO_SSL2 may not be defined.
|
100
117
|
have_func("SSLv2_method")
|
101
|
-
have_func("SSLv2_server_method")
|
102
|
-
have_func("SSLv2_client_method")
|
103
118
|
have_func("SSLv3_method")
|
104
|
-
have_func("SSLv3_server_method")
|
105
|
-
have_func("SSLv3_client_method")
|
106
119
|
have_func("TLSv1_1_method")
|
107
|
-
have_func("TLSv1_1_server_method")
|
108
|
-
have_func("TLSv1_1_client_method")
|
109
120
|
have_func("TLSv1_2_method")
|
110
|
-
have_func("
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
have_func("ENGINE_add")
|
120
|
-
have_func("ENGINE_load_builtin_engines")
|
121
|
-
have_func("ENGINE_load_openbsd_dev_crypto")
|
122
|
-
have_func("ENGINE_get_digest")
|
123
|
-
have_func("ENGINE_get_cipher")
|
124
|
-
have_func("ENGINE_cleanup")
|
125
|
-
have_func("ENGINE_load_dynamic")
|
126
|
-
have_func("ENGINE_load_4758cca")
|
127
|
-
have_func("ENGINE_load_aep")
|
128
|
-
have_func("ENGINE_load_atalla")
|
129
|
-
have_func("ENGINE_load_chil")
|
130
|
-
have_func("ENGINE_load_cswift")
|
131
|
-
have_func("ENGINE_load_nuron")
|
132
|
-
have_func("ENGINE_load_sureware")
|
133
|
-
have_func("ENGINE_load_ubsec")
|
134
|
-
have_func("ENGINE_load_padlock")
|
135
|
-
have_func("ENGINE_load_capi")
|
136
|
-
have_func("ENGINE_load_gmp")
|
137
|
-
have_func("ENGINE_load_gost")
|
138
|
-
have_func("ENGINE_load_cryptodev")
|
139
|
-
have_func("ENGINE_load_aesni")
|
140
|
-
end
|
141
|
-
have_func("DH_generate_parameters_ex")
|
142
|
-
have_func("DSA_generate_parameters_ex")
|
143
|
-
have_func("RSA_generate_key_ex")
|
144
|
-
if checking_for('OpenSSL version is 0.9.7 or later') {
|
145
|
-
try_static_assert('OPENSSL_VERSION_NUMBER >= 0x00907000L', 'openssl/opensslv.h')
|
146
|
-
}
|
147
|
-
have_header("openssl/ocsp.h")
|
121
|
+
have_func("RAND_egd")
|
122
|
+
engines = %w{builtin_engines openbsd_dev_crypto dynamic 4758cca aep atalla chil
|
123
|
+
cswift nuron sureware ubsec padlock capi gmp gost cryptodev aesni}
|
124
|
+
engines.each { |name|
|
125
|
+
OpenSSL.check_func_or_macro("ENGINE_load_#{name}", "openssl/engine.h")
|
126
|
+
}
|
127
|
+
|
128
|
+
if ($mswin || $mingw) && have_macro("LIBRESSL_VERSION_NUMBER", "openssl/opensslv.h")
|
129
|
+
$defs.push("-DNOCRYPT")
|
148
130
|
end
|
131
|
+
|
132
|
+
# added in 0.9.8X
|
133
|
+
have_func("EVP_CIPHER_CTX_new")
|
134
|
+
have_func("EVP_CIPHER_CTX_free")
|
135
|
+
OpenSSL.check_func_or_macro("SSL_CTX_clear_options", "openssl/ssl.h")
|
136
|
+
|
137
|
+
# added in 1.0.0
|
138
|
+
have_func("ASN1_TIME_adj")
|
139
|
+
have_func("EVP_CIPHER_CTX_copy")
|
140
|
+
have_func("EVP_PKEY_base_id")
|
141
|
+
have_func("HMAC_CTX_copy")
|
142
|
+
have_func("PKCS5_PBKDF2_HMAC")
|
143
|
+
have_func("X509_NAME_hash_old")
|
144
|
+
have_func("X509_STORE_CTX_get0_current_crl")
|
145
|
+
have_func("X509_STORE_set_verify_cb")
|
146
|
+
have_func("i2d_ASN1_SET_ANY")
|
147
|
+
have_func("SSL_SESSION_cmp") # removed
|
148
|
+
OpenSSL.check_func_or_macro("SSL_set_tlsext_host_name", "openssl/ssl.h")
|
149
149
|
have_struct_member("CRYPTO_THREADID", "ptr", "openssl/crypto.h")
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
150
|
+
have_func("EVP_PKEY_get0")
|
151
|
+
|
152
|
+
# added in 1.0.1
|
153
|
+
have_func("SSL_CTX_set_next_proto_select_cb")
|
154
154
|
have_macro("EVP_CTRL_GCM_GET_TAG", ['openssl/evp.h']) && $defs.push("-DHAVE_AUTHENTICATED_ENCRYPTION")
|
155
155
|
|
156
|
+
# added in 1.0.2
|
157
|
+
have_func("EC_curve_nist2nid")
|
158
|
+
have_func("X509_REVOKED_dup")
|
159
|
+
have_func("X509_STORE_CTX_get0_store")
|
160
|
+
have_func("SSL_CTX_set_alpn_select_cb")
|
161
|
+
OpenSSL.check_func_or_macro("SSL_CTX_set1_curves_list", "openssl/ssl.h")
|
162
|
+
OpenSSL.check_func_or_macro("SSL_CTX_set_ecdh_auto", "openssl/ssl.h")
|
163
|
+
OpenSSL.check_func_or_macro("SSL_get_server_tmp_key", "openssl/ssl.h")
|
164
|
+
have_func("SSL_is_server")
|
165
|
+
|
166
|
+
# added in 1.1.0
|
167
|
+
if !have_struct_member("SSL", "ctx", "openssl/ssl.h") ||
|
168
|
+
try_static_assert("LIBRESSL_VERSION_NUMBER >= 0x2070000fL", "openssl/opensslv.h")
|
169
|
+
$defs.push("-DHAVE_OPAQUE_OPENSSL")
|
170
|
+
end
|
171
|
+
have_func("CRYPTO_lock") || $defs.push("-DHAVE_OPENSSL_110_THREADING_API")
|
172
|
+
have_func("BN_GENCB_new")
|
173
|
+
have_func("BN_GENCB_free")
|
174
|
+
have_func("BN_GENCB_get_arg")
|
175
|
+
have_func("EVP_MD_CTX_new")
|
176
|
+
have_func("EVP_MD_CTX_free")
|
177
|
+
have_func("HMAC_CTX_new")
|
178
|
+
have_func("HMAC_CTX_free")
|
179
|
+
OpenSSL.check_func("RAND_pseudo_bytes", "openssl/rand.h") # deprecated
|
180
|
+
have_func("X509_STORE_get_ex_data")
|
181
|
+
have_func("X509_STORE_set_ex_data")
|
182
|
+
have_func("X509_CRL_get0_signature")
|
183
|
+
have_func("X509_REQ_get0_signature")
|
184
|
+
have_func("X509_REVOKED_get0_serialNumber")
|
185
|
+
have_func("X509_REVOKED_get0_revocationDate")
|
186
|
+
have_func("X509_get0_tbs_sigalg")
|
187
|
+
have_func("X509_STORE_CTX_get0_untrusted")
|
188
|
+
have_func("X509_STORE_CTX_get0_cert")
|
189
|
+
have_func("X509_STORE_CTX_get0_chain")
|
190
|
+
have_func("OCSP_SINGLERESP_get0_id")
|
191
|
+
have_func("SSL_CTX_get_ciphers")
|
192
|
+
have_func("X509_up_ref")
|
193
|
+
have_func("X509_CRL_up_ref")
|
194
|
+
have_func("X509_STORE_up_ref")
|
195
|
+
have_func("SSL_SESSION_up_ref")
|
196
|
+
have_func("EVP_PKEY_up_ref")
|
197
|
+
OpenSSL.check_func_or_macro("SSL_CTX_set_tmp_ecdh_callback", "openssl/ssl.h") # removed
|
198
|
+
OpenSSL.check_func_or_macro("SSL_CTX_set_min_proto_version", "openssl/ssl.h")
|
199
|
+
have_func("SSL_CTX_get_security_level")
|
200
|
+
have_func("X509_get0_notBefore")
|
201
|
+
have_func("SSL_SESSION_get_protocol_version")
|
202
|
+
|
156
203
|
Logging::message "=== Checking done. ===\n"
|
157
204
|
|
158
205
|
create_header
|
159
|
-
create_makefile("openssl/openssl")
|
160
|
-
conf << "THREAD_MODEL = #{CONFIG["THREAD_MODEL"]}\n"
|
161
|
-
}
|
206
|
+
create_makefile("openssl/openssl")
|
162
207
|
Logging::message "Done.\n"
|
@@ -9,107 +9,42 @@
|
|
9
9
|
*/
|
10
10
|
#include RUBY_EXTCONF_H
|
11
11
|
|
12
|
-
#
|
12
|
+
#include <string.h> /* memcpy() */
|
13
|
+
#if !defined(OPENSSL_NO_ENGINE)
|
13
14
|
# include <openssl/engine.h>
|
14
15
|
#endif
|
15
|
-
#include <openssl/x509_vfy.h>
|
16
|
-
|
17
16
|
#if !defined(OPENSSL_NO_HMAC)
|
18
|
-
#include <
|
19
|
-
#include <openssl/hmac.h>
|
20
|
-
|
21
|
-
#include "openssl_missing.h"
|
22
|
-
|
23
|
-
#if !defined(HAVE_HMAC_CTX_COPY)
|
24
|
-
void
|
25
|
-
HMAC_CTX_copy(HMAC_CTX *out, HMAC_CTX *in)
|
26
|
-
{
|
27
|
-
if (!out || !in) return;
|
28
|
-
memcpy(out, in, sizeof(HMAC_CTX));
|
29
|
-
|
30
|
-
EVP_MD_CTX_copy(&out->md_ctx, &in->md_ctx);
|
31
|
-
EVP_MD_CTX_copy(&out->i_ctx, &in->i_ctx);
|
32
|
-
EVP_MD_CTX_copy(&out->o_ctx, &in->o_ctx);
|
33
|
-
}
|
34
|
-
#endif /* HAVE_HMAC_CTX_COPY */
|
35
|
-
#endif /* NO_HMAC */
|
36
|
-
|
37
|
-
#if !defined(HAVE_X509_STORE_SET_EX_DATA)
|
38
|
-
int X509_STORE_set_ex_data(X509_STORE *str, int idx, void *data)
|
39
|
-
{
|
40
|
-
return CRYPTO_set_ex_data(&str->ex_data, idx, data);
|
41
|
-
}
|
17
|
+
# include <openssl/hmac.h>
|
42
18
|
#endif
|
19
|
+
#include <openssl/x509_vfy.h>
|
43
20
|
|
44
|
-
#
|
45
|
-
void *X509_STORE_get_ex_data(X509_STORE *str, int idx)
|
46
|
-
{
|
47
|
-
return CRYPTO_get_ex_data(&str->ex_data, idx);
|
48
|
-
}
|
49
|
-
#endif
|
21
|
+
#include "openssl_missing.h"
|
50
22
|
|
51
|
-
|
52
|
-
|
53
|
-
|
23
|
+
/* added in 0.9.8X */
|
24
|
+
#if !defined(HAVE_EVP_CIPHER_CTX_NEW)
|
25
|
+
EVP_CIPHER_CTX *
|
26
|
+
ossl_EVP_CIPHER_CTX_new(void)
|
54
27
|
{
|
55
|
-
|
56
|
-
if (!ctx)
|
57
|
-
|
58
|
-
|
59
|
-
|
28
|
+
EVP_CIPHER_CTX *ctx = OPENSSL_malloc(sizeof(EVP_CIPHER_CTX));
|
29
|
+
if (!ctx)
|
30
|
+
return NULL;
|
31
|
+
EVP_CIPHER_CTX_init(ctx);
|
60
32
|
return ctx;
|
61
33
|
}
|
62
34
|
#endif
|
63
35
|
|
64
|
-
#if !defined(
|
65
|
-
int
|
66
|
-
EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx)
|
67
|
-
{
|
68
|
-
/* FIXME!!! */
|
69
|
-
memset(ctx, 0, sizeof(EVP_MD_CTX));
|
70
|
-
|
71
|
-
return 1;
|
72
|
-
}
|
73
|
-
#endif
|
74
|
-
|
75
|
-
#if !defined(HAVE_EVP_MD_CTX_DESTROY)
|
76
|
-
void
|
77
|
-
EVP_MD_CTX_destroy(EVP_MD_CTX *ctx)
|
78
|
-
{
|
79
|
-
EVP_MD_CTX_cleanup(ctx);
|
80
|
-
OPENSSL_free(ctx);
|
81
|
-
}
|
82
|
-
#endif
|
83
|
-
|
84
|
-
#if !defined(HAVE_EVP_MD_CTX_INIT)
|
85
|
-
void
|
86
|
-
EVP_MD_CTX_init(EVP_MD_CTX *ctx)
|
87
|
-
{
|
88
|
-
memset(ctx, 0, sizeof(EVP_MD_CTX));
|
89
|
-
}
|
90
|
-
#endif
|
91
|
-
|
92
|
-
#if !defined(HAVE_HMAC_CTX_INIT)
|
36
|
+
#if !defined(HAVE_EVP_CIPHER_CTX_FREE)
|
93
37
|
void
|
94
|
-
|
38
|
+
ossl_EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx)
|
95
39
|
{
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
}
|
100
|
-
#endif
|
101
|
-
|
102
|
-
#if !defined(HAVE_HMAC_CTX_CLEANUP)
|
103
|
-
void
|
104
|
-
HMAC_CTX_cleanup(HMAC_CTX *ctx)
|
105
|
-
{
|
106
|
-
EVP_MD_CTX_cleanup(&ctx->i_ctx);
|
107
|
-
EVP_MD_CTX_cleanup(&ctx->o_ctx);
|
108
|
-
EVP_MD_CTX_cleanup(&ctx->md_ctx);
|
109
|
-
memset(ctx, 0, sizeof(HMAC_CTX));
|
40
|
+
if (ctx) {
|
41
|
+
EVP_CIPHER_CTX_cleanup(ctx);
|
42
|
+
OPENSSL_free(ctx);
|
43
|
+
}
|
110
44
|
}
|
111
45
|
#endif
|
112
46
|
|
47
|
+
/* added in 1.0.0 */
|
113
48
|
#if !defined(HAVE_EVP_CIPHER_CTX_COPY)
|
114
49
|
/*
|
115
50
|
* this function does not exist in OpenSSL yet... or ever?.
|
@@ -117,11 +52,11 @@ HMAC_CTX_cleanup(HMAC_CTX *ctx)
|
|
117
52
|
* tested on 0.9.7d.
|
118
53
|
*/
|
119
54
|
int
|
120
|
-
|
55
|
+
ossl_EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in)
|
121
56
|
{
|
122
57
|
memcpy(out, in, sizeof(EVP_CIPHER_CTX));
|
123
58
|
|
124
|
-
#if defined(
|
59
|
+
#if !defined(OPENSSL_NO_ENGINE)
|
125
60
|
if (in->engine) ENGINE_add(out->engine);
|
126
61
|
if (in->cipher_data) {
|
127
62
|
out->cipher_data = OPENSSL_malloc(in->cipher->ctx_size);
|
@@ -133,222 +68,106 @@ EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, EVP_CIPHER_CTX *in)
|
|
133
68
|
}
|
134
69
|
#endif
|
135
70
|
|
136
|
-
#if !defined(
|
137
|
-
|
138
|
-
X509_CRL_set_version(X509_CRL *x, long version)
|
139
|
-
{
|
140
|
-
if (x == NULL || x->crl == NULL) return 0;
|
141
|
-
if (x->crl->version == NULL) {
|
142
|
-
x->crl->version = M_ASN1_INTEGER_new();
|
143
|
-
if (x->crl->version == NULL) return 0;
|
144
|
-
}
|
145
|
-
return ASN1_INTEGER_set(x->crl->version, version);
|
146
|
-
}
|
147
|
-
#endif
|
148
|
-
|
149
|
-
#if !defined(HAVE_X509_CRL_SET_ISSUER_NAME)
|
150
|
-
int
|
151
|
-
X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name)
|
152
|
-
{
|
153
|
-
if (x == NULL || x->crl == NULL) return 0;
|
154
|
-
return X509_NAME_set(&x->crl->issuer, name);
|
155
|
-
}
|
156
|
-
#endif
|
157
|
-
|
158
|
-
#if !defined(HAVE_X509_CRL_SORT)
|
71
|
+
#if !defined(OPENSSL_NO_HMAC)
|
72
|
+
#if !defined(HAVE_HMAC_CTX_COPY)
|
159
73
|
int
|
160
|
-
|
74
|
+
ossl_HMAC_CTX_copy(HMAC_CTX *out, HMAC_CTX *in)
|
161
75
|
{
|
162
|
-
|
163
|
-
|
164
|
-
/* sort the data so it will be written in serial
|
165
|
-
* number order */
|
166
|
-
sk_X509_REVOKED_sort(c->crl->revoked);
|
167
|
-
for (i=0; i<sk_X509_REVOKED_num(c->crl->revoked); i++) {
|
168
|
-
r=sk_X509_REVOKED_value(c->crl->revoked, i);
|
169
|
-
r->sequence=i;
|
170
|
-
}
|
171
|
-
return 1;
|
172
|
-
}
|
173
|
-
#endif
|
76
|
+
if (!out || !in)
|
77
|
+
return 0;
|
174
78
|
|
175
|
-
|
176
|
-
static int
|
177
|
-
OSSL_X509_REVOKED_cmp(const X509_REVOKED * const *a, const X509_REVOKED * const *b)
|
178
|
-
{
|
179
|
-
return(ASN1_STRING_cmp(
|
180
|
-
(ASN1_STRING *)(*a)->serialNumber,
|
181
|
-
(ASN1_STRING *)(*b)->serialNumber));
|
182
|
-
}
|
79
|
+
memcpy(out, in, sizeof(HMAC_CTX));
|
183
80
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
X509_CRL_INFO *inf;
|
81
|
+
EVP_MD_CTX_copy(&out->md_ctx, &in->md_ctx);
|
82
|
+
EVP_MD_CTX_copy(&out->i_ctx, &in->i_ctx);
|
83
|
+
EVP_MD_CTX_copy(&out->o_ctx, &in->o_ctx);
|
188
84
|
|
189
|
-
inf = crl->crl;
|
190
|
-
if (!inf->revoked)
|
191
|
-
inf->revoked = sk_X509_REVOKED_new(OSSL_X509_REVOKED_cmp);
|
192
|
-
if (!inf->revoked || !sk_X509_REVOKED_push(inf->revoked, rev))
|
193
|
-
return 0;
|
194
85
|
return 1;
|
195
86
|
}
|
196
|
-
#endif
|
87
|
+
#endif /* HAVE_HMAC_CTX_COPY */
|
88
|
+
#endif /* NO_HMAC */
|
197
89
|
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
{
|
202
|
-
|
203
|
-
|
204
|
-
}
|
205
|
-
|
90
|
+
/* added in 1.0.2 */
|
91
|
+
#if !defined(OPENSSL_NO_EC)
|
92
|
+
#if !defined(HAVE_EC_CURVE_NIST2NID)
|
93
|
+
static struct {
|
94
|
+
const char *name;
|
95
|
+
int nid;
|
96
|
+
} nist_curves[] = {
|
97
|
+
{"B-163", NID_sect163r2},
|
98
|
+
{"B-233", NID_sect233r1},
|
99
|
+
{"B-283", NID_sect283r1},
|
100
|
+
{"B-409", NID_sect409r1},
|
101
|
+
{"B-571", NID_sect571r1},
|
102
|
+
{"K-163", NID_sect163k1},
|
103
|
+
{"K-233", NID_sect233k1},
|
104
|
+
{"K-283", NID_sect283k1},
|
105
|
+
{"K-409", NID_sect409k1},
|
106
|
+
{"K-571", NID_sect571k1},
|
107
|
+
{"P-192", NID_X9_62_prime192v1},
|
108
|
+
{"P-224", NID_secp224r1},
|
109
|
+
{"P-256", NID_X9_62_prime256v1},
|
110
|
+
{"P-384", NID_secp384r1},
|
111
|
+
{"P-521", NID_secp521r1}
|
112
|
+
};
|
206
113
|
|
207
|
-
#if !defined(HAVE_BN_MOD_ADD) || !defined(HAVE_BN_MOD_SUB)
|
208
|
-
int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx)
|
209
|
-
{
|
210
|
-
if (!BN_mod(r,m,d,ctx)) return 0;
|
211
|
-
if (!r->neg) return 1;
|
212
|
-
return (d->neg ? BN_sub : BN_add)(r, r, d);
|
213
|
-
}
|
214
|
-
#endif
|
215
|
-
|
216
|
-
#if !defined(HAVE_BN_MOD_ADD)
|
217
114
|
int
|
218
|
-
|
115
|
+
ossl_EC_curve_nist2nid(const char *name)
|
219
116
|
{
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
#if !defined(HAVE_BN_MOD_SUB)
|
226
|
-
int
|
227
|
-
BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx)
|
228
|
-
{
|
229
|
-
if (!BN_sub(r, a, b)) return 0;
|
230
|
-
return BN_nnmod(r, r, m, ctx);
|
231
|
-
}
|
232
|
-
#endif
|
233
|
-
|
234
|
-
#if !defined(HAVE_BN_RAND_RANGE) || !defined(HAVE_BN_PSEUDO_RAND_RANGE)
|
235
|
-
static int
|
236
|
-
bn_rand_range(int pseudo, BIGNUM *r, BIGNUM *range)
|
237
|
-
{
|
238
|
-
int (*bn_rand)(BIGNUM *, int, int, int) = pseudo ? BN_pseudo_rand : BN_rand;
|
239
|
-
int n;
|
240
|
-
|
241
|
-
if (range->neg || BN_is_zero(range)) return 0;
|
242
|
-
|
243
|
-
n = BN_num_bits(range);
|
244
|
-
|
245
|
-
if (n == 1) {
|
246
|
-
if (!BN_zero(r)) return 0;
|
247
|
-
} else if (!BN_is_bit_set(range, n - 2) && !BN_is_bit_set(range, n - 3)) {
|
248
|
-
do {
|
249
|
-
if (!bn_rand(r, n + 1, -1, 0)) return 0;
|
250
|
-
if (BN_cmp(r ,range) >= 0) {
|
251
|
-
if (!BN_sub(r, r, range)) return 0;
|
252
|
-
if (BN_cmp(r, range) >= 0)
|
253
|
-
if (!BN_sub(r, r, range)) return 0;
|
254
|
-
}
|
255
|
-
} while (BN_cmp(r, range) >= 0);
|
256
|
-
} else {
|
257
|
-
do {
|
258
|
-
if (!bn_rand(r, n, -1, 0)) return 0;
|
259
|
-
} while (BN_cmp(r, range) >= 0);
|
117
|
+
size_t i;
|
118
|
+
for (i = 0; i < (sizeof(nist_curves) / sizeof(nist_curves[0])); i++) {
|
119
|
+
if (!strcmp(nist_curves[i].name, name))
|
120
|
+
return nist_curves[i].nid;
|
260
121
|
}
|
261
|
-
|
262
|
-
return 1;
|
122
|
+
return NID_undef;
|
263
123
|
}
|
264
124
|
#endif
|
265
|
-
|
266
|
-
#if !defined(HAVE_BN_RAND_RANGE)
|
267
|
-
int
|
268
|
-
BN_rand_range(BIGNUM *r, BIGNUM *range)
|
269
|
-
{
|
270
|
-
return bn_rand_range(0, r, range);
|
271
|
-
}
|
272
125
|
#endif
|
273
126
|
|
274
|
-
|
275
|
-
|
276
|
-
|
127
|
+
/*** added in 1.1.0 ***/
|
128
|
+
#if !defined(HAVE_HMAC_CTX_NEW)
|
129
|
+
HMAC_CTX *
|
130
|
+
ossl_HMAC_CTX_new(void)
|
277
131
|
{
|
278
|
-
|
132
|
+
HMAC_CTX *ctx = OPENSSL_malloc(sizeof(HMAC_CTX));
|
133
|
+
if (!ctx)
|
134
|
+
return NULL;
|
135
|
+
HMAC_CTX_init(ctx);
|
136
|
+
return ctx;
|
279
137
|
}
|
280
138
|
#endif
|
281
139
|
|
282
|
-
#if !defined(
|
283
|
-
|
284
|
-
|
285
|
-
CONF_get1_default_config_file(void)
|
140
|
+
#if !defined(HAVE_HMAC_CTX_FREE)
|
141
|
+
void
|
142
|
+
ossl_HMAC_CTX_free(HMAC_CTX *ctx)
|
286
143
|
{
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
if (file) return BUF_strdup(file);
|
292
|
-
len = strlen(X509_get_default_cert_area());
|
293
|
-
#ifndef OPENSSL_SYS_VMS
|
294
|
-
len++;
|
295
|
-
#endif
|
296
|
-
len += strlen(OPENSSL_CONF);
|
297
|
-
file = OPENSSL_malloc(len + 1);
|
298
|
-
if (!file) return NULL;
|
299
|
-
strcpy(file,X509_get_default_cert_area());
|
300
|
-
#ifndef OPENSSL_SYS_VMS
|
301
|
-
strcat(file,"/");
|
302
|
-
#endif
|
303
|
-
strcat(file,OPENSSL_CONF);
|
304
|
-
|
305
|
-
return file;
|
144
|
+
if (ctx) {
|
145
|
+
HMAC_CTX_cleanup(ctx);
|
146
|
+
OPENSSL_free(ctx);
|
147
|
+
}
|
306
148
|
}
|
307
149
|
#endif
|
308
150
|
|
309
|
-
#if !defined(
|
310
|
-
|
311
|
-
|
312
|
-
|
151
|
+
#if !defined(HAVE_X509_CRL_GET0_SIGNATURE)
|
152
|
+
void
|
153
|
+
ossl_X509_CRL_get0_signature(const X509_CRL *crl, const ASN1_BIT_STRING **psig,
|
154
|
+
const X509_ALGOR **palg)
|
313
155
|
{
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
i = strlen(key);
|
319
|
-
i = (i > num) ? num : i;
|
320
|
-
memcpy(buf, key, i);
|
321
|
-
return i;
|
322
|
-
}
|
323
|
-
|
324
|
-
prompt = EVP_get_pw_prompt();
|
325
|
-
if (prompt == NULL) prompt = "Enter PEM pass phrase:";
|
326
|
-
for (;;) {
|
327
|
-
i = EVP_read_pw_string(buf, num, prompt, w);
|
328
|
-
if (i != 0) {
|
329
|
-
memset(buf, 0, (unsigned int)num);
|
330
|
-
return(-1);
|
331
|
-
}
|
332
|
-
j = strlen(buf);
|
333
|
-
if (j < OSSL_PASS_MIN_LENGTH) {
|
334
|
-
fprintf(stderr,
|
335
|
-
"phrase is too short, needs to be at least %d chars\n",
|
336
|
-
OSSL_PASS_MIN_LENGTH);
|
337
|
-
}
|
338
|
-
else break;
|
339
|
-
}
|
340
|
-
return j;
|
156
|
+
if (psig != NULL)
|
157
|
+
*psig = crl->signature;
|
158
|
+
if (palg != NULL)
|
159
|
+
*palg = crl->sig_alg;
|
341
160
|
}
|
342
161
|
#endif
|
343
162
|
|
344
|
-
#if !defined(
|
345
|
-
|
346
|
-
|
163
|
+
#if !defined(HAVE_X509_REQ_GET0_SIGNATURE)
|
164
|
+
void
|
165
|
+
ossl_X509_REQ_get0_signature(const X509_REQ *req, const ASN1_BIT_STRING **psig,
|
166
|
+
const X509_ALGOR **palg)
|
347
167
|
{
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
return 2;
|
168
|
+
if (psig != NULL)
|
169
|
+
*psig = req->signature;
|
170
|
+
if (palg != NULL)
|
171
|
+
*palg = req->sig_alg;
|
353
172
|
}
|
354
173
|
#endif
|