1
0
mirror of https://github.com/danog/tgseclib.git synced 2024-11-27 12:44:38 +01:00

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

View File

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

View File

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

View File

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

View File

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