cryptoBoxOpenEasyAfternm static method

Uint8List cryptoBoxOpenEasyAfternm(
  1. Uint8List c,
  2. Uint8List n,
  3. Uint8List k
)

Implementation

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

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

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

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