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.
By default, DartXchacha20 will be used.
If you use Flutter, you can enable cryptography_flutter. It can improve performance in many cases.
Things to know
- Secret key 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.
- Inheritance
-
- Object
- Cipher
- StreamingCipher
- Xchacha20
- Implementers
Constructors
- Xchacha20({required MacAlgorithm macAlgorithm})
-
factory
- Xchacha20.constructor({Random? random})
-
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
- random → Random?
-
Random number generator used by newSecretKey for generating secret keys.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- secretKeyLength → int
-
Number of bytes in the SecretKey.
no setteroverride
Methods
-
checkParameters(
{int? length, required SecretKey secretKey, required int nonceLength, int aadLength = 0, int keyStreamIndex = 0}) → void -
Checks parameters for encrypt / decrypt and throws ArgumentError if
any is invalid.
inherited
-
cipherTextLength(
int clearTextLength) → int -
Calculates the length of the ciphertext given a clear text length.
inherited
-
decrypt(
SecretBox secretBox, {required SecretKey secretKey, List< int> aad = const <int>[], int keyStreamIndex = 0, Uint8List? possibleBuffer}) → Future<List< int> > -
Decrypts a ciphertext.
inherited
-
decryptStream(
Stream< List< stream, {required SecretKey secretKey, required List<int> >int> nonce, required FutureOr<Mac> mac, List<int> aad = const [], bool allowUseSameBytes = false}) → Stream<List< int> > -
Decrypts a Stream of bytes.
inherited
-
decryptString(
SecretBox secretBox, {required SecretKey secretKey}) → Future< String> -
Calls decrypt and then converts the bytes to a string by using
utf8 codec.
inherited
-
encrypt(
List< int> clearText, {required SecretKey secretKey, List<int> ? nonce, List<int> aad = const <int>[], int keyStreamIndex = 0, Uint8List? possibleBuffer}) → Future<SecretBox> -
Encrypts a cleartext.
inherited
-
encryptStream(
Stream< List< stream, {required SecretKey secretKey, required List<int> >int> nonce, required void onMac(Mac mac), List<int> aad = const [], bool allowUseSameBytes = false}) → Stream<List< int> > -
Encrypts a Stream of bytes.
inherited
-
encryptString(
String clearText, {required SecretKey secretKey}) → Future< SecretBox> -
Converts a string to bytes using utf8 codec and then calls encrypt.
inherited
-
newCipherWand(
) → Future< CipherWand> -
Constructs a CipherWand that uses this implementation and a new random
secret key (that can't be extracted).
inherited
-
newCipherWandFromSecretKey(
SecretKey secretKey, {bool allowEncrypt = true, bool allowDecrypt = true}) → Future< CipherWand> -
Constructs a CipherWand that uses this implementation and the
given SecretKey.
inherited
-
newNonce(
) → List< int> -
Generates a new nonce.
inherited
-
newSecretKey(
) → Future< SecretKey> -
Generates a new SecretKey.
inherited
-
newSecretKeyFromBytes(
List< int> bytes) → Future<SecretKey> -
Constructs a new SecretKey from the bytes.
inherited
-
newState(
) → CipherState -
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
-
toSync(
) → DartXchacha20 -
Returns a synchronous, pure Dart implementation of this cipher.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override