* a "context information" string CTXinfo (which may be null)
* See http://eprint.iacr.org/2010/264.pdf Section 4.1
*/
- protected $context = array();
+ protected $context = [];
/**
* Round count is computed based on the hash'es output length,
* which neither php nor openssl seem to provide easily.
*/
- public static $hashLength = array(
+ public static $hashLength = [
'md5' => 16,
'sha1' => 20,
'sha224' => 28,
'ripemd256' => 32,
'ripemd320' => 40,
'whirlpool' => 64,
- );
-
+ ];
/**
* @param string $secretKeyMaterial
$this->cache = $cache;
$this->salt = ''; // Initialize a blank salt, see getSaltUsingCache()
$this->prk = '';
- $this->context = is_array( $context ) ? $context : array( $context );
+ $this->context = is_array( $context ) ? $context : [ $context ];
// To prevent every call from hitting the same memcache server, pick
// from a set of keys to use. mt_rand is only use to pick a random
/**
* Return a singleton instance, based on the global configs.
- * @return HKDF
+ * @return self
* @throws MWException
*/
protected static function singleton() {
// In HKDF, the context can be known to the attacker, but this will
// keep simultaneous runs from producing the same output.
- $context = array();
+ $context = [];
$context[] = microtime();
$context[] = getmypid();
$context[] = gethostname();
);
}
- $CTXinfo = implode( ':', array_merge( $this->context, array( $context ) ) );
+ $CTXinfo = implode( ':', array_merge( $this->context, [ $context ] ) );
return self::HKDFExpand(
$this->algorithm,
);
}
-
/**
* RFC5869 defines HKDF in 2 steps, extraction and expansion.
* From http://eprint.iacr.org/2010/264.pdf: