-
Notifications
You must be signed in to change notification settings - Fork 6k
Add breaking change documentation for CoseSigner.Key property nullability #47740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0aa7665
Initial plan
Copilot aea4b35
Add breaking change documentation for CoseSigner.Key property
Copilot 07c5c79
Apply suggestions from code review
gewarren be939c8
Update date
gewarren 34f3739
Update docs/core/compatibility/cryptography/10.0/cosesigner-key-null.md
gewarren File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
docs/core/compatibility/cryptography/10.0/cosesigner-key-null.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
title: "Breaking change - CoseSigner.Key may now be null" | ||
description: "Learn about the breaking change in .NET 10 where CoseSigner.Key may now be null when backed by Post-Quantum Cryptography algorithms." | ||
ms.date: 01/25/2025 | ||
ai-usage: ai-assisted | ||
ms.custom: https://github.com/dotnet/docs/issues/46999 | ||
--- | ||
|
||
# CoseSigner.Key can now be null | ||
|
||
In .NET 10, the <xref:System.Security.Cryptography.Cose.CoseSigner.Key?displayProperty=nameWithType> property can now return `null`. If `CoseSigner` is backed by an RSA or ECDSA key, then `CoseSigner.Key` returns a non-null key. However, when `CoseSigner` is backed by a key that doesn't derive from <xref:System.Security.Cryptography.AsymmetricAlgorithm>, like `MLDsa` (a new Post-Quantum Cryptography (PQC) signing algorithm), `CoseSigner.Key` returns `null`. | ||
|
||
## Version introduced | ||
|
||
.NET 10 Preview 7 | ||
|
||
## Previous behavior | ||
|
||
`CoseSigner.Key` couldn't be `null`. It had type `AsymmetricAlgorithm`. | ||
|
||
## New behavior | ||
|
||
`CoseSigner.Key` can be `null`. Its type is `AsymmetricAlgorithm?`. | ||
|
||
```csharp | ||
using RSA rsaKey = RSA.Create(); | ||
|
||
CoseSigner signer = new CoseSigner(rsaKey, RSASignaturePadding.Pss, HashAlgorithmName.SHA512); | ||
// signer.Key is rsaKey here. | ||
|
||
// CoseKey is a new abstraction for all keys used in COSE. | ||
CoseKey coseKey = new CoseKey(rsaKey, RSASignaturePadding.Pss, HashAlgorithmName.SHA512); | ||
signer = new CoseSigner(coseKey); | ||
// signer.Key is rsaKey here. | ||
|
||
using MLDsa mldsa = MLDsa.GenerateKey(MLDsaAlgorithm.MLDsa44); | ||
|
||
coseKey = new CoseKey(mldsa); | ||
signer = new CoseSigner(coseKey); | ||
// signer.Key is null here. | ||
``` | ||
|
||
## Type of breaking change | ||
|
||
This is both a [behavioral change](../../categories.md#behavioral-change) but it can also affect [source compatibility](../../categories.md#source-compatibility). | ||
gewarren marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
## Reason for change | ||
|
||
With the introduction of new signing algorithms such as ML-DSA, .NET has moved away from using `AsymmetricAlgorithm` as the universal base class for all asymmetric algorithms. Likewise, `CoseSigner` can now be constructed with a key that doesn't derive from `AsymmetricAlgorithm`. In this case `CoseSigner.Key` can't return an `AsymmetricAlgorithm` representing the underlying key and thus returns `null` instead. | ||
|
||
## Recommended action | ||
|
||
It's still okay to use `CoseSigner.Key` but be sure to handle `null` values. | ||
|
||
## Affected APIs | ||
|
||
- <xref:System.Security.Cryptography.Cose.CoseSigner.Key?displayProperty=fullName> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.