cryptoBoxOpenDetachedAfternm static method

Uint8List cryptoBoxOpenDetachedAfternm(
  1. Uint8List c,
  2. Uint8List mac,
  3. Uint8List n,
  4. Uint8List k,
)

Implementation

static Uint8List cryptoBoxOpenDetachedAfternm(
    Uint8List c, Uint8List mac, Uint8List n, Uint8List k) {
  RangeError.checkValueInInterval(mac.length, cryptoBoxMacbytes,
      cryptoBoxMacbytes, 'mac', 'Invalid length');
  RangeError.checkValueInInterval(n.length, cryptoBoxNoncebytes,
      cryptoBoxNoncebytes, 'n', 'Invalid length');
  RangeError.checkValueInInterval(k.length, cryptoBoxBeforenmbytes,
      cryptoBoxBeforenmbytes, 'k', 'Invalid length');

  final _m = calloc<Uint8>(c.length);
  final _mac = mac.toPointer();
  final _c = c.toPointer();
  final _n = n.toPointer();
  final _k = k.toPointer();

  try {
    _cryptoBox
        .crypto_box_open_detached_afternm(_m, _c, _mac, c.length, _n, _k)
        .mustSucceed('crypto_box_open_detached_afternm');

    return _m.toList(c.length);
  } finally {
    calloc.free(_m);
    calloc.free(_mac);
    calloc.free(_c);
    calloc.free(_n);
    calloc.free(_k);
  }
}