-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
donutnomad
committed
Nov 1, 2024
1 parent
555ec4a
commit bcd548f
Showing
5 changed files
with
455 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package xasn1 | ||
|
||
import ( | ||
"bytes" | ||
"crypto/rand" | ||
"github.com/samber/lo" | ||
"testing" | ||
) | ||
|
||
func TestMarshalSigRS(t *testing.T) { | ||
var r = mustRand(31) | ||
var s = mustRand(31) | ||
var asn1Sig = MarshalAsn1SignatureRS(r, s) | ||
var rr, ss, err = ParseSignatureRS(asn1Sig) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if !bytes.Equal(padSliceLeft(r, 32), rr) || !bytes.Equal(padSliceLeft(s, 32), ss) { | ||
t.Fatalf("marshal failed") | ||
} | ||
} | ||
|
||
func mustRand(size int) []byte { | ||
var out = make([]byte, size) | ||
lo.Must1(rand.Reader.Read(out)) | ||
return out | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.