dotnet / dotnet/runtime

[API Proposal]: OID mapping to PQC Algorithms

Open
#133,019 4 comments 0 reactions 0 assignees View on GitHub
api-suggestion area-System.Security
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

### Background and motivation

For PQC parameter sets we introduced types like `MLKemAlgorithm`, `MLDsaAlgorithm`, etc to identify the parameter set of the algorithm, as well as some useful properties for the parameter set like encapsulation key sizes, signature sizes, etc.

Parameter sets also have an OID assigned to them - these OIDs are used in AlgorithmIdentifiers for things like SPKI, PKCS#8, or CMS. These OIDs already exist on the parameter set, they just aren't publicly exposed. Exposing them publicly will allow for easier use in other assemblies like S.S.C.Pkcs or 3rd parties that want to build on top of the abstract classes.

### API Proposal

`FromOid` and `TryFromOid` are existing names on `HashAlgorithmName`.

```csharp
namespace System.Security.Cryptography;

public sealed partial class MLKemAlgorithm {
public Oid Oid { get; }

public static MLKemAlgorithm FromOid(string oid);
public static bool TryFromOid(string oid, [NotNullWhen(true)] out MLKemAlgorithm? algorithm);
}

public sealed partial class MLDsaAlgorithm {
public Oid Oid { get; }

public static MLDsaAlgorithm FromOid(string oid);
public static bool TryFromOid(string oid, [NotNullWhen(true)] out MLDsaAlgorithm? algorithm);
}

public sealed partial class SlhDsaAlgorithm {
public Oid Oid { get; }

public static SlhDsaAlgorithm FromOid(string oid);
public static bool TryFromOid(string oid, [NotNullWhen(true)] out SlhDsaAlgorithm? algorithm);
}

public sealed partial class CompositeMLKemAlgorithm {
public Oid Oid { get; }

public static CompositeMLKemAlgorithm FromOid(string oid);
public static bool TryFromOid(string oid, [NotNullWhen(true)] out CompositeMLKemAlgorithm? algorithm);
}

public sealed partial class CompositeMLDsaAlgorithm {
public Oid Oid { get; }

public static CompositeMLDsaAlgorithm FromOid(string oid);
public static bool TryFromOid(string oid, [NotNullWhen(true)] out CompositeMLDsaAlgorithm? algorithm);
}
```

### API Usage

```csharp
EnvelopedCms cms = new EnvelopedCms();
cms.Decode(encodedMessage);

KemRecipientInfo recipientInfo = cms.RecipientInfos.OfType().Single();
MLKemAlgorithm alg = MLKemAlgorithm.FromOid(recipientInfo.KeyEncapsulationAlgorithm.Oid.Value);
```

### Alternative Designs

_No response_

### Risks

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by locating the five named algorithm classes and their existing parameter-set OID data, then compare the proposed FromOid and TryFromOid APIs with HashAlgorithmName's existing pattern. Done means the public Oid properties and lookups are consistent for all listed algorithms and the related cryptography tests cover recognized and unrecognized OIDs.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, cryptography, security
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.