-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update SDK to 7.0.100-rc.2.22419.24 (#43028)
- {lots of different SDK versions tried} - Validate DataProtection custom algorithm has a constructor - Additional fixes - Suppress IL2121 - Fix NoWarn overrides - Update LinkabilityChecker.csproj - Update WasmLinkerTest.csproj - Bump SDK version yet again - Hack to stop using `msbuild` server - please open an issue to keep trying to remove this - Disable msbuild server for source-build job Co-authored-by: Steve Sanderson <SteveSandersonMS@users.noreply.github.com> Co-authored-by: Chris Ross <chrross@microsoft.com> Co-authored-by: Tanay Parikh <TanayParikh@users.noreply.github.com> Co-authored-by: James Newton-King <james@newtonking.com> Co-authored-by: Sébastien Ros <sebastienros@gmail.com> Co-authored-by: Doug Bunting <6431421+dougbu@users.noreply.github.com> Co-authored-by: Safia Abdalla <safia@microsoft.com>
- Loading branch information
1 parent
5659774
commit bcf7319
Showing
18 changed files
with
167 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
.../DataProtection/src/AuthenticatedEncryption/ConfigurationModel/ManagedAlgorithmHelpers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Security.Cryptography; | ||
using System.Xml.Linq; | ||
|
||
namespace Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel; | ||
|
||
internal static class ManagedAlgorithmHelpers | ||
{ | ||
private static readonly List<Type> KnownAlgorithmTypes = new List<Type> | ||
{ | ||
typeof(Aes), | ||
typeof(HMACSHA1), | ||
typeof(HMACSHA256), | ||
typeof(HMACSHA384), | ||
typeof(HMACSHA512) | ||
}; | ||
|
||
// Any changes to this method should also be be reflected in FriendlyNameToType. | ||
public static string TypeToFriendlyName(Type type) | ||
{ | ||
if (KnownAlgorithmTypes.Contains(type)) | ||
{ | ||
return type.Name; | ||
} | ||
else | ||
{ | ||
return type.AssemblyQualifiedName!; | ||
} | ||
} | ||
|
||
// Any changes to this method should also be be reflected in TypeToFriendlyName. | ||
[return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] | ||
[UnconditionalSuppressMessage("Trimmer", "IL2075", Justification = "Unknown type is checked for whether it has a public parameterless constructor. Handle trimmed types by providing a useful error message.")] | ||
[UnconditionalSuppressMessage("Trimmer", "IL2073", Justification = "Unknown type is checked for whether it has a public parameterless constructor. Handle trimmed types by providing a useful error message.")] | ||
public static Type FriendlyNameToType(string typeName) | ||
{ | ||
foreach (var knownType in KnownAlgorithmTypes) | ||
{ | ||
if (knownType.Name == typeName) | ||
{ | ||
return knownType; | ||
} | ||
} | ||
|
||
var type = TypeExtensions.GetTypeWithTrimFriendlyErrorMessage(typeName); | ||
|
||
// Type name could be full or assembly qualified name of known type. | ||
if (KnownAlgorithmTypes.Contains(type)) | ||
{ | ||
return type; | ||
} | ||
|
||
// All other types are created using Activator.CreateInstance. Validate it has a valid constructor. | ||
if (type.GetConstructor(Type.EmptyTypes) == null) | ||
{ | ||
throw new InvalidOperationException($"Algorithm type {type} doesn't have a public parameterless constructor. If the app is published with trimming then the constructor may have been trimmed. Ensure the type's assembly is excluded from trimming."); | ||
} | ||
|
||
return type; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.