aboutsummaryrefslogtreecommitdiffstats
path: root/ext/openssl/ossl.h
Commit message (Collapse)AuthorAgeFilesLines
* errno.h must be included after config.h because config.h might defineodaira2021-09-261-1/+1
| | | | | | | | | | | | | | _REENTRANT, _THREAD_SAFE, etc., which affect how errno is defined on some architectures [ This is a backport to the 2.1 branch. ] * ext/openssl/ossl.h: include errno.h after ruby.h * include/ruby/io.h: include errno.h after ruby/config.h git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e (cherry picked from commit ruby/ruby@3385395796127878887bce015431b830fed82c4e)
* Fix build failure against OpenSSL 1.1 built with no-deprecatedMark Wright2017-11-041-0/+5
| | | | Thanks rhenium for the code review and fixes.
* Remove unused functions and macrosKazuki Yamaguchi2017-05-221-27/+0
|
* Add ossl_str_new(), an exception-safe rb_str_new()Kazuki Yamaguchi2017-05-221-0/+1
| | | | | | | Add a new function ossl_str_new() as an exception-safe wrapper of rb_str_new(). This is useful for the openssl library because we can't always raise NoMemoryError immediately due to the independent memory management of OpenSSL.
* ossl.h: add NUM2UINT64T() macroKazuki Yamaguchi2017-03-231-0/+13
| | | | | As a wrapper of NUM2ULONG() or NUM2ULL(). Converts a Ruby object to uint64_t, raising an exception if the conversion fails.
* kdf: introduce OpenSSL::KDF moduleKazuki Yamaguchi2017-03-231-1/+1
| | | | | | | | | Introduce a new OpenSSL::KDF module as a namespace for to-be-added KDFs. This makes it easier to add new KDFs in future. We already have a stand-alone KDF, OpenSSL::PKCS5.pbkdf2_hmac. This is migrated to the new namespace. The backwards compatibility is retained by the method defined in the newly added lib/openssl/pkcs5.rb.
* Move verify_callback stuff to ossl_x509store.cKazuki Yamaguchi2016-10-281-8/+0
| | | | | Accordingly, unused functions ossl_x509stctx_new() and ossl_x509stctx_clear_ptr() are now removed.
* Don't include openssl/e_os2.hKazuki Yamaguchi2016-10-281-15/+1
| | | | | It defines the platform specific macros. But it should be included from other OpenSSL headers.
* Don't check for assert.hKazuki Yamaguchi2016-10-281-6/+1
| | | | | The Ruby core code uses assert.h without a guard. So, we can assume it is always available.
* Always include openssl/crypto.hKazuki Yamaguchi2016-10-281-3/+1
| | | | It should be usable regardless of the platform.
* ssl: avoid using ossl_exc_new()Kazuki Yamaguchi2016-10-271-1/+0
| | | | | | | Avoid using ossl_exc_new() and rb_exc_raise() but just use ossl_raise(). This simplifies the code with the exactly same effect. ossl_exc_new() is now removed as it is no longer used anywhere.
* Remove unnecessary #undef RFILEKazuki Yamaguchi2016-10-271-6/+0
| | | | | | The macro RFILE is defined in e_os.h, that is no longer an exported header in OpenSSL >= 0.9.7. Since OpenSSL < 0.9.8 is not supported, we can safely remove this.
* Avoid unnecessary memory allocation in string2hex()Kazuki Yamaguchi2016-08-261-5/+5
| | | | | | | 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.
* asn1: constify functionsKazuki Yamaguchi2016-08-261-3/+3
| | | | In order to avoid compiler warnings when build with OpenSSL 1.1.0.
* Refactor common verify callback codeKazuki Yamaguchi2016-07-101-8/+1
| | | | | | | | | | There is a function ossl_verify_cb() that fetches the custom callback Proc from X509_STORE/X509_STORE_CTX and calls it, but it was not very useful for SSL code. It's only used in ossl_x509store.c and ossl_ssl.c so move X509::Store specific code to ossl_x509store.c. Also make struct ossl_verify_cb_args and ossl_call_verify_cb_proc() local to ossl.c.
* openssl: drop OpenSSL 0.9.6/0.9.7 supportrhe2016-05-311-19/+2
| | | | | | * ext/openssl, test/openssl: Drop OpenSSL < 0.9.8 support. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* openssl: remove unnecessary 'extern "C"' blocks from local headersrhe2016-05-311-8/+0
| | | | | | | | * ext/openssl/openssl_missing.h, ext/openssl/ossl.h: Remove unnecessary 'extern "C"' blocks. We don't use C++ and these headers are local to ext/openssl, so there is no need to enclose with it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* openssl: avoid deprecated M_ASN1_* macrosrhe2016-05-311-1/+1
| | | | | | | | | | | | | | | | * ext/openssl/ossl_x509ext.c (ossl_x509ext_set_value): Use ASN1_OCTET_STRING_set() instead of M_ASN1_OCTET_STRING_set(). Macros prefixed by "M_" are discouraged to be used from outside OpenSSL library[1]. (ossl_x509ext_get_value): Likewise, use ASN1_STRING_print() instead of M_ASN1_OCTET_STRING_print(). [1] https://git.openssl.org/gitweb/?p=openssl.git;a=blob;f=CHANGES;h=bf61913d7b01212b4d8b2f3c13d71d645914f67c;hb=b6079a7835f61daa9fb2cbf9addfa86049523933#l878 * ext/openssl/ossl.h: Include openssl/asn1.h instead of openssl/asn1_mac.h. It just includes openssl/asn1.h and defines some additional "M_" macros. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55145 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* openssl: improve handling of password for encrypted PEMrhe2016-05-311-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * ext/openssl/ossl.c (ossl_pem_passwd_value): Added. Convert the argument to String with StringValue() and validate the length is in 4..PEM_BUFSIZE. PEM_BUFSIZE is a macro defined in OpenSSL headers. (ossl_pem_passwd_cb): When reading/writing encrypted PEM format, we used to pass the password to PEM_def_callback() directly but it was problematic. It is not NUL character safe. And surprisingly, it silently truncates the password to 1024 bytes. [GH ruby/openssl#51] * ext/openssl/ossl.h: Add function prototype declaration of newly added ossl_pem_passwd_value(). * ext/openssl/ossl_pkey.c (ossl_pkey_new_from_data): Use ossl_pem_passwd_value() to validate the password String. * ext/openssl/ossl_pkey_dsa.c (ossl_dsa_initialize, ossl_dsa_export): ditto. * ext/openssl/ossl_pkey_ec.c (ossl_ec_key_initialize, ossl_ec_key_to_string): ditto. * ext/openssl/ossl_pkey_rsa.c (ossl_rsa_initialize, ossl_rsa_export): ditto. * test/openssl/test_pkey_{dsa,ec,rsa}.rb: test this. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* openssl: register ex_data index for X509_STORE{_CTX,} respectivelyrhe2016-05-311-1/+2
| | | | | | | | | | | | | | | | | | | | | | | * ext/openssl/ossl.c (Init_openssl): register an ex_data index for X509_STORE and X509_STORE_CTX respectively. Since they don't share the ex_data index registry, we can't use the same index. (ossl_verify_cb): use the the correct index. * ext/openssl/ossl_ssl.c (ossl_ssl_verify_callback): ditto. * ext/openssl/ossl_x509store.c (ossl_x509store_set_vfy_cb): ditto. (ossl_x509stctx_verify): ditto. * ext/openssl/ossl.h (void ossl_clear_error): add extern declarations of ossl_store_{ctx_,}ex_verify_cb_idx. * ext/openssl/openssl_missing.c: remove X509_STORE_set_ex_data and X509_STORE_get_ex_data. * ext/openssl/openssl_missing.h: implement X509_STORE_get_ex_data, X509_STORE_set_ex_data and X509_STORE_get_ex_new_index as macros. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55074 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* openssl: report errors in OpenSSL error queue when clear itrhe2016-05-311-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | * ext/openssl/ossl.c (ossl_clear_error): Extracted from ossl_make_error(). This prints errors in the OpenSSL error queue if OpenSSL.debug is true, and clears the queue. (ossl_make_error): use ossl_clear_error(). * ext/openssl/ossl.h: add prototype declaration of ossl_make_error(). (OSSL_BIO_reset) use ossl_clear_error() to clear the queue. Clearing silently makes debugging difficult. * ext/openssl/ossl_engine.c (ossl_engine_s_by_id): ditto. * ext/openssl/ossl_ns_spki.c (ossl_spki_initialize): ditto. * ext/openssl/ossl_pkcs7.c (ossl_pkcs7_verify): ditto. * ext/openssl/ossl_pkey_dsa.c (ossl_dsa_initialize): ditto. * ext/openssl/ossl_pkey_ec.c (ossl_ec_key_initialize): ditto. (ossl_ec_group_initialize): ditto. * ext/openssl/ossl_ssl.c (ossl_ssl_shutdown): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sync code from upstreamSHIBATA Hiroshi2015-12-301-1/+1
|
* Sync with ruby trunkZachary Scott2015-09-231-2/+0
|
* Apply ruby/ruby@325a50fc572516a171d640765d6ddf9b20be14dc to fix typosZachary Scott2015-05-041-1/+1
| | | | See also r50351 from ruby/ruby#876
* Sync with ruby trunkZachary Scott2015-01-051-0/+3
|
* import ruby trunkSHIBATA Hiroshi2014-10-271-0/+247