Skip to content

Commit 500bd96

Browse files
author
Cam Soper
committed
issues/44500
1 parent c44b3bf commit 500bd96

File tree

3 files changed

+68
-1
lines changed

3 files changed

+68
-1
lines changed

docs/core/compatibility/10.0.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Breaking changes in .NET 10
33
titleSuffix: ""
44
description: Navigate to the breaking changes in .NET 10.
5-
ms.date: 12/19/2024
5+
ms.date: 01/30/2025
66
no-loc: [Blazor, Razor, Kestrel]
77
---
88
# Breaking changes in .NET 10
@@ -20,3 +20,9 @@ If you're migrating an app to .NET 10, the breaking changes listed here might af
2020
| Title | Type of change | Introduced version |
2121
|------------------------------------------------------------------------------------------|---------------------|--------------------|
2222
| [API obsoletions with non-default diagnostic IDs](core-libraries/10.0/obsolete-apis.md) | Source incompatible | Preview 1 |
23+
24+
## Cryptography
25+
26+
| Title | Type of change | Introduced version |
27+
|------------------------------------------------------------------------------------------------------|---------------------|--------------------|
28+
| [Rfc2898DeriveBytes constructors are obsolete](cryptography/10.0/rfc2898derivebytes-constructors.md) | Source incompatible | Preview 1 |
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
title: "Breaking change: Rfc2898DeriveBytes constructors are obsolete"
3+
description: Learn about the .NET 10 breaking change in core .NET libraries where Rfc2898DeriveBytes constructors are obsolete.
4+
ms.date: 10/10/2023
5+
---
6+
# Rfc2898DeriveBytes constructors are obsolete
7+
8+
Starting in .NET 10, all of the constructors on `Rfc2898DeriveBytes` are obsolete.
9+
10+
## Previous behavior
11+
12+
The `Rfc2898DeriveBytes` had constructors that were not obsolete, or obsolete under a different diagnostic ID.
13+
14+
## New behavior
15+
16+
The `Rfc2898DeriveBytes` constructors are obsolete with SYSLIB0060 diagnostic ID and message:
17+
18+
> The constructors on Rfc2898DeriveBytes are obsolete. Use the static Pbkdf2 method instead.
19+
20+
## Version introduced
21+
22+
.NET 10 Preview 1
23+
24+
## Type of breaking change
25+
26+
This change is a [source incompatible](../../categories.md#source-incompatible) change.
27+
28+
## Reason for change
29+
30+
The instance-based implementation of PBKDF2, which `Rfc2898DeriveBytes` provides, offers a non-standard usage by "streaming" bytes back by allowing successive calls to `GetBytes`. This is not the intended use of PBKDF2, the algorithm should be used as a one-shot. The one-shot functionality exists as the static method [`Rfc2898DeriveBytes.Pbkdf2`](https://learn.microsoft.com/dotnet/api/system.security.cryptography.rfc2898derivebytes.pbkdf2) and should be used instead of instantiating `Rfc2898DeriveBytes`.
31+
32+
## Recommended action
33+
34+
Change instances of `Rfc2898DeriveBytes` and calls to `GetBytes` to use the `Pkbdf2` one-shot static method instead.
35+
36+
For example, change:
37+
38+
```csharp
39+
using System.Security.Cryptography;
40+
41+
Rfc2898DeriveBytes kdf = new Rfc2898DeriveBytes(password, salt, iterations, hashAlgorithm);
42+
byte[] derivedKey = kdf.GetBytes(64);
43+
```
44+
45+
to
46+
47+
```csharp
48+
byte[] derivedKey = Rfc2898DeriveBytes.Pbkdf2(password, salt, iterations, hashAlgorithm, 64);
49+
```
50+
51+
## Affected APIs
52+
53+
- <xref:System.Security.Cryptography.Rfc2898DeriveBytes.#ctor>

docs/core/compatibility/toc.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ items:
1212
items:
1313
- name: API obsoletions with non-default diagnostic IDs
1414
href: core-libraries/10.0/obsolete-apis.md
15+
- name: Cryptography
16+
items:
17+
- name: RRfc2898DeriveBytes constructors are obsolete
18+
href: cryptography/10.0/rfc2898derivebytes-constructors.md
1519
- name: .NET 9
1620
items:
1721
- name: Overview
@@ -1546,6 +1550,10 @@ items:
15461550
href: corefx.md
15471551
- name: Cryptography
15481552
items:
1553+
- name: .NET 10
1554+
items:
1555+
- name: Rfc2898DeriveBytes constructors are obsolete
1556+
href: cryptography/10.0/rfc2898derivedbytes-constructors.md
15491557
- name: .NET 9
15501558
items:
15511559
- name: SafeEvpPKeyHandle.DuplicateHandle up-refs the handle

0 commit comments

Comments
 (0)