code: function encrypt(credentials, key, rounds) {
      var algo = CryptoEngine.createAesCbc();
      return algo.importKey(ByteUtils.arrayToBuffer(key))
          .then(function() {
              var resolvers = [];
              for (var idx = 0; idx < credentialSize; idx += aesBlockSize) {
                  resolvers.push(encryptBlock(algo,
                      credentials.subarray(idx, idx + aesBlockSize), rounds));
              }
              return Promise.all(resolvers);
          })
          .then(function(results) {
              var res = new Uint8Array(credentialSize);
              results.forEach(function (result, idx) {
                  var base = idx * aesBlockSize;
                  for (var i = 0; i < aesBlockSize; ++i) {
                      res[i + base] = result[i];
                  }
                  ByteUtils.zeroBuffer(result);
              });
              return res;
          });
  }
docs: /*
  In order to simulate multiple rounds of ECB encryption, we do CBC encryption
  across a zero buffer of large length with the IV being the desired plaintext.
  The zero buffer does not contribute to the xor, so xoring the previous block
  with the next one simulates running ECB multiple times. We limit the maximum
  size of the zero buffer to prevent enormous memory usage.