Skip to content

Commit 2d7482d

Browse files
committed
skip tests not supported by SymCrypt
1 parent 2ae7b98 commit 2d7482d

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

export_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
package openssl
22

3+
import "sync"
4+
35
var ErrOpen = errOpen
6+
7+
var SymCryptProviderAvailable = sync.OnceValue(func() bool {
8+
return isProviderAvailable("symcryptprovider")
9+
})

openssl.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ func FIPS() bool {
111111
}
112112
}
113113

114+
// isProviderAvailable checks if the provider with the given name is available.
115+
// This function is used in export_test.go, as test files can't access C functions.
116+
func isProviderAvailable(name string) bool {
117+
providerName := C.CString(name)
118+
defer C.free(unsafe.Pointer(providerName))
119+
return C.go_openssl_OSSL_PROVIDER_available(nil, providerName) == 1
120+
}
121+
114122
// SetFIPS enables or disables FIPS mode.
115123
//
116124
// For OpenSSL 3, the `fips` provider is loaded if enabled is true,

rsa_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ func TestEncryptDecryptOAEP_EmptyLabel(t *testing.T) {
8181
}
8282

8383
func TestEncryptDecryptOAEP_WithMGF1Hash(t *testing.T) {
84+
if openssl.SymCryptProviderAvailable() {
85+
t.Skip("SymCrypt provider does not support MGF1 hash")
86+
}
87+
8488
sha1 := openssl.NewSHA1()
8589
sha256 := openssl.NewSHA256()
8690
msg := []byte("hi!")
@@ -148,6 +152,10 @@ func TestSignVerifyPKCS1v15(t *testing.T) {
148152
}
149153

150154
func TestSignVerifyPKCS1v15_Unhashed(t *testing.T) {
155+
if openssl.SymCryptProviderAvailable() {
156+
t.Skip("SymCrypt provider does not support unhashed PKCS1v15")
157+
}
158+
151159
msg := []byte("hi!")
152160
priv, pub := newRSAKey(t, 2048)
153161
signed, err := openssl.SignRSAPKCS1v15(priv, 0, msg)

0 commit comments

Comments
 (0)