Skip to content

Commit

Permalink
fix compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
qmuntal authored May 18, 2022
1 parent 558632b commit b69c23e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion openssl/bbig/bridge/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

// These wrappers only exist for code reuse in places where we need the old pre-go1.19 signature.

package bbig
package bridge

import (
"encoding/asn1"
Expand Down
14 changes: 7 additions & 7 deletions openssl/ecdsa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"crypto/elliptic"
"testing"

"github.com/microsoft/go-crypto-openssl/openssl/bbig"
"github.com/microsoft/go-crypto-openssl/openssl/bbig/bridge"
)

func testAllCurves(t *testing.T, f func(*testing.T, elliptic.Curve)) {
Expand Down Expand Up @@ -57,32 +57,32 @@ func testECDSASignAndVerify(t *testing.T, c elliptic.Curve) {
t.Fatal(err)
}

priv, err := bbig.NewPrivateKeyECDSA(key.Params().Name, key.X, key.Y, key.D)
priv, err := bridge.NewPrivateKeyECDSA(key.Params().Name, key.X, key.Y, key.D)
if err != nil {
t.Fatal(err)
}
hashed := []byte("testing")
r, s, err := bbig.SignECDSA(priv, hashed)
r, s, err := bridge.SignECDSA(priv, hashed)
if err != nil {
t.Errorf("error signing: %s", err)
return
}

pub, err := bbig.NewPublicKeyECDSA(key.Params().Name, key.X, key.Y)
pub, err := bridge.NewPublicKeyECDSA(key.Params().Name, key.X, key.Y)
if err != nil {
t.Fatal(err)
}
if !bbig.VerifyECDSA(pub, hashed, r, s) {
if !bridge.VerifyECDSA(pub, hashed, r, s) {
t.Errorf("Verify failed")
}
hashed[0] ^= 0xff
if bbig.VerifyECDSA(pub, hashed, r, s) {
if bridge.VerifyECDSA(pub, hashed, r, s) {
t.Errorf("Verify succeeded despite intentionally invalid hash!")
}
}

func generateKeycurve(c elliptic.Curve) (*ecdsa.PrivateKey, error) {
x, y, d, err := bbig.GenerateKeyECDSA(c.Params().Name)
x, y, d, err := bridge.GenerateKeyECDSA(c.Params().Name)
if err != nil {
return nil, err
}
Expand Down
12 changes: 6 additions & 6 deletions openssl/rsa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"testing"

"github.com/microsoft/go-crypto-openssl/openssl"
"github.com/microsoft/go-crypto-openssl/openssl/bbig"
"github.com/microsoft/go-crypto-openssl/openssl/bbig/bridge"
)

func TestRSAKeyGeneration(t *testing.T) {
Expand Down Expand Up @@ -134,15 +134,15 @@ func TestSignVerifyRSAPSS(t *testing.T) {

func newRSAKey(t *testing.T, size int) (*openssl.PrivateKeyRSA, *openssl.PublicKeyRSA) {
t.Helper()
N, E, D, P, Q, Dp, Dq, Qinv, err := bbig.GenerateKeyRSA(size)
N, E, D, P, Q, Dp, Dq, Qinv, err := bridge.GenerateKeyRSA(size)
if err != nil {
t.Fatalf("GenerateKeyRSA(%d): %v", size, err)
}
priv, err := bbig.NewPrivateKeyRSA(N, E, D, P, Q, Dp, Dq, Qinv)
priv, err := bridge.NewPrivateKeyRSA(N, E, D, P, Q, Dp, Dq, Qinv)
if err != nil {
t.Fatalf("NewPrivateKeyRSA(%d): %v", size, err)
}
pub, err := bbig.NewPublicKeyRSA(N, E)
pub, err := bridge.NewPublicKeyRSA(N, E)
if err != nil {
t.Fatalf("NewPublicKeyRSA(%d): %v", size, err)
}
Expand All @@ -161,7 +161,7 @@ func BenchmarkEncryptRSAPKCS1(b *testing.B) {
b.StopTimer()
// Public key length should be at least of 2048 bits, else OpenSSL will report an error when running in FIPS mode.
n := fromBase36("14314132931241006650998084889274020608918049032671858325988396851334124245188214251956198731333464217832226406088020736932173064754214329009979944037640912127943488972644697423190955557435910767690712778463524983667852819010259499695177313115447116110358524558307947613422897787329221478860907963827160223559690523660574329011927531289655711860504630573766609239332569210831325633840174683944553667352219670930408593321661375473885147973879086994006440025257225431977751512374815915392249179976902953721486040787792801849818254465486633791826766873076617116727073077821584676715609985777563958286637185868165868520557")
test2048PubKey, err := bbig.NewPublicKeyRSA(n, big.NewInt(3))
test2048PubKey, err := bridge.NewPublicKeyRSA(n, big.NewInt(3))
if err != nil {
b.Fatal(err)
}
Expand All @@ -177,7 +177,7 @@ func BenchmarkEncryptRSAPKCS1(b *testing.B) {
func BenchmarkGenerateKeyRSA(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_, _, _, _, _, _, _, _, err := bbig.GenerateKeyRSA(2048)
_, _, _, _, _, _, _, _, err := bridge.GenerateKeyRSA(2048)
if err != nil {
b.Fatal(err)
}
Expand Down

0 comments on commit b69c23e

Please sign in to comment.