Skip to content

Commit 9f532a9

Browse files
author
Cory Thompson
committed
Fixes firefox support #2
1 parent 5f5a0ea commit 9f532a9

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/Util/JWSSigner.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,17 @@ public string GenerateSignature(Dictionary<string, object> header, Dictionary<st
3838
signer.Init(true, _privateKey);
3939
BigInteger[] results = signer.GenerateSignature(hashedMessage);
4040

41-
// Required to be exactly 33 bytes
4241
// Concated to create signature
43-
var a = ByteArrayPadLeft(results[0].ToByteArrayUnsigned(), 33);
44-
var b = ByteArrayPadLeft(results[1].ToByteArrayUnsigned(), 33);
42+
var a = results[0].ToByteArrayUnsigned();
43+
var b = results[1].ToByteArrayUnsigned();
44+
45+
// a,b are required to be exactly the same length of bytes
46+
if (a.Length != b.Length)
47+
{
48+
int largestLength = Math.Max(a.Length, b.Length);
49+
a = ByteArrayPadLeft(a, largestLength);
50+
b = ByteArrayPadLeft(b, largestLength);
51+
}
4552

4653
string signature = UrlBase64.Encode(a.Concat(b).ToArray());
4754
return String.Format("{0}.{1}", securedInput, signature);

0 commit comments

Comments
 (0)