Skip to content

AesGcmOptions Class ​

Definition ​

Class defining options availble for AesGcm encryption operations

  • Namespace: JASE.Crypto
  • Assembly: JASE.Crypto.dll

Properties ​

NameDescription
AssociatedDataOptional associated authenticated data (AAD)
EncodingGet the Text encoding to be used
FormatEnvelope format of the encrypted byte[]. Raw-key factories fall back to
KeyRequired key (can be derived from passphrase+salt or set directly)
NonceByteSizeAES-GCM nonce length (in bytes) used for this operation. Snapshotted from
TagByteSizeAES-GCM authentication tag length (in bytes) used for this operation. Snapshotted from

Methods ​

NameDescription
AesGcmOptions Create(byte[] key, byte[] associatedData = null, Encoding encoding = null, AesEnvelopeFormat? format = null)Creates an AesGcmOptions instance using a raw 256-bit AES key.
AesGcmOptions Create(string passphrase, string salt, int iterations = null, byte[] associatedData = null, Encoding encoding = null, KeyDerivationAlgorithm? kdfAlgorithm = null, HashProvider? hashProvider = null, AesEnvelopeFormat? format = null)Creates an AesGcmOptions instance by deriving a 256-bit key from a passphrase and salt, using the specified key-derivation settings, and optional binary associated data.
AesGcmOptions Create(string passphrase, string salt, int iterations = null, string associatedData = null, Encoding encoding = null, KeyDerivationAlgorithm? kdfAlgorithm = null, HashProvider? hashProvider = null, AesEnvelopeFormat? format = null)Creates an AesGcmOptions instance by deriving a 256-bit key from a passphrase and salt, using the specified key-derivation settings, and optional string-based associated data.
AesGcmOptions CreateWithArgon2id(string passphrase, string salt, IArgon2Options argon2Options = null, byte[] associatedData = null, Encoding encoding = null, AesEnvelopeFormat? format = null)Creates an AesGcmOptions instance by deriving a 256-bit key from a passphrase using the memory-hard Argon2id KDF. This is an opt-in alternative to the library-default PBKDF2 path; the Argon2 cost parameters are embedded in the resulting self-describing JaseV1 envelope so decryption needs only the passphrase.
AesGcmOptions WithGcmSizes(int nonceByteSize, int tagByteSize)Overrides the AES-GCM nonce and tag sizes for this single operation, without mutating the process-wide Configuration defaults. Returns the same instance for chaining.

Remarks ​

Secret lifetime: this instance retains sensitive material—the derived/raw Key and, for passphrase factories, the Passphrase—in ordinary managed memory for the lifetime of the object. The library does not pin, encrypt, or zero this memory, and the garbage collector may relocate or copy it. Treat an AesGcmOptions as short-lived: build it, use it for the operation, and drop the reference. Callers with stricter requirements should manage their own secret protection (and prefer the raw-key factory with key material they control and can clear).

Thread-safety: instances are not thread-safe for concurrent mutation. Treat an instance as effectively immutable once configured; do not call WithGcmSizes while the same instance is in use on another thread.