/** * @param Pkcs8PrivateKey $privateKey * @param string $password * @return Sequence */ public function getEncryptedPrivateKeyInfo(Pkcs8PrivateKey $privateKey, $password) { $digestParams = $privateKey->getKdfParams(); $cipherParams = $privateKey->getCipherParams(); $pkcs5Info = $this->pkcs5->getPkcs5Data($digestParams, $cipherParams); $encKey = $this->digester->digest($password, $digestParams); $data = $this->getPrivateKeyInfo($privateKey); $cipherText = $this->crypter->encrypt($data->getBinary(), $encKey, $cipherParams); return new Sequence($pkcs5Info, new OctetString(unpack("H*", $cipherText)[1])); }
/** * @expectedException \RuntimeException * @expectedExceptionMessage Unknown or unsupported digest algorithm */ public function testUnknownParams() { $mock = $this->getMockBuilder(DigestParamsInterface::class)->setMethods(['getMethod'])->getMock(); $digester = new Digester(); $digester->digest('data', $mock); }