Path: redb-route/redb.Route.As4/As4Algorithms.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.As4/As4Algorithms.cs
----
namespace redb.Route.As4;
///
/// Algorithm identifiers used by AS4 message security, and the set this connector supports. The supported
/// set is exactly what the eDelivery AS4 1.16 common profile mandates; an agreement naming anything else is
/// refused when it is validated, not when the first message arrives.
///
public static class As4Algorithms
{
/// RSA with SHA-256 signature (XML Signature).
public const string RsaSha256 = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256";
/// SHA-256 digest (XML Encryption namespace URI, as XML Signature uses it).
public const string Sha256 = "http://www.w3.org/2001/04/xmlenc#sha256";
/// AES-128 in GCM mode (XML Encryption 1.1).
public const string Aes128Gcm = "http://www.w3.org/2009/xmlenc11#aes128-gcm";
/// RSA-OAEP key transport (XML Encryption 1.1), with explicit MGF and digest.
public const string RsaOaep = "http://www.w3.org/2009/xmlenc11#rsa-oaep";
/// MGF1 with SHA-256 mask generation (XML Encryption 1.1).
public const string Mgf1Sha256 = "http://www.w3.org/2009/xmlenc11#mgf1sha256";
private static readonly HashSet Signatures = new(StringComparer.Ordinal) { RsaSha256 };
private static readonly HashSet Digests = new(StringComparer.Ordinal) { Sha256 };
private static readonly HashSet DataEncryption = new(StringComparer.Ordinal) { Aes128Gcm };
private static readonly HashSet KeyTransports = new(StringComparer.Ordinal) { RsaOaep };
private static readonly HashSet MaskGenerations = new(StringComparer.Ordinal) { Mgf1Sha256 };
/// Whether is a supported signature algorithm.
public static bool IsSupportedSignature(string? uri) => uri is not null && Signatures.Contains(uri);
/// Whether is a supported digest algorithm.
public static bool IsSupportedDigest(string? uri) => uri is not null && Digests.Contains(uri);
/// Whether is a supported payload encryption algorithm.
public static bool IsSupportedDataEncryption(string? uri) => uri is not null && DataEncryption.Contains(uri);
/// Whether is a supported key transport algorithm.
public static bool IsSupportedKeyTransport(string? uri) => uri is not null && KeyTransports.Contains(uri);
/// Whether is a supported mask generation function.
public static bool IsSupportedMaskGeneration(string? uri) => uri is not null && MaskGenerations.Contains(uri);
}