Skip to content

Commit 5e08146

Browse files
authored
Merge pull request #225
feat: Expose the cbor raw data from a MakeCredential command
2 parents 7e2d256 + 42f0d32 commit 5e08146

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

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

Lines changed: 9 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,12 @@ public class MakeCredentialData
167166
/// </summary>
168167
public ReadOnlyMemory<byte>? LargeBlobKey { get; private set; }
169168

169+
170+
/// <summary>
171+
/// This returns the raw CBOR encoded credential data from the YubiKey, as returned by the MakeCredential operation.
172+
/// </summary>
173+
public ReadOnlyMemory<byte> RawData { get; }
174+
170175
// The default constructor explicitly defined. We don't want it to be
171176
// used.
172177
private MakeCredentialData()
@@ -193,10 +198,11 @@ private MakeCredentialData()
193198
/// </exception>
194199
public MakeCredentialData(ReadOnlyMemory<byte> cborEncoding)
195200
{
201+
RawData = cborEncoding;
202+
var map = new CborMap<int>(RawData);
203+
196204
try
197205
{
198-
var map = new CborMap<int>(cborEncoding);
199-
200206
Format = map.ReadTextString(KeyFormat);
201207
AuthenticatorData = new AuthenticatorData(map.ReadByteString(KeyAuthData));
202208
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 RawCredentialData_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)