Skip to main content

JsonWebKeyFactory Class

Abblix.Jwt

Abblix.Jwt

JsonWebKeyFactory Class

A factory for creating JsonWebKey objects for various cryptographic key types. Supports RSA, Elliptic Curve, and symmetric (HMAC) keys for JWT operations.

public static class JsonWebKeyFactory

Inheritance System.Object → JsonWebKeyFactory

Methods

JsonWebKeyFactory.CreateEllipticCurve(string, string) Method

Creates an Elliptic Curve JsonWebKey with a specified curve.

public static Abblix.Jwt.EllipticCurveJsonWebKey CreateEllipticCurve(string curve, string algorithm);

Parameters

curve System.String

The elliptic curve to use. Common values: P-256, P-384, P-521.

algorithm System.String

The signing algorithm. Common values: ES256, ES384, ES512.

Returns

EllipticCurveJsonWebKey
A EllipticCurveJsonWebKey suitable for ECDSA signing operations.

JsonWebKeyFactory.CreateHmac(string, Nullable<int>) Method

Creates a symmetric (Octet) JsonWebKey for HMAC signing.

public static Abblix.Jwt.OctetJsonWebKey CreateHmac(string algorithm, System.Nullable<int> keySize=null);

Parameters

algorithm System.String

The HMAC algorithm. Common values: HS256, HS384, HS512.

keySize System.Nullable<System.Int32>

The key size in bytes. Defaults based on algorithm: HS256=32, HS384=48, HS512=64.

Returns

OctetJsonWebKey
A OctetJsonWebKey suitable for HMAC signing operations.

JsonWebKeyFactory.CreateRsa(string, string, int) Method

Creates an RSA JsonWebKey with a specified algorithm.

public static Abblix.Jwt.RsaJsonWebKey CreateRsa(string usage, string? algorithm=null, int keySize=2048);

Parameters

usage System.String

The intended usage of the key, typically 'sig' for signing or 'enc' for encryption.

algorithm System.String

The signing or encryption algorithm. Key size is determined automatically based on the algorithm.

keySize System.Int32

The size of the RSA key in bits. If null, determined by algorithm (defaults to 2048).

Returns

RsaJsonWebKey
A RsaJsonWebKey configured for the specified algorithm.