/**
  * Initialize from PrivateKeyInfo.
  *
  * Encrypts PrivateKeyInfo with given pre-derived key.
  *
  * @param PrivateKeyInfo $pki
  * @param PBEAlgorithmIdentifier $algo
  * @param string $key
  * @param Crypto $crypto
  * @return self
  */
 public static function encryptPrivateKeyInfoWithDerivedKey(PrivateKeyInfo $pki, PBEAlgorithmIdentifier $algo, $key, Crypto $crypto)
 {
     $data = $pki->toDER();
     $scheme = PBEScheme::fromAlgorithmIdentifier($algo, $crypto);
     $ciphertext = $scheme->encryptWithKey($data, $key);
     return new self($algo, $ciphertext);
 }