Skip to content

Commit a68cf0c

Browse files
committed
feat: expose the cbor raw data from a MakeCredential command
1 parent a4c4df1 commit a68cf0c

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

Yubico.YubiKey/src/Yubico/YubiKey/Fido2/MakeCredentialData.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
using System.Collections.Generic;
1717
using System.Formats.Cbor;
1818
using System.Globalization;
19-
using System.Security.Cryptography;
2019
using System.Security.Cryptography.X509Certificates;
2120
using Yubico.YubiKey.Cryptography;
2221
using Yubico.YubiKey.Fido2.Cbor;
@@ -167,6 +166,8 @@ public class MakeCredentialData
167166
/// </summary>
168167
public ReadOnlyMemory<byte>? LargeBlobKey { get; private set; }
169168

169+
public ReadOnlyMemory<byte> RawData { get; private set; }
170+
170171
// The default constructor explicitly defined. We don't want it to be
171172
// used.
172173
private MakeCredentialData()
@@ -193,10 +194,13 @@ private MakeCredentialData()
193194
/// </exception>
194195
public MakeCredentialData(ReadOnlyMemory<byte> cborEncoding)
195196
{
197+
var map = new CborMap<int>(cborEncoding);
198+
byte[] rawData = new byte[cborEncoding.Length];
199+
cborEncoding.CopyTo(rawData);
200+
RawData = rawData;
201+
196202
try
197203
{
198-
var map = new CborMap<int>(cborEncoding);
199-
200204
Format = map.ReadTextString(KeyFormat);
201205
AuthenticatorData = new AuthenticatorData(map.ReadByteString(KeyAuthData));
202206
if (!(AuthenticatorData.CredentialPublicKey is CoseEcPublicKey)

Yubico.YubiKey/tests/unit/Yubico/YubiKey/Fido2/CredentialDataTests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ namespace Yubico.YubiKey.Fido2
1818
{
1919
public class CredentialDataTests
2020
{
21+
[Fact]
22+
public void RawData_Is_Set()
23+
{
24+
byte[] encoding = GetSampleEncoding();
25+
var cData = new MakeCredentialData(encoding);
26+
Assert.Equal(encoding, cData.RawData);
27+
}
28+
29+
2130
[Fact]
2231
public void Decode_Format_Correct()
2332
{

0 commit comments

Comments
 (0)