Skip to content

Commit a42fef3

Browse files
authored
Cryptography breaking changes for .NET 8 (#33699)
1 parent 868ef08 commit a42fef3

File tree

8 files changed

+181
-14
lines changed

8 files changed

+181
-14
lines changed

docs/core/compatibility/8.0.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Breaking changes in .NET 8
33
description: Navigate to the breaking changes in .NET 8.
4-
ms.date: 01/19/2023
4+
ms.date: 01/24/2023
55
no-loc: [Blazor, Razor, Kestrel]
66
---
77
# Breaking changes in .NET 8
@@ -14,9 +14,16 @@ If you're migrating an app to .NET 8, the breaking changes listed here might aff
1414
>
1515
> This article is a work in progress. It's not a complete list of breaking changes in .NET 8. To query breaking changes that are still pending publication, see [Issues of .NET](https://issuesof.net/?q=%20is:open%20-label:Documented%20is:issue%20(label:%22Breaking%20Change%22%20or%20label:breaking-change)%20(repo:dotnet/docs%20or%20repo:aspnet/Announcements)%20group:repo%20(label:%22:checkered_flag:%20Release:%20.NET%208%22%20or%20label:8.0.0)%20sort:created-desc).
1616
17+
## Cryptography
18+
19+
| Title | Type of change | Introduced |
20+
| -------------------------------------------------------------------------------------------------------- | ----------------- | ---------- |
21+
| [AesGcm authentication tag size on macOS](cryptography/8.0/aesgcm-auth-tag-size.md) | Behavioral change | Preview 1 |
22+
| [RSA.EncryptValue and RSA.DecryptValue obsolete](cryptography/8.0/rsa-encrypt-decrypt-value-obsolete.md) | Behavioral change | Preview 1 |
23+
1724
## Windows Forms
1825

1926
| Title | Type of change | Introduced |
2027
| ----------------------------------------------------------------------------------------------------- | ----------------- | ---------- |
21-
| [Top-level forms scale minimum and maximum size to DPI](windows-forms/8.0/forms-scale-size-to-dpi.md) | Behavioral change | Preview 1 |
2228
| [Anchor layout changes](windows-forms/8.0/anchor-layout.md) | Behavioral change | Preview 1 |
29+
| [Top-level forms scale minimum and maximum size to DPI](windows-forms/8.0/forms-scale-size-to-dpi.md) | Behavioral change | Preview 1 |
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
title: "Breaking change: AesGcm authentication tag size on macOS"
3+
description: Learn about the .NET 8 breaking change in cryptography where AesGcm on macOS only supports 16-byte (128-bit) authentication tags.
4+
ms.date: 01/24/2023
5+
---
6+
# AesGcm authentication tag size on macOS
7+
8+
<xref:System.Security.Cryptography.AesGcm> on macOS only supports 16-byte (128-bit) authentication tags when using <xref:System.Security.Cryptography.AesGcm.Encrypt%2A> or <xref:System.Security.Cryptography.AesGcm.Decrypt%2A> in .NET 8 and later versions.
9+
10+
## Previous behavior
11+
12+
On macOS, <xref:System.Security.Cryptography.AesGcm.Encrypt%2A?nameWithType> and <xref:System.Security.Cryptography.AesGcm.Decrypt%2A?nameWithType> supported authentication tag sizes ranging from 12 to 16 bytes, provided OpenSSL was available.
13+
14+
In addition, the <xref:System.Security.Cryptography.AesGcm.TagByteSizes?displayProperty=nameWithType> property reported that it supported sizes ranging from 12 to 16 bytes, inclusive.
15+
16+
## New behavior
17+
18+
On macOS, <xref:System.Security.Cryptography.AesGcm.Encrypt%2A?nameWithType> and <xref:System.Security.Cryptography.AesGcm.Decrypt%2A?nameWithType> support 16-byte authentication tags only. If you use a smaller tag size on macOS, an <xref:System.ArgumentException> is thrown at run time.
19+
20+
The <xref:System.Security.Cryptography.AesGcm.TagByteSizes?displayProperty=nameWithType> property returns a value of 16 as the supported tag size.
21+
22+
## Version introduced
23+
24+
.NET 8 Preview 1
25+
26+
## Type of breaking change
27+
28+
This change is a [behavioral change](../../categories.md#behavioral-change).
29+
30+
## Reason for change
31+
32+
The <xref:System.Security.Cryptography.AesGcm> class on macOS previously relied on OpenSSL for underlying support. OpenSSL is an external dependency that needed to be installed and configured separately from .NET. <xref:System.Security.Cryptography.AesGcm> now uses Apple's CryptoKit to provide an implementation of Advanced Encryption Standard with Galois/Counter Mode (AES-GCM) so that OpenSSL is no longer a dependency for using <xref:System.Security.Cryptography.AesGcm>.
33+
34+
The CryptoKit implementation of AES-GCM does not support authentication tag sizes other than 128-bits (16-bytes).
35+
36+
## Recommended action
37+
38+
Use 128-bit authentication tags with <xref:System.Security.Cryptography.AesGcm> for macOS support.
39+
40+
## Affected APIs
41+
42+
- <xref:System.Security.Cryptography.AesGcm.TagByteSizes?displayProperty=fullName>
43+
- <xref:System.Security.Cryptography.AesGcm.Encrypt%2A?displayProperty=fullName>
44+
- <xref:System.Security.Cryptography.AesGcm.Decrypt%2A?displayProperty=fullName>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
title: "RSA.EncryptValue and RSA.DecryptValue are obsolete"
3+
description: Learn about the .NET 8 breaking change in cryptography where RSA.EncryptValue and RSA.DecryptValue are marked obsolete.
4+
ms.date: 01/24/2023
5+
---
6+
# RSA.EncryptValue and RSA.DecryptValue are obsolete
7+
8+
The following methods are obsolete in .NET 8 (and later versions):
9+
10+
- <xref:System.Security.Cryptography.RSA.EncryptValue(System.Byte[])?displayProperty=nameWithType>
11+
- <xref:System.Security.Cryptography.RSA.DecryptValue(System.Byte[])?displayProperty=nameWithType>
12+
- <xref:System.Security.Cryptography.RSACryptoServiceProvider.EncryptValue(System.Byte[])?displayProperty=nameWithType>
13+
- <xref:System.Security.Cryptography.RSACryptoServiceProvider.DecryptValue(System.Byte[])?displayProperty=nameWithType>
14+
15+
All references to these methods will result in a [SYSLIB0048](../../../../fundamentals/syslib-diagnostics/syslib0048.md) warning at compile time.
16+
17+
## Previous behavior
18+
19+
Previously, code could call the [affected methods](#affected-apis) without any compilation warnings. However, they threw a <xref:System.NotSupportedException> at run time.
20+
21+
## New behavior
22+
23+
Starting in .NET 8, calling the [affected methods](#affected-apis) produces a `SYSLIB0048` compilation warning.
24+
25+
## Version introduced
26+
27+
.NET 8 Preview 1
28+
29+
## Type of breaking change
30+
31+
This change can affect [source compatibility](../../categories.md#source-compatibility).
32+
33+
## Reason for change
34+
35+
The affected methods were never implemented and always threw a <xref:System.NotSupportedException>. Since the purpose of these methods is unclear and they shouldn't be called, they were marked as obsolete.
36+
37+
## Recommended action
38+
39+
To encrypt or decrypt with RSA, use <xref:System.Security.Cryptography.RSA.Encrypt%2A?displayProperty=nameWithType> or <xref:System.Security.Cryptography.RSA.Decrypt%2A?displayProperty=nameWithType> instead.
40+
41+
## Affected APIs
42+
43+
- <xref:System.Security.Cryptography.RSA.EncryptValue(System.Byte[])?displayProperty=fullName>
44+
- <xref:System.Security.Cryptography.RSA.DecryptValue(System.Byte[])?displayProperty=fullName>
45+
- <xref:System.Security.Cryptography.RSACryptoServiceProvider.EncryptValue(System.Byte[])?displayProperty=fullName>
46+
- <xref:System.Security.Cryptography.RSACryptoServiceProvider.DecryptValue(System.Byte[])?displayProperty=fullName>

docs/core/compatibility/toc.yml

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,22 @@ items:
44
- name: Breaking changes by version
55
expanded: true
66
items:
7+
- name: .NET 8
8+
items:
9+
- name: Overview
10+
href: 8.0.md
11+
- name: Cryptography
12+
items:
13+
- name: AesGcm authentication tag size on macOS
14+
href: cryptography/8.0/aesgcm-auth-tag-size.md
15+
- name: RSA.EncryptValue and RSA.DecryptValue are obsolete
16+
href: cryptography/8.0/rsa-encrypt-decrypt-value-obsolete.md
17+
- name: Windows Forms
18+
items:
19+
- name: Anchor layout changes
20+
href: windows-forms/8.0/anchor-layout.md
21+
- name: Top-level forms scale size to DPI
22+
href: windows-forms/8.0/forms-scale-size-to-dpi.md
723
- name: .NET 7
824
items:
925
- name: Overview
@@ -662,16 +678,6 @@ items:
662678
items:
663679
- name: ASP.NET Core
664680
items:
665-
- name: .NET 8
666-
items:
667-
- name: Overview
668-
href: 8.0.md
669-
- name: Windows Forms
670-
items:
671-
- name: Anchor layout changes
672-
href: windows-forms/8.0/anchor-layout.md
673-
- name: Top-level forms scale size to DPI
674-
href: windows-forms/8.0/forms-scale-size-to-dpi.md
675681
- name: .NET 7
676682
items:
677683
- name: API controller actions try to infer parameters from DI
@@ -1016,6 +1022,12 @@ items:
10161022
href: corefx.md
10171023
- name: Cryptography
10181024
items:
1025+
- name: .NET 8
1026+
items:
1027+
- name: AesGcm authentication tag size on macOS
1028+
href: cryptography/8.0/aesgcm-auth-tag-size.md
1029+
- name: RSA.EncryptValue and RSA.DecryptValue are obsolete
1030+
href: cryptography/8.0/rsa-encrypt-decrypt-value-obsolete.md
10191031
- name: .NET 7
10201032
items:
10211033
- name: Dynamic X509ChainPolicy verification time

docs/core/compatibility/unsupported-apis.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Unsupported APIs on .NET Core and .NET 5+
33
titleSuffix: ""
44
description: Learn which .NET APIs always throw an exception on .NET Core and .NET 5 and later versions.
5-
ms.date: 11/23/2021
5+
ms.date: 01/24/2023
66
---
77
# APIs that always throw exceptions on .NET Core and .NET 5+
88

@@ -271,6 +271,10 @@ This article organizes the affected APIs by namespace.
271271
| <xref:System.Security.Cryptography.KeyedHashAlgorithm.Create(System.String)?displayProperty=nameWithType> | All |
272272
| <xref:System.Security.Cryptography.ProtectedData.Protect%2A?displayProperty=nameWithType> | Linux and macOS |
273273
| <xref:System.Security.Cryptography.ProtectedData.Unprotect%2A?displayProperty=nameWithType> | Linux and macOS |
274+
| <xref:System.Security.Cryptography.RSACryptoServiceProvider.DecryptValue(System.Byte[])?displayProperty=fullName> | All |
275+
| <xref:System.Security.Cryptography.RSACryptoServiceProvider.EncryptValue(System.Byte[])?displayProperty=fullName> | All |
276+
| <xref:System.Security.Cryptography.RSA.DecryptValue(System.Byte[])?displayProperty=fullName> | All |
277+
| <xref:System.Security.Cryptography.RSA.EncryptValue(System.Byte[])?displayProperty=fullName> | All |
274278
| <xref:System.Security.Cryptography.RSA.FromXmlString%2A?displayProperty=nameWithType> | All |
275279
| <xref:System.Security.Cryptography.RSA.ToXmlString%2A?displayProperty=nameWithType> | All |
276280
| <xref:System.Security.Cryptography.SymmetricAlgorithm.Create?displayProperty=nameWithType> | All |

docs/fundamentals/syslib-diagnostics/obsoletions-overview.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Obsolete features in .NET 5+
33
titleSuffix: ""
44
description: Learn about APIs that are marked as obsolete in .NET 5 and later versions that produce SYSLIB compiler warnings.
5-
ms.date: 11/07/2022
5+
ms.date: 01/24/2023
66
---
77

88
# Obsolete features in .NET 5+
@@ -68,6 +68,7 @@ The following table provides an index to the `SYSLIB0XXX` obsoletions in .NET 5+
6868
| [SYSLIB0045](syslib0045.md) | Warning | Cryptographic factory methods accepting an algorithm name are obsolete. Use the parameterless `Create` factory method on the algorithm type instead. |
6969
| [SYSLIB0046](syslib0046.md) | Warning | The <xref:System.Runtime.ControlledExecution.Run(System.Action,System.Threading.CancellationToken)?displayProperty=nameWithType> method might corrupt the process and should not be used in production code. |
7070
| [SYSLIB0047](syslib0047.md) | Warning | <xref:System.Xml.XmlSecureResolver> is obsolete. Use `XmlResolver.ThrowingResolver` instead when attempting to forbid XML external entity resolution. |
71+
| [SYSLIB0048](syslib0048.md) | Warning | <xref:System.Security.Cryptography.RSA.EncryptValue(System.Byte[])?displayProperty=nameWithType> and <xref:System.Security.Cryptography.RSA.DecryptValue(System.Byte[])?displayProperty=nameWithType> are obsolete. Use <xref:System.Security.Cryptography.RSA.Encrypt%2A?displayProperty=nameWithType> and <xref:System.Security.Cryptography.RSA.Decrypt%2A?displayProperty=nameWithType> instead. |
7172

7273
## Suppress warnings
7374

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
title: SYSLIB0048 warning - RSA.EncryptValue and DecryptValue are obsolete
3+
description: Learn about the obsoletion of the RSA.EncryptValue and RSA.DecryptValue methods that generates compile-time warning SYSLIB0048.
4+
ms.date: 04/08/2022
5+
---
6+
# SYSLIB0048: RSA.EncryptValue and DecryptValue are obsolete
7+
8+
The following methods are obsolete, starting in .NET 8. Calling them in code generates warning `SYSLIB0048` at compile time.
9+
10+
- <xref:System.Security.Cryptography.RSA.EncryptValue(System.Byte[])?displayProperty=fullName>
11+
- <xref:System.Security.Cryptography.RSA.DecryptValue(System.Byte[])?displayProperty=fullName>
12+
- <xref:System.Security.Cryptography.RSACryptoServiceProvider.EncryptValue(System.Byte[])?displayProperty=fullName>
13+
- <xref:System.Security.Cryptography.RSACryptoServiceProvider.DecryptValue(System.Byte[])?displayProperty=fullName>
14+
15+
## Workaround
16+
17+
Use <xref:System.Security.Cryptography.RSA.Encrypt%2A?displayProperty=nameWithType> and <xref:System.Security.Cryptography.RSA.Decrypt%2A?displayProperty=nameWithType> instead.
18+
19+
## Suppress a warning
20+
21+
If you must use the obsolete APIs, you can suppress the warning in code or in your project file.
22+
23+
To suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the warning.
24+
25+
```csharp
26+
// Disable the warning.
27+
#pragma warning disable SYSLIB0048
28+
29+
// Code that uses obsolete API.
30+
// ...
31+
32+
// Re-enable the warning.
33+
#pragma warning restore SYSLIB0048
34+
```
35+
36+
To suppress all the `SYSLIB0048` warnings in your project, add a `<NoWarn>` property to your project file.
37+
38+
```xml
39+
<Project Sdk="Microsoft.NET.Sdk">
40+
<PropertyGroup>
41+
...
42+
<NoWarn>$(NoWarn);SYSLIB0048</NoWarn>
43+
</PropertyGroup>
44+
</Project>
45+
```
46+
47+
For more information, see [Suppress warnings](obsoletions-overview.md#suppress-warnings).
48+
49+
## See also
50+
51+
- [RSA.EncryptValue and RSA.DecryptValue are obsolete](../../core/compatibility/cryptography/8.0/rsa-encrypt-decrypt-value-obsolete.md)

docs/toc/tools-diagnostics/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,8 @@ items:
14441444
href: ../../fundamentals/syslib-diagnostics/syslib0046.md
14451445
- name: SYSLIB0047
14461446
href: ../../fundamentals/syslib-diagnostics/syslib0047.md
1447+
- name: SYSLIB0048
1448+
href: ../../fundamentals/syslib-diagnostics/syslib0048.md
14471449
- name: Source-generated code
14481450
items:
14491451
- name: Overview

0 commit comments

Comments
 (0)