| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
| |
OpenSSL::ASN1.{decode,decode_all,traverse} have a bug of out-of-bounds
read. int_ossl_asn1_decode0_cons() does not give the correct available
length to ossl_asn1_decode() when decoding the inner components of a
constructed object. This can cause out-of-bounds read if a crafted input
given.
Reference: https://hackerone.com/reports/170316
|
|\
| |
| |
| |
| |
| |
| | |
* ruby-trunk r56173..r56225: (1 commits)
(r56225) fid typos [ci skip]
Sync-with-trunk: r56225
|
| |
| |
| |
| |
| |
| | |
* fix typos, "a" before "Integer" to "an". [Fix GH-1438]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Check existence of the public key in the PKey object before starting
verifying a signature.
For RSA keys, EVP_VerifyFinal() internally calls RSA_size(), which
requires the existence of RSA::n. Since we allow instatiating PKey::RSA
without any key materials, calling PKey#verify against an empty
PKey::RSA causes segfault.
Reference: https://bugs.ruby-lang.org/issues/12783
|
| |
| |
| |
| |
| |
| |
| |
| | |
Remove code relating DO_IT_VIA_RUBY. If DO_IT_VIA_RUBY is set to 1,
OpenSSL::ASN1.decode will decode ASN.1 INTEGER values into a Ruby's
Integer instead of OpenSSL::BN. However it would be too late to change
now. Anyway, if we change out mind, we will rewrite it to avoid
unnecessary conversions between BIGNUM.
|
| |
| |
| |
| |
| | |
Store the Symbols rather than their ID. This simplifies the source code,
and fixes the illegal assignment of ID value to VALUE type variables.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
rb_class_superclass() returns nil when there is no available super class
for the class object. Since the condition of the while statement is
incorrect, we call rb_class_superclass() against nil. This fixes the
segfault occurs with a code:
OpenSSL::ASN1::Primitive.new("abc")
|
|/
|
|
|
| |
The length is not necessary 3. Fixes r55288 (0b1e59f2c11b, "openssl:
avoid d2i_ASN1_BOOLEAN()", 2016-06-05).
|
|\
| |
| |
| |
| |
| |
| |
| |
| | |
* ruby-trunk r56028..r56173: (3 commits)
(r56173) * ext/openssl/ossl_ssl.c (ssl_npn_select_cb_common): Fix co..
(r56147) openssl: workaround for Ubuntu's patched OpenSSL
(r56098) openssl: import v2.0.0.beta.2
Sync-with-trunk: r56173
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
with old version of fcc (Fujitsu C Compiler) on Solaris 10.
[Bug #12769] [ruby-dev:49809]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
| |
| |
| |
| |
| |
| |
| |
| | |
* {ext,test}/openssl: Import Ruby/OpenSSL 2.0.0.beta.2. The full commit
history since v2.0.0.beta.1 can be found at:
https://github.com/ruby/openssl/compare/v2.0.0.beta.1...v2.0.0.beta.2
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
| |
| |
| |
| |
| |
| | |
CLASS_OF() (or, rb_class_of()) may return the singleton class of the
object; so avoid using it and replace with rb_obj_class() that returns
the actual class of the object.
|
| |
| |
| |
| |
| |
| | |
r45944 exported the internal thread_native.h as ruby/thread_native.h.
It does not depend on the thread model specific headers, so the
workaround is no longer necessary.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
As done for EC::Point, remove ossl_ec_group struct. This contains a
breaking change. Modifications to an EC::Group returned by EC#group
no longer affects the EC object unless set to the key explicitly using
EC#group=. This is the common behavior in Ruby/OpenSSL, including other
getter methods of EC such as EC#public_key.
EC#group currently returns a EC::Group linked with the key, i.e. the
EC::Group object holds a reference to an EC_GROUP that the EC_KEY owns.
We use some ugly workaround - the ossl_ec_group struct has a flag
'dont_free' that indicates we must not free the EC_GROUP. But it is
still not possible to control OpenSSL of free'ing the EC_GROUP, so,
for example, the following code behaves strangely:
ec = OpenSSL::PKey::EC.generate("prime256v1")
group = ec.group
p group.curve_name #=> "prime256v1"
ec.group = OpenSSL::PKey::EC::Group.new("prime256v1")
p group.curve_name #=> nil
|
| |
| |
| |
| |
| |
| |
| | |
Currently an OpenSSL::PKey::EC::Point wraps an ossl_ec_point struct
which has a pointer for EC_POINT. This commit make EC::Point wrap an
EC_POINT directly in order to simplify the source code. There should be
no changes on behavior seen from Ruby.
|
| |
| |
| |
| |
| |
| |
| | |
Make ossl_pkey_ec.c follow the general convension on macro names. Prefer
CamelCase to Snake_Case and unify Require_*() and Get_*() macros into
Get*() macros. There is nothing wrong with the style itself but it's
hard to read if two different styles are mixed.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
It's possible that a PKCS #12 strucuture holds zero private keys. At
such a time PKCS12_parse() returns NULL as the private key. Likewise,
when the strucuture does not contain the corresponding certificate to
the private key, PKCS12_parse() returns NULL as the certificate.
Reported and fix suggested by Masahiro Tomita <tommy@tmtm.org>.
[ruby-dev:49776] [Bug #12726]
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Use rb_attr_get() instead of rb_iv_get() so that we can remove
SSLContext::INIT_VARS.
SSLContext::INIT_VARS contains the names of the instance variables used
in SSLContext. SSLContext#initialize sets nil for those variables. It
is necessary to suppress "instance variable @foo not initialized"
warnings emitted by rb_iv_get(). The warnings can be avoided by using
rb_attr_get() that does not check the existence of the variable. So use
it.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Remove '@' prefix from the variable name to hide it from Ruby.
Currently a SSLSocket instance allows modifying the value of
@callback_state if an user use Object#instance_variable_set. This is
dangerous because the variable is used for storing the tag jump state -
modifying it from Ruby can crash the process.
|
| |
| |
| |
| |
| |
| |
| |
| | |
The OpenSSL::PKey::{DH,EC} object is stored in an instance variable to
prevent the object from being GC'd (cf. r51460). However it turned out
to be unnecessary. The underlying object, DH and EC_KEY, have a
reference counter and OpenSSL increments it for the object returned by
the callback functions.
|
| |
| |
| |
| |
| |
| | |
The function can fail on memory allocation error. Note that the
function returns 0 on success unlike other almost all functions in
OpenSSL.
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
They aren't exception safe - they are called during parsing the
Client/Server Hello from OpenSSL code. An exception raised in the
callbacks escapes directly from OpenSSL code so it can break internal
status of OpenSSL.
We have a procedure for handling such exceptions raised during an
handshake: catch them and store the state number in the SSLSocket
object, and then check it in ossl_ssl_start() and re-raise after the
control turned back to our side.
This fixes the instability of
TestSSL::test_alpn_protocol_selection_cancel.
|
|
|
|
| |
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
| |
|
|
|
|
|
| |
This suppresses runtime warning of "instance variable @group not
initialized".
|
|
|
|
|
|
|
| |
The assumption in commit 1b1d520818e0 ("x509ext: fix memory leak in
X509::ExtensionFactory#config=") was wrong. The uninitialized
X509V3_CTX::db can be referred through "r2i" functions when creating
certain types of extension that use them.
|
|
|
|
|
|
|
| |
Remove string2hex() and replace with newly added ossl_bin2hex(). Since
the output hex string is always returned to users as a String, we can
avoid the memory allocation by writing directly to the String buffer.
This also reduces some lines of code.
|
|\
| |
| |
| |
| | |
* topic/cipher-auth-tag-len:
cipher: add Cipher#auth_tag_len=
|
| |
| |
| |
| |
| |
| | |
Add a method to set the authentication tag length to be generate by an
AEAD ciphers. In particular, OCB mode which is implemented in OpenSSL
1.1.0 requires this.
|
| |
| |
| |
| |
| | |
OCSP_{basic,request}_verify() can return a negative value for
verification failure.
|
| |
| |
| |
| |
| |
| | |
The variable names 'flg' and 'flags' are mixed up and it doesn't set
OCSP_NOCERTS flag correctly when the 'certs' argument is not given.
[Bug #12704] [ruby-core:77061]
|
| |
| |
| |
| |
| |
| |
| | |
Fix compiler errors and warnings. The order of parameters of
X509_{CRL,REQ}_get0_signature() has been changed, and certificate and
CRL time accessors have been reorganized: *_get_* functions are
deprecated and replaced by *_get0_* that return a const pointer.
|
| |
| |
| |
| | |
In order to avoid compiler warnings when build with OpenSSL 1.1.0.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Use the same logic as BN#initialize. It is used through GetBNPtr(). For
example, with this change, the following code will be about 7x faster:
puts Benchmark.measure {
a = 0.to_bn
b = 2 ** 2048
i = 0; a + b while (i += 1) <= 1_000_000
}
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The function GetCipherPtr() is used when we want a const EVP_CIPHER that
represents a cipher algorithm. This change allows users to write a code
that exports a PKey encrypted without creating an OpenSSL::Cipher
instance:
pkey = OpenSSL::PKey.read(...)
pkey.export("aes-128-cbc") { password }
This is the same as what happened to GetDigestPtr() in r12128.
|
|\ \
| | |
| | | |
[WIP] Add NEWS and update CONTRIBUTING.md
|
| |\ \ |
|
| | | | |
|
| | | | |
|
| | | | |
|
| | | | |
|
| | | | |
|
| | | | |
|
| | | | |
|
| | | | |
|
|\ \ \ \
| | | | |
| | | | |
| | | | |
| | | | | |
* topic/cipher-doc-aead:
cipher: follow up for the previous documentation update
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Add some explaination about the associated data. Also fix the
description of the AES-GCM example: the IV (nonce) doesn't need to be
unpredictable.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Similar to 0789643d7333 or 9af69abcec15, EVP_VerifyFinal() may put an
error to the error queue when the verification failed.
|