Crypt: define visibility for more variables / methods

This commit is contained in:
terrafrost 2016-12-09 16:01:48 -06:00
parent 067c1882e5
commit 813b85b5b2
5 changed files with 48 additions and 48 deletions

View File

@ -44,14 +44,14 @@ abstract class PKCS
* @access private * @access private
* @param int * @param int
*/ */
static $format = self::MODE_ANY; protected static $format = self::MODE_ANY;
/** /**
* Require base64-encoded PEM's be supplied * Require base64-encoded PEM's be supplied
* *
* @access public * @access public
*/ */
static function requirePEM() public static function requirePEM()
{ {
self::$format = self::MODE_PEM; self::$format = self::MODE_PEM;
} }
@ -61,7 +61,7 @@ abstract class PKCS
* *
* @access public * @access public
*/ */
static function requireDER() public static function requireDER()
{ {
self::$format = self::MODE_DER; self::$format = self::MODE_DER;
} }
@ -73,7 +73,7 @@ abstract class PKCS
* *
* @access public * @access public
*/ */
static function requireAny() public static function requireAny()
{ {
self::$format = self::MODE_ANY; self::$format = self::MODE_ANY;
} }

View File

@ -40,7 +40,7 @@ abstract class PKCS1 extends PKCS
* @var string * @var string
* @access private * @access private
*/ */
static $defaultEncryptionAlgorithm = 'AES-128-CBC'; private static $defaultEncryptionAlgorithm = 'AES-128-CBC';
/** /**
* Sets the default encryption algorithm * Sets the default encryption algorithm
@ -48,7 +48,7 @@ abstract class PKCS1 extends PKCS
* @access public * @access public
* @param string $algo * @param string $algo
*/ */
static function setEncryptionAlgorithm($algo) public static function setEncryptionAlgorithm($algo)
{ {
self::$defaultEncryptionAlgorithm = $algo; self::$defaultEncryptionAlgorithm = $algo;
} }
@ -61,7 +61,7 @@ abstract class PKCS1 extends PKCS
* @return int * @return int
* @throws \UnexpectedValueException if the block cipher mode is unsupported * @throws \UnexpectedValueException if the block cipher mode is unsupported
*/ */
static function getEncryptionMode($mode) public static function getEncryptionMode($mode)
{ {
switch ($mode) { switch ($mode) {
case 'CBC': case 'CBC':
@ -86,7 +86,7 @@ abstract class PKCS1 extends PKCS
* @return string * @return string
* @throws \UnexpectedValueException if the encryption algorithm is unsupported * @throws \UnexpectedValueException if the encryption algorithm is unsupported
*/ */
static function getEncryptionObject($algo) public static function getEncryptionObject($algo)
{ {
$modes = '(CBC|ECB|CFB|OFB|CTR)'; $modes = '(CBC|ECB|CFB|OFB|CTR)';
switch (true) { switch (true) {
@ -112,7 +112,7 @@ abstract class PKCS1 extends PKCS
* @param int $length * @param int $length
* @return string * @return string
*/ */
static function generateSymmetricKey($password, $iv, $length) public static function generateSymmetricKey($password, $iv, $length)
{ {
$symkey = ''; $symkey = '';
$iv = substr($iv, 0, 8); $iv = substr($iv, 0, 8);
@ -130,7 +130,7 @@ abstract class PKCS1 extends PKCS
* @param string $password optional * @param string $password optional
* @return array * @return array
*/ */
static function load($key, $password) public static function load($key, $password)
{ {
if (!is_string($key)) { if (!is_string($key)) {
return false; return false;
@ -186,7 +186,7 @@ abstract class PKCS1 extends PKCS
* @param string $password * @param string $password
* @return string * @return string
*/ */
static function wrapPrivateKey($key, $type, $password) public static function wrapPrivateKey($key, $type, $password)
{ {
if (empty($password) || !is_string($password)) { if (empty($password) || !is_string($password)) {
return "-----BEGIN $type PRIVATE KEY-----\r\n" . return "-----BEGIN $type PRIVATE KEY-----\r\n" .
@ -215,7 +215,7 @@ abstract class PKCS1 extends PKCS
* @param string $type * @param string $type
* @return string * @return string
*/ */
static function wrapPublicKey($key, $type) public static function wrapPublicKey($key, $type)
{ {
return "-----BEGIN $type PUBLIC KEY-----\r\n" . return "-----BEGIN $type PUBLIC KEY-----\r\n" .
chunk_split(Base64::encode($key), 64) . chunk_split(Base64::encode($key), 64) .

View File

@ -55,7 +55,7 @@ class PKCS8 extends PKCS
* @var string * @var string
* @access private * @access private
*/ */
static $defaultEncryptionAlgorithm = 'id-PBES2'; private static $defaultEncryptionAlgorithm = 'id-PBES2';
/** /**
* Default encryption scheme * Default encryption scheme
@ -65,7 +65,7 @@ class PKCS8 extends PKCS
* @var string * @var string
* @access private * @access private
*/ */
static $defaultEncryptionScheme = 'aes128-CBC-PAD'; private static $defaultEncryptionScheme = 'aes128-CBC-PAD';
/** /**
* Default PRF * Default PRF
@ -75,7 +75,7 @@ class PKCS8 extends PKCS
* @var string * @var string
* @access private * @access private
*/ */
static $defaultPRF = 'id-hmacWithSHA256'; private static $defaultPRF = 'id-hmacWithSHA256';
/** /**
* Default Iteration Count * Default Iteration Count
@ -83,7 +83,7 @@ class PKCS8 extends PKCS
* @var int * @var int
* @access private * @access private
*/ */
static $defaultIterationCount = 2048; private static $defaultIterationCount = 2048;
/** /**
* OIDs loaded * OIDs loaded
@ -91,7 +91,7 @@ class PKCS8 extends PKCS
* @var bool * @var bool
* @access private * @access private
*/ */
static $oidsLoaded = false; private static $oidsLoaded = false;
/** /**
* Sets the default encryption algorithm * Sets the default encryption algorithm
@ -99,7 +99,7 @@ class PKCS8 extends PKCS
* @access public * @access public
* @param string $algo * @param string $algo
*/ */
static function setEncryptionAlgorithm($algo) public static function setEncryptionAlgorithm($algo)
{ {
self::$defaultEncryptionAlgorithm = $algo; self::$defaultEncryptionAlgorithm = $algo;
} }
@ -110,7 +110,7 @@ class PKCS8 extends PKCS
* @access public * @access public
* @param string $algo * @param string $algo
*/ */
static function setEncryptionScheme($algo) public static function setEncryptionScheme($algo)
{ {
self::$defaultEncryptionScheme = $algo; self::$defaultEncryptionScheme = $algo;
} }
@ -121,7 +121,7 @@ class PKCS8 extends PKCS
* @access public * @access public
* @param int $count * @param int $count
*/ */
static function setIterationCount($count) public static function setIterationCount($count)
{ {
self::$defaultIterationCount = $count; self::$defaultIterationCount = $count;
} }
@ -132,7 +132,7 @@ class PKCS8 extends PKCS
* @access public * @access public
* @param string $algo * @param string $algo
*/ */
static function setPRF($algo) public static function setPRF($algo)
{ {
self::$defaultPRF = $algo; self::$defaultPRF = $algo;
} }
@ -143,7 +143,7 @@ class PKCS8 extends PKCS
* @access public * @access public
* @param string $algo * @param string $algo
*/ */
static function getPBES1EncryptionObject($algo) public static function getPBES1EncryptionObject($algo)
{ {
$algo = preg_match('#^pbeWith(?:MD2|MD5|SHA1|SHA)And(.*?)-CBC$#', $algo, $matches) ? $algo = preg_match('#^pbeWith(?:MD2|MD5|SHA1|SHA)And(.*?)-CBC$#', $algo, $matches) ?
$matches[1] : $matches[1] :
@ -192,7 +192,7 @@ class PKCS8 extends PKCS
* @access public * @access public
* @param string $algo * @param string $algo
*/ */
static function getPBES1Hash($algo) public static function getPBES1Hash($algo)
{ {
if (preg_match('#^pbeWith(MD2|MD5|SHA1|SHA)And.*?-CBC$#', $algo, $matches)) { if (preg_match('#^pbeWith(MD2|MD5|SHA1|SHA)And.*?-CBC$#', $algo, $matches)) {
return $matches[1] == 'SHA' ? 'sha1' : $matches[1]; return $matches[1] == 'SHA' ? 'sha1' : $matches[1];
@ -207,7 +207,7 @@ class PKCS8 extends PKCS
* @access public * @access public
* @param string $algo * @param string $algo
*/ */
static function getPBES1KDF($algo) public static function getPBES1KDF($algo)
{ {
switch ($algo) { switch ($algo) {
case 'pbeWithMD2AndDES-CBC': case 'pbeWithMD2AndDES-CBC':
@ -228,7 +228,7 @@ class PKCS8 extends PKCS
* @access public * @access public
* @param string $algo * @param string $algo
*/ */
static function getPBES2EncryptionObject($algo) public static function getPBES2EncryptionObject($algo)
{ {
switch ($algo) { switch ($algo) {
case 'desCBC': case 'desCBC':
@ -262,7 +262,7 @@ class PKCS8 extends PKCS
* *
* @access private * @access private
*/ */
static function _initialize_static_variables() public static function _initialize_static_variables()
{ {
if (!self::$oidsLoaded) { if (!self::$oidsLoaded) {
// from https://tools.ietf.org/html/rfc2898 // from https://tools.ietf.org/html/rfc2898
@ -318,7 +318,7 @@ class PKCS8 extends PKCS
* @param string $password optional * @param string $password optional
* @return array * @return array
*/ */
static function load($key, $password = '') public static function load($key, $password = '')
{ {
self::_initialize_static_variables(); self::_initialize_static_variables();
@ -482,7 +482,7 @@ class PKCS8 extends PKCS
* @param string $password * @param string $password
* @return string * @return string
*/ */
static function wrapPrivateKey($key, $algorithm, $attr, $password) public static function wrapPrivateKey($key, $algorithm, $attr, $password)
{ {
self::_initialize_static_variables(); self::_initialize_static_variables();
@ -577,7 +577,7 @@ class PKCS8 extends PKCS
* @param string $key * @param string $key
* @return string * @return string
*/ */
static function wrapPublicKey($key, $algorithm) public static function wrapPublicKey($key, $algorithm)
{ {
self::_initialize_static_variables(); self::_initialize_static_variables();

View File

@ -52,7 +52,7 @@ class Hash
* @var int * @var int
* @access private * @access private
*/ */
var $hashParam; private $hashParam;
/** /**
* Byte-length of hash output (Internal HMAC) * Byte-length of hash output (Internal HMAC)
@ -61,7 +61,7 @@ class Hash
* @var int * @var int
* @access private * @access private
*/ */
var $length; private $length;
/** /**
* Hash Algorithm * Hash Algorithm
@ -70,7 +70,7 @@ class Hash
* @var string * @var string
* @access private * @access private
*/ */
var $hash; private $hash;
/** /**
* Key * Key
@ -79,7 +79,7 @@ class Hash
* @var string * @var string
* @access private * @access private
*/ */
var $key = false; private $key = false;
/** /**
* Initial Hash * Initial Hash
@ -90,7 +90,7 @@ class Hash
* @var array * @var array
* @access private * @access private
*/ */
var $initial = false; private $initial = false;
/** /**
* Outer XOR (Internal HMAC) * Outer XOR (Internal HMAC)
@ -101,7 +101,7 @@ class Hash
* @var string * @var string
* @access private * @access private
*/ */
var $opad; private $opad;
/** /**
* Inner XOR (Internal HMAC) * Inner XOR (Internal HMAC)
@ -112,7 +112,7 @@ class Hash
* @var string * @var string
* @access private * @access private
*/ */
var $ipad; private $ipad;
/** /**
* Default Constructor. * Default Constructor.
@ -120,7 +120,7 @@ class Hash
* @param string $hash * @param string $hash
* @access public * @access public
*/ */
function __construct($hash = 'sha256') public function __construct($hash = 'sha256')
{ {
$this->setHash($hash); $this->setHash($hash);
@ -136,7 +136,7 @@ class Hash
* @access public * @access public
* @param string $key * @param string $key
*/ */
function setKey($key = false) public function setKey($key = false)
{ {
$this->key = $key; $this->key = $key;
} }
@ -149,7 +149,7 @@ class Hash
* @access public * @access public
* @return string * @return string
*/ */
function getHash() public function getHash()
{ {
return $this->hashParam; return $this->hashParam;
} }
@ -160,7 +160,7 @@ class Hash
* @access public * @access public
* @param string $hash * @param string $hash
*/ */
function setHash($hash) public function setHash($hash)
{ {
$this->hashParam = $hash = strtolower($hash); $this->hashParam = $hash = strtolower($hash);
switch ($hash) { switch ($hash) {
@ -247,7 +247,7 @@ class Hash
* @param string $text * @param string $text
* @return string * @return string
*/ */
function hash($text) public function hash($text)
{ {
switch ($this->hash) { switch ($this->hash) {
case 'sha512/224': case 'sha512/224':
@ -286,7 +286,7 @@ class Hash
* @access public * @access public
* @return int * @return int
*/ */
function getLength() public function getLength()
{ {
return $this->length << 3; return $this->length << 3;
} }
@ -297,7 +297,7 @@ class Hash
* @access public * @access public
* @return int * @return int
*/ */
function getLengthInBytes() public function getLengthInBytes()
{ {
return $this->length; return $this->length;
} }
@ -308,7 +308,7 @@ class Hash
* @access public * @access public
* @return int * @return int
*/ */
function getBlockLength() public function getBlockLength()
{ {
return $this->blockSize; return $this->blockSize;
} }
@ -319,7 +319,7 @@ class Hash
* @access public * @access public
* @return int * @return int
*/ */
function getBlockLengthInBytes() public function getBlockLengthInBytes()
{ {
return $this->blockSize >> 3; return $this->blockSize >> 3;
} }
@ -330,7 +330,7 @@ class Hash
* @access private * @access private
* @param string $m * @param string $m
*/ */
static function _sha512($m, $hash) private static function _sha512($m, $hash)
{ {
static $k; static $k;

View File

@ -46,7 +46,7 @@ abstract class Random
* @throws \RuntimeException if a symmetric cipher is needed but not loaded * @throws \RuntimeException if a symmetric cipher is needed but not loaded
* @return string * @return string
*/ */
static function string($length) public static function string($length)
{ {
try { try {
return \random_bytes($length); return \random_bytes($length);
@ -196,7 +196,7 @@ abstract class Random
* @param mixed $arr * @param mixed $arr
* @access public * @access public
*/ */
static function safe_serialize(&$arr) private static function safe_serialize(&$arr)
{ {
if (is_object($arr)) { if (is_object($arr)) {
return ''; return '';