Skip to content

Commit c7402ce

Browse files
iamcarbonabergs
authored andcommitted
Reduce Linq.Concat usage
1 parent b3fd219 commit c7402ce

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

Test/Attestation/FidoU2f.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,16 @@ public FidoU2f()
3333

3434
var x = _credentialPublicKey.GetCBORObject()[CBORObject.FromObject(COSE.KeyTypeParameter.X)].GetByteString();
3535
var y = _credentialPublicKey.GetCBORObject()[CBORObject.FromObject(COSE.KeyTypeParameter.Y)].GetByteString();
36-
var publicKeyU2F = new byte[1] { 0x4 }.Concat(x).Concat(y).ToArray();
3736

38-
var verificationData = new byte[1] { 0x00 };
39-
verificationData = verificationData
40-
.Concat(_rpIdHash)
41-
.Concat(_clientDataHash)
42-
.Concat(_credentialID)
43-
.Concat(publicKeyU2F.ToArray())
44-
.ToArray();
37+
byte[] publicKeyU2F = DataHelper.Concat(new byte[1] { 0x4 }, x, y);
38+
39+
byte[] verificationData = DataHelper.Concat(
40+
new byte[1] { 0x00 },
41+
_rpIdHash,
42+
_clientDataHash,
43+
_credentialID,
44+
publicKeyU2F
45+
);
4546

4647
byte[] signature = Fido2Tests.SignData(COSE.KeyType.EC2, COSE.Algorithm.ES256, verificationData, ecdsaAtt, null, null);
4748

Test/Fido2Tests.cs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -812,17 +812,19 @@ internal static byte[] CreateCertInfo(byte[] magic, byte[] type, byte[] qualifie
812812
byte[] extraData, byte[] clock, byte[] resetCount, byte[] restartCount,
813813
byte[] safe, byte[] firmwareRevision, byte[] tPM2BName, byte[] attestedQualifiedNameBuffer)
814814
{
815-
IEnumerable<byte> raw = magic
816-
.Concat(type)
817-
.Concat(qualifiedSigner)
818-
.Concat(extraData)
819-
.Concat(clock)
820-
.Concat(resetCount)
821-
.Concat(restartCount)
822-
.Concat(safe)
823-
.Concat(firmwareRevision)
824-
.Concat(tPM2BName)
825-
.Concat(attestedQualifiedNameBuffer);
815+
var raw = new MemoryStream();
816+
817+
raw.Write(magic);
818+
raw.Write(type);
819+
raw.Write(qualifiedSigner);
820+
raw.Write(extraData);
821+
raw.Write(clock);
822+
raw.Write(resetCount);
823+
raw.Write(restartCount);
824+
raw.Write(safe);
825+
raw.Write(firmwareRevision);
826+
raw.Write(tPM2BName);
827+
raw.Write(attestedQualifiedNameBuffer);
826828

827829
return raw.ToArray();
828830
}

0 commit comments

Comments
 (0)