Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ internal static class WellKnownOids
[ 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, ] => "2.16.840.1.101.3.4.2.1",
[ 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, ] => "2.16.840.1.101.3.4.2.2",
[ 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, ] => "2.16.840.1.101.3.4.2.3",
[ 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x03, 0x11, ] => "2.16.840.1.101.3.4.3.17",
[ 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x03, 0x12, ] => "2.16.840.1.101.3.4.3.18",
[ 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x03, 0x13, ] => "2.16.840.1.101.3.4.3.19",
[ 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x04, 0x01, ] => "2.16.840.1.101.3.4.4.1",
[ 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x04, 0x02, ] => "2.16.840.1.101.3.4.4.2",
[ 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x04, 0x03, ] => "2.16.840.1.101.3.4.4.3",
[ 0x67, 0x81, 0x0C, 0x01, 0x02, 0x01, ] => "2.23.140.1.2.1",
[ 0x67, 0x81, 0x0C, 0x01, 0x02, 0x02, ] => "2.23.140.1.2.2",
_ => null,
Expand Down Expand Up @@ -214,6 +220,12 @@ internal static ReadOnlySpan<byte> GetContents(ReadOnlySpan<char> value)
0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, // Sha256
0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, // Sha384
0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, // Sha512
0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x03, 0x11, // MLDsa44
0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x03, 0x12, // MLDsa65
0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x03, 0x13, // MLDsa87
0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x04, 0x01, // MlKem512
0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x04, 0x02, // MlKem768
0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x04, 0x03, // MlKem1024
0x67, 0x81, 0x0C, 0x01, 0x02, 0x01, // CabForumDV
0x67, 0x81, 0x0C, 0x01, 0x02, 0x02, // CabForumOV
];
Expand Down Expand Up @@ -317,8 +329,14 @@ internal static ReadOnlySpan<byte> GetContents(ReadOnlySpan<char> value)
"2.16.840.1.101.3.4.2.1" => data.Slice(740, 9), // Sha256
"2.16.840.1.101.3.4.2.2" => data.Slice(749, 9), // Sha384
"2.16.840.1.101.3.4.2.3" => data.Slice(758, 9), // Sha512
"2.23.140.1.2.1" => data.Slice(767, 6), // CabForumDV
"2.23.140.1.2.2" => data.Slice(773, 6), // CabForumOV
"2.16.840.1.101.3.4.3.17" => data.Slice(767, 9), // MLDsa44
"2.16.840.1.101.3.4.3.18" => data.Slice(776, 9), // MLDsa65
"2.16.840.1.101.3.4.3.19" => data.Slice(785, 9), // MLDsa87
"2.16.840.1.101.3.4.4.1" => data.Slice(794, 9), // MlKem512
"2.16.840.1.101.3.4.4.2" => data.Slice(803, 9), // MlKem768
"2.16.840.1.101.3.4.4.3" => data.Slice(812, 9), // MlKem1024
"2.23.140.1.2.1" => data.Slice(821, 6), // CabForumDV
"2.23.140.1.2.2" => data.Slice(827, 6), // CabForumOV
_ => ReadOnlySpan<byte>.Empty
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,23 @@ public void ExpectedTag_IgnoresConstructed(

public static class ReadObjectIdentifierDecoderTests
{
[Theory]
[InlineData("0609608648016503040311", "2.16.840.1.101.3.4.3.17")]
[InlineData("0609608648016503040312", "2.16.840.1.101.3.4.3.18")]
[InlineData("0609608648016503040313", "2.16.840.1.101.3.4.3.19")]
[InlineData("0609608648016503040401", "2.16.840.1.101.3.4.4.1")]
[InlineData("0609608648016503040402", "2.16.840.1.101.3.4.4.2")]
[InlineData("0609608648016503040403", "2.16.840.1.101.3.4.4.3")]
public static void ReadWellKnownObjectIdentifier(string inputHex, string expectedValue)
{
byte[] input = inputHex.HexToByteArray();

string oid = AsnDecoder.ReadObjectIdentifier(input, AsnEncodingRules.DER, out int consumed);

Assert.Equal(expectedValue, oid);
Assert.Equal(input.Length, consumed);
Comment thread
vcsjones marked this conversation as resolved.
}

[Theory]
[InlineData(AsnEncodingRules.BER)]
[InlineData(AsnEncodingRules.CER)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,42 @@ public void VerifyWriteObjectIdentifier_ConstructedIgnored(AsnEncodingRules rule
"06092A864886F70D01010A",
},
new object[]
{
AsnEncodingRules.BER,
"2.16.840.1.101.3.4.3.17",
"0609608648016503040311",
},
new object[]
{
AsnEncodingRules.CER,
"2.16.840.1.101.3.4.3.18",
"0609608648016503040312",
},
new object[]
{
AsnEncodingRules.DER,
"2.16.840.1.101.3.4.3.19",
"0609608648016503040313",
},
new object[]
{
AsnEncodingRules.BER,
"2.16.840.1.101.3.4.4.1",
"0609608648016503040401",
},
new object[]
{
AsnEncodingRules.CER,
"2.16.840.1.101.3.4.4.2",
"0609608648016503040402",
},
new object[]
{
AsnEncodingRules.DER,
"2.16.840.1.101.3.4.4.3",
"0609608648016503040403",
},
new object[]
{
// Using the rules of ITU-T-REC-X.667-201210 for 2.25.{UUID} unregistered arcs, and
// their sample value of f81d4fae-7dec-11d0-a765-00a0c91e6bf6
Expand Down
Loading