Skip to content

Commit 4f74041

Browse files
authored
Add breaking change documentation for CoseSigner.Key property nullability (dotnet#47740)
1 parent c17bda3 commit 4f74041

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

docs/core/compatibility/10.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ If you're migrating an app to .NET 10, the breaking changes listed here might af
5656

5757
| Title | Type of change | Introduced version |
5858
|-------|-------------------|--------------------|
59+
| [CoseSigner.Key can be null](cryptography/10.0/cosesigner-key-null.md) | Behavioral/source incompatible change | Preview 7 |
5960
| [OpenSSL cryptographic primitives aren't supported on macOS](cryptography/10.0/openssl-macos-unsupported.md) | Behavioral change | Preview 6 |
6061
| [X500DistinguishedName validation is stricter](cryptography/10.0/x500distinguishedname-validation.md) | Behavioral change | Preview 1 |
6162
| [X509Certificate and PublicKey key parameters can be null](cryptography/10.0/x509-publickey-null.md) | Behavioral/source incompatible change | Preview 3 |
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
title: "Breaking change - CoseSigner.Key may now be null"
3+
description: "Learn about the breaking change in .NET 10 where CoseSigner.Key may now be null when backed by Post-Quantum Cryptography algorithms."
4+
ms.date: 08/07/2025
5+
ai-usage: ai-assisted
6+
ms.custom: https://github.com/dotnet/docs/issues/46999
7+
---
8+
9+
# CoseSigner.Key can now be null
10+
11+
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`.
12+
13+
## Version introduced
14+
15+
.NET 10 Preview 7
16+
17+
## Previous behavior
18+
19+
`CoseSigner.Key` couldn't be `null`. It had type `AsymmetricAlgorithm`.
20+
21+
## New behavior
22+
23+
`CoseSigner.Key` can be `null`. Its type is `AsymmetricAlgorithm?`.
24+
25+
```csharp
26+
using RSA rsaKey = RSA.Create();
27+
28+
CoseSigner signer = new CoseSigner(rsaKey, RSASignaturePadding.Pss, HashAlgorithmName.SHA512);
29+
// signer.Key is rsaKey here.
30+
31+
// CoseKey is a new abstraction for all keys used in COSE.
32+
CoseKey coseKey = new CoseKey(rsaKey, RSASignaturePadding.Pss, HashAlgorithmName.SHA512);
33+
signer = new CoseSigner(coseKey);
34+
// signer.Key is rsaKey here.
35+
36+
using MLDsa mldsa = MLDsa.GenerateKey(MLDsaAlgorithm.MLDsa44);
37+
38+
coseKey = new CoseKey(mldsa);
39+
signer = new CoseSigner(coseKey);
40+
// signer.Key is null here.
41+
```
42+
43+
## Type of breaking change
44+
45+
This is a [behavioral change](../../categories.md#behavioral-change) but it can also affect [source compatibility](../../categories.md#source-compatibility).
46+
47+
## Reason for change
48+
49+
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.
50+
51+
## Recommended action
52+
53+
It's still okay to use `CoseSigner.Key` but be sure to handle `null` values.
54+
55+
## Affected APIs
56+
57+
- <xref:System.Security.Cryptography.Cose.CoseSigner.Key?displayProperty=fullName>

docs/core/compatibility/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ items:
4040
href: core-libraries/10.0/ymm-embedded-rounding.md
4141
- name: Cryptography
4242
items:
43+
- name: CoseSigner.Key can be null
44+
href: cryptography/10.0/cosesigner-key-null.md
4345
- name: Environment variable renamed to DOTNET_OPENSSL_VERSION_OVERRIDE
4446
href: cryptography/10.0/version-override.md
4547
- name: OpenSSL cryptographic primitives not supported on macOS

0 commit comments

Comments
 (0)