Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions eng/native/configurecompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -670,22 +670,22 @@ if (CLR_CMAKE_HOST_UNIX)
set(DISABLE_OVERRIDING_MIN_VERSION_ERROR -Wno-overriding-t-option)
add_link_options(-Wno-overriding-t-option)
if(CLR_CMAKE_HOST_ARCH_ARM64)
set(MACOS_VERSION_MIN_FLAGS "-target arm64-apple-ios15.0-macabi")
add_link_options(-target arm64-apple-ios15.0-macabi)
set(CLR_CMAKE_MACCATALYST_COMPILER_TARGET "arm64-apple-ios15.0-macabi")
add_link_options(-target ${CLR_CMAKE_MACCATALYST_COMPILER_TARGET})
elseif(CLR_CMAKE_HOST_ARCH_AMD64)
set(MACOS_VERSION_MIN_FLAGS "-target x86_64-apple-ios15.0-macabi")
add_link_options(-target x86_64-apple-ios15.0-macabi)
set(CLR_CMAKE_MACCATALYST_COMPILER_TARGET "x86_64-apple-ios15.0-macabi")
add_link_options(-target ${CLR_CMAKE_MACCATALYST_COMPILER_TARGET})
else()
clr_unknown_arch()
endif()
# These options are intentionally set using the CMAKE_XXX_FLAGS instead of
# add_compile_options so that they take effect on the configuration functions
# in various configure.cmake files.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MACOS_VERSION_MIN_FLAGS} ${DISABLE_OVERRIDING_MIN_VERSION_ERROR}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MACOS_VERSION_MIN_FLAGS} ${DISABLE_OVERRIDING_MIN_VERSION_ERROR}")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${MACOS_VERSION_MIN_FLAGS} ${DISABLE_OVERRIDING_MIN_VERSION_ERROR}")
set(CMAKE_OBJC_FLAGS "${CMAKE_OBJC_FLAGS} ${MACOS_VERSION_MIN_FLAGS} ${DISABLE_OVERRIDING_MIN_VERSION_ERROR}")
set(CMAKE_OBJCXX_FLAGS "${CMAKE_OBJCXX_FLAGS} ${MACOS_VERSION_MIN_FLAGS} ${DISABLE_OVERRIDING_MIN_VERSION_ERROR}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -target ${CLR_CMAKE_MACCATALYST_COMPILER_TARGET} ${DISABLE_OVERRIDING_MIN_VERSION_ERROR}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -target ${CLR_CMAKE_MACCATALYST_COMPILER_TARGET} ${DISABLE_OVERRIDING_MIN_VERSION_ERROR}")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -target ${CLR_CMAKE_MACCATALYST_COMPILER_TARGET} ${DISABLE_OVERRIDING_MIN_VERSION_ERROR}")
set(CMAKE_OBJC_FLAGS "${CMAKE_OBJC_FLAGS}-target ${CLR_CMAKE_MACCATALYST_COMPILER_TARGET} ${DISABLE_OVERRIDING_MIN_VERSION_ERROR}")
set(CMAKE_OBJCXX_FLAGS "${CMAKE_OBJCXX_FLAGS} -target ${CLR_CMAKE_MACCATALYST_COMPILER_TARGET} ${DISABLE_OVERRIDING_MIN_VERSION_ERROR}")
elseif(CLR_CMAKE_HOST_OSX)
set(CMAKE_OSX_DEPLOYMENT_TARGET "12.0")
if(CLR_CMAKE_HOST_ARCH_ARM64)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ The .NET Foundation licenses this file to you under the MIT license.

