Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/util/PhabricatorHash.php
Show First 20 Lines • Show All 218 Lines • ▼ Show 20 Lines | /* -( HMAC Key Management )------------------------------------------------ */ | ||||
private static function getNamedHMACKey($hmac_name) { | private static function getNamedHMACKey($hmac_name) { | ||||
$cache = PhabricatorCaches::getImmutableCache(); | $cache = PhabricatorCaches::getImmutableCache(); | ||||
$cache_key = "hmac.key({$hmac_name})"; | $cache_key = "hmac.key({$hmac_name})"; | ||||
$hmac_key = $cache->getKey($cache_key); | $hmac_key = $cache->getKey($cache_key); | ||||
if (!strlen($hmac_key)) { | if (($hmac_key === null) || !strlen($hmac_key)) { | ||||
$hmac_key = self::readHMACKey($hmac_name); | $hmac_key = self::readHMACKey($hmac_name); | ||||
if ($hmac_key === null) { | if ($hmac_key === null) { | ||||
$hmac_key = self::newHMACKey($hmac_name); | $hmac_key = self::newHMACKey($hmac_name); | ||||
self::writeHMACKey($hmac_name, $hmac_key); | self::writeHMACKey($hmac_name, $hmac_key); | ||||
} | } | ||||
$cache->setKey($cache_key, $hmac_key); | $cache->setKey($cache_key, $hmac_key); | ||||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |