示例#1
0
 public function testInstance()
 {
     $method = Pbkdf2Factory::PBKDF2_WITH_SHA256;
     $salt = 'abcd01234';
     $iterCount = 1000;
     $keyLength = 32;
     $params = new Pbkdf2Params($method, $salt, $iterCount, $keyLength);
     $this->assertEquals($method, $params->getMethod());
     $this->assertEquals($salt, $params->getSalt());
     $this->assertEquals($iterCount, $params->getIterationCount());
     $this->assertEquals($keyLength, $params->getKeyLength());
 }
示例#2
0
 /**
  * @param Pbkdf2Params $params
  * @return Sequence
  */
 public function getAsn(Pbkdf2Params $params)
 {
     $inner = new Sequence(new OctetString(unpack("H*", $params->getSalt())[1]), new Integer($params->getIterationCount()));
     if ($params->getKeyLength() !== null) {
         $inner[] = new Integer($params->getKeyLength());
     }
     if ($params->getMethod() !== null) {
         $inner[] = new AlgorithmIdentifier(Pbkdf2AlgoOidMapper::getOidByName($params->getMethod())->getContent());
     }
     return new Sequence(DigestOidMapper::getOidByName(Pbkdf2Factory::NAME_PBKDF2), $inner);
 }