deriveKey method

  1. @override
int deriveKey(
  1. Uint8List inp,
  2. int inpOff,
  3. Uint8List out,
  4. int outOff,
)
override

Derive key from given input and put it in out at offset outOff.

Implementation

@override
int deriveKey(Uint8List inp, int inpOff, Uint8List out, int outOff) {
  var ecdh = ECDHBasicAgreement()..init(parameters.privateKey);
  var ag = ecdh.calculateAgreement(parameters.publicKey);
  var key = encodeBigIntAsUnsigned(ag);
  // pad to keysize
  var padlength = max((keySize / 8).ceil() - key.length, 0);
  out.setAll(outOff, Uint8List.fromList(List.filled(padlength, 0)));
  out.setAll(outOff + padlength, key);
  return padlength + key.length;
}