diff options
author | Martin Baulig <mabaul@microsoft.com> | 2019-04-26 15:08:36 +0300 |
---|---|---|
committer | Alexander Köplinger <alex.koeplinger@outlook.com> | 2019-04-26 15:08:36 +0300 |
commit | 5e2069746c7c00d833b233bc0ae8c37afc6d8029 (patch) | |
tree | 05f6e25b7b094631f5d4218825ea8043755f90fc /mcs/class/Mono.Security | |
parent | d44e45c32ec1315f5ab97b2e2ec5104ccad6e868 (diff) |
Avoid `HashAlgorithm.Create()` on `FULL_AOT_RUNTIME`. (#14228)
Diffstat (limited to 'mcs/class/Mono.Security')
-rw-r--r-- | mcs/class/Mono.Security/Mono.Security/StrongName.cs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/mcs/class/Mono.Security/Mono.Security/StrongName.cs b/mcs/class/Mono.Security/Mono.Security/StrongName.cs index b7c1f0483ee..dbc0b1f8f04 100644 --- a/mcs/class/Mono.Security/Mono.Security/StrongName.cs +++ b/mcs/class/Mono.Security/Mono.Security/StrongName.cs @@ -239,7 +239,7 @@ namespace Mono.Security { byte[] publicKey = PublicKey; if (publicKey == null) return null; - HashAlgorithm ha = HashAlgorithm.Create (TokenAlgorithm); + HashAlgorithm ha = GetHashAlgorithm (TokenAlgorithm); byte[] hash = ha.ComputeHash (publicKey); // we need the last 8 bytes in reverse order keyToken = new byte [8]; @@ -250,6 +250,22 @@ namespace Mono.Security { } } + static HashAlgorithm GetHashAlgorithm (string algorithm) + { +#if FULL_AOT_RUNTIME + switch (algorithm.ToUpper (CultureInfo.InvariantCulture)) { + case "SHA1": + return new SHA1CryptoServiceProvider (); + case "MD5": + return new MD5CryptoServiceProvider (); + default: + throw new ArgumentException ("Unsupported hash algorithm for token"); + } +#else + return HashAlgorithm.Create (algorithm); +#endif + } + public string TokenAlgorithm { get { if (tokenAlgorithm == null) |