Skip to content

Commit

Permalink
Update LibCrypto bindings for LibreSSL 3.5+ (#14872)
Browse files Browse the repository at this point in the history
* Fix libssl bindings for LibreSSL 3.5
* [CI] Add test for libreSSL 3.5
* [CI] Add test for libreSSL 3.8
  • Loading branch information
straight-shoota authored Aug 14, 2024
1 parent 78c9282 commit 38304b3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
30 changes: 30 additions & 0 deletions .github/workflows/openssl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,33 @@ jobs:
run: bin/crystal eval 'require "openssl"; p! LibSSL::OPENSSL_VERSION, LibSSL::LIBRESSL_VERSION'
- name: Run OpenSSL specs
run: bin/crystal spec --order=random spec/std/openssl/
libressl35:
runs-on: ubuntu-latest
name: "LibreSSL 3.5"
container: crystallang/crystal:1.13.1-alpine
steps:
- name: Download Crystal source
uses: actions/checkout@v2
- name: Uninstall openssl
run: apk del openssl-dev openssl-libs-static
- name: Install libressl 3.5
run: apk add "libressl-dev=~3.5" --repository=http://dl-cdn.alpinelinux.org/alpine/v3.16/community
- name: Check LibSSL version
run: bin/crystal eval 'require "openssl"; p! LibSSL::OPENSSL_VERSION, LibSSL::LIBRESSL_VERSION'
- name: Run OpenSSL specs
run: bin/crystal spec --order=random spec/std/openssl/
libressl38:
runs-on: ubuntu-latest
name: "LibreSSL 3.5"
container: crystallang/crystal:1.13.1-alpine
steps:
- name: Download Crystal source
uses: actions/checkout@v2
- name: Uninstall openssl
run: apk del openssl-dev openssl-libs-static
- name: Install libressl 3.8
run: apk add "libressl-dev=~3.8" --repository=http://dl-cdn.alpinelinux.org/alpine/v3.20/community
- name: Check LibSSL version
run: bin/crystal eval 'require "openssl"; p! LibSSL::OPENSSL_VERSION, LibSSL::LIBRESSL_VERSION'
- name: Run OpenSSL specs
run: bin/crystal spec --order=random spec/std/openssl/
8 changes: 7 additions & 1 deletion src/openssl/lib_crypto.cr
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ lib LibCrypto

struct Bio
method : Void*
callback : (Void*, Int, Char*, Int, Long, Long) -> Long
callback : BIO_callback_fn
{% if compare_versions(LIBRESSL_VERSION, "3.5.0") >= 0 %}
callback_ex : BIO_callback_fn_ex
{% end %}
cb_arg : Char*
init : Int
shutdown : Int
Expand All @@ -72,6 +75,9 @@ lib LibCrypto
num_write : ULong
end

alias BIO_callback_fn = (Bio*, Int, Char*, Int, Long, Long) -> Long
alias BIO_callback_fn_ex = (Bio*, Int, Char, SizeT, Int, Long, Int, SizeT*) -> Long

PKCS5_SALT_LEN = 8
EVP_MAX_KEY_LENGTH = 32
EVP_MAX_IV_LENGTH = 16
Expand Down

0 comments on commit 38304b3

Please sign in to comment.