Skip to content

Commit

Permalink
Add the TPM Object Identifiers to the static table in OidLookup
Browse files Browse the repository at this point in the history
Experimentation suggests that these values are non-localized in Windows,
and are currently unmapped in OpenSSL; so they are good candidates for
static registration in OidLookup.

The TpmIdentifiers test passed on Windows Server 2012 R2 before the change,
to help prevent typos with registration.
  • Loading branch information
bartonjs authored Apr 6, 2019
1 parent b561cd4 commit 2862fae
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ public static string ToOid(string friendlyName, OidGroup oidGroup, bool fallBack
{ "specifiedECDSA", "1.2.840.10045.4.3" },
{ "STREET", "2.5.4.9" },
{ "T", "2.5.4.12" },
{ "TPMManufacturer", "2.23.133.2.1" },
{ "TPMModel", "2.23.133.2.2" },
{ "TPMVersion", "2.23.133.2.3" },
{ "wtls9", "2.23.43.1.4.9" },
{ "X21Address", "2.5.4.24" },
{ "x962P192v2", "1.2.840.10045.3.1.2" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Runtime.InteropServices;
using Test.Cryptography;
using Xunit;

Expand Down Expand Up @@ -183,6 +184,23 @@ public static void EdgeCaseUseCommaAndNewLines()
Assert.Equal(rname, dn.Decode(X500DistinguishedNameFlags.UseCommas | X500DistinguishedNameFlags.UseNewLines));
}

[Fact]
public static void TpmIdentifiers()
{
// On Windows the X.500 name pretty printer is in crypt32, so it doesn't use our OidLookup.
// Windows 7 doesn't have the TPM OIDs mapped, so they come back as (e.g.) OID.2.23.133.2.3 still.
//
// Just skip this test there.
if (PlatformDetection.IsWindows7)
{
return;
}

X500DistinguishedName dn = new X500DistinguishedName("OID.2.23.133.2.3=id:0020065,OID.2.23.133.2.2=,OID.2.23.133.2.1=id:564D5700");
X500DistinguishedName dn2 = new X500DistinguishedName(dn.RawData);
Assert.Equal("TPMManufacturer=id:564D5700, TPMModel=\"\", TPMVersion=id:0020065", dn2.Decode(X500DistinguishedNameFlags.None));
}

public static readonly object[][] WhitespaceBeforeCases =
{
// Regular space.
Expand Down

0 comments on commit 2862fae

Please sign in to comment.