Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Support OpenSSL 3.0 #399

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,40 @@ jobs:

- name: test
run: rake test TESTOPTS="-v --no-show-detail-immediately" OSSL_MDEBUG=1

test-openssl-master:
name: OpenSSL master
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
ruby: [ 2.7 ]
steps:
- name: repo checkout
uses: actions/checkout@v2

- name: prepare openssl
run: |
mkdir -p tmp/build-openssl && cd tmp/build-openssl
git clone https://github.com/openssl/openssl.git --depth=1
cd openssl
./Configure --prefix=$HOME/.openssl/master --libdir=lib \
linux-x86_64
make depend
make -j4
make install_sw

- name: load ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}

- name: depends
run: bundle install

- name: compile
run: rake compile -- --enable-debug --with-openssl-dir=$HOME/.openssl/master

- name: test
run: rake test TESTOPTS="-v --no-show-detail-immediately"
1 change: 1 addition & 0 deletions ext/openssl/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ def find_openssl_library
have_func("EVP_MD_CTX_get_pkey_ctx")
have_func("EVP_PKEY_eq")
have_func("EVP_PKEY_dup")
have_func("EVP_PKEY_todata")

Logging::message "=== Checking done. ===\n"

Expand Down
17 changes: 17 additions & 0 deletions ext/openssl/ossl_bn.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,23 @@ ossl_bn_new(const BIGNUM *bn)
return obj;
}

#ifdef HAVE_EVP_PKEY_TODATA
VALUE
ossl_bn_new_from_native(const void *data, size_t data_size)
{
BIGNUM *bn;
VALUE obj;

obj = NewBN(cBN);
bn = BN_native2bn(data, data_size, NULL);
if (!bn)
ossl_raise(eBNError, "BN_native2bn");
SetBN(obj, bn);

return obj;
}
#endif

static BIGNUM *
integer_to_bnptr(VALUE obj, BIGNUM *orig)
{
Expand Down
3 changes: 3 additions & 0 deletions ext/openssl/ossl_bn.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ BN_CTX *ossl_bn_ctx_get(void);
#define GetBNPtr(obj) ossl_bn_value_ptr(&(obj))

VALUE ossl_bn_new(const BIGNUM *);
#ifdef HAVE_EVP_PKEY_TODATA
VALUE ossl_bn_new_from_native(const void *data, size_t data_size);
#endif
BIGNUM *ossl_bn_value_ptr(volatile VALUE *);
void Init_ossl_bn(void);

Expand Down
Loading