cryptoCoreHchacha20 static method

Uint8List cryptoCoreHchacha20(
  1. Uint8List i,
  2. Uint8List k,
  3. Uint8List? c
)

Implementation

static Uint8List cryptoCoreHchacha20(Uint8List i, Uint8List k, Uint8List? c) {
  RangeError.checkValueInInterval(i.length, cryptoCoreHchacha20Inputbytes,
      cryptoCoreHchacha20Inputbytes, 'i', 'Invalid length');
  RangeError.checkValueInInterval(k.length, cryptoCoreHchacha20Keybytes,
      cryptoCoreHchacha20Keybytes, 'k', 'Invalid length');
  if (c != null) {
    RangeError.checkValueInInterval(c.length, cryptoCoreHchacha20Constbytes,
        cryptoCoreHchacha20Constbytes, 'c', 'Invalid length');
  }
  final _out = calloc<Uint8>(cryptoCoreHchacha20Outputbytes);
  final _in = i.toPointer();
  final _k = k.toPointer();
  final _c = c?.toPointer() ?? nullptr;

  try {
    _cryptoCore
        .crypto_core_hchacha20(_out, _in, _k, _c)
        .mustSucceed('crypto_core_hchacha20');
    return _out.toList(cryptoCoreHchacha20Outputbytes);
  } finally {
    calloc.free(_out);
    calloc.free(_in);
    calloc.free(_k);
    if (_c != nullptr) {
      calloc.free(_c);
    }
  }
}