Xchacha20 class abstract

Xchacha20 (draft-irtf-cfrg-xchacha). cipher.

The only difference between Xchacha20 and Chacha20 is that Xchacha20 uses 192-bit nonces whereas Chacha20 uses 96-bit nonces.

Things to know

  • SecretKey must be 32 bytes.
  • Nonce must be 24 bytes.
  • keyStreamIndex enables choosing index in the key stream.
  • It's dangerous to use the same (key, nonce) combination twice.
  • It's dangerous to use the cipher without authentication.

Example

See chacha20.

In need of synchronous APIs?

If you need to perform operations synchronously, use DartXchacha20 in package:better_cryptography/dart.dart.

Inheritance
Implementers

Constructors

Xchacha20({required MacAlgorithm macAlgorithm})
factory
Xchacha20.constructor()
Constructor for classes that extend this class.
const
Xchacha20.poly1305Aead()
XAEAD_CHACHA20_POLY1305 (draft-irtf-cfrg-xchacha) cipher.
factory

Properties

hashCode → int
The hash code for this object.
no setteroverride
macAlgorithm → MacAlgorithm
Message authentication code (MacAlgorithm) used by the cipher.
no setterinherited
nonceLength → int
Number of bytes in the nonce ("Initialization Vector", "IV", "salt").
no setteroverride
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
secretKeyLength → int
Number of bytes in the SecretKey.
no setteroverride

Methods

decrypt(SecretBox secretBox, {required SecretKey secretKey, List<int> aad = const <int>[], int keyStreamIndex = 0}) → Future<List<int>>
Decrypts a ciphertext.
inherited
encrypt(List<int> clearText, {required SecretKey secretKey, List<int>? nonce, List<int> aad = const <int>[], int keyStreamIndex = 0}) → Future<SecretBox>
Encrypts a cleartext.
inherited
newNonce() → List<int>
Generates a new nonce with the correct length (nonceLength).
inherited
newSecretKey() → Future<SecretKey>
Generates a new SecretKey with the correct length (secretKeyLength).
inherited
newSecretKeyFromBytes(List<int> bytes) → Future<SecretKey>
Constructs a new SecretKey from the bytes.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
override