Skip to content

Commit

Permalink
Mark System.Security.Cryptography.Algorithms as unsupported on Browse…
Browse files Browse the repository at this point in the history
…r WASM (dotnet#42010)

* Mark System.Security.Cryptography.Algorithms as unsupported on Browser WASM

* Address the comment regarding IncrementalHash.CreateHMAC

* Group System.* usings

* Restore the blank lines between the meta-comment and the code for all the HMAC classes

* Fix style issues

* Mark MD5 class as unsupported on Browser; clean up the api exclusion list and proj file.

* Using

* Style fix
  • Loading branch information
MaximLipnin authored and Mitchell Hwang committed Sep 15, 2020
1 parent a2b40bc commit ea8ab67
Show file tree
Hide file tree
Showing 49 changed files with 153 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<Import Project="..\Directory.Build.props" />
<PropertyGroup>
<StrongNameKeyId>Microsoft</StrongNameKeyId>
<IncludePlatformAttributes>true</IncludePlatformAttributes>
</PropertyGroup>
</Project>

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
T:System.Security.Cryptography.RandomNumberGenerator
T:System.Security.Cryptography.IncrementalHash
T:System.Security.Cryptography.MD5
T:System.Security.Cryptography.SHA1
T:System.Security.Cryptography.SHA256
T:System.Security.Cryptography.SHA384
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,6 @@
<Compile Include="Internal\Cryptography\SHAHashProvider.Browser.cs" />
<Compile Include="System\Security\Cryptography\RandomNumberGenerator.cs" />
<Compile Include="System\Security\Cryptography\IncrementalHash.cs" />
<Compile Include="System\Security\Cryptography\MD5.cs" />
<Compile Include="System\Security\Cryptography\SHA1.cs" />
<Compile Include="System\Security\Cryptography\SHA1Managed.cs" />
<Compile Include="System\Security\Cryptography\SHA256.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.Versioning;
using Internal.Cryptography;

namespace System.Security.Cryptography
{
[UnsupportedOSPlatform("browser")]
public abstract class Aes : SymmetricAlgorithm
{
protected Aes()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.Versioning;
using Internal.Cryptography;

namespace System.Security.Cryptography
{
[UnsupportedOSPlatform("browser")]
public sealed partial class AesCcm : IDisposable
{
public static KeySizes NonceByteSizes { get; } = new KeySizes(7, 13, 1);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.Versioning;
using Internal.Cryptography;

namespace System.Security.Cryptography
{
[UnsupportedOSPlatform("browser")]
public sealed partial class AesGcm : IDisposable
{
private const int NonceSize = 12;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.ComponentModel;
using System.Runtime.Versioning;

namespace System.Security.Cryptography
{
[UnsupportedOSPlatform("browser")]
[EditorBrowsable(EditorBrowsableState.Never)]
public sealed class AesManaged : Aes
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.Versioning;

namespace System.Security.Cryptography
{
[UnsupportedOSPlatform("browser")]
public abstract class AsymmetricKeyExchangeDeformatter
{
protected AsymmetricKeyExchangeDeformatter() { }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.Versioning;

namespace System.Security.Cryptography
{
[UnsupportedOSPlatform("browser")]
public abstract class AsymmetricKeyExchangeFormatter
{
protected AsymmetricKeyExchangeFormatter() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics;
using System.Runtime.Versioning;
using Internal.Cryptography;

namespace System.Security.Cryptography
{
[UnsupportedOSPlatform("browser")]
public abstract class AsymmetricSignatureDeformatter
{
protected AsymmetricSignatureDeformatter() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics;
using System.Runtime.Versioning;
using Internal.Cryptography;

namespace System.Security.Cryptography
{
[UnsupportedOSPlatform("browser")]
public abstract class AsymmetricSignatureFormatter
{
protected AsymmetricSignatureFormatter() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
using System.Globalization;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;

namespace System.Security.Cryptography
{
[UnsupportedOSPlatform("browser")]
public class CryptoConfig
{
private const string AssemblyName_Cng = "System.Security.Cryptography.Cng";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Internal.Cryptography;
using System.ComponentModel;
using System.Buffers.Binary;
using System.ComponentModel;
using System.Runtime.Versioning;
using Internal.Cryptography;

namespace System.Security.Cryptography
{
[UnsupportedOSPlatform("browser")]
[EditorBrowsable(EditorBrowsableState.Never)]
public abstract class DES : SymmetricAlgorithm
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
using System.Diagnostics;
using System.Formats.Asn1;
using System.IO;
using System.Runtime.Versioning;
using System.Security.Cryptography.Asn1;
using Internal.Cryptography;

namespace System.Security.Cryptography
{
[UnsupportedOSPlatform("browser")]
public abstract partial class DSA : AsymmetricAlgorithm
{
// As of FIPS 186-4 the maximum Q size is 256 bits (32 bytes).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.Versioning;
using Internal.Cryptography;

namespace System.Security.Cryptography
{
[UnsupportedOSPlatform("browser")]
public class DSASignatureDeformatter : AsymmetricSignatureDeformatter
{
private DSA? _dsaKey;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.Versioning;
using Internal.Cryptography;

namespace System.Security.Cryptography
{
[UnsupportedOSPlatform("browser")]
public class DSASignatureFormatter : AsymmetricSignatureFormatter
{
private DSA? _dsaKey;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.Versioning;

namespace System.Security.Cryptography
{
[UnsupportedOSPlatform("browser")]
public abstract class DeriveBytes : IDisposable
{
public abstract byte[] GetBytes(int cb);
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.

using System.Diagnostics;
using System.Runtime.Versioning;

namespace System.Security.Cryptography
{
Expand All @@ -13,6 +14,7 @@ namespace System.Security.Cryptography
/// which is either a prime curve or a characteristic-2 curve.
/// </remarks>
[DebuggerDisplay("ECCurve: {Oid}")]
[UnsupportedOSPlatform("browser")]
public partial struct ECCurve
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Formats.Asn1;
using Internal.Cryptography;
using System.Runtime.Versioning;
using System.Security.Cryptography.Asn1;
using Internal.Cryptography;

namespace System.Security.Cryptography
{
/// <summary>
/// Abstract base class for implementations of elliptic curve Diffie-Hellman to derive from
/// </summary>
[UnsupportedOSPlatform("browser")]
public abstract partial class ECDiffieHellman : AsymmetricAlgorithm
{
private static readonly string[] s_validOids =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
using System.Diagnostics;
using System.Formats.Asn1;
using System.IO;
using System.Runtime.Versioning;
using System.Security.Cryptography.Asn1;

namespace System.Security.Cryptography
{
[UnsupportedOSPlatform("browser")]
public abstract partial class ECDsa : AsymmetricAlgorithm
{
// secp521r1 maxes out at 139 bytes in the DER format, so 256 should always be enough
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@

using System.Buffers;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Cryptography.Asn1;

namespace System.Security.Cryptography
{
/// <summary>
/// Represents the public and private key of the specified elliptic curve.
/// </summary>
[UnsupportedOSPlatform("browser")]
public struct ECParameters
{
/// <summary>
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.

using System.Diagnostics;
using System.Runtime.Versioning;

namespace System.Security.Cryptography
{
Expand All @@ -13,6 +14,7 @@ namespace System.Security.Cryptography
/// phase to be skipped, and the master key to be used directly as the pseudorandom key.
/// See <a href="https://tools.ietf.org/html/rfc5869">RFC5869</a> for more information.
/// </remarks>
[UnsupportedOSPlatform("browser")]
public static class HKDF
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.Versioning;
using Internal.Cryptography;

namespace System.Security.Cryptography
Expand All @@ -10,6 +11,7 @@ namespace System.Security.Cryptography
// preexisting contract from the .NET Framework locks all of these into deriving directly from HMAC, it can't be helped.
//

[UnsupportedOSPlatform("browser")]
public class HMACMD5 : HMAC
{
public HMACMD5()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using Internal.Cryptography;
using System.ComponentModel;
using System.Runtime.Versioning;

namespace System.Security.Cryptography
{
Expand All @@ -11,6 +12,7 @@ namespace System.Security.Cryptography
// preexisting contract from the .NET Framework locks all of these into deriving directly from HMAC, it can't be helped.
//

[UnsupportedOSPlatform("browser")]
public class HMACSHA1 : HMAC
{
public HMACSHA1()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

using System;
using System.Diagnostics;
using System.Runtime.Versioning;
using System.Security.Cryptography;

using Internal.Cryptography;

namespace System.Security.Cryptography
Expand All @@ -14,6 +14,7 @@ namespace System.Security.Cryptography
// preexisting contract from the .NET Framework locks all of these into deriving directly from HMAC, it can't be helped.
//

[UnsupportedOSPlatform("browser")]
public class HMACSHA256 : HMAC
{
public HMACSHA256()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

using System;
using System.Diagnostics;
using System.Runtime.Versioning;
using System.Security.Cryptography;

using Internal.Cryptography;

namespace System.Security.Cryptography
Expand All @@ -14,6 +14,7 @@ namespace System.Security.Cryptography
// preexisting contract from the .NET Framework locks all of these into deriving directly from HMAC, it can't be helped.
//

[UnsupportedOSPlatform("browser")]
public class HMACSHA384 : HMAC
{
public HMACSHA384()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

using System;
using System.Diagnostics;
using System.Runtime.Versioning;
using System.Security.Cryptography;

using Internal.Cryptography;

namespace System.Security.Cryptography
Expand All @@ -14,6 +14,7 @@ namespace System.Security.Cryptography
// preexisting contract from the .NET Framework locks all of these into deriving directly from HMAC, it can't be helped.
//

[UnsupportedOSPlatform("browser")]
public class HMACSHA512 : HMAC
{
public HMACSHA512()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics;
using Internal.Cryptography;
using System.Diagnostics;
using System.Runtime.Versioning;

namespace System.Security.Cryptography
{
Expand Down Expand Up @@ -346,6 +347,7 @@ public static IncrementalHash CreateHash(HashAlgorithmName hashAlgorithm)
/// the empty string.
/// </exception>
/// <exception cref="CryptographicException"><paramref name="hashAlgorithm"/> is not a known hash algorithm.</exception>
[UnsupportedOSPlatform("browser")]
public static IncrementalHash CreateHMAC(HashAlgorithmName hashAlgorithm, byte[] key)
{
if (key == null)
Expand Down Expand Up @@ -376,6 +378,7 @@ public static IncrementalHash CreateHMAC(HashAlgorithmName hashAlgorithm, byte[]
/// the empty string.
/// </exception>
/// <exception cref="CryptographicException"><paramref name="hashAlgorithm"/> is not a known hash algorithm.</exception>
[UnsupportedOSPlatform("browser")]
public static IncrementalHash CreateHMAC(HashAlgorithmName hashAlgorithm, ReadOnlySpan<byte> key)
{
if (string.IsNullOrEmpty(hashAlgorithm.Name))
Expand Down
Loading

0 comments on commit ea8ab67

Please sign in to comment.