Skip to content

Commit

Permalink
Automated rollback of commit 7ee4492.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 698350366
Change-Id: I2c75caa9410e88ef017d6bb180fab8b2c35c97a0
  • Loading branch information
morambro authored and copybara-github committed Nov 20, 2024
1 parent 891c2cc commit c41ea0e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions signature/ecdsa/ecdsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/tink-crypto/tink-go/v2/core/registry"
"github.com/tink-crypto/tink-go/v2/internal/protoserialization"
"github.com/tink-crypto/tink-go/v2/internal/registryconfig"
)

func init() {
Expand All @@ -45,4 +46,10 @@ func init() {
if err := protoserialization.RegisterParametersSerializer[*Parameters](&parametersSerializer{}); err != nil {
panic(fmt.Sprintf("ecdsa.init() failed: %v", err))
}
if err := registryconfig.RegisterPrimitiveConstructor[*PublicKey](verifierConstructor); err != nil {
panic(fmt.Sprintf("ecdsa.init() failed: %v", err))
}
if err := registryconfig.RegisterPrimitiveConstructor[*PrivateKey](signerConstructor); err != nil {
panic(fmt.Sprintf("ecdsa.init() failed: %v", err))
}
}
9 changes: 9 additions & 0 deletions signature/ecdsa/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/tink-crypto/tink-go/v2/insecuresecretdataaccess"
"github.com/tink-crypto/tink-go/v2/internal/internalapi"
internalecdsa "github.com/tink-crypto/tink-go/v2/internal/signature/ecdsa"
"github.com/tink-crypto/tink-go/v2/key"
"github.com/tink-crypto/tink-go/v2/subtle"
"github.com/tink-crypto/tink-go/v2/tink"
)
Expand Down Expand Up @@ -116,3 +117,11 @@ func (e *signer) Sign(data []byte) ([]byte, error) {
}
return slices.Concat(e.prefix, signatureBytes), nil
}

func signerConstructor(key key.Key) (any, error) {
that, ok := key.(*PrivateKey)
if !ok {
return nil, fmt.Errorf("key is not a *ecdsa.PrivateKey")
}
return NewSigner(that, internalapi.Token{})
}
9 changes: 9 additions & 0 deletions signature/ecdsa/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"github.com/tink-crypto/tink-go/v2/internal/internalapi"
internalecdsa "github.com/tink-crypto/tink-go/v2/internal/signature/ecdsa"
"github.com/tink-crypto/tink-go/v2/key"
"github.com/tink-crypto/tink-go/v2/subtle"
"github.com/tink-crypto/tink-go/v2/tink"
)
Expand Down Expand Up @@ -101,3 +102,11 @@ func (e *verifier) Verify(signatureBytes, data []byte) error {
}
return nil
}

func verifierConstructor(key key.Key) (any, error) {
that, ok := key.(*PublicKey)
if !ok {
return nil, fmt.Errorf("key is not a *ecdsa.PublicKey")
}
return NewVerifier(that, internalapi.Token{})
}

0 comments on commit c41ea0e

Please sign in to comment.