<ItemGroup Condition="'$(_IsApplePlatform)' == 'true'">
<NativeFramework Include="CoreFoundation" />
<NativeFramework Condition="'$(_targetOS)' == 'osx'" Include="CryptoKit" />
<NativeFramework Include="CryptoKit" />
<NativeFramework Include="Foundation" />
<NativeFramework Include="Security" />
<!-- The library builds don't reference the GSS API on tvOS builds. -->
Expand All @@ -188,8 +188,8 @@ The .NET Foundation licenses this file to you under the MIT license.
<NativeSystemLibrary Include="stdc++" Condition="'$(LinkStandardCPlusPlusLibrary)' == 'true'" />
<NativeSystemLibrary Include="dl" />
<NativeSystemLibrary Include="objc" Condition="'$(_IsApplePlatform)' == 'true'" />
<NativeSystemLibrary Include="swiftCore" Condition="'$(_targetOS)' == 'osx'" />
<NativeSystemLibrary Include="swiftFoundation" Condition="'$(_targetOS)' == 'osx'" />
<NativeSystemLibrary Include="swiftCore" Condition="'$(_IsApplePlatform)' == 'true'" />
<NativeSystemLibrary Include="swiftFoundation" Condition="'$(_IsApplePlatform)' == 'true'" />
<NativeSystemLibrary Include="z" Condition="'$(UseSystemZlib)' == 'true'" />
<NativeSystemLibrary Include="rt" Condition="'$(_IsApplePlatform)' != 'true' and '$(_linuxLibcFlavor)' != 'bionic'" />
<NativeSystemLibrary Include="log" Condition="'$(_linuxLibcFlavor)' == 'bionic'" />
Expand All @@ -214,7 +214,7 @@ The .NET Foundation licenses this file to you under the MIT license.
<LinkerArg Include="-Wl,-e0x0" Condition="'$(NativeLib)' == 'Shared' and '$(_IsApplePlatform)' != 'true'" />
<LinkerArg Include="-pthread" Condition="'$(_IsApplePlatform)' != 'true'" />
<LinkerArg Include="@(NativeSystemLibrary->'-l%(Identity)')" />
<LinkerArg Include="-L/usr/lib/swift" Condition="'$(_targetOS)' == 'osx'" />
<LinkerArg Include="-L/usr/lib/swift" Condition="'$(_IsApplePlatform)' == 'true'" />
<LinkerArg Include="@(StaticICULibs)" Condition="'$(StaticICULinking)' == 'true'" />
<LinkerArg Include="@(StaticSslLibs)" Condition="'$(StaticOpenSslLinking)' == 'true'" />
<LinkerArg Include="-static" Condition="'$(StaticExecutable)' == 'true' and '$(PositionIndependentExecutable)' == 'false'" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.Swift;
using System.Runtime.Versioning;
using System.Security.Cryptography;
using System.Security.Cryptography.Apple;
using Swift.Runtime;
Expand All @@ -27,6 +28,11 @@ private static ref readonly byte GetSwiftRef(ReadOnlySpan<byte> b)
: ref MemoryMarshal.GetReference(b));
}

