Skip to content

Commit

Permalink
Add helper function to add RSAPSS options
Browse files Browse the repository at this point in the history
  • Loading branch information
ret2libc committed Jan 12, 2024
1 parent ef70c23 commit 62ee40f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pkg/signature/signerverifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ type LoadSignerVerifierOpts struct {
RSAPSSOptions *rsa.PSSOptions
}

// WithRSAPSSOptions is a helper function to add RSA PSS options to the LoadSignerVerifierOpts.
func (l LoadSignerVerifierOpts) WithRSAPSSOptions(opts *rsa.PSSOptions) *LoadSignerVerifierOpts {
l.RSAPSSOptions = opts
return &l
}

// LoadSignerVerifier returns a signature.SignerVerifier based on the algorithm of the private key
// provided and the user's choice.
//
Expand Down
3 changes: 2 additions & 1 deletion pkg/signature/signerverifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ func TestLoadRSAPSSSignerVerifier(t *testing.T) {
if err != nil {
t.Errorf("unexpected error unmarshalling private key: %v", err)
}
sv, err := LoadSignerVerifier(privateKey, crypto.SHA256, LoadRSAPSSSV|LoadED25519phSV, &LoadSignerVerifierOpts{RSAPSSOptions: opts})

sv, err := LoadSignerVerifier(privateKey, crypto.SHA256, LoadRSAPSSSV|LoadED25519phSV, LoadSignerVerifierOpts{}.WithRSAPSSOptions(opts))
if err != nil {
t.Errorf("unexpected error creating signer/verifier: %v", err)
}
Expand Down

0 comments on commit 62ee40f

Please sign in to comment.