opensshKeyCrypt function

Uint8List opensshKeyCrypt(
  1. bool forEncryption,
  2. Uint8List password,
  3. Uint8List salt,
  4. int rounds,
  5. Uint8List input,
  6. int cipherAlgo
)

Implementation

Uint8List opensshKeyCrypt(bool forEncryption, Uint8List password,
    Uint8List salt, int rounds, Uint8List input, int cipherAlgo) {
  int keySize = Cipher.keySize(cipherAlgo),
      blockSize = Cipher.blockSize(cipherAlgo);
  Uint8List key = bcryptPbkdf(password, salt, keySize + blockSize, rounds);
  BlockCipher cipher = Cipher.cipher(cipherAlgo);
  cipher.init(
      forEncryption,
      ParametersWithIV(KeyParameter(viewUint8List(key, 0, keySize)),
          viewUint8List(key, keySize, blockSize)));
  return applyBlockCipher(cipher, input);
}