[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[SupportedOSPlatform("maccatalyst")]
[SupportedOSPlatform("ios13.0")]
[SupportedOSPlatform("tvos13.0")]
internal static unsafe void ChaCha20Poly1305Encrypt(
ReadOnlySpan<byte> key,
ReadOnlySpan<byte> nonce,
Expand Down Expand Up @@ -60,6 +66,11 @@ internal static unsafe void ChaCha20Poly1305Encrypt(
}
}

[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[SupportedOSPlatform("maccatalyst")]
[SupportedOSPlatform("ios13.0")]
[SupportedOSPlatform("tvos13.0")]
internal static unsafe void ChaCha20Poly1305Decrypt(
ReadOnlySpan<byte> key,
ReadOnlySpan<byte> nonce,
Expand Down Expand Up @@ -100,6 +111,11 @@ internal static unsafe void ChaCha20Poly1305Decrypt(
}
}

[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[SupportedOSPlatform("maccatalyst")]
[SupportedOSPlatform("ios13.0")]
[SupportedOSPlatform("tvos13.0")]
internal static unsafe void AesGcmEncrypt(
ReadOnlySpan<byte> key,
ReadOnlySpan<byte> nonce,
Expand Down Expand Up @@ -133,6 +149,11 @@ internal static unsafe void AesGcmEncrypt(
}
}

[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[SupportedOSPlatform("maccatalyst")]
[SupportedOSPlatform("ios13.0")]
[SupportedOSPlatform("tvos13.0")]
internal static unsafe void AesGcmDecrypt(
ReadOnlySpan<byte> key,
ReadOnlySpan<byte> nonce,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ public void KeySizeProp()
}

[Theory, MemberData(nameof(TestNewCurves))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/51332", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)]
public void TestRegenKeyExplicit(CurveDef curveDef)
{
ECParameters param, param2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ public override void GenerateKey() { }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")]
[System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")]
[System.Runtime.Versioning.SupportedOSPlatform("ios13.0")]
[System.Runtime.Versioning.SupportedOSPlatform("tvos13.0")]
public sealed partial class AesGcm : System.IDisposable
{
[System.ObsoleteAttribute("AesGcm should indicate the required tag size for encryption and decryption. Use a constructor that accepts the tag size.", DiagnosticId="SYSLIB0053", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
Expand Down Expand Up @@ -284,6 +287,9 @@ public AuthenticationTagMismatchException(string? message, System.Exception? inn
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")]
[System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")]
[System.Runtime.Versioning.SupportedOSPlatform("ios13.0")]
[System.Runtime.Versioning.SupportedOSPlatform("tvos13.0")]
public sealed partial class ChaCha20Poly1305 : System.IDisposable
{
public ChaCha20Poly1305(byte[] key) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,10 @@
Link="Common\Interop\OSX\Interop.CoreFoundation.CFString.cs" />
<Compile Include="$(CommonPath)Interop\OSX\Interop.Libraries.cs"
Link="Common\Interop\OSX\Interop.Libraries.cs" />
<Compile Include="$(CommonPath)Interop\OSX\Swift.Runtime\UnsafeBufferPointer.cs"
Link="Common\Interop\OSX\Swift.Runtime\UnsafeBufferPointer.cs" />
<Compile Include="$(CommonPath)Interop\OSX\System.Security.Cryptography.Native.Apple\Interop.Aead.cs"
Link="Common\Interop\OSX\System.Security.Cryptography.Native.Apple\Interop.Aead.cs" />
<Compile Include="$(CommonPath)Interop\OSX\System.Security.Cryptography.Native.Apple\Interop.Digest.cs"
Link="Common\Interop\OSX\System.Security.Cryptography.Native.Apple\Interop.Digest.cs" />
<Compile Include="$(CommonPath)Interop\OSX\System.Security.Cryptography.Native.Apple\Interop.Ecc.cs"
Expand Down Expand Up @@ -1128,6 +1132,8 @@
<Compile Include="$(CommonPath)System\Security\Cryptography\SecKeyPair.cs"
Link="Common\System\Security\Cryptography\SecKeyPair.cs" />
<Compile Include="System\Security\Cryptography\AesImplementation.Apple.cs" />
<Compile Include="System\Security\Cryptography\AesGcm.Apple.cs" />
<Compile Include="System\Security\Cryptography\ChaCha20Poly1305.Apple.cs" />
<Compile Include="System\Security\Cryptography\AppleCCCryptor.cs" />
<Compile Include="System\Security\Cryptography\AppleCCCryptorLite.cs" />
<Compile Include="System\Security\Cryptography\AsnFormatter.Managed.cs" />
Expand Down Expand Up @@ -1219,10 +1225,6 @@
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.EvpPkey.Rsa.cs" />
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.OpenSslVersion.cs"
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.OpenSslVersion.cs" />
<Compile Include="$(CommonPath)Interop\OSX\Swift.Runtime\UnsafeBufferPointer.cs"
Link="Common\Interop\OSX\Swift.Runtime\UnsafeBufferPointer.cs" />
<Compile Include="$(CommonPath)Interop\OSX\System.Security.Cryptography.Native.Apple\Interop.Aead.cs"
Link="Common\Interop\OSX\System.Security.Cryptography.Native.Apple\Interop.Aead.cs" />
<Compile Include="$(CommonPath)Interop\OSX\System.Security.Cryptography.Native.Apple\Interop.Keychain.macOS.cs"
Link="Common\Interop\OSX\System.Security.Cryptography.Native.Apple\Interop.Keychain.macOS.cs" />
<Compile Include="$(CommonPath)Interop\OSX\System.Security.Cryptography.Native.Apple\Interop.SecKeyRef.macOS.cs"
Expand Down Expand Up @@ -1253,8 +1255,6 @@
Link="Common\System\Security\Cryptography\RSASecurityTransforms.macOS.cs" />
<Compile Include="$(CommonPath)System\Security\Cryptography\RSAOpenSsl.cs"
Link="Common\System\Security\Cryptography\RSAOpenSsl.cs" />
<Compile Include="System\Security\Cryptography\AesGcm.macOS.cs" />
<Compile Include="System\Security\Cryptography\ChaCha20Poly1305.macOS.cs" />
<Compile Include="System\Security\Cryptography\DSA.Create.SecurityTransforms.cs" />
<Compile Include="System\Security\Cryptography\DSACryptoServiceProvider.Unix.cs" />
<Compile Include="System\Security\Cryptography\DSAOpenSsl.cs" />
Expand Down Expand Up @@ -1285,8 +1285,6 @@
<Compile Include="$(CommonPath)System\Security\Cryptography\RSASecurityTransforms.iOS.cs"
Link="Common\System\Security\Cryptography\RSASecurityTransforms.iOS.cs" />
<Compile Include="System\Security\Cryptography\AesCcm.NotSupported.cs" />
<Compile Include="System\Security\Cryptography\AesGcm.NotSupported.cs" />
<Compile Include="System\Security\Cryptography\ChaCha20Poly1305.NotSupported.cs" />
<Compile Include="System\Security\Cryptography\DSA.Create.NotSupported.cs" />
<Compile Include="System\Security\Cryptography\DSACryptoServiceProvider.NotSupported.cs" />
<Compile Include="System\Security\Cryptography\OpenSsl.NotSupported.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public sealed partial class AesGcm
{
private FixedMemoryKeyBox _keyBox;

// CryptoKit added AES.GCM in macOS 10.15, which is lower than our minimum target for macOS.
public static bool IsSupported => true;
// CryptoKit added AES.GCM in macOS 10.15, which is lower than our minimum target for macOS/MacCatalyst. On iOS/tvOS, it was added in 13.0.
public static bool IsSupported => OperatingSystem.IsMacOS() || OperatingSystem.IsMacCatalyst() || OperatingSystem.IsIOSVersionAtLeast(13) || OperatingSystem.IsTvOSVersionAtLeast(13);

// CryptoKit only supports 16 byte tags.
public static KeySizes TagByteSizes { get; } = new KeySizes(16, 16, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ namespace System.Security.Cryptography
[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[SupportedOSPlatform("maccatalyst")]
[SupportedOSPlatform("ios13.0")]
[SupportedOSPlatform("tvos13.0")]
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 @@ -8,8 +8,8 @@ namespace System.Security.Cryptography
{
public sealed partial class ChaCha20Poly1305
{
// CryptoKit added ChaCha20Poly1305 in macOS 10.15, which is lower than our minimum target for macOS.
public static bool IsSupported => true;
// CryptoKit added ChaCha20Poly1305 in macOS 10.15, which is lower than our minimum target for macOS/MacCatalyst. On iOS/tvOS, it was added in 13.0.
public static bool IsSupported => OperatingSystem.IsMacOS() || OperatingSystem.IsMacCatalyst() || OperatingSystem.IsIOSVersionAtLeast(13) || OperatingSystem.IsTvOSVersionAtLeast(13);
private FixedMemoryKeyBox _keyBox;

[MemberNotNull(nameof(_keyBox))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ namespace System.Security.Cryptography
[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[SupportedOSPlatform("maccatalyst")]
[SupportedOSPlatform("ios13.0")]
[SupportedOSPlatform("tvos13.0")]
public sealed partial class ChaCha20Poly1305 : IDisposable
{
// Per https://tools.ietf.org/html/rfc7539, ChaCha20Poly1305 AEAD requires a 256-bit key and 96-bit nonce,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ namespace System.Security.Cryptography.Tests
public class AesCcmTests : CommonAEADTests
{
[Theory]
[ActiveIssue("https://github.com/dotnet/runtime/issues/51332", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)]
[MemberData(nameof(EncryptTamperAADDecryptTestInputs))]
public static void EncryptTamperAADDecrypt(int dataLength, int additionalDataLength)
{
Expand Down Expand Up @@ -73,7 +72,6 @@ public static void InvalidNonceSize(int nonceSize)

[Theory]
[MemberData(nameof(GetValidNonceSizes))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/51332", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)]
public static void ValidNonceSize(int nonceSize)
{
const int dataLength = 35;
Expand Down Expand Up @@ -116,7 +114,6 @@ public static void InvalidTagSize(int tagSize)

[Theory]
[MemberData(nameof(GetValidTagSizes))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/51332", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)]
public static void ValidTagSize(int tagSize)
{
const int dataLength = 35;
Expand All @@ -139,7 +136,6 @@ public static void ValidTagSize(int tagSize)
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/51332", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)]
public static void TwoEncryptionsAndDecryptionsUsingOneInstance()
{
byte[] key = "d5a194ed90cfe08abecd4691997ceb2c".HexToByteArray();
Expand Down Expand Up @@ -267,7 +263,6 @@ public static void EncryptDecryptNullTag()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/51332", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)]
public static void InplaceEncryptDecrypt()
{
byte[] key = "d5a194ed90cfe08abecd4691997ceb2c".HexToByteArray();
Expand All @@ -288,7 +283,6 @@ public static void InplaceEncryptDecrypt()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/51332", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)]
public static void InplaceEncryptTamperTagDecrypt()
{
byte[] key = "d5a194ed90cfe08abecd4691997ceb2c".HexToByteArray();
Expand All @@ -313,7 +307,6 @@ public static void InplaceEncryptTamperTagDecrypt()

[Theory]
[MemberData(nameof(GetNistCcmTestCases))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/51332", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)]
public static void AesCcmNistTests(AEADTest testCase)
{
using (var aesCcm = new AesCcm(testCase.Key))
Expand All @@ -332,7 +325,6 @@ public static void AesCcmNistTests(AEADTest testCase)

[Theory]
[MemberData(nameof(GetNistCcmTestCases))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/51332", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)]
public static void AesCcmNistTestsTamperTag(AEADTest testCase)
{
using (var aesCcm = new AesCcm(testCase.Key))
Expand All @@ -355,7 +347,6 @@ public static void AesCcmNistTestsTamperTag(AEADTest testCase)

[Theory]
[MemberData(nameof(GetNistCcmTestCasesWithNonEmptyPT))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/51332", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)]
public static void AesCcmNistTestsTamperCiphertext(AEADTest testCase)
{
using (var aesCcm = new AesCcm(testCase.Key))
Expand Down
Loading