Skip to main content

OctetJsonWebKey Class

Abblix.Jwt

Abblix.Jwt

OctetJsonWebKey Class

Represents a Symmetric JSON Web Key (JWK) containing symmetric key material for algorithms like HMAC. Supports symmetric keys per RFC 7518 Section 6.4.

public sealed record OctetJsonWebKey : Abblix.Jwt.JsonWebKey, System.IEquatable<Abblix.Jwt.OctetJsonWebKey>

Inheritance System.ObjectJsonWebKey → OctetJsonWebKey

Implements System.IEquatable<OctetJsonWebKey>

Properties

OctetJsonWebKey.HasPrivateKey Property

Checks if the key contains private key material.

public override bool HasPrivateKey { get; }

Property Value

System.Boolean

OctetJsonWebKey.HasPublicKey Property

Checks if the key contains public key material.

public override bool HasPublicKey { get; }

Property Value

System.Boolean

OctetJsonWebKey.KeyType Property

The key type identifier for symmetric (Octet Sequence) keys. Always returns "oct".

public override string KeyType { get; }

Property Value

System.String

OctetJsonWebKey.KeyValue Property

Symmetric Key Value (k). Used for oct (Octet Sequence) keys, which are symmetric keys used in algorithms like HMAC-SHA256, HMAC-SHA384, and HMAC-SHA512. This is a required parameter for symmetric keys and must be kept confidential.

public byte[]? KeyValue { get; set; }

Property Value

System.Byte[]

Methods

OctetJsonWebKey.Sanitize(bool) Method

Prepares a sanitized version of the symmetric JWK that excludes the key value unless explicitly included.

public override Abblix.Jwt.JsonWebKey Sanitize(bool includePrivateKeys);

Parameters

includePrivateKeys System.Boolean

Whether to include the symmetric key value in the sanitized output.

Returns

JsonWebKey
A new instance of OctetJsonWebKey with or without the key value based on the input parameter.

Exceptions

System.InvalidOperationException
Thrown when includePrivateKeys is true but the key contains no key value.

Remarks

For symmetric keys, the key value is always considered sensitive and should be treated as private key material.