*/
private function validateHexSortkey( $hexSortkey ) {
// A hex sortkey has an unbound number of 2 letter pairs
- return preg_match( '/^(?:[a-fA-F0-9]{2})*$/', $hexSortkey );
+ return preg_match( '/^(?:[a-fA-F0-9]{2})*$/D', $hexSortkey );
}
/**
// Add a WHERE clause for sortkey and from
$this->dieContinueUsageIf( !$this->validateHexSortkey( $cont[1] ) );
- // pack( "H*", $foo ) is used to convert hex back to binary
- $escSortkey = $this->getDB()->addQuotes( pack( 'H*', $cont[1] ) );
+ $escSortkey = $this->getDB()->addQuotes( hex2bin( $cont[1] ) );
$from = intval( $cont[2] );
$op = $dir == 'newer' ? '>' : '<';
// $contWhere is used further down
if ( !$this->validateHexSortkey( $params['starthexsortkey'] ) ) {
$this->dieUsage( 'The starthexsortkey provided is not valid', 'bad_starthexsortkey' );
}
- $startsortkey = pack( 'H*', $params['starthexsortkey'] );
+ $startsortkey = hex2bin( $params['starthexsortkey'] );
} else {
$startsortkey = $params['startsortkey'];
}
if ( !$this->validateHexSortkey( $params['endhexsortkey'] ) ) {
$this->dieUsage( 'The endhexsortkey provided is not valid', 'bad_endhexsortkey' );
}
- $endsortkey = pack( 'H*', $params['endhexsortkey'] );
+ $endsortkey = hex2bin( $params['endhexsortkey'] );
} else {
$endsortkey = $params['endsortkey'];
}
* @dataProvider providerRfc5869
*/
public function testRfc5869( $hash, $ikm, $salt, $info, $L, $prk, $okm ) {
- $ikm = pack( 'H*', $ikm );
- $salt = pack( 'H*', $salt );
- $info = pack( 'H*', $info );
- $okm = pack( 'H*', $okm );
+ $ikm = hex2bin( $ikm );
+ $salt = hex2bin( $salt );
+ $info = hex2bin( $info );
+ $okm = hex2bin( $okm );
$result = MWCryptHKDF::HKDF( $hash, $ikm, $salt, $info, $L );
$this->assertEquals( $okm, $result );
}