Skip to content

Commit

Permalink
Fix ECCurve comparison and add new credscan exclusion entry
Browse files Browse the repository at this point in the history
* On some systems, the Oid.Value property is the primary referenced
identifier, while on others it's the Oid.FriendlyName property.
https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.eccurve.oid?view=netcore-3.0#remarks
  • Loading branch information
GeoK committed Dec 12, 2019
1 parent 498a9fe commit cb40870
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions build/credscan-exclusion.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
{
"file": "SignedHttpRequestTestUtils.cs",
"_justification": "File contains tokens that are used only for testing purposes."
},
{
"file": "JsonWebKeyTests.cs",
"_justification": "File contains tokens that are used only for testing purposes."
}
]
}
8 changes: 4 additions & 4 deletions src/Microsoft.IdentityModel.Tokens/ECDsaAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,14 +378,14 @@ internal string GetCrvParameterValue(ECCurve curve)
if (curve.Oid == null)
throw LogHelper.LogArgumentNullException(nameof(curve.Oid));

if (string.Equals(curve.Oid.FriendlyName, ECCurve.NamedCurves.nistP256.Oid.FriendlyName, StringComparison.Ordinal))
if (string.Equals(curve.Oid.Value, ECCurve.NamedCurves.nistP256.Oid.Value, StringComparison.Ordinal) || string.Equals(curve.Oid.FriendlyName, ECCurve.NamedCurves.nistP256.Oid.FriendlyName, StringComparison.Ordinal))
return JsonWebKeyECTypes.P256;
else if (string.Equals(curve.Oid.FriendlyName, ECCurve.NamedCurves.nistP384.Oid.FriendlyName, StringComparison.Ordinal))
else if (string.Equals(curve.Oid.Value, ECCurve.NamedCurves.nistP384.Oid.Value, StringComparison.Ordinal) || string.Equals(curve.Oid.FriendlyName, ECCurve.NamedCurves.nistP384.Oid.FriendlyName, StringComparison.Ordinal))
return JsonWebKeyECTypes.P384;
else if (string.Equals(curve.Oid.FriendlyName, ECCurve.NamedCurves.nistP521.Oid.FriendlyName, StringComparison.Ordinal))
else if (string.Equals(curve.Oid.Value, ECCurve.NamedCurves.nistP521.Oid.Value, StringComparison.Ordinal) || string.Equals(curve.Oid.FriendlyName, ECCurve.NamedCurves.nistP521.Oid.FriendlyName, StringComparison.Ordinal))
return JsonWebKeyECTypes.P521;
else
throw LogHelper.LogExceptionMessage(new ArgumentException(LogHelper.FormatInvariant(LogMessages.IDX10645, curve.Oid.FriendlyName ?? "null")));
throw LogHelper.LogExceptionMessage(new ArgumentException(LogHelper.FormatInvariant(LogMessages.IDX10645, (curve.Oid.Value ?? curve.Oid.FriendlyName) ?? "null")));
}


Expand Down

0 comments on commit cb40870

Please sign in to comment.