Skip to content

Commit e6a1983

Browse files
authored
crypto.ecdsa: add support for OpenSSL on OpenBSD (#24772)
1 parent a45e23a commit e6a1983

6 files changed

Lines changed: 21 additions & 9 deletions

File tree

‎cmd/tools/modules/testing/common.v‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ pub const is_python_present = os.execute('python --version').exit_code == 0
5454
pub const is_sqlite3_present = os.execute('sqlite3 --version').exit_code == 0
5555
&& os.execute('pkg-config sqlite3 --libs').exit_code == 0
5656

57-
pub const is_openssl_present = os.execute('openssl --version').exit_code == 0
58-
&& os.execute('pkg-config openssl --libs').exit_code == 0
59-
6057
pub const all_processes = get_all_processes()
6158

6259
pub const header_bytes_to_search_for_module_main = 500
@@ -881,6 +878,18 @@ fn get_max_header_len() int {
881878
return cols
882879
}
883880

881+
fn check_openssl_present() bool {
882+
$if openbsd {
883+
return os.execute('eopenssl34 --version').exit_code == 0
884+
&& os.execute('pkg-config eopenssl34 --libs').exit_code == 0
885+
} $else {
886+
return os.execute('openssl --version').exit_code == 0
887+
&& os.execute('pkg-config openssl --libs').exit_code == 0
888+
}
889+
}
890+
891+
pub const is_openssl_present = check_openssl_present()
892+
884893
// is_started_mysqld is true, when the test runner determines that there is a running mysql server
885894
pub const is_started_mysqld = find_started_process('mysqld') or { '' }
886895

‎vlib/crypto/ecdsa/ecdsa.c.v‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ module ecdsa
1515
#flag linux -I/usr/local/include/openssl
1616
#flag linux -L/usr/local/lib64/
1717

18+
#flag openbsd -I/usr/local/include/eopenssl34
19+
#flag openbsd -L/usr/local/lib/eopenssl34 -Wl,-rpath,/usr/local/lib/eopenssl34
20+
1821
// Installed through choco:
1922
#flag windows -IC:/Program Files/OpenSSL-Win64/include
2023
#flag windows -LC:/Program Files/OpenSSL-Win64/lib/VC/x64/MD

‎vlib/crypto/ecdsa/ecdsa_test.v‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// vtest build: present_openssl? && !(sanitize-memory-clang || docker-ubuntu-musl)
1+
// vtest build: present_openssl? && !(openbsd && gcc) && !(sanitize-memory-clang || docker-ubuntu-musl)
22
module ecdsa
33

44
fn test_ecdsa() {

‎vlib/crypto/ecdsa/example/ecdsa_seed_test.v‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// vtest build: present_openssl? && !(sanitize-memory-clang || docker-ubuntu-musl)
1+
// vtest build: present_openssl? && !(openbsd && gcc) && !(sanitize-memory-clang || docker-ubuntu-musl)
22
import rand
33
import crypto.ecdsa
44
import encoding.hex

‎vlib/crypto/ecdsa/example/ensure_compatibility_with_net_openssl_test.v‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// vtest build: present_openssl? && !(sanitize-memory-clang || docker-ubuntu-musl)
1+
// vtest build: present_openssl? && !(openbsd && gcc) && !(sanitize-memory-clang || docker-ubuntu-musl)
22
import net.openssl
33
import crypto.ecdsa
44

‎vlib/crypto/ecdsa/util_test.v‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// vtest build: present_openssl? && !(sanitize-memory-clang || docker-ubuntu-musl)
1+
// vtest build: present_openssl? && !(openbsd && gcc) && !(sanitize-memory-clang || docker-ubuntu-musl)
22
module ecdsa
33

44
import encoding.hex
@@ -90,7 +90,7 @@ fn test_load_privkey_from_string_sign_and_verify() ! {
9090
expected_pvkey_bytes := '30ce3da288965ac6093f0ba9a9a15b2476bea3eda925e1b3c1f094674f52795cd6cb3cafe235dfc15bec542448ffa715'
9191
assert pvkey.bytes()!.hex() == expected_pvkey_bytes
9292

93-
// public key part
93+
// public key part
9494
pbkey := pvkey.public_key()!
9595
pbkey_bytes := pbkey.bytes()!
9696
expected_pubkey_bytes := '04f8fdeb845913d5f5c761b6370a9701761eb14c2ef831017171fb4d543df310f573a3ffce6a52156ad635eb692c83cb9158176f145b8767d38c55791b8f05b085c5cfeea988f6b3922d1dc019495dcbe6c1a55da74f7d3aa8223081400c78e24f'
@@ -133,7 +133,7 @@ UHhnmmVRraSwrVkPdYIeXhH/Ob4+8OLcwrQBMv4RXsD1GVFsgkvEYDTEb/vnMA==
133133
fn test_key_signing_verifying_with_custom_hash() ! {
134134
// privatekey_sample was P-384 key
135135
pvkey := privkey_from_string(privatekey_sample)!
136-
// public key part
136+
// public key part
137137
pbkey := pvkey.public_key()!
138138
pbk := pubkey_from_string(public_key_sample)!
139139

0 commit comments

Comments
 (0)