+ */
+class UnsupportedOperationException extends \RuntimeException
+{
+}
diff --git a/lam/lib/3rdParty/phpseclib/File/ANSI.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ANSI.php
similarity index 81%
rename from lam/lib/3rdParty/phpseclib/File/ANSI.php
rename to lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ANSI.php
index 5ff1f2ea1..f0dc19618 100644
--- a/lam/lib/3rdParty/phpseclib/File/ANSI.php
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ANSI.php
@@ -5,10 +5,10 @@
*
* PHP version 5
*
- * If you call read() in \phpseclib\Net\SSH2 you may get {@link http://en.wikipedia.org/wiki/ANSI_escape_code ANSI escape codes} back.
+ * If you call read() in \phpseclib3\Net\SSH2 you may get {@link http://en.wikipedia.org/wiki/ANSI_escape_code ANSI escape codes} back.
* They'd look like chr(0x1B) . '[00m' or whatever (0x1B = ESC). They tell a
* {@link http://en.wikipedia.org/wiki/Terminal_emulator terminal emulator} how to format the characters, what
- * color to display them in, etc. \phpseclib\File\ANSI is a {@link http://en.wikipedia.org/wiki/VT100 VT100} terminal emulator.
+ * color to display them in, etc. \phpseclib3\File\ANSI is a {@link http://en.wikipedia.org/wiki/VT100 VT100} terminal emulator.
*
* @category File
* @package ANSI
@@ -18,7 +18,7 @@
* @link http://phpseclib.sourceforge.net
*/
-namespace phpseclib\File;
+namespace phpseclib3\File;
/**
* Pure-PHP ANSI Decoder
@@ -35,7 +35,7 @@ class ANSI
* @var int
* @access private
*/
- var $max_x;
+ private $max_x;
/**
* Max Height
@@ -43,7 +43,7 @@ class ANSI
* @var int
* @access private
*/
- var $max_y;
+ private $max_y;
/**
* Max History
@@ -51,7 +51,7 @@ class ANSI
* @var int
* @access private
*/
- var $max_history;
+ private $max_history;
/**
* History
@@ -59,7 +59,7 @@ class ANSI
* @var array
* @access private
*/
- var $history;
+ private $history;
/**
* History Attributes
@@ -67,7 +67,7 @@ class ANSI
* @var array
* @access private
*/
- var $history_attrs;
+ private $history_attrs;
/**
* Current Column
@@ -75,7 +75,7 @@ class ANSI
* @var int
* @access private
*/
- var $x;
+ private $x;
/**
* Current Row
@@ -83,7 +83,7 @@ class ANSI
* @var int
* @access private
*/
- var $y;
+ private $y;
/**
* Old Column
@@ -91,7 +91,7 @@ class ANSI
* @var int
* @access private
*/
- var $old_x;
+ private $old_x;
/**
* Old Row
@@ -99,7 +99,7 @@ class ANSI
* @var int
* @access private
*/
- var $old_y;
+ private $old_y;
/**
* An empty attribute cell
@@ -107,7 +107,7 @@ class ANSI
* @var object
* @access private
*/
- var $base_attr_cell;
+ private $base_attr_cell;
/**
* The current attribute cell
@@ -115,7 +115,7 @@ class ANSI
* @var object
* @access private
*/
- var $attr_cell;
+ private $attr_cell;
/**
* An empty attribute row
@@ -123,7 +123,7 @@ class ANSI
* @var array
* @access private
*/
- var $attr_row;
+ private $attr_row;
/**
* The current screen text
@@ -131,7 +131,7 @@ class ANSI
* @var array
* @access private
*/
- var $screen;
+ private $screen;
/**
* The current screen attributes
@@ -139,7 +139,7 @@ class ANSI
* @var array
* @access private
*/
- var $attrs;
+ private $attrs;
/**
* Current ANSI code
@@ -147,7 +147,7 @@ class ANSI
* @var string
* @access private
*/
- var $ansi;
+ private $ansi;
/**
* Tokenization
@@ -155,15 +155,15 @@ class ANSI
* @var array
* @access private
*/
- var $tokenization;
+ private $tokenization;
/**
* Default Constructor.
*
- * @return \phpseclib\File\ANSI
+ * @return \phpseclib3\File\ANSI
* @access public
*/
- function __construct()
+ public function __construct()
{
$attr_cell = new \stdClass();
$attr_cell->bold = false;
@@ -188,12 +188,12 @@ class ANSI
* @param int $y
* @access public
*/
- function setDimensions($x, $y)
+ public function setDimensions($x, $y)
{
$this->max_x = $x - 1;
$this->max_y = $y - 1;
$this->x = $this->y = 0;
- $this->history = $this->history_attrs = array();
+ $this->history = $this->history_attrs = [];
$this->attr_row = array_fill(0, $this->max_x + 2, $this->base_attr_cell);
$this->screen = array_fill(0, $this->max_y + 1, '');
$this->attrs = array_fill(0, $this->max_y + 1, $this->attr_row);
@@ -203,11 +203,10 @@ class ANSI
/**
* Set the number of lines that should be logged past the terminal height
*
- * @param int $x
- * @param int $y
+ * @param int $history
* @access public
*/
- function setHistory($history)
+ public function setHistory($history)
{
$this->max_history = $history;
}
@@ -218,7 +217,7 @@ class ANSI
* @param string $source
* @access public
*/
- function loadString($source)
+ public function loadString($source)
{
$this->setDimensions($this->max_x + 1, $this->max_y + 1);
$this->appendString($source);
@@ -230,9 +229,9 @@ class ANSI
* @param string $source
* @access public
*/
- function appendString($source)
+ public function appendString($source)
{
- $this->tokenization = array('');
+ $this->tokenization = [''];
for ($i = 0; $i < strlen($source); $i++) {
if (strlen($this->ansi)) {
$this->ansi.= $source[$i];
@@ -272,7 +271,7 @@ class ANSI
case "\x1B[K": // Clear screen from cursor right
$this->screen[$this->y] = substr($this->screen[$this->y], 0, $this->x);
- array_splice($this->attrs[$this->y], $this->x + 1, $this->max_x - $this->x, array_fill($this->x, $this->max_x - $this->x - 1, $this->base_attr_cell));
+ array_splice($this->attrs[$this->y], $this->x + 1, $this->max_x - $this->x, array_fill($this->x, $this->max_x - ($this->x - 1), $this->base_attr_cell));
break;
case "\x1B[2K": // Clear entire line
$this->screen[$this->y] = str_repeat(' ', $this->x);
@@ -283,7 +282,7 @@ class ANSI
case "\x1B(B": // set united states g0 character set
break;
case "\x1BE": // Move to next line
- $this->_newLine();
+ $this->newLine();
$this->x = 0;
break;
default:
@@ -316,19 +315,20 @@ class ANSI
$mods = explode(';', $match[1]);
foreach ($mods as $mod) {
switch ($mod) {
- case 0: // Turn off character attributes
+ case '':
+ case '0': // Turn off character attributes
$attr_cell = clone $this->base_attr_cell;
break;
- case 1: // Turn bold mode on
+ case '1': // Turn bold mode on
$attr_cell->bold = true;
break;
- case 4: // Turn underline mode on
+ case '4': // Turn underline mode on
$attr_cell->underline = true;
break;
- case 5: // Turn blinking mode on
+ case '5': // Turn blinking mode on
$attr_cell->blink = true;
break;
- case 7: // Turn reverse video on
+ case '7': // Turn reverse video on
$attr_cell->reverse = !$attr_cell->reverse;
$temp = $attr_cell->background;
$attr_cell->background = $attr_cell->foreground;
@@ -341,23 +341,23 @@ class ANSI
$back = &$attr_cell->{ $attr_cell->reverse ? 'foreground' : 'background' };
switch ($mod) {
// @codingStandardsIgnoreStart
- case 30: $front = 'black'; break;
- case 31: $front = 'red'; break;
- case 32: $front = 'green'; break;
- case 33: $front = 'yellow'; break;
- case 34: $front = 'blue'; break;
- case 35: $front = 'magenta'; break;
- case 36: $front = 'cyan'; break;
- case 37: $front = 'white'; break;
+ case '30': $front = 'black'; break;
+ case '31': $front = 'red'; break;
+ case '32': $front = 'green'; break;
+ case '33': $front = 'yellow'; break;
+ case '34': $front = 'blue'; break;
+ case '35': $front = 'magenta'; break;
+ case '36': $front = 'cyan'; break;
+ case '37': $front = 'white'; break;
- case 40: $back = 'black'; break;
- case 41: $back = 'red'; break;
- case 42: $back = 'green'; break;
- case 43: $back = 'yellow'; break;
- case 44: $back = 'blue'; break;
- case 45: $back = 'magenta'; break;
- case 46: $back = 'cyan'; break;
- case 47: $back = 'white'; break;
+ case '40': $back = 'black'; break;
+ case '41': $back = 'red'; break;
+ case '42': $back = 'green'; break;
+ case '43': $back = 'yellow'; break;
+ case '44': $back = 'blue'; break;
+ case '45': $back = 'magenta'; break;
+ case '46': $back = 'cyan'; break;
+ case '47': $back = 'white'; break;
// @codingStandardsIgnoreEnd
default:
@@ -382,7 +382,7 @@ class ANSI
$this->x = 0;
break;
case "\n":
- $this->_newLine();
+ $this->newLine();
break;
case "\x08": // backspace
if ($this->x) {
@@ -419,7 +419,7 @@ class ANSI
if ($this->x > $this->max_x) {
$this->x = 0;
- $this->_newLine();
+ $this->newLine();
} else {
$this->x++;
}
@@ -434,17 +434,17 @@ class ANSI
*
* @access private
*/
- function _newLine()
+ private function newLine()
{
//if ($this->y < $this->max_y) {
// $this->y++;
//}
while ($this->y >= $this->max_y) {
- $this->history = array_merge($this->history, array(array_shift($this->screen)));
+ $this->history = array_merge($this->history, [array_shift($this->screen)]);
$this->screen[] = '';
- $this->history_attrs = array_merge($this->history_attrs, array(array_shift($this->attrs)));
+ $this->history_attrs = array_merge($this->history_attrs, [array_shift($this->attrs)]);
$this->attrs[] = $this->attr_row;
if (count($this->history) >= $this->max_history) {
@@ -461,9 +461,12 @@ class ANSI
* Returns the current coordinate without preformating
*
* @access private
+ * @param \stdClass $last_attr
+ * @param \stdClass $cur_attr
+ * @param string $char
* @return string
*/
- function _processCoordinate($last_attr, $cur_attr, $char)
+ private function processCoordinate($last_attr, $cur_attr, $char)
{
$output = '';
@@ -520,21 +523,21 @@ class ANSI
* @access private
* @return string
*/
- function _getScreen()
+ private function getScreenHelper()
{
$output = '';
$last_attr = $this->base_attr_cell;
for ($i = 0; $i <= $this->max_y; $i++) {
for ($j = 0; $j <= $this->max_x; $j++) {
$cur_attr = $this->attrs[$i][$j];
- $output.= $this->_processCoordinate($last_attr, $cur_attr, isset($this->screen[$i][$j]) ? $this->screen[$i][$j] : '');
+ $output.= $this->processCoordinate($last_attr, $cur_attr, isset($this->screen[$i][$j]) ? $this->screen[$i][$j] : '');
$last_attr = $this->attrs[$i][$j];
}
$output.= "\r\n";
}
$output = substr($output, 0, -2);
// close any remaining open tags
- $output.= $this->_processCoordinate($last_attr, $this->base_attr_cell, '');
+ $output.= $this->processCoordinate($last_attr, $this->base_attr_cell, '');
return rtrim($output);
}
@@ -544,9 +547,9 @@ class ANSI
* @access public
* @return string
*/
- function getScreen()
+ public function getScreen()
{
- return '' . $this->_getScreen() . '
';
+ return '' . $this->getScreenHelper() . '
';
}
/**
@@ -555,21 +558,21 @@ class ANSI
* @access public
* @return string
*/
- function getHistory()
+ public function getHistory()
{
$scrollback = '';
$last_attr = $this->base_attr_cell;
for ($i = 0; $i < count($this->history); $i++) {
for ($j = 0; $j <= $this->max_x + 1; $j++) {
$cur_attr = $this->history_attrs[$i][$j];
- $scrollback.= $this->_processCoordinate($last_attr, $cur_attr, isset($this->history[$i][$j]) ? $this->history[$i][$j] : '');
+ $scrollback.= $this->processCoordinate($last_attr, $cur_attr, isset($this->history[$i][$j]) ? $this->history[$i][$j] : '');
$last_attr = $this->history_attrs[$i][$j];
}
$scrollback.= "\r\n";
}
$base_attr_cell = $this->base_attr_cell;
$this->base_attr_cell = $last_attr;
- $scrollback.= $this->_getScreen();
+ $scrollback.= $this->getScreen();
$this->base_attr_cell = $base_attr_cell;
return '' . $scrollback . '
';
diff --git a/lam/lib/3rdParty/phpseclib/File/ASN1.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1.php
similarity index 78%
rename from lam/lib/3rdParty/phpseclib/File/ASN1.php
rename to lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1.php
index 3aaa30900..cdc5b697d 100644
--- a/lam/lib/3rdParty/phpseclib/File/ASN1.php
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1.php
@@ -9,7 +9,7 @@
* utilized scheme is DER or the "Distinguished Encoding Rules". PEM's are base64 encoded
* DER blobs.
*
- * \phpseclib\File\ASN1 decodes and encodes DER formatted messages and places them in a semantic context.
+ * \phpseclib3\File\ASN1 decodes and encodes DER formatted messages and places them in a semantic context.
*
* Uses the 1988 ASN.1 syntax.
*
@@ -21,10 +21,12 @@
* @link http://phpseclib.sourceforge.net
*/
-namespace phpseclib\File;
+namespace phpseclib3\File;
-use phpseclib\File\ASN1\Element;
-use phpseclib\Math\BigInteger;
+use ParagonIE\ConstantTime\Base64;
+use phpseclib3\File\ASN1\Element;
+use phpseclib3\Math\BigInteger;
+use phpseclib3\Common\Functions\Strings;
use DateTime;
use DateTimeZone;
@@ -35,26 +37,17 @@ use DateTimeZone;
* @author Jim Wigginton
* @access public
*/
-class ASN1
+abstract class ASN1
{
- /**#@+
- * Tag Classes
- *
- * @access private
- * @link http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#page=12
- */
+ // Tag Classes
+ // http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#page=12
const CLASS_UNIVERSAL = 0;
const CLASS_APPLICATION = 1;
const CLASS_CONTEXT_SPECIFIC = 2;
const CLASS_PRIVATE = 3;
- /**#@-*/
- /**#@+
- * Tag Classes
- *
- * @access private
- * @link http://www.obj-sys.com/asn1tutorial/node124.html
- */
+ // Tag Classes
+ // http://www.obj-sys.com/asn1tutorial/node124.html
const TYPE_BOOLEAN = 1;
const TYPE_INTEGER = 2;
const TYPE_BIT_STRING = 3;
@@ -70,13 +63,9 @@ class ASN1
//const TYPE_RELATIVE_OID = 13;
const TYPE_SEQUENCE = 16; // SEQUENCE OF
const TYPE_SET = 17; // SET OF
- /**#@-*/
- /**#@+
- * More Tag Classes
- *
- * @access private
- * @link http://www.obj-sys.com/asn1tutorial/node10.html
- */
+
+ // More Tag Classes
+ // http://www.obj-sys.com/asn1tutorial/node10.html
const TYPE_NUMERIC_STRING = 18;
const TYPE_PRINTABLE_STRING = 19;
const TYPE_TELETEX_STRING = 20; // T61String
@@ -90,27 +79,28 @@ class ASN1
const TYPE_UNIVERSAL_STRING = 28;
//const TYPE_CHARACTER_STRING = 29;
const TYPE_BMP_STRING = 30;
- /**#@-*/
- /**#@+
- * Tag Aliases
- *
- * These tags are kinda place holders for other tags.
- *
- * @access private
- */
+ // Tag Aliases
+ // These tags are kinda place holders for other tags.
const TYPE_CHOICE = -1;
const TYPE_ANY = -2;
- /**#@-*/
/**
- * ASN.1 object identifier
+ * ASN.1 object identifiers
*
* @var array
* @access private
* @link http://en.wikipedia.org/wiki/Object_identifier
*/
- var $oids = array();
+ private static $oids = [];
+
+ /**
+ * ASN.1 object identifier reverse mapping
+ *
+ * @var array
+ * @access private
+ */
+ private static $reverseOIDs = [];
/**
* Default date format
@@ -119,18 +109,7 @@ class ASN1
* @access private
* @link http://php.net/class.datetime
*/
- var $format = 'D, d M Y H:i:s O';
-
- /**
- * Default date format
- *
- * @var array
- * @access private
- * @see self::setTimeFormat()
- * @see self::asn1map()
- * @link http://php.net/class.datetime
- */
- var $encoded;
+ private static $format = 'D, d M Y H:i:s O';
/**
* Filters
@@ -139,21 +118,43 @@ class ASN1
*
* @var array
* @access private
- * @see self::_encode_der()
+ * @see self::encode_der()
*/
- var $filters;
+ private static $filters;
+
+ /**
+ * Current Location of most recent ASN.1 encode process
+ *
+ * Useful for debug purposes
+ *
+ * @var array
+ * @access private
+ * @see self::encode_der()
+ */
+ private static $location;
+
+ /**
+ * DER Encoded String
+ *
+ * In case we need to create ASN1\Element object's..
+ *
+ * @var string
+ * @access private
+ * @see self::decodeDER()
+ */
+ private static $encoded;
/**
* Type mapping table for the ANY type.
*
- * Structured or unknown types are mapped to a \phpseclib\File\ASN1\Element.
+ * Structured or unknown types are mapped to a \phpseclib3\File\ASN1\Element.
* Unambiguous types get the direct mapping (int/real/bool).
* Others are mapped as a choice, with an extra indexing level.
*
* @var array
* @access public
*/
- var $ANYmap = array(
+ const ANY_MAP = [
self::TYPE_BOOLEAN => true,
self::TYPE_INTEGER => true,
self::TYPE_BIT_STRING => 'bitString',
@@ -176,7 +177,7 @@ class ASN1
self::TYPE_UNIVERSAL_STRING => 'universalString',
//self::TYPE_CHARACTER_STRING => 'characterString',
self::TYPE_BMP_STRING => 'bmpString'
- );
+ ];
/**
* String type to character size mapping table.
@@ -187,7 +188,7 @@ class ASN1
* @var array
* @access public
*/
- var $stringTypeSize = array(
+ const STRING_TYPE_SIZE = [
self::TYPE_UTF8_STRING => 0,
self::TYPE_BMP_STRING => 2,
self::TYPE_UNIVERSAL_STRING => 4,
@@ -195,7 +196,7 @@ class ASN1
self::TYPE_TELETEX_STRING => 1,
self::TYPE_IA5_STRING => 1,
self::TYPE_VISIBLE_STRING => 1,
- );
+ ];
/**
* Parse BER-encoding
@@ -206,15 +207,18 @@ class ASN1
* @return array
* @access public
*/
- function decodeBER($encoded)
+ public static function decodeBER($encoded)
{
if ($encoded instanceof Element) {
$encoded = $encoded->element;
}
- $this->encoded = $encoded;
+ self::$encoded = $encoded;
+
+ $decoded = [self::decode_ber($encoded)];
+
// encapsulate in an array for BC with the old decodeBER
- return array($this->_decode_ber($encoded));
+ return $decoded;
}
/**
@@ -227,12 +231,12 @@ class ASN1
* @param string $encoded
* @param int $start
* @param int $encoded_pos
- * @return array
+ * @return array|bool
* @access private
*/
- function _decode_ber($encoded, $start = 0, $encoded_pos = 0)
+ private static function decode_ber($encoded, $start = 0, $encoded_pos = 0)
{
- $current = array('start' => $start);
+ $current = ['start' => $start];
$type = ord($encoded[$encoded_pos++]);
$start++;
@@ -266,11 +270,12 @@ class ASN1
$temp = substr($encoded, $encoded_pos, $length);
$encoded_pos += $length;
// tags of indefinte length don't really have a header length; this length includes the tag
- $current+= array('headerlength' => $length + 2);
+ $current+= ['headerlength' => $length + 2];
$start+= $length;
extract(unpack('Nlength', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4)));
+ /** @var integer $length */
} else {
- $current+= array('headerlength' => 2);
+ $current+= ['headerlength' => 2];
}
if ($length > (strlen($encoded) - $encoded_pos)) {
@@ -297,18 +302,18 @@ class ASN1
case self::CLASS_PRIVATE:
case self::CLASS_CONTEXT_SPECIFIC:
if (!$constructed) {
- return array(
+ return [
'type' => $class,
'constant' => $tag,
'content' => $content,
'length' => $length + $start - $current['start']
- );
+ ] + $current;
}
- $newcontent = array();
+ $newcontent = [];
$remainingLength = $length;
while ($remainingLength > 0) {
- $temp = $this->_decode_ber($content, $start, $content_pos);
+ $temp = self::decode_ber($content, $start, $content_pos);
if ($temp === false) {
break;
}
@@ -326,7 +331,7 @@ class ASN1
$content_pos += $length;
}
- return array(
+ return [
'type' => $class,
'constant' => $tag,
// the array encapsulation is for BC with the old format
@@ -335,10 +340,10 @@ class ASN1
// the absence of $content['headerlength'] is how we know if something is indefinite or not.
// technically, it could be defined to be 2 and then another indicator could be used but whatever.
'length' => $start - $current['start']
- ) + $current;
+ ] + $current;
}
- $current+= array('type' => $tag);
+ $current+= ['type' => $tag];
// decode UNIVERSAL tags
switch ($tag) {
@@ -362,7 +367,7 @@ class ASN1
if (!$constructed) {
$current['content'] = substr($content, $content_pos);
} else {
- $temp = $this->_decode_ber($content, $start, $content_pos);
+ $temp = self::decode_ber($content, $start, $content_pos);
if ($temp === false) {
return false;
}
@@ -389,7 +394,7 @@ class ASN1
$current['content'] = '';
$length = 0;
while (substr($content, $content_pos, 2) != "\0\0") {
- $temp = $this->_decode_ber($content, $length + $start, $content_pos);
+ $temp = self::decode_ber($content, $length + $start, $content_pos);
if ($temp === false) {
return false;
}
@@ -415,7 +420,7 @@ class ASN1
case self::TYPE_SEQUENCE:
case self::TYPE_SET:
$offset = 0;
- $current['content'] = array();
+ $current['content'] = [];
$content_len = strlen($content);
while ($content_pos < $content_len) {
// if indefinite length construction was used and we have an end-of-content string next
@@ -424,7 +429,7 @@ class ASN1
$length = $offset + 2; // +2 for the EOC
break 2;
}
- $temp = $this->_decode_ber($content, $start + $offset, $content_pos);
+ $temp = self::decode_ber($content, $start + $offset, $content_pos);
if ($temp === false) {
return false;
}
@@ -434,7 +439,7 @@ class ASN1
}
break;
case self::TYPE_OBJECT_IDENTIFIER:
- $current['content'] = $this->_decodeOID(substr($content, $content_pos));
+ $current['content'] = self::decodeOID(substr($content, $content_pos));
break;
/* Each character string type shall be encoded as if it had been declared:
[UNIVERSAL x] IMPLICIT OCTET STRING
@@ -468,14 +473,14 @@ class ASN1
break;
case self::TYPE_UTC_TIME:
case self::TYPE_GENERALIZED_TIME:
- $current['content'] = $this->_decodeTime(substr($content, $content_pos), $tag);
+ $current['content'] = self::decodeTime(substr($content, $content_pos), $tag);
default:
}
$start+= $length;
// ie. length is the length of the full TLV encoding - it's not just the length of the value
- return $current + array('length' => $start - $current['start']);
+ return $current + ['length' => $start - $current['start']];
}
/**
@@ -488,11 +493,15 @@ class ASN1
* @param array $decoded
* @param array $mapping
* @param array $special
- * @return array
+ * @return array|bool|Element
* @access public
*/
- function asn1map($decoded, $mapping, $special = array())
+ public static function asn1map($decoded, $mapping, $special = [])
{
+ if (!is_array($decoded)) {
+ return false;
+ }
+
if (isset($mapping['explicit']) && is_array($decoded['content'])) {
$decoded = $decoded['content'][0];
}
@@ -500,12 +509,13 @@ class ASN1
switch (true) {
case $mapping['type'] == self::TYPE_ANY:
$intype = $decoded['type'];
- if (isset($decoded['constant']) || !isset($this->ANYmap[$intype]) || (ord($this->encoded[$decoded['start']]) & 0x20)) {
- return new Element(substr($this->encoded, $decoded['start'], $decoded['length']));
+ // !isset(self::ANY_MAP[$intype]) produces a fatal error on PHP 5.6
+ if (isset($decoded['constant']) || !array_key_exists($intype, self::ANY_MAP) || (ord(self::$encoded[$decoded['start']]) & 0x20)) {
+ return new Element(substr(self::$encoded, $decoded['start'], $decoded['length']));
}
- $inmap = $this->ANYmap[$intype];
+ $inmap = self::ANY_MAP[$intype];
if (is_string($inmap)) {
- return array($inmap => $this->asn1map($decoded, array('type' => $intype) + $mapping, $special));
+ return [$inmap => self::asn1map($decoded, ['type' => $intype] + $mapping, $special)];
}
break;
case $mapping['type'] == self::TYPE_CHOICE:
@@ -513,19 +523,19 @@ class ASN1
switch (true) {
case isset($option['constant']) && $option['constant'] == $decoded['constant']:
case !isset($option['constant']) && $option['type'] == $decoded['type']:
- $value = $this->asn1map($decoded, $option, $special);
+ $value = self::asn1map($decoded, $option, $special);
break;
case !isset($option['constant']) && $option['type'] == self::TYPE_CHOICE:
- $v = $this->asn1map($decoded, $option, $special);
+ $v = self::asn1map($decoded, $option, $special);
if (isset($v)) {
$value = $v;
}
}
if (isset($value)) {
if (isset($special[$key])) {
- $value = call_user_func($special[$key], $value);
+ $value = $special[$key]($value);
}
- return array($key => $value);
+ return [$key => $value];
}
}
return null;
@@ -551,13 +561,13 @@ class ASN1
switch ($decoded['type']) {
case self::TYPE_SEQUENCE:
- $map = array();
+ $map = [];
// ignore the min and max
if (isset($mapping['min']) && isset($mapping['max'])) {
$child = $mapping['children'];
foreach ($decoded['content'] as $content) {
- if (($map[] = $this->asn1map($content, $child, $special)) === null) {
+ if (($map[] = self::asn1map($content, $child, $special)) === null) {
return null;
}
}
@@ -593,26 +603,37 @@ class ASN1
$maymatch = $constant == $temp['constant'] && $childClass == $tempClass;
} else {
// Can only match if no constant expected and type matches or is generic.
- $maymatch = !isset($child['constant']) && array_search($child['type'], array($temp['type'], self::TYPE_ANY, self::TYPE_CHOICE)) !== false;
+ $maymatch = !isset($child['constant']) && array_search($child['type'], [$temp['type'], self::TYPE_ANY, self::TYPE_CHOICE]) !== false;
}
}
}
if ($maymatch) {
// Attempt submapping.
- $candidate = $this->asn1map($temp, $child, $special);
+ $candidate = self::asn1map($temp, $child, $special);
$maymatch = $candidate !== null;
}
if ($maymatch) {
// Got the match: use it.
if (isset($special[$key])) {
- $candidate = call_user_func($special[$key], $candidate);
+ $candidate = $special[$key]($candidate);
}
$map[$key] = $candidate;
$i++;
} elseif (isset($child['default'])) {
- $map[$key] = $child['default']; // Use default.
+ switch ($child['type']) {
+ case ASN1::TYPE_INTEGER:
+ $map[$key] = new BigInteger($child['default']);
+ break;
+ //case self::TYPE_OBJECT_IDENTIFIER:
+ // if (!isset(self::$reverseOIDs[$name])) {
+ // return null;
+ // }
+ //case ASN1::TYPE_BOOLEAN:
+ default:
+ $map[$key] = $child['default'];
+ }
} elseif (!isset($child['optional'])) {
return null; // Syntax error.
}
@@ -623,13 +644,13 @@ class ASN1
// the main diff between sets and sequences is the encapsulation of the foreach in another for loop
case self::TYPE_SET:
- $map = array();
+ $map = [];
// ignore the min and max
if (isset($mapping['min']) && isset($mapping['max'])) {
$child = $mapping['children'];
foreach ($decoded['content'] as $content) {
- if (($map[] = $this->asn1map($content, $child, $special)) === null) {
+ if (($map[] = self::asn1map($content, $child, $special)) === null) {
return null;
}
}
@@ -665,13 +686,13 @@ class ASN1
$maymatch = $constant == $temp['constant'] && $childClass == $tempClass;
} else {
// Can only match if no constant expected and type matches or is generic.
- $maymatch = !isset($child['constant']) && array_search($child['type'], array($temp['type'], self::TYPE_ANY, self::TYPE_CHOICE)) !== false;
+ $maymatch = !isset($child['constant']) && array_search($child['type'], [$temp['type'], self::TYPE_ANY, self::TYPE_CHOICE]) !== false;
}
}
if ($maymatch) {
// Attempt submapping.
- $candidate = $this->asn1map($temp, $child, $special);
+ $candidate = self::asn1map($temp, $child, $special);
$maymatch = $candidate !== null;
}
@@ -681,7 +702,7 @@ class ASN1
// Got the match: use it.
if (isset($special[$key])) {
- $candidate = call_user_func($special[$key], $candidate);
+ $candidate = $special[$key]($candidate);
}
$map[$key] = $candidate;
break;
@@ -699,13 +720,20 @@ class ASN1
}
return $map;
case self::TYPE_OBJECT_IDENTIFIER:
- return isset($this->oids[$decoded['content']]) ? $this->oids[$decoded['content']] : $decoded['content'];
+ return isset(self::$oids[$decoded['content']]) ? self::$oids[$decoded['content']] : $decoded['content'];
case self::TYPE_UTC_TIME:
case self::TYPE_GENERALIZED_TIME:
- if (isset($mapping['implicit'])) {
- $decoded['content'] = $this->_decodeTime($decoded['content'], $decoded['type']);
+ // for explicitly tagged optional stuff
+ if (is_array($decoded['content'])) {
+ $decoded['content'] = $decoded['content'][0]['content'];
}
- return $decoded['content'] ? $decoded['content']->format($this->format) : false;
+ // for implicitly tagged optional stuff
+ // in theory, doing isset($mapping['implicit']) would work but malformed certs do exist
+ // in the wild that OpenSSL decodes without issue so we'll support them as well
+ if (!is_object($decoded['content'])) {
+ $decoded['content'] = self::decodeTime($decoded['content'], $decoded['type']);
+ }
+ return $decoded['content'] ? $decoded['content']->format(self::$format) : false;
case self::TYPE_BIT_STRING:
if (isset($mapping['mapping'])) {
$offset = ord($decoded['content'][0]);
@@ -718,7 +746,7 @@ class ASN1
therefore ensure that different semantics are not associated with such values which differ only in the number of trailing
0 bits."
*/
- $bits = count($mapping['mapping']) == $size ? array() : array_fill(0, count($mapping['mapping']) - $size, false);
+ $bits = count($mapping['mapping']) == $size ? [] : array_fill(0, count($mapping['mapping']) - $size, false);
for ($i = strlen($decoded['content']) - 1; $i > 0; $i--) {
$current = ord($decoded['content'][$i]);
for ($j = $offset; $j < 8; $j++) {
@@ -726,7 +754,7 @@ class ASN1
}
$offset = 0;
}
- $values = array();
+ $values = [];
$map = array_reverse($mapping['mapping']);
foreach ($map as $i => $value) {
if ($bits[$i]) {
@@ -736,7 +764,7 @@ class ASN1
return $values;
}
case self::TYPE_OCTET_STRING:
- return base64_encode($decoded['content']);
+ return $decoded['content'];
case self::TYPE_NULL:
return '';
case self::TYPE_BOOLEAN:
@@ -769,6 +797,27 @@ class ASN1
}
}
+ /**
+ * DER-decode the length
+ *
+ * DER supports lengths up to (2**8)**127, however, we'll only support lengths up to (2**8)**4. See
+ * {@link http://itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#p=13 X.690 paragraph 8.1.3} for more information.
+ *
+ * @access public
+ * @param string $string
+ * @return int
+ */
+ public static function decodeLength(&$string)
+ {
+ $length = ord(Strings::shift($string));
+ if ($length & 0x80) { // definite length, long form
+ $length&= 0x7F;
+ $temp = Strings::shift($string, $length);
+ list(, $length) = unpack('N', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4));
+ }
+ return $length;
+ }
+
/**
* ASN.1 Encode
*
@@ -777,28 +826,29 @@ class ASN1
*
* "Special" mappings can be applied via $special.
*
- * @param string $source
- * @param string $mapping
- * @param int $idx
+ * @param Element|string|array $source
+ * @param array $mapping
+ * @param array $special
* @return string
* @access public
*/
- function encodeDER($source, $mapping, $special = array())
+ public static function encodeDER($source, $mapping, $special = [])
{
- $this->location = array();
- return $this->_encode_der($source, $mapping, null, $special);
+ self::$location = [];
+ return self::encode_der($source, $mapping, null, $special);
}
/**
* ASN.1 Encode (Helper function)
*
- * @param string $source
- * @param string $mapping
+ * @param Element|string|array $source
+ * @param array $mapping
* @param int $idx
+ * @param array $special
* @return string
* @access private
*/
- function _encode_der($source, $mapping, $idx = null, $special = array())
+ private static function encode_der($source, $mapping, $idx = null, $special = [])
{
if ($source instanceof Element) {
return $source->element;
@@ -811,9 +861,9 @@ class ASN1
if (isset($idx)) {
if (isset($special[$idx])) {
- $source = call_user_func($special[$idx], $source);
+ $source = $special[$idx]($source);
}
- $this->location[] = $idx;
+ self::$location[] = $idx;
}
$tag = $mapping['type'];
@@ -825,11 +875,11 @@ class ASN1
// ignore the min and max
if (isset($mapping['min']) && isset($mapping['max'])) {
- $value = array();
+ $value = [];
$child = $mapping['children'];
foreach ($source as $content) {
- $temp = $this->_encode_der($content, $child, null, $special);
+ $temp = self::encode_der($content, $child, null, $special);
if ($temp === false) {
return false;
}
@@ -843,7 +893,7 @@ class ASN1
if ($mapping['type'] == self::TYPE_SET) {
sort($value);
}
- $value = implode($value, '');
+ $value = implode('', $value);
break;
}
@@ -856,7 +906,7 @@ class ASN1
continue;
}
- $temp = $this->_encode_der($source[$key], $child, $key, $special);
+ $temp = self::encode_der($source[$key], $child, $key, $special);
if ($temp === false) {
return false;
}
@@ -880,7 +930,7 @@ class ASN1
*/
if (isset($child['explicit']) || $child['type'] == self::TYPE_CHOICE) {
$subtag = chr((self::CLASS_CONTEXT_SPECIFIC << 6) | 0x20 | $child['constant']);
- $temp = $subtag . $this->_encodeLength(strlen($temp)) . $temp;
+ $temp = $subtag . self::encodeLength(strlen($temp)) . $temp;
} else {
$subtag = chr((self::CLASS_CONTEXT_SPECIFIC << 6) | (ord($temp[0]) & 0x20) | $child['constant']);
$temp = $subtag . substr($temp, 1);
@@ -897,7 +947,7 @@ class ASN1
continue;
}
- $temp = $this->_encode_der($source[$key], $child, $key, $special);
+ $temp = self::encode_der($source[$key], $child, $key, $special);
if ($temp === false) {
return false;
}
@@ -914,7 +964,7 @@ class ASN1
if (isset($child['constant'])) {
if (isset($child['explicit']) || $child['type'] == self::TYPE_CHOICE) {
$subtag = chr((self::CLASS_CONTEXT_SPECIFIC << 6) | 0x20 | $child['constant']);
- $temp = $subtag . $this->_encodeLength(strlen($temp)) . $temp;
+ $temp = $subtag . self::encodeLength(strlen($temp)) . $temp;
} else {
$subtag = chr((self::CLASS_CONTEXT_SPECIFIC << 6) | (ord($temp[0]) & 0x20) | $child['constant']);
$temp = $subtag . substr($temp, 1);
@@ -923,7 +973,7 @@ class ASN1
}
if (isset($idx)) {
- array_pop($this->location);
+ array_pop(self::$location);
}
if ($temp && isset($mapping['cast'])) {
@@ -994,36 +1044,36 @@ class ASN1
the number of unused bits in the final subsequent octet. The number shall be in the range zero to seven.
-- http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#page=16 */
- $value = base64_decode($source);
+ $value = $source;
break;
case self::TYPE_OBJECT_IDENTIFIER:
- $value = $this->_encodeOID($source);
+ $value = self::encodeOID($source);
break;
case self::TYPE_ANY:
- $loc = $this->location;
+ $loc = self::$location;
if (isset($idx)) {
- array_pop($this->location);
+ array_pop(self::$location);
}
switch (true) {
case !isset($source):
- return $this->_encode_der(null, array('type' => self::TYPE_NULL) + $mapping, null, $special);
+ return self::encode_der(null, ['type' => self::TYPE_NULL] + $mapping, null, $special);
case is_int($source):
case $source instanceof BigInteger:
- return $this->_encode_der($source, array('type' => self::TYPE_INTEGER) + $mapping, null, $special);
+ return self::encode_der($source, ['type' => self::TYPE_INTEGER] + $mapping, null, $special);
case is_float($source):
- return $this->_encode_der($source, array('type' => self::TYPE_REAL) + $mapping, null, $special);
+ return self::encode_der($source, ['type' => self::TYPE_REAL] + $mapping, null, $special);
case is_bool($source):
- return $this->_encode_der($source, array('type' => self::TYPE_BOOLEAN) + $mapping, null, $special);
+ return self::encode_der($source, ['type' => self::TYPE_BOOLEAN] + $mapping, null, $special);
case is_array($source) && count($source) == 1:
$typename = implode('', array_keys($source));
- $outtype = array_search($typename, $this->ANYmap, true);
+ $outtype = array_search($typename, self::ANY_MAP, true);
if ($outtype !== false) {
- return $this->_encode_der($source[$typename], array('type' => $outtype) + $mapping, null, $special);
+ return self::encode_der($source[$typename], ['type' => $outtype] + $mapping, null, $special);
}
}
- $filters = $this->filters;
+ $filters = self::$filters;
foreach ($loc as $part) {
if (!isset($filters[$part])) {
$filters = false;
@@ -1032,10 +1082,9 @@ class ASN1
$filters = $filters[$part];
}
if ($filters === false) {
- user_error('No filters defined for ' . implode('/', $loc));
- return false;
+ throw new \RuntimeException('No filters defined for ' . implode('/', $loc));
}
- return $this->_encode_der($source, $filters + $mapping, null, $special);
+ return self::encode_der($source, $filters + $mapping, null, $special);
case self::TYPE_NULL:
$value = '';
break;
@@ -1056,44 +1105,23 @@ class ASN1
$value = $source ? "\xFF" : "\x00";
break;
default:
- user_error('Mapping provides no type definition for ' . implode('/', $this->location));
- return false;
+ throw new \RuntimeException('Mapping provides no type definition for ' . implode('/', self::$location));
}
if (isset($idx)) {
- array_pop($this->location);
+ array_pop(self::$location);
}
if (isset($mapping['cast'])) {
if (isset($mapping['explicit']) || $mapping['type'] == self::TYPE_CHOICE) {
- $value = chr($tag) . $this->_encodeLength(strlen($value)) . $value;
+ $value = chr($tag) . self::encodeLength(strlen($value)) . $value;
$tag = ($mapping['class'] << 6) | 0x20 | $mapping['cast'];
} else {
$tag = ($mapping['class'] << 6) | (ord($temp[0]) & 0x20) | $mapping['cast'];
}
}
- return chr($tag) . $this->_encodeLength(strlen($value)) . $value;
- }
-
- /**
- * DER-encode the length
- *
- * DER supports lengths up to (2**8)**127, however, we'll only support lengths up to (2**8)**4. See
- * {@link http://itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#p=13 X.690 paragraph 8.1.3} for more information.
- *
- * @access private
- * @param int $length
- * @return string
- */
- function _encodeLength($length)
- {
- if ($length <= 0x7F) {
- return chr($length);
- }
-
- $temp = ltrim(pack('N', $length), chr(0));
- return pack('Ca*', 0x80 | strlen($temp), $temp);
+ return chr($tag) . self::encodeLength(strlen($value)) . $value;
}
/**
@@ -1101,11 +1129,11 @@ class ASN1
*
* Called by _decode_ber()
*
- * @access private
+ * @access public
* @param string $content
* @return string
*/
- function _decodeOID($content)
+ public static function decodeOID($content)
{
static $eighty;
if (!$eighty) {
@@ -1149,11 +1177,11 @@ class ASN1
*
* Called by _encode_der()
*
- * @access private
- * @param string $content
+ * @access public
+ * @param string $source
* @return string
*/
- function _encodeOID($source)
+ public static function encodeOID($source)
{
static $mask, $zero, $forty;
if (!$mask) {
@@ -1162,11 +1190,15 @@ class ASN1
$forty = new BigInteger(40);
}
- $oid = preg_match('#(?:\d+\.)+#', $source) ? $source : array_search($source, $this->oids);
- if ($oid === false) {
- user_error('Invalid OID');
- return false;
+ if (!preg_match('#(?:\d+\.)+#', $source)) {
+ $oid = isset(self::$reverseOIDs[$source]) ? self::$reverseOIDs[$source] : false;
+ } else {
+ $oid = $source;
}
+ if ($oid === false) {
+ throw new \RuntimeException('Invalid OID');
+ }
+
$parts = explode('.', $oid);
$part1 = array_shift($parts);
$part2 = array_shift($parts);
@@ -1208,7 +1240,7 @@ class ASN1
* @param int $tag
* @return string
*/
- function _decodeTime($content, $tag)
+ private static function decodeTime($content, $tag)
{
/* UTCTime:
http://tools.ietf.org/html/rfc5280#section-4.1.2.5.1
@@ -1254,52 +1286,38 @@ class ASN1
* @access public
* @param string $format
*/
- function setTimeFormat($format)
+ public static function setTimeFormat($format)
{
- $this->format = $format;
+ self::$format = $format;
}
/**
* Load OIDs
*
* Load the relevant OIDs for a particular ASN.1 semantic mapping.
+ * Previously loaded OIDs are retained.
*
* @access public
* @param array $oids
*/
- function loadOIDs($oids)
+ public static function loadOIDs($oids)
{
- $this->oids = $oids;
+ self::$reverseOIDs+= $oids;
+ self::$oids = array_flip(self::$reverseOIDs);
}
/**
- * Load filters
+ * Set filters
*
- * See \phpseclib\File\X509, etc, for an example.
+ * See \phpseclib3\File\X509, etc, for an example.
+ * Previously loaded filters are not retained.
*
* @access public
* @param array $filters
*/
- function loadFilters($filters)
+ public static function setFilters($filters)
{
- $this->filters = $filters;
- }
-
- /**
- * String Shift
- *
- * Inspired by array_shift
- *
- * @param string $string
- * @param int $index
- * @return string
- * @access private
- */
- function _string_shift(&$string, $index = 1)
- {
- $substr = substr($string, 0, $index);
- $string = substr($string, $index);
- return $substr;
+ self::$filters = $filters;
}
/**
@@ -1314,13 +1332,14 @@ class ASN1
* @return string
* @access public
*/
- function convert($in, $from = self::TYPE_UTF8_STRING, $to = self::TYPE_UTF8_STRING)
+ public static function convert($in, $from = self::TYPE_UTF8_STRING, $to = self::TYPE_UTF8_STRING)
{
- if (!isset($this->stringTypeSize[$from]) || !isset($this->stringTypeSize[$to])) {
+ // isset(self::STRING_TYPE_SIZE[$from] returns a fatal error on PHP 5.6
+ if (!array_key_exists($from, self::STRING_TYPE_SIZE) || !array_key_exists($to, self::STRING_TYPE_SIZE)) {
return false;
}
- $insize = $this->stringTypeSize[$from];
- $outsize = $this->stringTypeSize[$to];
+ $insize = self::STRING_TYPE_SIZE[$from];
+ $outsize = self::STRING_TYPE_SIZE[$to];
$inlength = strlen($in);
$out = '';
@@ -1400,4 +1419,80 @@ class ASN1
}
return $out;
}
+
+ /**
+ * Extract raw BER from Base64 encoding
+ *
+ * @access private
+ * @param string $str
+ * @return string
+ */
+ public static function extractBER($str)
+ {
+ /* X.509 certs are assumed to be base64 encoded but sometimes they'll have additional things in them
+ * above and beyond the ceritificate.
+ * ie. some may have the following preceding the -----BEGIN CERTIFICATE----- line:
+ *
+ * Bag Attributes
+ * localKeyID: 01 00 00 00
+ * subject=/O=organization/OU=org unit/CN=common name
+ * issuer=/O=organization/CN=common name
+ */
+ if (strlen($str) > ini_get('pcre.backtrack_limit')) {
+ $temp = $str;
+ } else {
+ $temp = preg_replace('#.*?^-+[^-]+-+[\r\n ]*$#ms', '', $str, 1);
+ $temp = preg_replace('#-+END.*[\r\n ]*.*#ms', '', $str, 1);
+ }
+ // remove new lines
+ $temp = str_replace(["\r", "\n", ' '], '', $temp);
+ // remove the -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- stuff
+ $temp = preg_replace('#^-+[^-]+-+|-+[^-]+-+$#', '', $temp);
+ $temp = preg_match('#^[a-zA-Z\d/+]*={0,2}$#', $temp) ? Base64::decode($temp) : false;
+ return $temp != false ? $temp : $str;
+ }
+
+ /**
+ * DER-encode the length
+ *
+ * DER supports lengths up to (2**8)**127, however, we'll only support lengths up to (2**8)**4. See
+ * {@link http://itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#p=13 X.690 paragraph 8.1.3} for more information.
+ *
+ * @access public
+ * @param int $length
+ * @return string
+ */
+ public static function encodeLength($length)
+ {
+ if ($length <= 0x7F) {
+ return chr($length);
+ }
+
+ $temp = ltrim(pack('N', $length), chr(0));
+ return pack('Ca*', 0x80 | strlen($temp), $temp);
+ }
+
+ /**
+ * Returns the OID corresponding to a name
+ *
+ * What's returned in the associative array returned by loadX509() (or load*()) is either a name or an OID if
+ * no OID to name mapping is available. The problem with this is that what may be an unmapped OID in one version
+ * of phpseclib may not be unmapped in the next version, so apps that are looking at this OID may not be able
+ * to work from version to version.
+ *
+ * This method will return the OID if a name is passed to it and if no mapping is avialable it'll assume that
+ * what's being passed to it already is an OID and return that instead. A few examples.
+ *
+ * getOID('2.16.840.1.101.3.4.2.1') == '2.16.840.1.101.3.4.2.1'
+ * getOID('id-sha256') == '2.16.840.1.101.3.4.2.1'
+ * getOID('zzz') == 'zzz'
+ *
+ * @access public
+ * @param string $name
+ * @return string
+ */
+ public static function getOID($name)
+ {
+ return isset(self::$reverseOIDs[$name]) ? self::$reverseOIDs[$name] : $name;
+ }
}
diff --git a/lam/lib/3rdParty/phpseclib/File/ASN1/Element.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Element.php
similarity index 65%
rename from lam/lib/3rdParty/phpseclib/File/ASN1/Element.php
rename to lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Element.php
index 68246e2b5..ade26ae51 100644
--- a/lam/lib/3rdParty/phpseclib/File/ASN1/Element.php
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Element.php
@@ -1,6 +1,7 @@
@@ -31,16 +33,16 @@ class Element
* @var string
* @access private
*/
- var $element;
+ public $element;
/**
* Constructor
*
* @param string $encoded
- * @return \phpseclib\File\ASN1\Element
+ * @return \phpseclib3\File\ASN1\Element
* @access public
*/
- function __construct($encoded)
+ public function __construct($encoded)
{
$this->element = $encoded;
}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AccessDescription.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AccessDescription.php
new file mode 100644
index 000000000..969de8c44
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AccessDescription.php
@@ -0,0 +1,36 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * AccessDescription
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class AccessDescription
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'accessMethod' => ['type' => ASN1::TYPE_OBJECT_IDENTIFIER],
+ 'accessLocation' => GeneralName::MAP
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AdministrationDomainName.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AdministrationDomainName.php
new file mode 100644
index 000000000..1b607e7cd
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AdministrationDomainName.php
@@ -0,0 +1,40 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * AdministrationDomainName
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class AdministrationDomainName
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_CHOICE,
+ // if class isn't present it's assumed to be \phpseclib3\File\ASN1::CLASS_UNIVERSAL or
+ // (if constant is present) \phpseclib3\File\ASN1::CLASS_CONTEXT_SPECIFIC
+ 'class' => ASN1::CLASS_APPLICATION,
+ 'cast' => 2,
+ 'children' => [
+ 'numeric' => ['type' => ASN1::TYPE_NUMERIC_STRING],
+ 'printable' => ['type' => ASN1::TYPE_PRINTABLE_STRING]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AlgorithmIdentifier.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AlgorithmIdentifier.php
new file mode 100644
index 000000000..f9f25334a
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AlgorithmIdentifier.php
@@ -0,0 +1,39 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * AlgorithmIdentifier
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class AlgorithmIdentifier
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'algorithm' => ['type' => ASN1::TYPE_OBJECT_IDENTIFIER],
+ 'parameters' => [
+ 'type' => ASN1::TYPE_ANY,
+ 'optional' => true
+ ]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AnotherName.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AnotherName.php
new file mode 100644
index 000000000..3fe2ba0bd
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AnotherName.php
@@ -0,0 +1,41 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * AnotherName
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class AnotherName
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'type-id' => ['type' => ASN1::TYPE_OBJECT_IDENTIFIER],
+ 'value' => [
+ 'type' => ASN1::TYPE_ANY,
+ 'constant' => 0,
+ 'optional' => true,
+ 'explicit' => true
+ ]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Attribute.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Attribute.php
new file mode 100644
index 000000000..a80dad31c
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Attribute.php
@@ -0,0 +1,41 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * Attribute
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class Attribute
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'type' => AttributeType::MAP,
+ 'value'=> [
+ 'type' => ASN1::TYPE_SET,
+ 'min' => 1,
+ 'max' => -1,
+ 'children' => AttributeValue::MAP
+ ]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AttributeType.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AttributeType.php
new file mode 100644
index 000000000..891b80825
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AttributeType.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * AttributeType
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class AttributeType
+{
+ const MAP = ['type' => ASN1::TYPE_OBJECT_IDENTIFIER];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AttributeTypeAndValue.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AttributeTypeAndValue.php
new file mode 100644
index 000000000..ff4faa078
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AttributeTypeAndValue.php
@@ -0,0 +1,36 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * AttributeTypeAndValue
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class AttributeTypeAndValue
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'type' => AttributeType::MAP,
+ 'value'=> AttributeValue::MAP
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AttributeValue.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AttributeValue.php
new file mode 100644
index 000000000..eca03273c
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AttributeValue.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * AttributeValue
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class AttributeValue
+{
+ const MAP = ['type' => ASN1::TYPE_ANY];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Attributes.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Attributes.php
new file mode 100644
index 000000000..563a69001
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Attributes.php
@@ -0,0 +1,35 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * Attributes
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class Attributes
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SET,
+ 'min' => 1,
+ 'max' => -1,
+ 'children' => Attribute::MAP
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AuthorityInfoAccessSyntax.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AuthorityInfoAccessSyntax.php
new file mode 100644
index 000000000..38c714d5a
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AuthorityInfoAccessSyntax.php
@@ -0,0 +1,35 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * AuthorityInfoAccessSyntax
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class AuthorityInfoAccessSyntax
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'min' => 1,
+ 'max' => -1,
+ 'children' => AccessDescription::MAP
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AuthorityKeyIdentifier.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AuthorityKeyIdentifier.php
new file mode 100644
index 000000000..b6b08ae01
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AuthorityKeyIdentifier.php
@@ -0,0 +1,49 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * AuthorityKeyIdentifier
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class AuthorityKeyIdentifier
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'keyIdentifier' => [
+ 'constant' => 0,
+ 'optional' => true,
+ 'implicit' => true
+ ] + KeyIdentifier::MAP,
+ 'authorityCertIssuer' => [
+ 'constant' => 1,
+ 'optional' => true,
+ 'implicit' => true
+ ] + GeneralNames::MAP,
+ 'authorityCertSerialNumber' => [
+ 'constant' => 2,
+ 'optional' => true,
+ 'implicit' => true
+ ] + CertificateSerialNumber::MAP
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BaseDistance.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BaseDistance.php
new file mode 100644
index 000000000..8453e49d9
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BaseDistance.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * BaseDistance
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class BaseDistance
+{
+ const MAP = ['type' => ASN1::TYPE_INTEGER];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BasicConstraints.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BasicConstraints.php
new file mode 100644
index 000000000..490bc9201
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BasicConstraints.php
@@ -0,0 +1,43 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * BasicConstraints
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class BasicConstraints
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'cA' => [
+ 'type' => ASN1::TYPE_BOOLEAN,
+ 'optional' => true,
+ 'default' => false
+ ],
+ 'pathLenConstraint' => [
+ 'type' => ASN1::TYPE_INTEGER,
+ 'optional' => true
+ ]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BuiltInDomainDefinedAttribute.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BuiltInDomainDefinedAttribute.php
new file mode 100644
index 000000000..19f31c24a
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BuiltInDomainDefinedAttribute.php
@@ -0,0 +1,36 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * BuiltInDomainDefinedAttribute
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class BuiltInDomainDefinedAttribute
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'type' => ['type' => ASN1::TYPE_PRINTABLE_STRING],
+ 'value' => ['type' => ASN1::TYPE_PRINTABLE_STRING]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BuiltInDomainDefinedAttributes.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BuiltInDomainDefinedAttributes.php
new file mode 100644
index 000000000..dc412118c
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BuiltInDomainDefinedAttributes.php
@@ -0,0 +1,35 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * BuiltInDomainDefinedAttributes
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class BuiltInDomainDefinedAttributes
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'min' => 1,
+ 'max' => 4, // ub-domain-defined-attributes
+ 'children' => BuiltInDomainDefinedAttribute::MAP
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BuiltInStandardAttributes.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BuiltInStandardAttributes.php
new file mode 100644
index 000000000..4cbe0b09f
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BuiltInStandardAttributes.php
@@ -0,0 +1,71 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * BuiltInStandardAttributes
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class BuiltInStandardAttributes
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'country-name' => ['optional' => true] + CountryName::MAP,
+ 'administration-domain-name' => ['optional' => true] + AdministrationDomainName::MAP,
+ 'network-address' => [
+ 'constant' => 0,
+ 'optional' => true,
+ 'implicit' => true
+ ] + NetworkAddress::MAP,
+ 'terminal-identifier' => [
+ 'constant' => 1,
+ 'optional' => true,
+ 'implicit' => true
+ ] + TerminalIdentifier::MAP,
+ 'private-domain-name' => [
+ 'constant' => 2,
+ 'optional' => true,
+ 'explicit' => true
+ ] + PrivateDomainName::MAP,
+ 'organization-name' => [
+ 'constant' => 3,
+ 'optional' => true,
+ 'implicit' => true
+ ] + OrganizationName::MAP,
+ 'numeric-user-identifier' => [
+ 'constant' => 4,
+ 'optional' => true,
+ 'implicit' => true
+ ] + NumericUserIdentifier::MAP,
+ 'personal-name' => [
+ 'constant' => 5,
+ 'optional' => true,
+ 'implicit' => true
+ ] + PersonalName::MAP,
+ 'organizational-unit-names' => [
+ 'constant' => 6,
+ 'optional' => true,
+ 'implicit' => true
+ ] + OrganizationalUnitNames::MAP
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CPSuri.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CPSuri.php
new file mode 100644
index 000000000..78733df9a
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CPSuri.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * CPSuri
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class CPSuri
+{
+ const MAP = ['type' => ASN1::TYPE_IA5_STRING];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CRLDistributionPoints.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CRLDistributionPoints.php
new file mode 100644
index 000000000..21ab66236
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CRLDistributionPoints.php
@@ -0,0 +1,35 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * CRLDistributionPoints
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class CRLDistributionPoints
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'min' => 1,
+ 'max' => -1,
+ 'children' => DistributionPoint::MAP
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CRLNumber.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CRLNumber.php
new file mode 100644
index 000000000..921fdd529
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CRLNumber.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * CRLNumber
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class CRLNumber
+{
+ const MAP = ['type' => ASN1::TYPE_INTEGER];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CRLReason.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CRLReason.php
new file mode 100644
index 000000000..e43e4dd75
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CRLReason.php
@@ -0,0 +1,45 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * CRLReason
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class CRLReason
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_ENUMERATED,
+ 'mapping' => [
+ 'unspecified',
+ 'keyCompromise',
+ 'cACompromise',
+ 'affiliationChanged',
+ 'superseded',
+ 'cessationOfOperation',
+ 'certificateHold',
+ // Value 7 is not used.
+ 8 => 'removeFromCRL',
+ 'privilegeWithdrawn',
+ 'aACompromise'
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertPolicyId.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertPolicyId.php
new file mode 100644
index 000000000..a4620e7d0
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertPolicyId.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * CertPolicyId
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class CertPolicyId
+{
+ const MAP = ['type' => ASN1::TYPE_OBJECT_IDENTIFIER];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Certificate.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Certificate.php
new file mode 100644
index 000000000..f8ff4130f
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Certificate.php
@@ -0,0 +1,37 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * Certificate
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class Certificate
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'tbsCertificate' => TBSCertificate::MAP,
+ 'signatureAlgorithm' => AlgorithmIdentifier::MAP,
+ 'signature' => ['type' => ASN1::TYPE_BIT_STRING]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificateIssuer.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificateIssuer.php
new file mode 100644
index 000000000..ba4504afc
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificateIssuer.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * CertificateIssuer
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class CertificateIssuer
+{
+ const MAP = GeneralNames::MAP;
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificateList.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificateList.php
new file mode 100644
index 000000000..79a1f3242
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificateList.php
@@ -0,0 +1,37 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * CertificateList
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class CertificateList
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'tbsCertList' => TBSCertList::MAP,
+ 'signatureAlgorithm' => AlgorithmIdentifier::MAP,
+ 'signature' => ['type' => ASN1::TYPE_BIT_STRING]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificatePolicies.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificatePolicies.php
new file mode 100644
index 000000000..e9f9354af
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificatePolicies.php
@@ -0,0 +1,35 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * CertificatePolicies
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class CertificatePolicies
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'min' => 1,
+ 'max' => -1,
+ 'children' => PolicyInformation::MAP
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificateSerialNumber.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificateSerialNumber.php
new file mode 100644
index 000000000..83f26d311
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificateSerialNumber.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * CertificateSerialNumber
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class CertificateSerialNumber
+{
+ const MAP = ['type' => ASN1::TYPE_INTEGER];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificationRequest.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificationRequest.php
new file mode 100644
index 000000000..23587f087
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificationRequest.php
@@ -0,0 +1,37 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * CertificationRequest
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class CertificationRequest
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'certificationRequestInfo' => CertificationRequestInfo::MAP,
+ 'signatureAlgorithm' => AlgorithmIdentifier::MAP,
+ 'signature' => ['type' => ASN1::TYPE_BIT_STRING]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificationRequestInfo.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificationRequestInfo.php
new file mode 100644
index 000000000..1ebff5ff6
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificationRequestInfo.php
@@ -0,0 +1,45 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * CertificationRequestInfo
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class CertificationRequestInfo
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'version' => [
+ 'type' => ASN1::TYPE_INTEGER,
+ 'mapping' => ['v1']
+ ],
+ 'subject' => Name::MAP,
+ 'subjectPKInfo' => SubjectPublicKeyInfo::MAP,
+ 'attributes' => [
+ 'constant' => 0,
+ 'optional' => true,
+ 'implicit' => true
+ ] + Attributes::MAP,
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Characteristic_two.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Characteristic_two.php
new file mode 100644
index 000000000..b73e0ba2d
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Characteristic_two.php
@@ -0,0 +1,40 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * Characteristic_two
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class Characteristic_two
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'm' => ['type' => ASN1::TYPE_INTEGER], // field size 2**m
+ 'basis' => ['type' => ASN1::TYPE_OBJECT_IDENTIFIER],
+ 'parameters' => [
+ 'type' => ASN1::TYPE_ANY,
+ 'optional' => true
+ ]
+ ]
+ ];
+}
\ No newline at end of file
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CountryName.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CountryName.php
new file mode 100644
index 000000000..83b3a2c3f
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CountryName.php
@@ -0,0 +1,40 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * CountryName
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class CountryName
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_CHOICE,
+ // if class isn't present it's assumed to be \phpseclib3\File\ASN1::CLASS_UNIVERSAL or
+ // (if constant is present) \phpseclib3\File\ASN1::CLASS_CONTEXT_SPECIFIC
+ 'class' => ASN1::CLASS_APPLICATION,
+ 'cast' => 1,
+ 'children' => [
+ 'x121-dcc-code' => ['type' => ASN1::TYPE_NUMERIC_STRING],
+ 'iso-3166-alpha2-code' => ['type' => ASN1::TYPE_PRINTABLE_STRING]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Curve.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Curve.php
new file mode 100644
index 000000000..1a574583b
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Curve.php
@@ -0,0 +1,40 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * Curve
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class Curve
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'a' => FieldElement::MAP,
+ 'b' => FieldElement::MAP,
+ 'seed' => [
+ 'type' => ASN1::TYPE_BIT_STRING,
+ 'optional' => true
+ ]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DHParameter.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DHParameter.php
new file mode 100644
index 000000000..8edd9d06b
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DHParameter.php
@@ -0,0 +1,42 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * DHParameter
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class DHParameter
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'prime' => ['type' => ASN1::TYPE_INTEGER],
+ 'base' => ['type' => ASN1::TYPE_INTEGER],
+ 'privateValueLength' => [
+ 'type' => ASN1::TYPE_INTEGER,
+ 'optional' => true
+ ]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DSAParams.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DSAParams.php
new file mode 100644
index 000000000..c89fd84b4
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DSAParams.php
@@ -0,0 +1,37 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * DSAParams
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class DSAParams
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'p' => ['type' => ASN1::TYPE_INTEGER],
+ 'q' => ['type' => ASN1::TYPE_INTEGER],
+ 'g' => ['type' => ASN1::TYPE_INTEGER]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DSAPrivateKey.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DSAPrivateKey.php
new file mode 100644
index 000000000..eaec347da
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DSAPrivateKey.php
@@ -0,0 +1,40 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * DSAPrivateKey
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class DSAPrivateKey
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'version' => ['type' => ASN1::TYPE_INTEGER],
+ 'p' => ['type' => ASN1::TYPE_INTEGER],
+ 'q' => ['type' => ASN1::TYPE_INTEGER],
+ 'g' => ['type' => ASN1::TYPE_INTEGER],
+ 'y' => ['type' => ASN1::TYPE_INTEGER],
+ 'x' => ['type' => ASN1::TYPE_INTEGER]
+ ]
+ ];
+}
\ No newline at end of file
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DSAPublicKey.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DSAPublicKey.php
new file mode 100644
index 000000000..867d80b7d
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DSAPublicKey.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * DSAPublicKey
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class DSAPublicKey
+{
+ const MAP = ['type' => ASN1::TYPE_INTEGER];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DigestInfo.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DigestInfo.php
new file mode 100644
index 000000000..828c27989
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DigestInfo.php
@@ -0,0 +1,38 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * DigestInfo
+ *
+ * from https://tools.ietf.org/html/rfc2898#appendix-A.3
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class DigestInfo
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'digestAlgorithm' => AlgorithmIdentifier::MAP,
+ 'digest' => ['type' => ASN1::TYPE_OCTET_STRING]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DirectoryString.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DirectoryString.php
new file mode 100644
index 000000000..458acab19
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DirectoryString.php
@@ -0,0 +1,39 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * DirectoryString
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class DirectoryString
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_CHOICE,
+ 'children' => [
+ 'teletexString' => ['type' => ASN1::TYPE_TELETEX_STRING],
+ 'printableString' => ['type' => ASN1::TYPE_PRINTABLE_STRING],
+ 'universalString' => ['type' => ASN1::TYPE_UNIVERSAL_STRING],
+ 'utf8String' => ['type' => ASN1::TYPE_UTF8_STRING],
+ 'bmpString' => ['type' => ASN1::TYPE_BMP_STRING]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DisplayText.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DisplayText.php
new file mode 100644
index 000000000..6c88b41cb
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DisplayText.php
@@ -0,0 +1,38 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * DisplayText
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class DisplayText
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_CHOICE,
+ 'children' => [
+ 'ia5String' => ['type' => ASN1::TYPE_IA5_STRING],
+ 'visibleString' => ['type' => ASN1::TYPE_VISIBLE_STRING],
+ 'bmpString' => ['type' => ASN1::TYPE_BMP_STRING],
+ 'utf8String' => ['type' => ASN1::TYPE_UTF8_STRING]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DistributionPoint.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DistributionPoint.php
new file mode 100644
index 000000000..91b3feef5
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DistributionPoint.php
@@ -0,0 +1,49 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * DistributionPoint
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class DistributionPoint
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'distributionPoint' => [
+ 'constant' => 0,
+ 'optional' => true,
+ 'explicit' => true
+ ] + DistributionPointName::MAP,
+ 'reasons' => [
+ 'constant' => 1,
+ 'optional' => true,
+ 'implicit' => true
+ ] + ReasonFlags::MAP,
+ 'cRLIssuer' => [
+ 'constant' => 2,
+ 'optional' => true,
+ 'implicit' => true
+ ] + GeneralNames::MAP
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DistributionPointName.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DistributionPointName.php
new file mode 100644
index 000000000..fc157bcae
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DistributionPointName.php
@@ -0,0 +1,44 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * DistributionPointName
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class DistributionPointName
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_CHOICE,
+ 'children' => [
+ 'fullName' => [
+ 'constant' => 0,
+ 'optional' => true,
+ 'implicit' => true
+ ] + GeneralNames::MAP,
+ 'nameRelativeToCRLIssuer' => [
+ 'constant' => 1,
+ 'optional' => true,
+ 'implicit' => true
+ ] + RelativeDistinguishedName::MAP
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DssSigValue.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DssSigValue.php
new file mode 100644
index 000000000..1bffe9253
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DssSigValue.php
@@ -0,0 +1,36 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * DssSigValue
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class DssSigValue
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'r' => ['type' => ASN1::TYPE_INTEGER],
+ 's' => ['type' => ASN1::TYPE_INTEGER]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ECParameters.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ECParameters.php
new file mode 100644
index 000000000..c27d16f9e
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ECParameters.php
@@ -0,0 +1,49 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * ECParameters
+ *
+ * ECParameters ::= CHOICE {
+ * namedCurve OBJECT IDENTIFIER
+ * -- implicitCurve NULL
+ * -- specifiedCurve SpecifiedECDomain
+ * }
+ * -- implicitCurve and specifiedCurve MUST NOT be used in PKIX.
+ * -- Details for SpecifiedECDomain can be found in [X9.62].
+ * -- Any future additions to this CHOICE should be coordinated
+ * -- with ANSI X9.
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class ECParameters
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_CHOICE,
+ 'children' => [
+ 'namedCurve' => ['type' => ASN1::TYPE_OBJECT_IDENTIFIER],
+ 'implicitCurve' => ['type' => ASN1::TYPE_NULL],
+ 'specifiedCurve' => SpecifiedECDomain::MAP
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ECPoint.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ECPoint.php
new file mode 100644
index 000000000..1a9429a44
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ECPoint.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * ECPoint
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class ECPoint
+{
+ const MAP = ['type' => ASN1::TYPE_OCTET_STRING];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ECPrivateKey.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ECPrivateKey.php
new file mode 100644
index 000000000..a0d7a066c
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ECPrivateKey.php
@@ -0,0 +1,52 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * ECPrivateKey
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class ECPrivateKey
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'version' => [
+ 'type' => ASN1::TYPE_INTEGER,
+ 'mapping' => [1 => 'ecPrivkeyVer1']
+ ],
+ 'privateKey' => ['type' => ASN1::TYPE_OCTET_STRING],
+ 'parameters' => [
+ 'constant' => 0,
+ 'optional' => true,
+ 'explicit' => true
+ ] + ECParameters::MAP,
+ 'publicKey' => [
+ 'type' => ASN1::TYPE_BIT_STRING,
+ 'constant' => 1,
+ 'optional' => true,
+ 'explicit' => true
+ ]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/EDIPartyName.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/EDIPartyName.php
new file mode 100644
index 000000000..0c2327b8e
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/EDIPartyName.php
@@ -0,0 +1,46 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * EDIPartyName
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class EDIPartyName
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'nameAssigner' => [
+ 'constant' => 0,
+ 'optional' => true,
+ 'implicit' => true
+ ] + DirectoryString::MAP,
+ // partyName is technically required but \phpseclib3\File\ASN1 doesn't currently support non-optional constants and
+ // setting it to optional gets the job done in any event.
+ 'partyName' => [
+ 'constant' => 1,
+ 'optional' => true,
+ 'implicit' => true
+ ] + DirectoryString::MAP
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/EcdsaSigValue.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/EcdsaSigValue.php
new file mode 100644
index 000000000..98dd965aa
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/EcdsaSigValue.php
@@ -0,0 +1,36 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * EcdsaSigValue
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class EcdsaSigValue
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'r' => ['type' => ASN1::TYPE_INTEGER],
+ 's' => ['type' => ASN1::TYPE_INTEGER]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/EncryptedData.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/EncryptedData.php
new file mode 100644
index 000000000..7873579fd
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/EncryptedData.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * EncryptedData
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class EncryptedData
+{
+ const MAP = ['type' => ASN1::TYPE_OCTET_STRING];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/EncryptedPrivateKeyInfo.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/EncryptedPrivateKeyInfo.php
new file mode 100644
index 000000000..5d409eb1a
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/EncryptedPrivateKeyInfo.php
@@ -0,0 +1,36 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * EncryptedPrivateKeyInfo
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class EncryptedPrivateKeyInfo
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'encryptionAlgorithm' => AlgorithmIdentifier::MAP,
+ 'encryptedData' => EncryptedData::MAP
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ExtKeyUsageSyntax.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ExtKeyUsageSyntax.php
new file mode 100644
index 000000000..c61116df4
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ExtKeyUsageSyntax.php
@@ -0,0 +1,35 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * ExtKeyUsageSyntax
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class ExtKeyUsageSyntax
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'min' => 1,
+ 'max' => -1,
+ 'children' => KeyPurposeId::MAP
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Extension.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Extension.php
new file mode 100644
index 000000000..392007938
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Extension.php
@@ -0,0 +1,47 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * Extension
+ *
+ * A certificate using system MUST reject the certificate if it encounters
+ * a critical extension it does not recognize; however, a non-critical
+ * extension may be ignored if it is not recognized.
+ *
+ * http://tools.ietf.org/html/rfc5280#section-4.2
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class Extension
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'extnId' => ['type' => ASN1::TYPE_OBJECT_IDENTIFIER],
+ 'critical' => [
+ 'type' => ASN1::TYPE_BOOLEAN,
+ 'optional' => true,
+ 'default' => false
+ ],
+ 'extnValue' => ['type' => ASN1::TYPE_OCTET_STRING]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ExtensionAttribute.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ExtensionAttribute.php
new file mode 100644
index 000000000..6455e1898
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ExtensionAttribute.php
@@ -0,0 +1,46 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * ExtensionAttribute
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class ExtensionAttribute
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'extension-attribute-type' => [
+ 'type' => ASN1::TYPE_PRINTABLE_STRING,
+ 'constant' => 0,
+ 'optional' => true,
+ 'implicit' => true
+ ],
+ 'extension-attribute-value' => [
+ 'type' => ASN1::TYPE_ANY,
+ 'constant' => 1,
+ 'optional' => true,
+ 'explicit' => true
+ ]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ExtensionAttributes.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ExtensionAttributes.php
new file mode 100644
index 000000000..047bb29a4
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ExtensionAttributes.php
@@ -0,0 +1,35 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * ExtensionAttributes
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class ExtensionAttributes
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SET,
+ 'min' => 1,
+ 'max' => 256, // ub-extension-attributes
+ 'children' => ExtensionAttribute::MAP
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Extensions.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Extensions.php
new file mode 100644
index 000000000..e3d528d45
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Extensions.php
@@ -0,0 +1,37 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * Extensions
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class Extensions
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'min' => 1,
+ // technically, it's MAX, but we'll assume anything < 0 is MAX
+ 'max' => -1,
+ // if 'children' isn't an array then 'min' and 'max' must be defined
+ 'children' => Extension::MAP
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/FieldElement.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/FieldElement.php
new file mode 100644
index 000000000..6666e2ade
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/FieldElement.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * FieldElement
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class FieldElement
+{
+ const MAP = ['type' => ASN1::TYPE_OCTET_STRING];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/FieldID.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/FieldID.php
new file mode 100644
index 000000000..13c6ac490
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/FieldID.php
@@ -0,0 +1,39 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * FieldID
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class FieldID
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'fieldType' => ['type' => ASN1::TYPE_OBJECT_IDENTIFIER],
+ 'parameters' => [
+ 'type' => ASN1::TYPE_ANY,
+ 'optional' => true
+ ]
+ ]
+ ];
+}
\ No newline at end of file
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/GeneralName.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/GeneralName.php
new file mode 100644
index 000000000..ba0b9e484
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/GeneralName.php
@@ -0,0 +1,84 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * GeneralName
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class GeneralName
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_CHOICE,
+ 'children' => [
+ 'otherName' => [
+ 'constant' => 0,
+ 'optional' => true,
+ 'implicit' => true
+ ] + AnotherName::MAP,
+ 'rfc822Name' => [
+ 'type' => ASN1::TYPE_IA5_STRING,
+ 'constant' => 1,
+ 'optional' => true,
+ 'implicit' => true
+ ],
+ 'dNSName' => [
+ 'type' => ASN1::TYPE_IA5_STRING,
+ 'constant' => 2,
+ 'optional' => true,
+ 'implicit' => true
+ ],
+ 'x400Address' => [
+ 'constant' => 3,
+ 'optional' => true,
+ 'implicit' => true
+ ] + ORAddress::MAP,
+ 'directoryName' => [
+ 'constant' => 4,
+ 'optional' => true,
+ 'explicit' => true
+ ] + Name::MAP,
+ 'ediPartyName' => [
+ 'constant' => 5,
+ 'optional' => true,
+ 'implicit' => true
+ ] + EDIPartyName::MAP,
+ 'uniformResourceIdentifier' => [
+ 'type' => ASN1::TYPE_IA5_STRING,
+ 'constant' => 6,
+ 'optional' => true,
+ 'implicit' => true
+ ],
+ 'iPAddress' => [
+ 'type' => ASN1::TYPE_OCTET_STRING,
+ 'constant' => 7,
+ 'optional' => true,
+ 'implicit' => true
+ ],
+ 'registeredID' => [
+ 'type' => ASN1::TYPE_OBJECT_IDENTIFIER,
+ 'constant' => 8,
+ 'optional' => true,
+ 'implicit' => true
+ ]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/GeneralNames.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/GeneralNames.php
new file mode 100644
index 000000000..c8a3c89bd
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/GeneralNames.php
@@ -0,0 +1,35 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * GeneralNames
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class GeneralNames
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'min' => 1,
+ 'max' => -1,
+ 'children' => GeneralName::MAP
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/GeneralSubtree.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/GeneralSubtree.php
new file mode 100644
index 000000000..15d954304
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/GeneralSubtree.php
@@ -0,0 +1,46 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * GeneralSubtree
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class GeneralSubtree
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'base' => GeneralName::MAP,
+ 'minimum' => [
+ 'constant' => 0,
+ 'optional' => true,
+ 'implicit' => true,
+ 'default' => '0'
+ ] + BaseDistance::MAP,
+ 'maximum' => [
+ 'constant' => 1,
+ 'optional' => true,
+ 'implicit' => true,
+ ] + BaseDistance::MAP
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/GeneralSubtrees.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/GeneralSubtrees.php
new file mode 100644
index 000000000..3b10265cd
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/GeneralSubtrees.php
@@ -0,0 +1,35 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * GeneralSubtrees
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class GeneralSubtrees
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'min' => 1,
+ 'max' => -1,
+ 'children' => GeneralSubtree::MAP
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/HashAlgorithm.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/HashAlgorithm.php
new file mode 100644
index 000000000..02f587d13
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/HashAlgorithm.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * HashAglorithm
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class HashAlgorithm
+{
+ const MAP = AlgorithmIdentifier::MAP;
+}
\ No newline at end of file
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/HoldInstructionCode.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/HoldInstructionCode.php
new file mode 100644
index 000000000..7d4959614
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/HoldInstructionCode.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * HoldInstructionCode
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class HoldInstructionCode
+{
+ const MAP = ['type' => ASN1::TYPE_OBJECT_IDENTIFIER];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/InvalidityDate.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/InvalidityDate.php
new file mode 100644
index 000000000..0ae964ce9
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/InvalidityDate.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * InvalidityDate
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class InvalidityDate
+{
+ const MAP = ['type' => ASN1::TYPE_GENERALIZED_TIME];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/IssuerAltName.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/IssuerAltName.php
new file mode 100644
index 000000000..5f71db8f7
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/IssuerAltName.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * IssuerAltName
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class IssuerAltName
+{
+ const MAP = GeneralNames::MAP;
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/IssuingDistributionPoint.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/IssuingDistributionPoint.php
new file mode 100644
index 000000000..f4b35b380
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/IssuingDistributionPoint.php
@@ -0,0 +1,72 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * IssuingDistributionPoint
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class IssuingDistributionPoint
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'distributionPoint' => [
+ 'constant' => 0,
+ 'optional' => true,
+ 'explicit' => true
+ ] + DistributionPointName::MAP,
+ 'onlyContainsUserCerts' => [
+ 'type' => ASN1::TYPE_BOOLEAN,
+ 'constant' => 1,
+ 'optional' => true,
+ 'default' => false,
+ 'implicit' => true
+ ],
+ 'onlyContainsCACerts' => [
+ 'type' => ASN1::TYPE_BOOLEAN,
+ 'constant' => 2,
+ 'optional' => true,
+ 'default' => false,
+ 'implicit' => true
+ ],
+ 'onlySomeReasons' => [
+ 'constant' => 3,
+ 'optional' => true,
+ 'implicit' => true
+ ] + ReasonFlags::MAP,
+ 'indirectCRL' => [
+ 'type' => ASN1::TYPE_BOOLEAN,
+ 'constant' => 4,
+ 'optional' => true,
+ 'default' => false,
+ 'implicit' => true
+ ],
+ 'onlyContainsAttributeCerts' =>[
+ 'type' => ASN1::TYPE_BOOLEAN,
+ 'constant' => 5,
+ 'optional' => true,
+ 'default' => false,
+ 'implicit' => true
+ ]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/KeyIdentifier.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/KeyIdentifier.php
new file mode 100644
index 000000000..eb2939b85
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/KeyIdentifier.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * KeyIdentifier
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class KeyIdentifier
+{
+ const MAP = ['type' => ASN1::TYPE_OCTET_STRING];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/KeyPurposeId.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/KeyPurposeId.php
new file mode 100644
index 000000000..7aee54ada
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/KeyPurposeId.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * KeyPurposeId
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class KeyPurposeId
+{
+ const MAP = ['type' => ASN1::TYPE_OBJECT_IDENTIFIER];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/KeyUsage.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/KeyUsage.php
new file mode 100644
index 000000000..abf599ed1
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/KeyUsage.php
@@ -0,0 +1,43 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * KeyUsage
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class KeyUsage
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_BIT_STRING,
+ 'mapping' => [
+ 'digitalSignature',
+ 'nonRepudiation',
+ 'keyEncipherment',
+ 'dataEncipherment',
+ 'keyAgreement',
+ 'keyCertSign',
+ 'cRLSign',
+ 'encipherOnly',
+ 'decipherOnly'
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/MaskGenAlgorithm.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/MaskGenAlgorithm.php
new file mode 100644
index 000000000..5e0e26f07
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/MaskGenAlgorithm.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * MaskGenAglorithm
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class MaskGenAlgorithm
+{
+ const MAP = AlgorithmIdentifier::MAP;
+}
\ No newline at end of file
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Name.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Name.php
new file mode 100644
index 000000000..a4ba82a0e
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Name.php
@@ -0,0 +1,35 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * Name
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class Name
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_CHOICE,
+ 'children' => [
+ 'rdnSequence' => RDNSequence::MAP
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/NameConstraints.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/NameConstraints.php
new file mode 100644
index 000000000..518e68f6b
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/NameConstraints.php
@@ -0,0 +1,44 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * NameConstraints
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class NameConstraints
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'permittedSubtrees' => [
+ 'constant' => 0,
+ 'optional' => true,
+ 'implicit' => true
+ ] + GeneralSubtrees::MAP,
+ 'excludedSubtrees' => [
+ 'constant' => 1,
+ 'optional' => true,
+ 'implicit' => true
+ ] + GeneralSubtrees::MAP
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/NetworkAddress.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/NetworkAddress.php
new file mode 100644
index 000000000..a67c0276c
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/NetworkAddress.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * NetworkAddress
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class NetworkAddress
+{
+ const MAP = ['type' => ASN1::TYPE_NUMERIC_STRING];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/NoticeReference.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/NoticeReference.php
new file mode 100644
index 000000000..cea267733
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/NoticeReference.php
@@ -0,0 +1,41 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * NoticeReference
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class NoticeReference
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'organization' => DisplayText::MAP,
+ 'noticeNumbers' => [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'min' => 1,
+ 'max' => 200,
+ 'children' => ['type' => ASN1::TYPE_INTEGER]
+ ]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/NumericUserIdentifier.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/NumericUserIdentifier.php
new file mode 100644
index 000000000..04998393c
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/NumericUserIdentifier.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * NumericUserIdentifier
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class NumericUserIdentifier
+{
+ const MAP = ['type' => ASN1::TYPE_NUMERIC_STRING];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ORAddress.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ORAddress.php
new file mode 100644
index 000000000..cde7b3d6c
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ORAddress.php
@@ -0,0 +1,37 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * ORAddress
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class ORAddress
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'built-in-standard-attributes' => BuiltInStandardAttributes::MAP,
+ 'built-in-domain-defined-attributes' => ['optional' => true] + BuiltInDomainDefinedAttributes::MAP,
+ 'extension-attributes' => ['optional' => true] + ExtensionAttributes::MAP
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OneAsymmetricKey.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OneAsymmetricKey.php
new file mode 100644
index 000000000..9a5c16873
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OneAsymmetricKey.php
@@ -0,0 +1,52 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * OneAsymmetricKey
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class OneAsymmetricKey
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'version' => [
+ 'type' => ASN1::TYPE_INTEGER,
+ 'mapping' => ['v1', 'v2']
+ ],
+ 'privateKeyAlgorithm'=> AlgorithmIdentifier::MAP,
+ 'privateKey' => PrivateKey::MAP,
+ 'attributes' => [
+ 'constant' => 0,
+ 'optional' => true,
+ 'implicit' => true
+ ] + Attributes::MAP,
+ 'publicKey' => [
+ 'constant' => 1,
+ 'optional' => true,
+ 'implicit' => true
+ ] + PublicKey::MAP
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OrganizationName.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OrganizationName.php
new file mode 100644
index 000000000..250c92774
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OrganizationName.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * OrganizationName
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class OrganizationName
+{
+ const MAP = ['type' => ASN1::TYPE_PRINTABLE_STRING];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OrganizationalUnitNames.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OrganizationalUnitNames.php
new file mode 100644
index 000000000..eb2ac677a
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OrganizationalUnitNames.php
@@ -0,0 +1,35 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * OrganizationalUnitNames
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class OrganizationalUnitNames
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'min' => 1,
+ 'max' => 4, // ub-organizational-units
+ 'children' => ['type' => ASN1::TYPE_PRINTABLE_STRING]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OtherPrimeInfo.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OtherPrimeInfo.php
new file mode 100644
index 000000000..d75fa3f7c
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OtherPrimeInfo.php
@@ -0,0 +1,38 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * OtherPrimeInfo
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class OtherPrimeInfo
+{
+ // version must be multi if otherPrimeInfos present
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'prime' => ['type' => ASN1::TYPE_INTEGER], // ri
+ 'exponent' => ['type' => ASN1::TYPE_INTEGER], // di
+ 'coefficient' => ['type' => ASN1::TYPE_INTEGER] // ti
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OtherPrimeInfos.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OtherPrimeInfos.php
new file mode 100644
index 000000000..bb833171d
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OtherPrimeInfos.php
@@ -0,0 +1,36 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * OtherPrimeInfos
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class OtherPrimeInfos
+{
+ // version must be multi if otherPrimeInfos present
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'min' => 1,
+ 'max' => -1,
+ 'children' => OtherPrimeInfo::MAP
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PBEParameter.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PBEParameter.php
new file mode 100644
index 000000000..bd17291fd
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PBEParameter.php
@@ -0,0 +1,38 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * PBEParameter
+ *
+ * from https://tools.ietf.org/html/rfc2898#appendix-A.3
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class PBEParameter
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'salt' => ['type' => ASN1::TYPE_OCTET_STRING],
+ 'iterationCount' => ['type' => ASN1::TYPE_INTEGER]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PBES2params.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PBES2params.php
new file mode 100644
index 000000000..1d807db70
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PBES2params.php
@@ -0,0 +1,38 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * PBES2params
+ *
+ * from https://tools.ietf.org/html/rfc2898#appendix-A.3
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class PBES2params
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'keyDerivationFunc'=> AlgorithmIdentifier::MAP,
+ 'encryptionScheme' => AlgorithmIdentifier::MAP
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PBKDF2params.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PBKDF2params.php
new file mode 100644
index 000000000..16d37a95b
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PBKDF2params.php
@@ -0,0 +1,45 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * PBKDF2params
+ *
+ * from https://tools.ietf.org/html/rfc2898#appendix-A.3
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class PBKDF2params
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ // technically, this is a CHOICE in RFC2898 but the other "choice" is, currently, more of a placeholder
+ // in the RFC
+ 'salt'=> ['type' => ASN1::TYPE_OCTET_STRING],
+ 'iterationCount'=> ['type' => ASN1::TYPE_INTEGER],
+ 'keyLength' => [
+ 'type' => ASN1::TYPE_INTEGER,
+ 'optional' => true
+ ],
+ 'prf' => AlgorithmIdentifier::MAP + ['optional' => true]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PBMAC1params.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PBMAC1params.php
new file mode 100644
index 000000000..f375aa16b
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PBMAC1params.php
@@ -0,0 +1,38 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * PBMAC1params
+ *
+ * from https://tools.ietf.org/html/rfc2898#appendix-A.3
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class PBMAC1params
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'keyDerivationFunc'=> AlgorithmIdentifier::MAP,
+ 'messageAuthScheme'=> AlgorithmIdentifier::MAP
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PKCS9String.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PKCS9String.php
new file mode 100644
index 000000000..11c638bdf
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PKCS9String.php
@@ -0,0 +1,36 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * PKCS9String
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class PKCS9String
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_CHOICE,
+ 'children' => [
+ 'ia5String' => ['type' => ASN1::TYPE_IA5_STRING],
+ 'directoryString' => DirectoryString::MAP
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Pentanomial.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Pentanomial.php
new file mode 100644
index 000000000..493cd2992
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Pentanomial.php
@@ -0,0 +1,37 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * Pentanomial
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class Pentanomial
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'k1' => ['type' => ASN1::TYPE_INTEGER], // k1 > 0
+ 'k2' => ['type' => ASN1::TYPE_INTEGER], // k2 > k1
+ 'k3' => ['type' => ASN1::TYPE_INTEGER], // k3 > h2
+ ]
+ ];
+}
\ No newline at end of file
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PersonalName.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PersonalName.php
new file mode 100644
index 000000000..c9492c9ef
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PersonalName.php
@@ -0,0 +1,58 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * PersonalName
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class PersonalName
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SET,
+ 'children' => [
+ 'surname' => [
+ 'type' => ASN1::TYPE_PRINTABLE_STRING,
+ 'constant' => 0,
+ 'optional' => true,
+ 'implicit' => true
+ ],
+ 'given-name' => [
+ 'type' => ASN1::TYPE_PRINTABLE_STRING,
+ 'constant' => 1,
+ 'optional' => true,
+ 'implicit' => true
+ ],
+ 'initials' => [
+ 'type' => ASN1::TYPE_PRINTABLE_STRING,
+ 'constant' => 2,
+ 'optional' => true,
+ 'implicit' => true
+ ],
+ 'generation-qualifier' => [
+ 'type' => ASN1::TYPE_PRINTABLE_STRING,
+ 'constant' => 3,
+ 'optional' => true,
+ 'implicit' => true
+ ]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PolicyInformation.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PolicyInformation.php
new file mode 100644
index 000000000..cfda3990c
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PolicyInformation.php
@@ -0,0 +1,42 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * PolicyInformation
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class PolicyInformation
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'policyIdentifier' => CertPolicyId::MAP,
+ 'policyQualifiers' => [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'min' => 0,
+ 'max' => -1,
+ 'optional' => true,
+ 'children' => PolicyQualifierInfo::MAP
+ ]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PolicyMappings.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PolicyMappings.php
new file mode 100644
index 000000000..c1086477a
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PolicyMappings.php
@@ -0,0 +1,41 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * PolicyMappings
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class PolicyMappings
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'min' => 1,
+ 'max' => -1,
+ 'children' => [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'issuerDomainPolicy' => CertPolicyId::MAP,
+ 'subjectDomainPolicy' => CertPolicyId::MAP
+ ]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PolicyQualifierId.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PolicyQualifierId.php
new file mode 100644
index 000000000..454a9d1a9
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PolicyQualifierId.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * PolicyQualifierId
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class PolicyQualifierId
+{
+ const MAP = ['type' => ASN1::TYPE_OBJECT_IDENTIFIER];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PolicyQualifierInfo.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PolicyQualifierInfo.php
new file mode 100644
index 000000000..a1d7e1727
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PolicyQualifierInfo.php
@@ -0,0 +1,36 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * PolicyQualifierInfo
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class PolicyQualifierInfo
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'policyQualifierId' => PolicyQualifierId::MAP,
+ 'qualifier' => ['type' => ASN1::TYPE_ANY]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PostalAddress.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PostalAddress.php
new file mode 100644
index 000000000..ec8354fa0
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PostalAddress.php
@@ -0,0 +1,36 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * PostalAddress
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class PostalAddress
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'optional' => true,
+ 'min' => 1,
+ 'max' => -1,
+ 'children' => DirectoryString::MAP
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Prime_p.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Prime_p.php
new file mode 100644
index 000000000..09c8006be
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Prime_p.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * Prime_p
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class Prime_p
+{
+ const MAP = ['type' => ASN1::TYPE_INTEGER];
+}
\ No newline at end of file
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PrivateDomainName.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PrivateDomainName.php
new file mode 100644
index 000000000..b26c0cbaa
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PrivateDomainName.php
@@ -0,0 +1,36 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * PrivateDomainName
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class PrivateDomainName
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_CHOICE,
+ 'children' => [
+ 'numeric' => ['type' => ASN1::TYPE_NUMERIC_STRING],
+ 'printable' => ['type' => ASN1::TYPE_PRINTABLE_STRING]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PrivateKey.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PrivateKey.php
new file mode 100644
index 000000000..7670f4add
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PrivateKey.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * PrivateKey
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class PrivateKey
+{
+ const MAP = ['type' => ASN1::TYPE_OCTET_STRING];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PrivateKeyInfo.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PrivateKeyInfo.php
new file mode 100644
index 000000000..170f6f276
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PrivateKeyInfo.php
@@ -0,0 +1,45 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * PrivateKeyInfo
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class PrivateKeyInfo
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'version' => [
+ 'type' => ASN1::TYPE_INTEGER,
+ 'mapping' => ['v1']
+ ],
+ 'privateKeyAlgorithm'=> AlgorithmIdentifier::MAP,
+ 'privateKey' => PrivateKey::MAP,
+ 'attributes' => [
+ 'constant' => 0,
+ 'optional' => true,
+ 'implicit' => true
+ ] + Attributes::MAP
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PrivateKeyUsagePeriod.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PrivateKeyUsagePeriod.php
new file mode 100644
index 000000000..8c396a000
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PrivateKeyUsagePeriod.php
@@ -0,0 +1,44 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * PrivateKeyUsagePeriod
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class PrivateKeyUsagePeriod
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'notBefore' => [
+ 'constant' => 0,
+ 'optional' => true,
+ 'implicit' => true,
+ 'type' => ASN1::TYPE_GENERALIZED_TIME],
+ 'notAfter' => [
+ 'constant' => 1,
+ 'optional' => true,
+ 'implicit' => true,
+ 'type' => ASN1::TYPE_GENERALIZED_TIME]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PublicKey.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PublicKey.php
new file mode 100644
index 000000000..b8239aa6a
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PublicKey.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * PublicKey
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class PublicKey
+{
+ const MAP = ['type' => ASN1::TYPE_BIT_STRING];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PublicKeyAndChallenge.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PublicKeyAndChallenge.php
new file mode 100644
index 000000000..ef212812d
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PublicKeyAndChallenge.php
@@ -0,0 +1,36 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * PublicKeyAndChallenge
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class PublicKeyAndChallenge
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'spki' => SubjectPublicKeyInfo::MAP,
+ 'challenge' => ['type' => ASN1::TYPE_IA5_STRING]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PublicKeyInfo.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PublicKeyInfo.php
new file mode 100644
index 000000000..587230bc3
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PublicKeyInfo.php
@@ -0,0 +1,39 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * PublicKeyInfo
+ *
+ * this format is not formally defined anywhere but is none-the-less the form you
+ * get when you do "openssl rsa -in private.pem -outform PEM -pubout"
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class PublicKeyInfo
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'publicKeyAlgorithm'=> AlgorithmIdentifier::MAP,
+ 'publicKey' => ['type' => ASN1::TYPE_BIT_STRING]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RC2CBCParameter.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RC2CBCParameter.php
new file mode 100644
index 000000000..3697f103b
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RC2CBCParameter.php
@@ -0,0 +1,41 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * RC2CBCParameter
+ *
+ * from https://tools.ietf.org/html/rfc2898#appendix-A.3
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class RC2CBCParameter
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'rc2ParametersVersion'=> [
+ 'type' => ASN1::TYPE_INTEGER,
+ 'optional' => true
+ ],
+ 'iv'=> ['type' => ASN1::TYPE_OCTET_STRING]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RDNSequence.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RDNSequence.php
new file mode 100644
index 000000000..848e2c938
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RDNSequence.php
@@ -0,0 +1,42 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * RDNSequence
+ *
+ * In practice, RDNs containing multiple name-value pairs (called "multivalued RDNs") are rare,
+ * but they can be useful at times when either there is no unique attribute in the entry or you
+ * want to ensure that the entry's DN contains some useful identifying information.
+ *
+ * - https://www.opends.org/wiki/page/DefinitionRelativeDistinguishedName
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class RDNSequence
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ // RDNSequence does not define a min or a max, which means it doesn't have one
+ 'min' => 0,
+ 'max' => -1,
+ 'children' => RelativeDistinguishedName::MAP
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RSAPrivateKey.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RSAPrivateKey.php
new file mode 100644
index 000000000..fbbb0f7cf
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RSAPrivateKey.php
@@ -0,0 +1,48 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * RSAPrivateKey
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class RSAPrivateKey
+{
+ // version must be multi if otherPrimeInfos present
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'version' => [
+ 'type' => ASN1::TYPE_INTEGER,
+ 'mapping' => ['two-prime', 'multi']
+ ],
+ 'modulus' => ['type' => ASN1::TYPE_INTEGER], // n
+ 'publicExponent' => ['type' => ASN1::TYPE_INTEGER], // e
+ 'privateExponent' => ['type' => ASN1::TYPE_INTEGER], // d
+ 'prime1' => ['type' => ASN1::TYPE_INTEGER], // p
+ 'prime2' => ['type' => ASN1::TYPE_INTEGER], // q
+ 'exponent1' => ['type' => ASN1::TYPE_INTEGER], // d mod (p-1)
+ 'exponent2' => ['type' => ASN1::TYPE_INTEGER], // d mod (q-1)
+ 'coefficient' => ['type' => ASN1::TYPE_INTEGER], // (inverse of q) mod p
+ 'otherPrimeInfos' => OtherPrimeInfos::MAP + ['optional' => true]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RSAPublicKey.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RSAPublicKey.php
new file mode 100644
index 000000000..1ea441d03
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RSAPublicKey.php
@@ -0,0 +1,36 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * RSAPublicKey
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class RSAPublicKey
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'modulus' => ['type' => ASN1::TYPE_INTEGER],
+ 'publicExponent' => ['type' => ASN1::TYPE_INTEGER]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RSASSA_PSS_params.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RSASSA_PSS_params.php
new file mode 100644
index 000000000..b9ad46b01
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RSASSA_PSS_params.php
@@ -0,0 +1,62 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * RSASSA_PSS_params
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class RSASSA_PSS_params
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'hashAlgorithm' => [
+ 'constant' => 0,
+ 'optional' => true,
+ 'explicit' => true,
+ //'default' => 'sha1Identifier'
+ ] + HashAlgorithm::MAP,
+ 'maskGenAlgorithm' => [
+ 'constant' => 1,
+ 'optional' => true,
+ 'explicit' => true,
+ //'default' => 'mgf1SHA1Identifier'
+ ] + MaskGenAlgorithm::MAP,
+ 'saltLength' => [
+ 'type' => ASN1::TYPE_INTEGER,
+ 'constant' => 2,
+ 'optional' => true,
+ 'explicit' => true,
+ 'default' => 20
+ ],
+ 'trailerField' => [
+ 'type' => ASN1::TYPE_INTEGER,
+ 'constant' => 3,
+ 'optional' => true,
+ 'explicit' => true,
+ 'default' => 1
+ ]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ReasonFlags.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ReasonFlags.php
new file mode 100644
index 000000000..3cb32c480
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ReasonFlags.php
@@ -0,0 +1,43 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * ReasonFlags
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class ReasonFlags
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_BIT_STRING,
+ 'mapping' => [
+ 'unused',
+ 'keyCompromise',
+ 'cACompromise',
+ 'affiliationChanged',
+ 'superseded',
+ 'cessationOfOperation',
+ 'certificateHold',
+ 'privilegeWithdrawn',
+ 'aACompromise'
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RelativeDistinguishedName.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RelativeDistinguishedName.php
new file mode 100644
index 000000000..de9dfaf60
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RelativeDistinguishedName.php
@@ -0,0 +1,41 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * RelativeDistinguishedName
+ *
+ * In practice, RDNs containing multiple name-value pairs (called "multivalued RDNs") are rare,
+ * but they can be useful at times when either there is no unique attribute in the entry or you
+ * want to ensure that the entry's DN contains some useful identifying information.
+ *
+ * - https://www.opends.org/wiki/page/DefinitionRelativeDistinguishedName
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class RelativeDistinguishedName
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SET,
+ 'min' => 1,
+ 'max' => -1,
+ 'children' => AttributeTypeAndValue::MAP
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RevokedCertificate.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RevokedCertificate.php
new file mode 100644
index 000000000..b012d9dff
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RevokedCertificate.php
@@ -0,0 +1,39 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * RevokedCertificate
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class RevokedCertificate
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'userCertificate' => CertificateSerialNumber::MAP,
+ 'revocationDate' => Time::MAP,
+ 'crlEntryExtensions' => [
+ 'optional' => true
+ ] + Extensions::MAP
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SignedPublicKeyAndChallenge.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SignedPublicKeyAndChallenge.php
new file mode 100644
index 000000000..c3591e2ff
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SignedPublicKeyAndChallenge.php
@@ -0,0 +1,37 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * SignedPublicKeyAndChallenge
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class SignedPublicKeyAndChallenge
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'publicKeyAndChallenge' => PublicKeyAndChallenge::MAP,
+ 'signatureAlgorithm' => AlgorithmIdentifier::MAP,
+ 'signature' => ['type' => ASN1::TYPE_BIT_STRING]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SpecifiedECDomain.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SpecifiedECDomain.php
new file mode 100644
index 000000000..fb437eab4
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SpecifiedECDomain.php
@@ -0,0 +1,49 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * SpecifiedECDomain
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class SpecifiedECDomain
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'version' => [
+ 'type' => ASN1::TYPE_INTEGER,
+ 'mapping' => [1 => 'ecdpVer1', 'ecdpVer2', 'ecdpVer3']
+ ],
+ 'fieldID' => FieldID::MAP,
+ 'curve' => Curve::MAP,
+ 'base' => ECPoint::MAP,
+ 'order' => ['type' => ASN1::TYPE_INTEGER],
+ 'cofactor' => [
+ 'type' => ASN1::TYPE_INTEGER,
+ 'optional' => true
+ ],
+ 'hash' => ['optional' => true] + HashAlgorithm::MAP
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SubjectAltName.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SubjectAltName.php
new file mode 100644
index 000000000..02d2d6d49
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SubjectAltName.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * SubjectAltName
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class SubjectAltName
+{
+ const MAP = GeneralNames::MAP;
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SubjectDirectoryAttributes.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SubjectDirectoryAttributes.php
new file mode 100644
index 000000000..1eff925a2
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SubjectDirectoryAttributes.php
@@ -0,0 +1,35 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * SubjectDirectoryAttributes
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class SubjectDirectoryAttributes
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'min' => 1,
+ 'max' => -1,
+ 'children' => Attribute::MAP
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SubjectInfoAccessSyntax.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SubjectInfoAccessSyntax.php
new file mode 100644
index 000000000..98ab3ddd6
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SubjectInfoAccessSyntax.php
@@ -0,0 +1,35 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * SubjectInfoAccessSyntax
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class SubjectInfoAccessSyntax
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'min' => 1,
+ 'max' => -1,
+ 'children' => AccessDescription::MAP
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SubjectPublicKeyInfo.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SubjectPublicKeyInfo.php
new file mode 100644
index 000000000..c367608cd
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SubjectPublicKeyInfo.php
@@ -0,0 +1,36 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * SubjectPublicKeyInfo
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class SubjectPublicKeyInfo
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'algorithm' => AlgorithmIdentifier::MAP,
+ 'subjectPublicKey' => ['type' => ASN1::TYPE_BIT_STRING]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/TBSCertList.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/TBSCertList.php
new file mode 100644
index 000000000..49be58eb9
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/TBSCertList.php
@@ -0,0 +1,58 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * TBSCertList
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class TBSCertList
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'version' => [
+ 'type' => ASN1::TYPE_INTEGER,
+ 'mapping' => ['v1', 'v2', 'v3'],
+ 'optional' => true,
+ 'default' => 'v2'
+ ],
+ 'signature' => AlgorithmIdentifier::MAP,
+ 'issuer' => Name::MAP,
+ 'thisUpdate' => Time::MAP,
+ 'nextUpdate' => [
+ 'optional' => true
+ ] + Time::MAP,
+ 'revokedCertificates' => [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'optional' => true,
+ 'min' => 0,
+ 'max' => -1,
+ 'children' => RevokedCertificate::MAP
+ ],
+ 'crlExtensions' => [
+ 'constant' => 0,
+ 'optional' => true,
+ 'explicit' => true
+ ] + Extensions::MAP
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/TBSCertificate.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/TBSCertificate.php
new file mode 100644
index 000000000..dc5fe2aa3
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/TBSCertificate.php
@@ -0,0 +1,69 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * TBSCertificate
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class TBSCertificate
+{
+ // assert($TBSCertificate['children']['signature'] == $Certificate['children']['signatureAlgorithm'])
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ // technically, default implies optional, but we'll define it as being optional, none-the-less, just to
+ // reenforce that fact
+ 'version' => [
+ 'type' => ASN1::TYPE_INTEGER,
+ 'constant' => 0,
+ 'optional' => true,
+ 'explicit' => true,
+ 'mapping' => ['v1', 'v2', 'v3'],
+ 'default' => 'v1'
+ ],
+ 'serialNumber' => CertificateSerialNumber::MAP,
+ 'signature' => AlgorithmIdentifier::MAP,
+ 'issuer' => Name::MAP,
+ 'validity' => Validity::MAP,
+ 'subject' => Name::MAP,
+ 'subjectPublicKeyInfo' => SubjectPublicKeyInfo::MAP,
+ // implicit means that the T in the TLV structure is to be rewritten, regardless of the type
+ 'issuerUniqueID' => [
+ 'constant' => 1,
+ 'optional' => true,
+ 'implicit' => true
+ ] + UniqueIdentifier::MAP,
+ 'subjectUniqueID' => [
+ 'constant' => 2,
+ 'optional' => true,
+ 'implicit' => true
+ ] + UniqueIdentifier::MAP,
+ // doesn't use the EXPLICIT keyword but if
+ // it's not IMPLICIT, it's EXPLICIT
+ 'extensions' => [
+ 'constant' => 3,
+ 'optional' => true,
+ 'explicit' => true
+ ] + Extensions::MAP
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/TerminalIdentifier.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/TerminalIdentifier.php
new file mode 100644
index 000000000..5c6fdddb6
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/TerminalIdentifier.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * TerminalIdentifier
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class TerminalIdentifier
+{
+ const MAP = ['type' => ASN1::TYPE_PRINTABLE_STRING];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Time.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Time.php
new file mode 100644
index 000000000..a673c3afc
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Time.php
@@ -0,0 +1,36 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * Time
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class Time
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_CHOICE,
+ 'children' => [
+ 'utcTime' => ['type' => ASN1::TYPE_UTC_TIME],
+ 'generalTime' => ['type' => ASN1::TYPE_GENERALIZED_TIME]
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Trinomial.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Trinomial.php
new file mode 100644
index 000000000..7cd4ba27c
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Trinomial.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * Trinomial
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class Trinomial
+{
+ const MAP = ['type' => ASN1::TYPE_INTEGER];
+}
\ No newline at end of file
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/UniqueIdentifier.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/UniqueIdentifier.php
new file mode 100644
index 000000000..64645773d
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/UniqueIdentifier.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * UniqueIdentifier
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class UniqueIdentifier
+{
+ const MAP = ['type' => ASN1::TYPE_BIT_STRING];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/UserNotice.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/UserNotice.php
new file mode 100644
index 000000000..2a0c86542
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/UserNotice.php
@@ -0,0 +1,42 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * UserNotice
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class UserNotice
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'noticeRef' => [
+ 'optional' => true,
+ 'implicit' => true
+ ] + NoticeReference::MAP,
+ 'explicitText' => [
+ 'optional' => true,
+ 'implicit' => true
+ ] + DisplayText::MAP
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Validity.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Validity.php
new file mode 100644
index 000000000..040aa7f59
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Validity.php
@@ -0,0 +1,36 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * Validity
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class Validity
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_SEQUENCE,
+ 'children' => [
+ 'notBefore' => Time::MAP,
+ 'notAfter' => Time::MAP
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/netscape_ca_policy_url.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/netscape_ca_policy_url.php
new file mode 100644
index 000000000..1da389a72
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/netscape_ca_policy_url.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * netscape_ca_policy_url
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class netscape_ca_policy_url
+{
+ const MAP = ['type' => ASN1::TYPE_IA5_STRING];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/netscape_cert_type.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/netscape_cert_type.php
new file mode 100644
index 000000000..c5845b594
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/netscape_cert_type.php
@@ -0,0 +1,44 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * netscape_cert_type
+ *
+ * mapping is from
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class netscape_cert_type
+{
+ const MAP = [
+ 'type' => ASN1::TYPE_BIT_STRING,
+ 'mapping' => [
+ 'SSLClient',
+ 'SSLServer',
+ 'Email',
+ 'ObjectSigning',
+ 'Reserved',
+ 'SSLCA',
+ 'EmailCA',
+ 'ObjectSigningCA'
+ ]
+ ];
+}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/netscape_comment.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/netscape_comment.php
new file mode 100644
index 000000000..8ff14dacc
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/netscape_comment.php
@@ -0,0 +1,30 @@
+
+ * @copyright 2016 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://phpseclib.sourceforge.net
+ */
+
+namespace phpseclib3\File\ASN1\Maps;
+
+use phpseclib3\File\ASN1;
+
+/**
+ * netscape_comment
+ *
+ * @package ASN1
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class netscape_comment
+{
+ const MAP = ['type' => ASN1::TYPE_IA5_STRING];
+}
diff --git a/lam/lib/3rdParty/phpseclib/File/X509.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/X509.php
similarity index 51%
rename from lam/lib/3rdParty/phpseclib/File/X509.php
rename to lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/X509.php
index 4ebafa171..639a02333 100644
--- a/lam/lib/3rdParty/phpseclib/File/X509.php
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/File/X509.php
@@ -24,15 +24,25 @@
* @link http://phpseclib.sourceforge.net
*/
-namespace phpseclib\File;
+namespace phpseclib3\File;
-use phpseclib\Crypt\Hash;
-use phpseclib\Crypt\Random;
-use phpseclib\Crypt\RSA;
-use phpseclib\File\ASN1\Element;
-use phpseclib\Math\BigInteger;
-use DateTime;
+use DateTimeImmutable;
+use DateTimeInterface;
use DateTimeZone;
+use ParagonIE\ConstantTime\Base64;
+use ParagonIE\ConstantTime\Hex;
+use phpseclib3\Crypt\Common\PrivateKey;
+use phpseclib3\Crypt\Common\PublicKey;
+use phpseclib3\Crypt\DSA;
+use phpseclib3\Crypt\EC;
+use phpseclib3\Crypt\Hash;
+use phpseclib3\Crypt\Random;
+use phpseclib3\Crypt\RSA;
+use phpseclib3\Crypt\RSA\Formats\Keys\PSS;
+use phpseclib3\Exception\UnsupportedAlgorithmException;
+use phpseclib3\File\ASN1\Element;
+use phpseclib3\File\ASN1\Maps;
+use phpseclib3\Math\BigInteger;
/**
* Pure-PHP X.509 Parser
@@ -52,55 +62,77 @@ class X509
*/
const VALIDATE_SIGNATURE_BY_CA = 1;
- /**#@+
- * @access public
- * @see \phpseclib\File\X509::getDN()
- */
/**
* Return internal array representation
+ *
+ * @access public
+ * @see \phpseclib3\File\X509::getDN()
*/
const DN_ARRAY = 0;
/**
* Return string
+ *
+ * @access public
+ * @see \phpseclib3\File\X509::getDN()
*/
const DN_STRING = 1;
/**
* Return ASN.1 name string
+ *
+ * @access public
+ * @see \phpseclib3\File\X509::getDN()
*/
const DN_ASN1 = 2;
/**
* Return OpenSSL compatible array
+ *
+ * @access public
+ * @see \phpseclib3\File\X509::getDN()
*/
const DN_OPENSSL = 3;
/**
* Return canonical ASN.1 RDNs string
+ *
+ * @access public
+ * @see \phpseclib3\File\X509::getDN()
*/
const DN_CANON = 4;
/**
* Return name hash for file indexing
+ *
+ * @access public
+ * @see \phpseclib3\File\X509::getDN()
*/
const DN_HASH = 5;
- /**#@-*/
- /**#@+
- * @access public
- * @see \phpseclib\File\X509::saveX509()
- * @see \phpseclib\File\X509::saveCSR()
- * @see \phpseclib\File\X509::saveCRL()
- */
/**
* Save as PEM
*
* ie. a base64-encoded PEM with a header and a footer
+ *
+ * @access public
+ * @see \phpseclib3\File\X509::saveX509()
+ * @see \phpseclib3\File\X509::saveCSR()
+ * @see \phpseclib3\File\X509::saveCRL()
*/
const FORMAT_PEM = 0;
/**
* Save as DER
+ *
+ * @access public
+ * @see \phpseclib3\File\X509::saveX509()
+ * @see \phpseclib3\File\X509::saveCSR()
+ * @see \phpseclib3\File\X509::saveCRL()
*/
const FORMAT_DER = 1;
/**
* Save as a SPKAC
*
+ * @access public
+ * @see \phpseclib3\File\X509::saveX509()
+ * @see \phpseclib3\File\X509::saveCSR()
+ * @see \phpseclib3\File\X509::saveCRL()
+ *
* Only works on CSRs. Not currently supported.
*/
const FORMAT_SPKAC = 2;
@@ -108,9 +140,13 @@ class X509
* Auto-detect the format
*
* Used only by the load*() functions
+ *
+ * @access public
+ * @see \phpseclib3\File\X509::saveX509()
+ * @see \phpseclib3\File\X509::saveCSR()
+ * @see \phpseclib3\File\X509::saveCRL()
*/
const FORMAT_AUTO_DETECT = 3;
- /**#@-*/
/**
* Attribute value disposition.
@@ -120,87 +156,13 @@ class X509
const ATTR_APPEND = -2; // Add a value.
const ATTR_REPLACE = -3; // Clear first, then add a value.
- /**
- * ASN.1 syntax for X.509 certificates
- *
- * @var array
- * @access private
- */
- var $Certificate;
-
- /**#@+
- * ASN.1 syntax for various extensions
- *
- * @access private
- */
- var $DirectoryString;
- var $PKCS9String;
- var $AttributeValue;
- var $Extensions;
- var $KeyUsage;
- var $ExtKeyUsageSyntax;
- var $BasicConstraints;
- var $KeyIdentifier;
- var $CRLDistributionPoints;
- var $AuthorityKeyIdentifier;
- var $CertificatePolicies;
- var $AuthorityInfoAccessSyntax;
- var $SubjectAltName;
- var $SubjectDirectoryAttributes;
- var $PrivateKeyUsagePeriod;
- var $IssuerAltName;
- var $PolicyMappings;
- var $NameConstraints;
-
- var $CPSuri;
- var $UserNotice;
-
- var $netscape_cert_type;
- var $netscape_comment;
- var $netscape_ca_policy_url;
-
- var $Name;
- var $RelativeDistinguishedName;
- var $CRLNumber;
- var $CRLReason;
- var $IssuingDistributionPoint;
- var $InvalidityDate;
- var $CertificateIssuer;
- var $HoldInstructionCode;
- var $SignedPublicKeyAndChallenge;
- /**#@-*/
-
- /**#@+
- * ASN.1 syntax for various DN attributes
- *
- * @access private
- */
- var $PostalAddress;
- /**#@-*/
-
- /**
- * ASN.1 syntax for Certificate Signing Requests (RFC2986)
- *
- * @var array
- * @access private
- */
- var $CertificationRequest;
-
- /**
- * ASN.1 syntax for Certificate Revocation Lists (RFC5280)
- *
- * @var array
- * @access private
- */
- var $CertificateList;
-
/**
* Distinguished Name
*
* @var array
* @access private
*/
- var $dn;
+ private $dn;
/**
* Public key
@@ -208,7 +170,7 @@ class X509
* @var string
* @access private
*/
- var $publicKey;
+ private $publicKey;
/**
* Private key
@@ -216,7 +178,7 @@ class X509
* @var string
* @access private
*/
- var $privateKey;
+ private $privateKey;
/**
* Object identifiers for X.509 certificates
@@ -225,7 +187,7 @@ class X509
* @access private
* @link http://en.wikipedia.org/wiki/Object_identifier
*/
- var $oids;
+ private $oids;
/**
* The certificate authorities
@@ -233,7 +195,7 @@ class X509
* @var array
* @access private
*/
- var $CAs;
+ private $CAs;
/**
* The currently loaded certificate
@@ -241,18 +203,18 @@ class X509
* @var array
* @access private
*/
- var $currentCert;
+ private $currentCert;
/**
* The signature subject
*
- * There's no guarantee \phpseclib\File\X509 is going to re-encode an X.509 cert in the same way it was originally
+ * There's no guarantee \phpseclib3\File\X509 is going to re-encode an X.509 cert in the same way it was originally
* encoded so we take save the portion of the original cert that the signature would have made for.
*
* @var string
* @access private
*/
- var $signatureSubject;
+ private $signatureSubject;
/**
* Certificate Start Date
@@ -260,7 +222,7 @@ class X509
* @var string
* @access private
*/
- var $startDate;
+ private $startDate;
/**
* Certificate End Date
@@ -268,7 +230,7 @@ class X509
* @var string
* @access private
*/
- var $endDate;
+ private $endDate;
/**
* Serial Number
@@ -276,7 +238,7 @@ class X509
* @var string
* @access private
*/
- var $serialNumber;
+ private $serialNumber;
/**
* Key Identifier
@@ -287,7 +249,7 @@ class X509
* @var string
* @access private
*/
- var $currentKeyIdentifier;
+ private $currentKeyIdentifier;
/**
* CA Flag
@@ -295,7 +257,7 @@ class X509
* @var bool
* @access private
*/
- var $caFlag = false;
+ private $caFlag = false;
/**
* SPKAC Challenge
@@ -303,7 +265,21 @@ class X509
* @var string
* @access private
*/
- var $challenge;
+ private $challenge;
+
+ /**
+ * @var array
+ * @access private
+ */
+ private $extensionValues = [];
+
+ /**
+ * OIDs loaded
+ *
+ * @var bool
+ * @access private
+ */
+ private static $oidsLoaded = false;
/**
* Recursion Limit
@@ -311,7 +287,7 @@ class X509
* @var int
* @access private
*/
- static $recur_limit = 5;
+ private static $recur_limit = 5;
/**
* URL fetch flag
@@ -319,1130 +295,160 @@ class X509
* @var bool
* @access private
*/
- static $disable_url_fetch = false;
+ private static $disable_url_fetch = false;
+
+ /**
+ * @var array
+ * @access private
+ */
+ private static $extensions = [];
/**
* Default Constructor.
*
- * @return \phpseclib\File\X509
+ * @return \phpseclib3\File\X509
* @access public
*/
- function __construct()
+ public function __construct()
{
// Explicitly Tagged Module, 1988 Syntax
// http://tools.ietf.org/html/rfc5280#appendix-A.1
- $this->DirectoryString = array(
- 'type' => ASN1::TYPE_CHOICE,
- 'children' => array(
- 'teletexString' => array('type' => ASN1::TYPE_TELETEX_STRING),
- 'printableString' => array('type' => ASN1::TYPE_PRINTABLE_STRING),
- 'universalString' => array('type' => ASN1::TYPE_UNIVERSAL_STRING),
- 'utf8String' => array('type' => ASN1::TYPE_UTF8_STRING),
- 'bmpString' => array('type' => ASN1::TYPE_BMP_STRING)
- )
- );
-
- $this->PKCS9String = array(
- 'type' => ASN1::TYPE_CHOICE,
- 'children' => array(
- 'ia5String' => array('type' => ASN1::TYPE_IA5_STRING),
- 'directoryString' => $this->DirectoryString
- )
- );
-
- $this->AttributeValue = array('type' => ASN1::TYPE_ANY);
-
- $AttributeType = array('type' => ASN1::TYPE_OBJECT_IDENTIFIER);
-
- $AttributeTypeAndValue = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'type' => $AttributeType,
- 'value'=> $this->AttributeValue
- )
- );
-
- /*
- In practice, RDNs containing multiple name-value pairs (called "multivalued RDNs") are rare,
- but they can be useful at times when either there is no unique attribute in the entry or you
- want to ensure that the entry's DN contains some useful identifying information.
-
- - https://www.opends.org/wiki/page/DefinitionRelativeDistinguishedName
- */
- $this->RelativeDistinguishedName = array(
- 'type' => ASN1::TYPE_SET,
- 'min' => 1,
- 'max' => -1,
- 'children' => $AttributeTypeAndValue
- );
-
- // http://tools.ietf.org/html/rfc5280#section-4.1.2.4
- $RDNSequence = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- // RDNSequence does not define a min or a max, which means it doesn't have one
- 'min' => 0,
- 'max' => -1,
- 'children' => $this->RelativeDistinguishedName
- );
-
- $this->Name = array(
- 'type' => ASN1::TYPE_CHOICE,
- 'children' => array(
- 'rdnSequence' => $RDNSequence
- )
- );
-
- // http://tools.ietf.org/html/rfc5280#section-4.1.1.2
- $AlgorithmIdentifier = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'algorithm' => array('type' => ASN1::TYPE_OBJECT_IDENTIFIER),
- 'parameters' => array(
- 'type' => ASN1::TYPE_ANY,
- 'optional' => true
- )
- )
- );
-
- /*
- A certificate using system MUST reject the certificate if it encounters
- a critical extension it does not recognize; however, a non-critical
- extension may be ignored if it is not recognized.
-
- http://tools.ietf.org/html/rfc5280#section-4.2
- */
- $Extension = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'extnId' => array('type' => ASN1::TYPE_OBJECT_IDENTIFIER),
- 'critical' => array(
- 'type' => ASN1::TYPE_BOOLEAN,
- 'optional' => true,
- 'default' => false
- ),
- 'extnValue' => array('type' => ASN1::TYPE_OCTET_STRING)
- )
- );
-
- $this->Extensions = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'min' => 1,
- // technically, it's MAX, but we'll assume anything < 0 is MAX
- 'max' => -1,
- // if 'children' isn't an array then 'min' and 'max' must be defined
- 'children' => $Extension
- );
-
- $SubjectPublicKeyInfo = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'algorithm' => $AlgorithmIdentifier,
- 'subjectPublicKey' => array('type' => ASN1::TYPE_BIT_STRING)
- )
- );
-
- $UniqueIdentifier = array('type' => ASN1::TYPE_BIT_STRING);
-
- $Time = array(
- 'type' => ASN1::TYPE_CHOICE,
- 'children' => array(
- 'utcTime' => array('type' => ASN1::TYPE_UTC_TIME),
- 'generalTime' => array('type' => ASN1::TYPE_GENERALIZED_TIME)
- )
- );
-
- // http://tools.ietf.org/html/rfc5280#section-4.1.2.5
- $Validity = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'notBefore' => $Time,
- 'notAfter' => $Time
- )
- );
-
- $CertificateSerialNumber = array('type' => ASN1::TYPE_INTEGER);
-
- $Version = array(
- 'type' => ASN1::TYPE_INTEGER,
- 'mapping' => array('v1', 'v2', 'v3')
- );
-
- // assert($TBSCertificate['children']['signature'] == $Certificate['children']['signatureAlgorithm'])
- $TBSCertificate = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- // technically, default implies optional, but we'll define it as being optional, none-the-less, just to
- // reenforce that fact
- 'version' => array(
- 'constant' => 0,
- 'optional' => true,
- 'explicit' => true,
- 'default' => 'v1'
- ) + $Version,
- 'serialNumber' => $CertificateSerialNumber,
- 'signature' => $AlgorithmIdentifier,
- 'issuer' => $this->Name,
- 'validity' => $Validity,
- 'subject' => $this->Name,
- 'subjectPublicKeyInfo' => $SubjectPublicKeyInfo,
- // implicit means that the T in the TLV structure is to be rewritten, regardless of the type
- 'issuerUniqueID' => array(
- 'constant' => 1,
- 'optional' => true,
- 'implicit' => true
- ) + $UniqueIdentifier,
- 'subjectUniqueID' => array(
- 'constant' => 2,
- 'optional' => true,
- 'implicit' => true
- ) + $UniqueIdentifier,
- // doesn't use the EXPLICIT keyword but if
- // it's not IMPLICIT, it's EXPLICIT
- 'extensions' => array(
- 'constant' => 3,
- 'optional' => true,
- 'explicit' => true
- ) + $this->Extensions
- )
- );
-
- $this->Certificate = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'tbsCertificate' => $TBSCertificate,
- 'signatureAlgorithm' => $AlgorithmIdentifier,
- 'signature' => array('type' => ASN1::TYPE_BIT_STRING)
- )
- );
-
- $this->KeyUsage = array(
- 'type' => ASN1::TYPE_BIT_STRING,
- 'mapping' => array(
- 'digitalSignature',
- 'nonRepudiation',
- 'keyEncipherment',
- 'dataEncipherment',
- 'keyAgreement',
- 'keyCertSign',
- 'cRLSign',
- 'encipherOnly',
- 'decipherOnly'
- )
- );
-
- $this->BasicConstraints = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'cA' => array(
- 'type' => ASN1::TYPE_BOOLEAN,
- 'optional' => true,
- 'default' => false
- ),
- 'pathLenConstraint' => array(
- 'type' => ASN1::TYPE_INTEGER,
- 'optional' => true
- )
- )
- );
-
- $this->KeyIdentifier = array('type' => ASN1::TYPE_OCTET_STRING);
-
- $OrganizationalUnitNames = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'min' => 1,
- 'max' => 4, // ub-organizational-units
- 'children' => array('type' => ASN1::TYPE_PRINTABLE_STRING)
- );
-
- $PersonalName = array(
- 'type' => ASN1::TYPE_SET,
- 'children' => array(
- 'surname' => array(
- 'type' => ASN1::TYPE_PRINTABLE_STRING,
- 'constant' => 0,
- 'optional' => true,
- 'implicit' => true
- ),
- 'given-name' => array(
- 'type' => ASN1::TYPE_PRINTABLE_STRING,
- 'constant' => 1,
- 'optional' => true,
- 'implicit' => true
- ),
- 'initials' => array(
- 'type' => ASN1::TYPE_PRINTABLE_STRING,
- 'constant' => 2,
- 'optional' => true,
- 'implicit' => true
- ),
- 'generation-qualifier' => array(
- 'type' => ASN1::TYPE_PRINTABLE_STRING,
- 'constant' => 3,
- 'optional' => true,
- 'implicit' => true
- )
- )
- );
-
- $NumericUserIdentifier = array('type' => ASN1::TYPE_NUMERIC_STRING);
-
- $OrganizationName = array('type' => ASN1::TYPE_PRINTABLE_STRING);
-
- $PrivateDomainName = array(
- 'type' => ASN1::TYPE_CHOICE,
- 'children' => array(
- 'numeric' => array('type' => ASN1::TYPE_NUMERIC_STRING),
- 'printable' => array('type' => ASN1::TYPE_PRINTABLE_STRING)
- )
- );
-
- $TerminalIdentifier = array('type' => ASN1::TYPE_PRINTABLE_STRING);
-
- $NetworkAddress = array('type' => ASN1::TYPE_NUMERIC_STRING);
-
- $AdministrationDomainName = array(
- 'type' => ASN1::TYPE_CHOICE,
- // if class isn't present it's assumed to be \phpseclib\File\ASN1::CLASS_UNIVERSAL or
- // (if constant is present) \phpseclib\File\ASN1::CLASS_CONTEXT_SPECIFIC
- 'class' => ASN1::CLASS_APPLICATION,
- 'cast' => 2,
- 'children' => array(
- 'numeric' => array('type' => ASN1::TYPE_NUMERIC_STRING),
- 'printable' => array('type' => ASN1::TYPE_PRINTABLE_STRING)
- )
- );
-
- $CountryName = array(
- 'type' => ASN1::TYPE_CHOICE,
- // if class isn't present it's assumed to be \phpseclib\File\ASN1::CLASS_UNIVERSAL or
- // (if constant is present) \phpseclib\File\ASN1::CLASS_CONTEXT_SPECIFIC
- 'class' => ASN1::CLASS_APPLICATION,
- 'cast' => 1,
- 'children' => array(
- 'x121-dcc-code' => array('type' => ASN1::TYPE_NUMERIC_STRING),
- 'iso-3166-alpha2-code' => array('type' => ASN1::TYPE_PRINTABLE_STRING)
- )
- );
-
- $AnotherName = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'type-id' => array('type' => ASN1::TYPE_OBJECT_IDENTIFIER),
- 'value' => array(
- 'type' => ASN1::TYPE_ANY,
- 'constant' => 0,
- 'optional' => true,
- 'explicit' => true
- )
- )
- );
-
- $ExtensionAttribute = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'extension-attribute-type' => array(
- 'type' => ASN1::TYPE_PRINTABLE_STRING,
- 'constant' => 0,
- 'optional' => true,
- 'implicit' => true
- ),
- 'extension-attribute-value' => array(
- 'type' => ASN1::TYPE_ANY,
- 'constant' => 1,
- 'optional' => true,
- 'explicit' => true
- )
- )
- );
-
- $ExtensionAttributes = array(
- 'type' => ASN1::TYPE_SET,
- 'min' => 1,
- 'max' => 256, // ub-extension-attributes
- 'children' => $ExtensionAttribute
- );
-
- $BuiltInDomainDefinedAttribute = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'type' => array('type' => ASN1::TYPE_PRINTABLE_STRING),
- 'value' => array('type' => ASN1::TYPE_PRINTABLE_STRING)
- )
- );
-
- $BuiltInDomainDefinedAttributes = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'min' => 1,
- 'max' => 4, // ub-domain-defined-attributes
- 'children' => $BuiltInDomainDefinedAttribute
- );
-
- $BuiltInStandardAttributes = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'country-name' => array('optional' => true) + $CountryName,
- 'administration-domain-name' => array('optional' => true) + $AdministrationDomainName,
- 'network-address' => array(
- 'constant' => 0,
- 'optional' => true,
- 'implicit' => true
- ) + $NetworkAddress,
- 'terminal-identifier' => array(
- 'constant' => 1,
- 'optional' => true,
- 'implicit' => true
- ) + $TerminalIdentifier,
- 'private-domain-name' => array(
- 'constant' => 2,
- 'optional' => true,
- 'explicit' => true
- ) + $PrivateDomainName,
- 'organization-name' => array(
- 'constant' => 3,
- 'optional' => true,
- 'implicit' => true
- ) + $OrganizationName,
- 'numeric-user-identifier' => array(
- 'constant' => 4,
- 'optional' => true,
- 'implicit' => true
- ) + $NumericUserIdentifier,
- 'personal-name' => array(
- 'constant' => 5,
- 'optional' => true,
- 'implicit' => true
- ) + $PersonalName,
- 'organizational-unit-names' => array(
- 'constant' => 6,
- 'optional' => true,
- 'implicit' => true
- ) + $OrganizationalUnitNames
- )
- );
-
- $ORAddress = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'built-in-standard-attributes' => $BuiltInStandardAttributes,
- 'built-in-domain-defined-attributes' => array('optional' => true) + $BuiltInDomainDefinedAttributes,
- 'extension-attributes' => array('optional' => true) + $ExtensionAttributes
- )
- );
-
- $EDIPartyName = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'nameAssigner' => array(
- 'constant' => 0,
- 'optional' => true,
- 'implicit' => true
- ) + $this->DirectoryString,
- // partyName is technically required but \phpseclib\File\ASN1 doesn't currently support non-optional constants and
- // setting it to optional gets the job done in any event.
- 'partyName' => array(
- 'constant' => 1,
- 'optional' => true,
- 'implicit' => true
- ) + $this->DirectoryString
- )
- );
-
- $GeneralName = array(
- 'type' => ASN1::TYPE_CHOICE,
- 'children' => array(
- 'otherName' => array(
- 'constant' => 0,
- 'optional' => true,
- 'implicit' => true
- ) + $AnotherName,
- 'rfc822Name' => array(
- 'type' => ASN1::TYPE_IA5_STRING,
- 'constant' => 1,
- 'optional' => true,
- 'implicit' => true
- ),
- 'dNSName' => array(
- 'type' => ASN1::TYPE_IA5_STRING,
- 'constant' => 2,
- 'optional' => true,
- 'implicit' => true
- ),
- 'x400Address' => array(
- 'constant' => 3,
- 'optional' => true,
- 'implicit' => true
- ) + $ORAddress,
- 'directoryName' => array(
- 'constant' => 4,
- 'optional' => true,
- 'explicit' => true
- ) + $this->Name,
- 'ediPartyName' => array(
- 'constant' => 5,
- 'optional' => true,
- 'implicit' => true
- ) + $EDIPartyName,
- 'uniformResourceIdentifier' => array(
- 'type' => ASN1::TYPE_IA5_STRING,
- 'constant' => 6,
- 'optional' => true,
- 'implicit' => true
- ),
- 'iPAddress' => array(
- 'type' => ASN1::TYPE_OCTET_STRING,
- 'constant' => 7,
- 'optional' => true,
- 'implicit' => true
- ),
- 'registeredID' => array(
- 'type' => ASN1::TYPE_OBJECT_IDENTIFIER,
- 'constant' => 8,
- 'optional' => true,
- 'implicit' => true
- )
- )
- );
-
- $GeneralNames = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'min' => 1,
- 'max' => -1,
- 'children' => $GeneralName
- );
-
- $this->IssuerAltName = $GeneralNames;
-
- $ReasonFlags = array(
- 'type' => ASN1::TYPE_BIT_STRING,
- 'mapping' => array(
- 'unused',
- 'keyCompromise',
- 'cACompromise',
- 'affiliationChanged',
- 'superseded',
- 'cessationOfOperation',
- 'certificateHold',
- 'privilegeWithdrawn',
- 'aACompromise'
- )
- );
-
- $DistributionPointName = array(
- 'type' => ASN1::TYPE_CHOICE,
- 'children' => array(
- 'fullName' => array(
- 'constant' => 0,
- 'optional' => true,
- 'implicit' => true
- ) + $GeneralNames,
- 'nameRelativeToCRLIssuer' => array(
- 'constant' => 1,
- 'optional' => true,
- 'implicit' => true
- ) + $this->RelativeDistinguishedName
- )
- );
-
- $DistributionPoint = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'distributionPoint' => array(
- 'constant' => 0,
- 'optional' => true,
- 'explicit' => true
- ) + $DistributionPointName,
- 'reasons' => array(
- 'constant' => 1,
- 'optional' => true,
- 'implicit' => true
- ) + $ReasonFlags,
- 'cRLIssuer' => array(
- 'constant' => 2,
- 'optional' => true,
- 'implicit' => true
- ) + $GeneralNames
- )
- );
-
- $this->CRLDistributionPoints = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'min' => 1,
- 'max' => -1,
- 'children' => $DistributionPoint
- );
-
- $this->AuthorityKeyIdentifier = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'keyIdentifier' => array(
- 'constant' => 0,
- 'optional' => true,
- 'implicit' => true
- ) + $this->KeyIdentifier,
- 'authorityCertIssuer' => array(
- 'constant' => 1,
- 'optional' => true,
- 'implicit' => true
- ) + $GeneralNames,
- 'authorityCertSerialNumber' => array(
- 'constant' => 2,
- 'optional' => true,
- 'implicit' => true
- ) + $CertificateSerialNumber
- )
- );
-
- $PolicyQualifierId = array('type' => ASN1::TYPE_OBJECT_IDENTIFIER);
-
- $PolicyQualifierInfo = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'policyQualifierId' => $PolicyQualifierId,
- 'qualifier' => array('type' => ASN1::TYPE_ANY)
- )
- );
-
- $CertPolicyId = array('type' => ASN1::TYPE_OBJECT_IDENTIFIER);
-
- $PolicyInformation = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'policyIdentifier' => $CertPolicyId,
- 'policyQualifiers' => array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'min' => 0,
- 'max' => -1,
- 'optional' => true,
- 'children' => $PolicyQualifierInfo
- )
- )
- );
-
- $this->CertificatePolicies = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'min' => 1,
- 'max' => -1,
- 'children' => $PolicyInformation
- );
-
- $this->PolicyMappings = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'min' => 1,
- 'max' => -1,
- 'children' => array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'issuerDomainPolicy' => $CertPolicyId,
- 'subjectDomainPolicy' => $CertPolicyId
- )
- )
- );
-
- $KeyPurposeId = array('type' => ASN1::TYPE_OBJECT_IDENTIFIER);
-
- $this->ExtKeyUsageSyntax = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'min' => 1,
- 'max' => -1,
- 'children' => $KeyPurposeId
- );
-
- $AccessDescription = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'accessMethod' => array('type' => ASN1::TYPE_OBJECT_IDENTIFIER),
- 'accessLocation' => $GeneralName
- )
- );
-
- $this->AuthorityInfoAccessSyntax = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'min' => 1,
- 'max' => -1,
- 'children' => $AccessDescription
- );
-
- $this->SubjectAltName = $GeneralNames;
-
- $this->PrivateKeyUsagePeriod = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'notBefore' => array(
- 'constant' => 0,
- 'optional' => true,
- 'implicit' => true,
- 'type' => ASN1::TYPE_GENERALIZED_TIME),
- 'notAfter' => array(
- 'constant' => 1,
- 'optional' => true,
- 'implicit' => true,
- 'type' => ASN1::TYPE_GENERALIZED_TIME)
- )
- );
-
- $BaseDistance = array('type' => ASN1::TYPE_INTEGER);
-
- $GeneralSubtree = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'base' => $GeneralName,
- 'minimum' => array(
- 'constant' => 0,
- 'optional' => true,
- 'implicit' => true,
- 'default' => new BigInteger(0)
- ) + $BaseDistance,
- 'maximum' => array(
- 'constant' => 1,
- 'optional' => true,
- 'implicit' => true,
- ) + $BaseDistance
- )
- );
-
- $GeneralSubtrees = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'min' => 1,
- 'max' => -1,
- 'children' => $GeneralSubtree
- );
-
- $this->NameConstraints = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'permittedSubtrees' => array(
- 'constant' => 0,
- 'optional' => true,
- 'implicit' => true
- ) + $GeneralSubtrees,
- 'excludedSubtrees' => array(
- 'constant' => 1,
- 'optional' => true,
- 'implicit' => true
- ) + $GeneralSubtrees
- )
- );
-
- $this->CPSuri = array('type' => ASN1::TYPE_IA5_STRING);
-
- $DisplayText = array(
- 'type' => ASN1::TYPE_CHOICE,
- 'children' => array(
- 'ia5String' => array('type' => ASN1::TYPE_IA5_STRING),
- 'visibleString' => array('type' => ASN1::TYPE_VISIBLE_STRING),
- 'bmpString' => array('type' => ASN1::TYPE_BMP_STRING),
- 'utf8String' => array('type' => ASN1::TYPE_UTF8_STRING)
- )
- );
-
- $NoticeReference = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'organization' => $DisplayText,
- 'noticeNumbers' => array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'min' => 1,
- 'max' => 200,
- 'children' => array('type' => ASN1::TYPE_INTEGER)
- )
- )
- );
-
- $this->UserNotice = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'noticeRef' => array(
- 'optional' => true,
- 'implicit' => true
- ) + $NoticeReference,
- 'explicitText' => array(
- 'optional' => true,
- 'implicit' => true
- ) + $DisplayText
- )
- );
-
- // mapping is from
- $this->netscape_cert_type = array(
- 'type' => ASN1::TYPE_BIT_STRING,
- 'mapping' => array(
- 'SSLClient',
- 'SSLServer',
- 'Email',
- 'ObjectSigning',
- 'Reserved',
- 'SSLCA',
- 'EmailCA',
- 'ObjectSigningCA'
- )
- );
-
- $this->netscape_comment = array('type' => ASN1::TYPE_IA5_STRING);
- $this->netscape_ca_policy_url = array('type' => ASN1::TYPE_IA5_STRING);
-
- // attribute is used in RFC2986 but we're using the RFC5280 definition
-
- $Attribute = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'type' => $AttributeType,
- 'value'=> array(
- 'type' => ASN1::TYPE_SET,
- 'min' => 1,
- 'max' => -1,
- 'children' => $this->AttributeValue
- )
- )
- );
-
- $this->SubjectDirectoryAttributes = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'min' => 1,
- 'max' => -1,
- 'children' => $Attribute
- );
-
- // adapted from
-
- $Attributes = array(
- 'type' => ASN1::TYPE_SET,
- 'min' => 1,
- 'max' => -1,
- 'children' => $Attribute
- );
-
- $CertificationRequestInfo = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'version' => array(
- 'type' => ASN1::TYPE_INTEGER,
- 'mapping' => array('v1')
- ),
- 'subject' => $this->Name,
- 'subjectPKInfo' => $SubjectPublicKeyInfo,
- 'attributes' => array(
- 'constant' => 0,
- 'optional' => true,
- 'implicit' => true
- ) + $Attributes,
- )
- );
-
- $this->CertificationRequest = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'certificationRequestInfo' => $CertificationRequestInfo,
- 'signatureAlgorithm' => $AlgorithmIdentifier,
- 'signature' => array('type' => ASN1::TYPE_BIT_STRING)
- )
- );
-
- $RevokedCertificate = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'userCertificate' => $CertificateSerialNumber,
- 'revocationDate' => $Time,
- 'crlEntryExtensions' => array(
- 'optional' => true
- ) + $this->Extensions
- )
- );
-
- $TBSCertList = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'version' => array(
- 'optional' => true,
- 'default' => 'v1'
- ) + $Version,
- 'signature' => $AlgorithmIdentifier,
- 'issuer' => $this->Name,
- 'thisUpdate' => $Time,
- 'nextUpdate' => array(
- 'optional' => true
- ) + $Time,
- 'revokedCertificates' => array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'optional' => true,
- 'min' => 0,
- 'max' => -1,
- 'children' => $RevokedCertificate
- ),
- 'crlExtensions' => array(
- 'constant' => 0,
- 'optional' => true,
- 'explicit' => true
- ) + $this->Extensions
- )
- );
-
- $this->CertificateList = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'tbsCertList' => $TBSCertList,
- 'signatureAlgorithm' => $AlgorithmIdentifier,
- 'signature' => array('type' => ASN1::TYPE_BIT_STRING)
- )
- );
-
- $this->CRLNumber = array('type' => ASN1::TYPE_INTEGER);
-
- $this->CRLReason = array('type' => ASN1::TYPE_ENUMERATED,
- 'mapping' => array(
- 'unspecified',
- 'keyCompromise',
- 'cACompromise',
- 'affiliationChanged',
- 'superseded',
- 'cessationOfOperation',
- 'certificateHold',
- // Value 7 is not used.
- 8 => 'removeFromCRL',
- 'privilegeWithdrawn',
- 'aACompromise'
- )
- );
-
- $this->IssuingDistributionPoint = array('type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'distributionPoint' => array(
- 'constant' => 0,
- 'optional' => true,
- 'explicit' => true
- ) + $DistributionPointName,
- 'onlyContainsUserCerts' => array(
- 'type' => ASN1::TYPE_BOOLEAN,
- 'constant' => 1,
- 'optional' => true,
- 'default' => false,
- 'implicit' => true
- ),
- 'onlyContainsCACerts' => array(
- 'type' => ASN1::TYPE_BOOLEAN,
- 'constant' => 2,
- 'optional' => true,
- 'default' => false,
- 'implicit' => true
- ),
- 'onlySomeReasons' => array(
- 'constant' => 3,
- 'optional' => true,
- 'implicit' => true
- ) + $ReasonFlags,
- 'indirectCRL' => array(
- 'type' => ASN1::TYPE_BOOLEAN,
- 'constant' => 4,
- 'optional' => true,
- 'default' => false,
- 'implicit' => true
- ),
- 'onlyContainsAttributeCerts' => array(
- 'type' => ASN1::TYPE_BOOLEAN,
- 'constant' => 5,
- 'optional' => true,
- 'default' => false,
- 'implicit' => true
- )
- )
- );
-
- $this->InvalidityDate = array('type' => ASN1::TYPE_GENERALIZED_TIME);
-
- $this->CertificateIssuer = $GeneralNames;
-
- $this->HoldInstructionCode = array('type' => ASN1::TYPE_OBJECT_IDENTIFIER);
-
- $PublicKeyAndChallenge = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'spki' => $SubjectPublicKeyInfo,
- 'challenge' => array('type' => ASN1::TYPE_IA5_STRING)
- )
- );
-
- $this->SignedPublicKeyAndChallenge = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'children' => array(
- 'publicKeyAndChallenge' => $PublicKeyAndChallenge,
- 'signatureAlgorithm' => $AlgorithmIdentifier,
- 'signature' => array('type' => ASN1::TYPE_BIT_STRING)
- )
- );
-
- $this->PostalAddress = array(
- 'type' => ASN1::TYPE_SEQUENCE,
- 'optional' => true,
- 'min' => 1,
- 'max' => -1,
- 'children' => $this->DirectoryString
- );
-
- // OIDs from RFC5280 and those RFCs mentioned in RFC5280#section-4.1.1.2
- $this->oids = array(
- '1.3.6.1.5.5.7' => 'id-pkix',
- '1.3.6.1.5.5.7.1' => 'id-pe',
- '1.3.6.1.5.5.7.2' => 'id-qt',
- '1.3.6.1.5.5.7.3' => 'id-kp',
- '1.3.6.1.5.5.7.48' => 'id-ad',
- '1.3.6.1.5.5.7.2.1' => 'id-qt-cps',
- '1.3.6.1.5.5.7.2.2' => 'id-qt-unotice',
- '1.3.6.1.5.5.7.48.1' =>'id-ad-ocsp',
- '1.3.6.1.5.5.7.48.2' => 'id-ad-caIssuers',
- '1.3.6.1.5.5.7.48.3' => 'id-ad-timeStamping',
- '1.3.6.1.5.5.7.48.5' => 'id-ad-caRepository',
- '2.5.4' => 'id-at',
- '2.5.4.41' => 'id-at-name',
- '2.5.4.4' => 'id-at-surname',
- '2.5.4.42' => 'id-at-givenName',
- '2.5.4.43' => 'id-at-initials',
- '2.5.4.44' => 'id-at-generationQualifier',
- '2.5.4.3' => 'id-at-commonName',
- '2.5.4.7' => 'id-at-localityName',
- '2.5.4.8' => 'id-at-stateOrProvinceName',
- '2.5.4.10' => 'id-at-organizationName',
- '2.5.4.11' => 'id-at-organizationalUnitName',
- '2.5.4.12' => 'id-at-title',
- '2.5.4.13' => 'id-at-description',
- '2.5.4.46' => 'id-at-dnQualifier',
- '2.5.4.6' => 'id-at-countryName',
- '2.5.4.5' => 'id-at-serialNumber',
- '2.5.4.65' => 'id-at-pseudonym',
- '2.5.4.17' => 'id-at-postalCode',
- '2.5.4.9' => 'id-at-streetAddress',
- '2.5.4.45' => 'id-at-uniqueIdentifier',
- '2.5.4.72' => 'id-at-role',
- '2.5.4.16' => 'id-at-postalAddress',
-
- '0.9.2342.19200300.100.1.25' => 'id-domainComponent',
- '1.2.840.113549.1.9' => 'pkcs-9',
- '1.2.840.113549.1.9.1' => 'pkcs-9-at-emailAddress',
- '2.5.29' => 'id-ce',
- '2.5.29.35' => 'id-ce-authorityKeyIdentifier',
- '2.5.29.14' => 'id-ce-subjectKeyIdentifier',
- '2.5.29.15' => 'id-ce-keyUsage',
- '2.5.29.16' => 'id-ce-privateKeyUsagePeriod',
- '2.5.29.32' => 'id-ce-certificatePolicies',
- '2.5.29.32.0' => 'anyPolicy',
-
- '2.5.29.33' => 'id-ce-policyMappings',
- '2.5.29.17' => 'id-ce-subjectAltName',
- '2.5.29.18' => 'id-ce-issuerAltName',
- '2.5.29.9' => 'id-ce-subjectDirectoryAttributes',
- '2.5.29.19' => 'id-ce-basicConstraints',
- '2.5.29.30' => 'id-ce-nameConstraints',
- '2.5.29.36' => 'id-ce-policyConstraints',
- '2.5.29.31' => 'id-ce-cRLDistributionPoints',
- '2.5.29.37' => 'id-ce-extKeyUsage',
- '2.5.29.37.0' => 'anyExtendedKeyUsage',
- '1.3.6.1.5.5.7.3.1' => 'id-kp-serverAuth',
- '1.3.6.1.5.5.7.3.2' => 'id-kp-clientAuth',
- '1.3.6.1.5.5.7.3.3' => 'id-kp-codeSigning',
- '1.3.6.1.5.5.7.3.4' => 'id-kp-emailProtection',
- '1.3.6.1.5.5.7.3.8' => 'id-kp-timeStamping',
- '1.3.6.1.5.5.7.3.9' => 'id-kp-OCSPSigning',
- '2.5.29.54' => 'id-ce-inhibitAnyPolicy',
- '2.5.29.46' => 'id-ce-freshestCRL',
- '1.3.6.1.5.5.7.1.1' => 'id-pe-authorityInfoAccess',
- '1.3.6.1.5.5.7.1.11' => 'id-pe-subjectInfoAccess',
- '2.5.29.20' => 'id-ce-cRLNumber',
- '2.5.29.28' => 'id-ce-issuingDistributionPoint',
- '2.5.29.27' => 'id-ce-deltaCRLIndicator',
- '2.5.29.21' => 'id-ce-cRLReasons',
- '2.5.29.29' => 'id-ce-certificateIssuer',
- '2.5.29.23' => 'id-ce-holdInstructionCode',
- '1.2.840.10040.2' => 'holdInstruction',
- '1.2.840.10040.2.1' => 'id-holdinstruction-none',
- '1.2.840.10040.2.2' => 'id-holdinstruction-callissuer',
- '1.2.840.10040.2.3' => 'id-holdinstruction-reject',
- '2.5.29.24' => 'id-ce-invalidityDate',
-
- '1.2.840.113549.2.2' => 'md2',
- '1.2.840.113549.2.5' => 'md5',
- '1.3.14.3.2.26' => 'id-sha1',
- '1.2.840.10040.4.1' => 'id-dsa',
- '1.2.840.10040.4.3' => 'id-dsa-with-sha1',
- '1.2.840.113549.1.1' => 'pkcs-1',
- '1.2.840.113549.1.1.1' => 'rsaEncryption',
- '1.2.840.113549.1.1.2' => 'md2WithRSAEncryption',
- '1.2.840.113549.1.1.4' => 'md5WithRSAEncryption',
- '1.2.840.113549.1.1.5' => 'sha1WithRSAEncryption',
- '1.2.840.10046.2.1' => 'dhpublicnumber',
- '2.16.840.1.101.2.1.1.22' => 'id-keyExchangeAlgorithm',
- '1.2.840.10045' => 'ansi-X9-62',
- '1.2.840.10045.4' => 'id-ecSigType',
- '1.2.840.10045.4.1' => 'ecdsa-with-SHA1',
- '1.2.840.10045.1' => 'id-fieldType',
- '1.2.840.10045.1.1' => 'prime-field',
- '1.2.840.10045.1.2' => 'characteristic-two-field',
- '1.2.840.10045.1.2.3' => 'id-characteristic-two-basis',
- '1.2.840.10045.1.2.3.1' => 'gnBasis',
- '1.2.840.10045.1.2.3.2' => 'tpBasis',
- '1.2.840.10045.1.2.3.3' => 'ppBasis',
- '1.2.840.10045.2' => 'id-publicKeyType',
- '1.2.840.10045.2.1' => 'id-ecPublicKey',
- '1.2.840.10045.3' => 'ellipticCurve',
- '1.2.840.10045.3.0' => 'c-TwoCurve',
- '1.2.840.10045.3.0.1' => 'c2pnb163v1',
- '1.2.840.10045.3.0.2' => 'c2pnb163v2',
- '1.2.840.10045.3.0.3' => 'c2pnb163v3',
- '1.2.840.10045.3.0.4' => 'c2pnb176w1',
- '1.2.840.10045.3.0.5' => 'c2pnb191v1',
- '1.2.840.10045.3.0.6' => 'c2pnb191v2',
- '1.2.840.10045.3.0.7' => 'c2pnb191v3',
- '1.2.840.10045.3.0.8' => 'c2pnb191v4',
- '1.2.840.10045.3.0.9' => 'c2pnb191v5',
- '1.2.840.10045.3.0.10' => 'c2pnb208w1',
- '1.2.840.10045.3.0.11' => 'c2pnb239v1',
- '1.2.840.10045.3.0.12' => 'c2pnb239v2',
- '1.2.840.10045.3.0.13' => 'c2pnb239v3',
- '1.2.840.10045.3.0.14' => 'c2pnb239v4',
- '1.2.840.10045.3.0.15' => 'c2pnb239v5',
- '1.2.840.10045.3.0.16' => 'c2pnb272w1',
- '1.2.840.10045.3.0.17' => 'c2pnb304w1',
- '1.2.840.10045.3.0.18' => 'c2pnb359v1',
- '1.2.840.10045.3.0.19' => 'c2pnb368w1',
- '1.2.840.10045.3.0.20' => 'c2pnb431r1',
- '1.2.840.10045.3.1' => 'primeCurve',
- '1.2.840.10045.3.1.1' => 'prime192v1',
- '1.2.840.10045.3.1.2' => 'prime192v2',
- '1.2.840.10045.3.1.3' => 'prime192v3',
- '1.2.840.10045.3.1.4' => 'prime239v1',
- '1.2.840.10045.3.1.5' => 'prime239v2',
- '1.2.840.10045.3.1.6' => 'prime239v3',
- '1.2.840.10045.3.1.7' => 'prime256v1',
- '1.2.840.113549.1.1.7' => 'id-RSAES-OAEP',
- '1.2.840.113549.1.1.9' => 'id-pSpecified',
- '1.2.840.113549.1.1.10' => 'id-RSASSA-PSS',
- '1.2.840.113549.1.1.8' => 'id-mgf1',
- '1.2.840.113549.1.1.14' => 'sha224WithRSAEncryption',
- '1.2.840.113549.1.1.11' => 'sha256WithRSAEncryption',
- '1.2.840.113549.1.1.12' => 'sha384WithRSAEncryption',
- '1.2.840.113549.1.1.13' => 'sha512WithRSAEncryption',
- '2.16.840.1.101.3.4.2.4' => 'id-sha224',
- '2.16.840.1.101.3.4.2.1' => 'id-sha256',
- '2.16.840.1.101.3.4.2.2' => 'id-sha384',
- '2.16.840.1.101.3.4.2.3' => 'id-sha512',
- '1.2.643.2.2.4' => 'id-GostR3411-94-with-GostR3410-94',
- '1.2.643.2.2.3' => 'id-GostR3411-94-with-GostR3410-2001',
- '1.2.643.2.2.20' => 'id-GostR3410-2001',
- '1.2.643.2.2.19' => 'id-GostR3410-94',
- // Netscape Object Identifiers from "Netscape Certificate Extensions"
- '2.16.840.1.113730' => 'netscape',
- '2.16.840.1.113730.1' => 'netscape-cert-extension',
- '2.16.840.1.113730.1.1' => 'netscape-cert-type',
- '2.16.840.1.113730.1.13' => 'netscape-comment',
- '2.16.840.1.113730.1.8' => 'netscape-ca-policy-url',
- // the following are X.509 extensions not supported by phpseclib
- '1.3.6.1.5.5.7.1.12' => 'id-pe-logotype',
- '1.2.840.113533.7.65.0' => 'entrustVersInfo',
- '2.16.840.1.113733.1.6.9' => 'verisignPrivate',
- // for Certificate Signing Requests
- // see http://tools.ietf.org/html/rfc2985
- '1.2.840.113549.1.9.2' => 'pkcs-9-at-unstructuredName', // PKCS #9 unstructured name
- '1.2.840.113549.1.9.7' => 'pkcs-9-at-challengePassword', // Challenge password for certificate revocations
- '1.2.840.113549.1.9.14' => 'pkcs-9-at-extensionRequest' // Certificate extension request
- );
+ if (!self::$oidsLoaded) {
+ // OIDs from RFC5280 and those RFCs mentioned in RFC5280#section-4.1.1.2
+ ASN1::loadOIDs([
+ //'id-pkix' => '1.3.6.1.5.5.7',
+ //'id-pe' => '1.3.6.1.5.5.7.1',
+ //'id-qt' => '1.3.6.1.5.5.7.2',
+ //'id-kp' => '1.3.6.1.5.5.7.3',
+ //'id-ad' => '1.3.6.1.5.5.7.48',
+ 'id-qt-cps' => '1.3.6.1.5.5.7.2.1',
+ 'id-qt-unotice' => '1.3.6.1.5.5.7.2.2',
+ 'id-ad-ocsp' =>'1.3.6.1.5.5.7.48.1',
+ 'id-ad-caIssuers' => '1.3.6.1.5.5.7.48.2',
+ 'id-ad-timeStamping' => '1.3.6.1.5.5.7.48.3',
+ 'id-ad-caRepository' => '1.3.6.1.5.5.7.48.5',
+ //'id-at' => '2.5.4',
+ 'id-at-name' => '2.5.4.41',
+ 'id-at-surname' => '2.5.4.4',
+ 'id-at-givenName' => '2.5.4.42',
+ 'id-at-initials' => '2.5.4.43',
+ 'id-at-generationQualifier' => '2.5.4.44',
+ 'id-at-commonName' => '2.5.4.3',
+ 'id-at-localityName' => '2.5.4.7',
+ 'id-at-stateOrProvinceName' => '2.5.4.8',
+ 'id-at-organizationName' => '2.5.4.10',
+ 'id-at-organizationalUnitName' => '2.5.4.11',
+ 'id-at-title' => '2.5.4.12',
+ 'id-at-description' => '2.5.4.13',
+ 'id-at-dnQualifier' => '2.5.4.46',
+ 'id-at-countryName' => '2.5.4.6',
+ 'id-at-serialNumber' => '2.5.4.5',
+ 'id-at-pseudonym' => '2.5.4.65',
+ 'id-at-postalCode' => '2.5.4.17',
+ 'id-at-streetAddress' => '2.5.4.9',
+ 'id-at-uniqueIdentifier' => '2.5.4.45',
+ 'id-at-role' => '2.5.4.72',
+ 'id-at-postalAddress' => '2.5.4.16',
+
+ //'id-domainComponent' => '0.9.2342.19200300.100.1.25',
+ //'pkcs-9' => '1.2.840.113549.1.9',
+ 'pkcs-9-at-emailAddress' => '1.2.840.113549.1.9.1',
+ //'id-ce' => '2.5.29',
+ 'id-ce-authorityKeyIdentifier' => '2.5.29.35',
+ 'id-ce-subjectKeyIdentifier' => '2.5.29.14',
+ 'id-ce-keyUsage' => '2.5.29.15',
+ 'id-ce-privateKeyUsagePeriod' => '2.5.29.16',
+ 'id-ce-certificatePolicies' => '2.5.29.32',
+ //'anyPolicy' => '2.5.29.32.0',
+
+ 'id-ce-policyMappings' => '2.5.29.33',
+
+ 'id-ce-subjectAltName' => '2.5.29.17',
+ 'id-ce-issuerAltName' => '2.5.29.18',
+ 'id-ce-subjectDirectoryAttributes' => '2.5.29.9',
+ 'id-ce-basicConstraints' => '2.5.29.19',
+ 'id-ce-nameConstraints' => '2.5.29.30',
+ 'id-ce-policyConstraints' => '2.5.29.36',
+ 'id-ce-cRLDistributionPoints' => '2.5.29.31',
+ 'id-ce-extKeyUsage' => '2.5.29.37',
+ //'anyExtendedKeyUsage' => '2.5.29.37.0',
+ 'id-kp-serverAuth' => '1.3.6.1.5.5.7.3.1',
+ 'id-kp-clientAuth' => '1.3.6.1.5.5.7.3.2',
+ 'id-kp-codeSigning' => '1.3.6.1.5.5.7.3.3',
+ 'id-kp-emailProtection' => '1.3.6.1.5.5.7.3.4',
+ 'id-kp-timeStamping' => '1.3.6.1.5.5.7.3.8',
+ 'id-kp-OCSPSigning' => '1.3.6.1.5.5.7.3.9',
+ 'id-ce-inhibitAnyPolicy' => '2.5.29.54',
+ 'id-ce-freshestCRL' => '2.5.29.46',
+ 'id-pe-authorityInfoAccess' => '1.3.6.1.5.5.7.1.1',
+ 'id-pe-subjectInfoAccess' => '1.3.6.1.5.5.7.1.11',
+ 'id-ce-cRLNumber' => '2.5.29.20',
+ 'id-ce-issuingDistributionPoint' => '2.5.29.28',
+ 'id-ce-deltaCRLIndicator' => '2.5.29.27',
+ 'id-ce-cRLReasons' => '2.5.29.21',
+ 'id-ce-certificateIssuer' => '2.5.29.29',
+ 'id-ce-holdInstructionCode' => '2.5.29.23',
+ //'holdInstruction' => '1.2.840.10040.2',
+ 'id-holdinstruction-none' => '1.2.840.10040.2.1',
+ 'id-holdinstruction-callissuer' => '1.2.840.10040.2.2',
+ 'id-holdinstruction-reject' => '1.2.840.10040.2.3',
+ 'id-ce-invalidityDate' => '2.5.29.24',
+
+ 'rsaEncryption' => '1.2.840.113549.1.1.1',
+ 'md2WithRSAEncryption' => '1.2.840.113549.1.1.2',
+ 'md5WithRSAEncryption' => '1.2.840.113549.1.1.4',
+ 'sha1WithRSAEncryption' => '1.2.840.113549.1.1.5',
+ 'sha224WithRSAEncryption' => '1.2.840.113549.1.1.14',
+ 'sha256WithRSAEncryption' => '1.2.840.113549.1.1.11',
+ 'sha384WithRSAEncryption' => '1.2.840.113549.1.1.12',
+ 'sha512WithRSAEncryption' => '1.2.840.113549.1.1.13',
+
+ 'id-ecPublicKey' => '1.2.840.10045.2.1',
+ 'ecdsa-with-SHA1' => '1.2.840.10045.4.1',
+ // from https://tools.ietf.org/html/rfc5758#section-3.2
+ 'ecdsa-with-SHA224' => '1.2.840.10045.4.3.1',
+ 'ecdsa-with-SHA256' => '1.2.840.10045.4.3.2',
+ 'ecdsa-with-SHA384' => '1.2.840.10045.4.3.3',
+ 'ecdsa-with-SHA512' => '1.2.840.10045.4.3.4',
+
+ 'id-dsa' => '1.2.840.10040.4.1',
+ 'id-dsa-with-sha1' => '1.2.840.10040.4.3',
+ // from https://tools.ietf.org/html/rfc5758#section-3.1
+ 'id-dsa-with-sha224' => '2.16.840.1.101.3.4.3.1',
+ 'id-dsa-with-sha256' => '2.16.840.1.101.3.4.3.2',
+
+ // from https://tools.ietf.org/html/rfc8410:
+ 'id-Ed25519' => '1.3.101.112',
+ 'id-Ed448' => '1.3.101.113',
+
+ 'id-RSASSA-PSS' => '1.2.840.113549.1.1.10',
+
+ //'id-sha224' => '2.16.840.1.101.3.4.2.4',
+ //'id-sha256' => '2.16.840.1.101.3.4.2.1',
+ //'id-sha384' => '2.16.840.1.101.3.4.2.2',
+ //'id-sha512' => '2.16.840.1.101.3.4.2.3',
+ //'id-GostR3411-94-with-GostR3410-94' => '1.2.643.2.2.4',
+ //'id-GostR3411-94-with-GostR3410-2001' => '1.2.643.2.2.3',
+ //'id-GostR3410-2001' => '1.2.643.2.2.20',
+ //'id-GostR3410-94' => '1.2.643.2.2.19',
+ // Netscape Object Identifiers from "Netscape Certificate Extensions"
+ 'netscape' => '2.16.840.1.113730',
+ 'netscape-cert-extension' => '2.16.840.1.113730.1',
+ 'netscape-cert-type' => '2.16.840.1.113730.1.1',
+ 'netscape-comment' => '2.16.840.1.113730.1.13',
+ 'netscape-ca-policy-url' => '2.16.840.1.113730.1.8',
+ // the following are X.509 extensions not supported by phpseclib
+ 'id-pe-logotype' => '1.3.6.1.5.5.7.1.12',
+ 'entrustVersInfo' => '1.2.840.113533.7.65.0',
+ 'verisignPrivate' => '2.16.840.1.113733.1.6.9',
+ // for Certificate Signing Requests
+ // see http://tools.ietf.org/html/rfc2985
+ 'pkcs-9-at-unstructuredName' => '1.2.840.113549.1.9.2', // PKCS #9 unstructured name
+ 'pkcs-9-at-challengePassword' => '1.2.840.113549.1.9.7', // Challenge password for certificate revocations
+ 'pkcs-9-at-extensionRequest' => '1.2.840.113549.1.9.14' // Certificate extension request
+ ]);
+ }
}
/**
@@ -1455,7 +461,7 @@ class X509
* @access public
* @return mixed
*/
- function loadX509($cert, $mode = self::FORMAT_AUTO_DETECT)
+ public function loadX509($cert, $mode = self::FORMAT_AUTO_DETECT)
{
if (is_array($cert) && isset($cert['tbsCertificate'])) {
unset($this->currentCert);
@@ -1474,10 +480,8 @@ class X509
return $cert;
}
- $asn1 = new ASN1();
-
if ($mode != self::FORMAT_DER) {
- $newcert = $this->_extractBER($cert);
+ $newcert = ASN1::extractBER($cert);
if ($mode == self::FORMAT_PEM && $cert == $newcert) {
return false;
}
@@ -1489,11 +493,10 @@ class X509
return false;
}
- $asn1->loadOIDs($this->oids);
- $decoded = $asn1->decodeBER($cert);
+ $decoded = ASN1::decodeBER($cert);
if (!empty($decoded)) {
- $x509 = $asn1->asn1map($decoded[0], $this->Certificate);
+ $x509 = ASN1::asn1map($decoded[0], Maps\Certificate::MAP);
}
if (!isset($x509) || $x509 === false) {
$this->currentCert = false;
@@ -1502,14 +505,18 @@ class X509
$this->signatureSubject = substr($cert, $decoded[0]['content'][0]['start'], $decoded[0]['content'][0]['length']);
- if ($this->_isSubArrayValid($x509, 'tbsCertificate/extensions')) {
- $this->_mapInExtensions($x509, 'tbsCertificate/extensions', $asn1);
+ if ($this->isSubArrayValid($x509, 'tbsCertificate/extensions')) {
+ $this->mapInExtensions($x509, 'tbsCertificate/extensions');
}
- $this->_mapInDNs($x509, 'tbsCertificate/issuer/rdnSequence', $asn1);
- $this->_mapInDNs($x509, 'tbsCertificate/subject/rdnSequence', $asn1);
+ $this->mapInDNs($x509, 'tbsCertificate/issuer/rdnSequence');
+ $this->mapInDNs($x509, 'tbsCertificate/subject/rdnSequence');
- $key = &$x509['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey'];
- $key = $this->_reformatKey($x509['tbsCertificate']['subjectPublicKeyInfo']['algorithm']['algorithm'], $key);
+ $key = $x509['tbsCertificate']['subjectPublicKeyInfo'];
+ $key = ASN1::encodeDER($key, Maps\SubjectPublicKeyInfo::MAP);
+ $x509['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey'] =
+ "-----BEGIN PUBLIC KEY-----\r\n" .
+ chunk_split(base64_encode($key), 64) .
+ "-----END PUBLIC KEY-----";
$this->currentCert = $x509;
$this->dn = $x509['tbsCertificate']['subject'];
@@ -1528,7 +535,7 @@ class X509
* @access public
* @return string
*/
- function saveX509($cert, $format = self::FORMAT_PEM)
+ public function saveX509($cert, $format = self::FORMAT_PEM)
{
if (!is_array($cert) || !isset($cert['tbsCertificate'])) {
return false;
@@ -1536,32 +543,22 @@ class X509
switch (true) {
// "case !$a: case !$b: break; default: whatever();" is the same thing as "if ($a && $b) whatever()"
- case !($algorithm = $this->_subArray($cert, 'tbsCertificate/subjectPublicKeyInfo/algorithm/algorithm')):
+ case !($algorithm = $this->subArray($cert, 'tbsCertificate/subjectPublicKeyInfo/algorithm/algorithm')):
case is_object($cert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey']):
break;
default:
- switch ($algorithm) {
- case 'rsaEncryption':
- $cert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey']
- = base64_encode("\0" . base64_decode(preg_replace('#-.+-|[\r\n]#', '', $cert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey'])));
- /* "[For RSA keys] the parameters field MUST have ASN.1 type NULL for this algorithm identifier."
- -- https://tools.ietf.org/html/rfc3279#section-2.3.1
-
- given that and the fact that RSA keys appear ot be the only key type for which the parameters field can be blank,
- it seems like perhaps the ASN.1 description ought not say the parameters field is OPTIONAL, but whatever.
- */
- $cert['tbsCertificate']['subjectPublicKeyInfo']['algorithm']['parameters'] = null;
- // https://tools.ietf.org/html/rfc3279#section-2.2.1
- $cert['signatureAlgorithm']['parameters'] = null;
- $cert['tbsCertificate']['signature']['parameters'] = null;
- }
+ $cert['tbsCertificate']['subjectPublicKeyInfo'] = new Element(
+ base64_decode(preg_replace('#-.+-|[\r\n]#', '', $cert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey']))
+ );
}
- $asn1 = new ASN1();
- $asn1->loadOIDs($this->oids);
+ if ($algorithm == 'rsaEncryption') {
+ $cert['signatureAlgorithm']['parameters'] = null;
+ $cert['tbsCertificate']['signature']['parameters'] = null;
+ }
- $filters = array();
- $type_utf8_string = array('type' => ASN1::TYPE_UTF8_STRING);
+ $filters = [];
+ $type_utf8_string = ['type' => ASN1::TYPE_UTF8_STRING];
$filters['tbsCertificate']['signature']['parameters'] = $type_utf8_string;
$filters['tbsCertificate']['signature']['issuer']['rdnSequence']['value'] = $type_utf8_string;
$filters['tbsCertificate']['issuer']['rdnSequence']['value'] = $type_utf8_string;
@@ -1573,27 +570,31 @@ class X509
$filters['distributionPoint']['fullName']['directoryName']['rdnSequence']['value'] = $type_utf8_string;
$filters['directoryName']['rdnSequence']['value'] = $type_utf8_string;
- /* in the case of policyQualifiers/qualifier, the type has to be \phpseclib\File\ASN1::TYPE_IA5_STRING.
- \phpseclib\File\ASN1::TYPE_PRINTABLE_STRING will cause OpenSSL's X.509 parser to spit out random
+ foreach (self::$extensions as $extension) {
+ $filters['tbsCertificate']['extensions'][] = $extension;
+ }
+
+ /* in the case of policyQualifiers/qualifier, the type has to be \phpseclib3\File\ASN1::TYPE_IA5_STRING.
+ \phpseclib3\File\ASN1::TYPE_PRINTABLE_STRING will cause OpenSSL's X.509 parser to spit out random
characters.
*/
$filters['policyQualifiers']['qualifier']
- = array('type' => ASN1::TYPE_IA5_STRING);
+ = ['type' => ASN1::TYPE_IA5_STRING];
- $asn1->loadFilters($filters);
+ ASN1::setFilters($filters);
- $this->_mapOutExtensions($cert, 'tbsCertificate/extensions', $asn1);
- $this->_mapOutDNs($cert, 'tbsCertificate/issuer/rdnSequence', $asn1);
- $this->_mapOutDNs($cert, 'tbsCertificate/subject/rdnSequence', $asn1);
+ $this->mapOutExtensions($cert, 'tbsCertificate/extensions');
+ $this->mapOutDNs($cert, 'tbsCertificate/issuer/rdnSequence');
+ $this->mapOutDNs($cert, 'tbsCertificate/subject/rdnSequence');
- $cert = $asn1->encodeDER($cert, $this->Certificate);
+ $cert = ASN1::encodeDER($cert, Maps\Certificate::MAP);
switch ($format) {
case self::FORMAT_DER:
return $cert;
// case self::FORMAT_PEM:
default:
- return "-----BEGIN CERTIFICATE-----\r\n" . chunk_split(base64_encode($cert), 64) . '-----END CERTIFICATE-----';
+ return "-----BEGIN CERTIFICATE-----\r\n" . chunk_split(Base64::encode($cert), 64) . '-----END CERTIFICATE-----';
}
}
@@ -1601,26 +602,27 @@ class X509
* Map extension values from octet string to extension-specific internal
* format.
*
- * @param array ref $root
+ * @param array $root (by reference)
* @param string $path
- * @param object $asn1
* @access private
*/
- function _mapInExtensions(&$root, $path, $asn1)
+ private function mapInExtensions(&$root, $path)
{
- $extensions = &$this->_subArrayUnchecked($root, $path);
+ $extensions = &$this->subArrayUnchecked($root, $path);
if ($extensions) {
for ($i = 0; $i < count($extensions); $i++) {
$id = $extensions[$i]['extnId'];
$value = &$extensions[$i]['extnValue'];
- $value = base64_decode($value);
- $decoded = $asn1->decodeBER($value);
+ $decoded = ASN1::decodeBER($value);
/* [extnValue] contains the DER encoding of an ASN.1 value
corresponding to the extension type identified by extnID */
- $map = $this->_getMapping($id);
+ $map = $this->getMapping($id);
if (!is_bool($map)) {
- $mapped = $asn1->asn1map($decoded[0], $map, array('iPAddress' => array($this, '_decodeIP')));
+ $decoder = $id == 'id-ce-nameConstraints' ?
+ [static::class, 'decodeNameConstraintIP'] :
+ [static::class, 'decodeIP'];
+ $mapped = ASN1::asn1map($decoded[0], $map, ['iPAddress' => $decoder]);
$value = $mapped === false ? $decoded[0] : $mapped;
if ($id == 'id-ce-certificatePolicies') {
@@ -1630,18 +632,16 @@ class X509
}
for ($k = 0; $k < count($value[$j]['policyQualifiers']); $k++) {
$subid = $value[$j]['policyQualifiers'][$k]['policyQualifierId'];
- $map = $this->_getMapping($subid);
+ $map = $this->getMapping($subid);
$subvalue = &$value[$j]['policyQualifiers'][$k]['qualifier'];
if ($map !== false) {
- $decoded = $asn1->decodeBER($subvalue);
- $mapped = $asn1->asn1map($decoded[0], $map);
+ $decoded = ASN1::decodeBER($subvalue);
+ $mapped = ASN1::asn1map($decoded[0], $map);
$subvalue = $mapped === false ? $decoded[0] : $mapped;
}
}
}
}
- } else {
- $value = base64_encode($value);
}
}
}
@@ -1651,14 +651,20 @@ class X509
* Map extension values from extension-specific internal format to
* octet string.
*
- * @param array ref $root
+ * @param array $root (by reference)
* @param string $path
- * @param object $asn1
* @access private
*/
- function _mapOutExtensions(&$root, $path, $asn1)
+ private function mapOutExtensions(&$root, $path)
{
- $extensions = &$this->_subArray($root, $path);
+ foreach ($this->extensionValues as $id => $value) {
+ $root['tbsCertificate']['extensions'][] = [
+ 'extnId' => $id,
+ 'extnValue' => $value,
+ ];
+ }
+
+ $extensions = &$this->subArray($root, $path);
if (is_array($extensions)) {
$size = count($extensions);
@@ -1678,12 +684,12 @@ class X509
}
for ($k = 0; $k < count($value[$j]['policyQualifiers']); $k++) {
$subid = $value[$j]['policyQualifiers'][$k]['policyQualifierId'];
- $map = $this->_getMapping($subid);
+ $map = $this->getMapping($subid);
$subvalue = &$value[$j]['policyQualifiers'][$k]['qualifier'];
if ($map !== false) {
- // by default \phpseclib\File\ASN1 will try to render qualifier as a \phpseclib\File\ASN1::TYPE_IA5_STRING since it's
- // actual type is \phpseclib\File\ASN1::TYPE_ANY
- $subvalue = new Element($asn1->encodeDER($subvalue, $map));
+ // by default \phpseclib3\File\ASN1 will try to render qualifier as a \phpseclib3\File\ASN1::TYPE_IA5_STRING since it's
+ // actual type is \phpseclib3\File\ASN1::TYPE_ANY
+ $subvalue = new Element(ASN1::encodeDER($subvalue, $map));
}
}
}
@@ -1699,15 +705,14 @@ class X509
/* [extnValue] contains the DER encoding of an ASN.1 value
corresponding to the extension type identified by extnID */
- $map = $this->_getMapping($id);
+ $map = $this->getMapping($id);
if (is_bool($map)) {
if (!$map) {
- user_error($id . ' is not a currently supported extension');
+ //user_error($id . ' is not a currently supported extension');
unset($extensions[$i]);
}
} else {
- $temp = $asn1->encodeDER($value, $map, array('iPAddress' => array($this, '_encodeIP')));
- $value = base64_encode($temp);
+ $value = ASN1::encodeDER($value, $map, ['iPAddress' => [static::class, 'encodeIP']]);
}
}
}
@@ -1717,36 +722,35 @@ class X509
* Map attribute values from ANY type to attribute-specific internal
* format.
*
- * @param array ref $root
+ * @param array $root (by reference)
* @param string $path
- * @param object $asn1
* @access private
*/
- function _mapInAttributes(&$root, $path, $asn1)
+ private function mapInAttributes(&$root, $path)
{
- $attributes = &$this->_subArray($root, $path);
+ $attributes = &$this->subArray($root, $path);
if (is_array($attributes)) {
for ($i = 0; $i < count($attributes); $i++) {
$id = $attributes[$i]['type'];
/* $value contains the DER encoding of an ASN.1 value
corresponding to the attribute type identified by type */
- $map = $this->_getMapping($id);
+ $map = $this->getMapping($id);
if (is_array($attributes[$i]['value'])) {
$values = &$attributes[$i]['value'];
for ($j = 0; $j < count($values); $j++) {
- $value = $asn1->encodeDER($values[$j], $this->AttributeValue);
- $decoded = $asn1->decodeBER($value);
+ $value = ASN1::encodeDER($values[$j], Maps\AttributeValue::MAP);
+ $decoded = ASN1::decodeBER($value);
if (!is_bool($map)) {
- $mapped = $asn1->asn1map($decoded[0], $map);
+ $mapped = ASN1::asn1map($decoded[0], $map);
if ($mapped !== false) {
$values[$j] = $mapped;
}
- if ($id == 'pkcs-9-at-extensionRequest' && $this->_isSubArrayValid($values, $j)) {
- $this->_mapInExtensions($values, $j, $asn1);
+ if ($id == 'pkcs-9-at-extensionRequest' && $this->isSubArrayValid($values, $j)) {
+ $this->mapInExtensions($values, $j);
}
} elseif ($map) {
- $values[$j] = base64_encode($value);
+ $values[$j] = $value;
}
}
}
@@ -1758,14 +762,13 @@ class X509
* Map attribute values from attribute-specific internal format to
* ANY type.
*
- * @param array ref $root
+ * @param array $root (by reference)
* @param string $path
- * @param object $asn1
* @access private
*/
- function _mapOutAttributes(&$root, $path, $asn1)
+ private function mapOutAttributes(&$root, $path)
{
- $attributes = &$this->_subArray($root, $path);
+ $attributes = &$this->subArray($root, $path);
if (is_array($attributes)) {
$size = count($attributes);
@@ -1773,23 +776,23 @@ class X509
/* [value] contains the DER encoding of an ASN.1 value
corresponding to the attribute type identified by type */
$id = $attributes[$i]['type'];
- $map = $this->_getMapping($id);
+ $map = $this->getMapping($id);
if ($map === false) {
- user_error($id . ' is not a currently supported attribute', E_USER_NOTICE);
+ //user_error($id . ' is not a currently supported attribute', E_USER_NOTICE);
unset($attributes[$i]);
} elseif (is_array($attributes[$i]['value'])) {
$values = &$attributes[$i]['value'];
for ($j = 0; $j < count($values); $j++) {
switch ($id) {
case 'pkcs-9-at-extensionRequest':
- $this->_mapOutExtensions($values, $j, $asn1);
+ $this->mapOutExtensions($values, $j);
break;
}
if (!is_bool($map)) {
- $temp = $asn1->encodeDER($values[$j], $map);
- $decoded = $asn1->decodeBER($temp);
- $values[$j] = $asn1->asn1map($decoded[0], $this->AttributeValue);
+ $temp = ASN1::encodeDER($values[$j], $map);
+ $decoded = ASN1::decodeBER($temp);
+ $values[$j] = ASN1::asn1map($decoded[0], Maps\AttributeValue::MAP);
}
}
}
@@ -1801,14 +804,13 @@ class X509
* Map DN values from ANY type to DN-specific internal
* format.
*
- * @param array ref $root
+ * @param array $root (by reference)
* @param string $path
- * @param object $asn1
* @access private
*/
- function _mapInDNs(&$root, $path, $asn1)
+ private function mapInDNs(&$root, $path)
{
- $dns = &$this->_subArray($root, $path);
+ $dns = &$this->subArray($root, $path);
if (is_array($dns)) {
for ($i = 0; $i < count($dns); $i++) {
@@ -1816,10 +818,10 @@ class X509
$type = $dns[$i][$j]['type'];
$value = &$dns[$i][$j]['value'];
if (is_object($value) && $value instanceof Element) {
- $map = $this->_getMapping($type);
+ $map = $this->getMapping($type);
if (!is_bool($map)) {
- $decoded = $asn1->decodeBER($value);
- $value = $asn1->asn1map($decoded[0], $map);
+ $decoded = ASN1::decodeBER($value);
+ $value = ASN1::asn1map($decoded[0], $map);
}
}
}
@@ -1831,14 +833,13 @@ class X509
* Map DN values from DN-specific internal format to
* ANY type.
*
- * @param array ref $root
+ * @param array $root (by reference)
* @param string $path
- * @param object $asn1
* @access private
*/
- function _mapOutDNs(&$root, $path, $asn1)
+ private function mapOutDNs(&$root, $path)
{
- $dns = &$this->_subArray($root, $path);
+ $dns = &$this->subArray($root, $path);
if (is_array($dns)) {
$size = count($dns);
@@ -1850,9 +851,9 @@ class X509
continue;
}
- $map = $this->_getMapping($type);
+ $map = $this->getMapping($type);
if (!is_bool($map)) {
- $value = new Element($asn1->encodeDER($value, $map));
+ $value = new Element(ASN1::encodeDER($value, $map));
}
}
}
@@ -1866,55 +867,59 @@ class X509
* @access private
* @return mixed
*/
- function _getMapping($extnId)
+ private function getMapping($extnId)
{
- if (!is_string($extnId)) { // eg. if it's a \phpseclib\File\ASN1\Element object
+ if (!is_string($extnId)) { // eg. if it's a \phpseclib3\File\ASN1\Element object
return true;
}
+ if (isset(self::$extensions[$extnId])) {
+ return self::$extensions[$extnId];
+ }
+
switch ($extnId) {
case 'id-ce-keyUsage':
- return $this->KeyUsage;
+ return Maps\KeyUsage::MAP;
case 'id-ce-basicConstraints':
- return $this->BasicConstraints;
+ return Maps\BasicConstraints::MAP;
case 'id-ce-subjectKeyIdentifier':
- return $this->KeyIdentifier;
+ return Maps\KeyIdentifier::MAP;
case 'id-ce-cRLDistributionPoints':
- return $this->CRLDistributionPoints;
+ return Maps\CRLDistributionPoints::MAP;
case 'id-ce-authorityKeyIdentifier':
- return $this->AuthorityKeyIdentifier;
+ return Maps\AuthorityKeyIdentifier::MAP;
case 'id-ce-certificatePolicies':
- return $this->CertificatePolicies;
+ return Maps\CertificatePolicies::MAP;
case 'id-ce-extKeyUsage':
- return $this->ExtKeyUsageSyntax;
+ return Maps\ExtKeyUsageSyntax::MAP;
case 'id-pe-authorityInfoAccess':
- return $this->AuthorityInfoAccessSyntax;
+ return Maps\AuthorityInfoAccessSyntax::MAP;
case 'id-ce-subjectAltName':
- return $this->SubjectAltName;
+ return Maps\SubjectAltName::MAP;
case 'id-ce-subjectDirectoryAttributes':
- return $this->SubjectDirectoryAttributes;
+ return Maps\SubjectDirectoryAttributes::MAP;
case 'id-ce-privateKeyUsagePeriod':
- return $this->PrivateKeyUsagePeriod;
+ return Maps\PrivateKeyUsagePeriod::MAP;
case 'id-ce-issuerAltName':
- return $this->IssuerAltName;
+ return Maps\IssuerAltName::MAP;
case 'id-ce-policyMappings':
- return $this->PolicyMappings;
+ return Maps\PolicyMappings::MAP;
case 'id-ce-nameConstraints':
- return $this->NameConstraints;
+ return Maps\NameConstraints::MAP;
case 'netscape-cert-type':
- return $this->netscape_cert_type;
+ return Maps\netscape_cert_type::MAP;
case 'netscape-comment':
- return $this->netscape_comment;
+ return Maps\netscape_comment::MAP;
case 'netscape-ca-policy-url':
- return $this->netscape_ca_policy_url;
+ return Maps\netscape_ca_policy_url::MAP;
// since id-qt-cps isn't a constructed type it will have already been decoded as a string by the time it gets
// back around to asn1map() and we don't want it decoded again.
//case 'id-qt-cps':
- // return $this->CPSuri;
+ // return Maps\CPSuri::MAP;
case 'id-qt-unotice':
- return $this->UserNotice;
+ return Maps\UserNotice::MAP;
// the following OIDs are unsupported but we don't want them to give notices when calling saveX509().
case 'id-pe-logotype': // http://www.ietf.org/rfc/rfc3709.txt
@@ -1935,31 +940,31 @@ class X509
// CSR attributes
case 'pkcs-9-at-unstructuredName':
- return $this->PKCS9String;
+ return Maps\PKCS9String::MAP;
case 'pkcs-9-at-challengePassword':
- return $this->DirectoryString;
+ return Maps\DirectoryString::MAP;
case 'pkcs-9-at-extensionRequest':
- return $this->Extensions;
+ return Maps\Extensions::MAP;
// CRL extensions.
case 'id-ce-cRLNumber':
- return $this->CRLNumber;
+ return Maps\CRLNumber::MAP;
case 'id-ce-deltaCRLIndicator':
- return $this->CRLNumber;
+ return Maps\CRLNumber::MAP;
case 'id-ce-issuingDistributionPoint':
- return $this->IssuingDistributionPoint;
+ return Maps\IssuingDistributionPoint::MAP;
case 'id-ce-freshestCRL':
- return $this->CRLDistributionPoints;
+ return Maps\CRLDistributionPoints::MAP;
case 'id-ce-cRLReasons':
- return $this->CRLReason;
+ return Maps\CRLReason::MAP;
case 'id-ce-invalidityDate':
- return $this->InvalidityDate;
+ return Maps\InvalidityDate::MAP;
case 'id-ce-certificateIssuer':
- return $this->CertificateIssuer;
+ return Maps\CertificateIssuer::MAP;
case 'id-ce-holdInstructionCode':
- return $this->HoldInstructionCode;
+ return Maps\HoldInstructionCode::MAP;
case 'id-at-postalAddress':
- return $this->PostalAddress;
+ return Maps\PostalAddress::MAP;
}
return false;
@@ -1972,7 +977,7 @@ class X509
* @access public
* @return bool
*/
- function loadCA($cert)
+ public function loadCA($cert)
{
$olddn = $this->dn;
$oldcert = $this->currentCert;
@@ -2039,7 +1044,7 @@ class X509
* @access public
* @return bool
*/
- function validateURL($url)
+ public function validateURL($url)
{
if (!is_array($this->currentCert) || !isset($this->currentCert['tbsCertificate'])) {
return false;
@@ -2053,7 +1058,7 @@ class X509
if ($names = $this->getExtension('id-ce-subjectAltName')) {
foreach ($names as $name) {
foreach ($name as $key => $value) {
- $value = str_replace(array('.', '*'), array('\.', '[^.]*'), $value);
+ $value = str_replace(['.', '*'], ['\.', '[^.]*'], $value);
switch ($key) {
case 'dNSName':
/* From RFC2818 "HTTP over TLS":
@@ -2083,7 +1088,7 @@ class X509
}
if ($value = $this->getDNProp('id-at-commonName')) {
- $value = str_replace(array('.', '*'), array('\.', '[^.]*'), $value[0]);
+ $value = str_replace(['.', '*'], ['\.', '[^.]*'], $value[0]);
return preg_match('#^' . $value . '$#', $components['host']);
}
@@ -2095,17 +1100,18 @@ class X509
*
* If $date isn't defined it is assumed to be the current date.
*
- * @param \DateTime|string $date optional
+ * @param DateTimeInterface|string $date optional
* @access public
+ * @return boolean
*/
- function validateDate($date = null)
+ public function validateDate($date = null)
{
if (!is_array($this->currentCert) || !isset($this->currentCert['tbsCertificate'])) {
return false;
}
if (!isset($date)) {
- $date = new DateTime(null, new DateTimeZone(@date_default_timezone_get()));
+ $date = new DateTimeImmutable(null, new DateTimeZone(@date_default_timezone_get()));
}
$notBefore = $this->currentCert['tbsCertificate']['validity']['notBefore'];
@@ -2115,19 +1121,13 @@ class X509
$notAfter = isset($notAfter['generalTime']) ? $notAfter['generalTime'] : $notAfter['utcTime'];
if (is_string($date)) {
- $date = new DateTime($date, new DateTimeZone(@date_default_timezone_get()));
+ $date = new DateTimeImmutable($date, new DateTimeZone(@date_default_timezone_get()));
}
- $notBefore = new DateTime($notBefore, new DateTimeZone(@date_default_timezone_get()));
- $notAfter = new DateTime($notAfter, new DateTimeZone(@date_default_timezone_get()));
+ $notBefore = new DateTimeImmutable($notBefore, new DateTimeZone(@date_default_timezone_get()));
+ $notAfter = new DateTimeImmutable($notAfter, new DateTimeZone(@date_default_timezone_get()));
- switch (true) {
- case $date < $notBefore:
- case $date > $notAfter:
- return false;
- }
-
- return true;
+ return $date >= $notBefore && $date<= $notAfter;
}
/**
@@ -2137,7 +1137,7 @@ class X509
* @access private
* @return bool|string
*/
- static function _fetchURL($url)
+ private static function fetchURL($url)
{
if (self::$disable_url_fetch) {
return false;
@@ -2167,7 +1167,11 @@ class X509
}
while (!feof($fsock)) {
- $data.= fread($fsock, 1024);
+ $temp = fread($fsock, 1024);
+ if ($temp === false) {
+ return false;
+ }
+ $data.= $temp;
}
break;
@@ -2189,7 +1193,7 @@ class X509
* @access private
* @return bool
*/
- function _testForIntermediate($caonly, $count)
+ private function testForIntermediate($caonly, $count)
{
$opts = $this->getExtension('id-pe-authorityInfoAccess');
if (!is_array($opts)) {
@@ -2211,7 +1215,7 @@ class X509
return false;
}
- $cert = static::_fetchURL($url);
+ $cert = static::fetchURL($url);
if (!is_string($cert)) {
return false;
}
@@ -2231,7 +1235,7 @@ class X509
return false;
}
- if (!$parent->_validateSignatureCountable($caonly, ++$count)) {
+ if (!$parent->validateSignatureCountable($caonly, ++$count)) {
return false;
}
@@ -2256,9 +1260,9 @@ class X509
* @access public
* @return mixed
*/
- function validateSignature($caonly = true)
+ public function validateSignature($caonly = true)
{
- return $this->_validateSignatureCountable($caonly, 0);
+ return $this->validateSignatureCountable($caonly, 0);
}
/**
@@ -2271,7 +1275,7 @@ class X509
* @access private
* @return mixed
*/
- function _validateSignatureCountable($caonly, $count)
+ private function validateSignatureCountable($caonly, $count)
{
if (!is_array($this->currentCert) || !isset($this->signatureSubject)) {
return null;
@@ -2326,32 +1330,32 @@ class X509
}
}
if (count($this->CAs) == $i && $caonly) {
- return $this->_testForIntermediate($caonly, $count) && $this->validateSignature($caonly);
+ return $this->testForIntermediate($caonly, $count) && $this->validateSignature($caonly);
}
} elseif (!isset($signingCert) || $caonly) {
- return $this->_testForIntermediate($caonly, $count) && $this->validateSignature($caonly);
+ return $this->testForIntermediate($caonly, $count) && $this->validateSignature($caonly);
}
- return $this->_validateSignature(
+ return $this->validateSignatureHelper(
$signingCert['tbsCertificate']['subjectPublicKeyInfo']['algorithm']['algorithm'],
$signingCert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey'],
$this->currentCert['signatureAlgorithm']['algorithm'],
- substr(base64_decode($this->currentCert['signature']), 1),
+ substr($this->currentCert['signature'], 1),
$this->signatureSubject
);
case isset($this->currentCert['certificationRequestInfo']):
- return $this->_validateSignature(
+ return $this->validateSignatureHelper(
$this->currentCert['certificationRequestInfo']['subjectPKInfo']['algorithm']['algorithm'],
$this->currentCert['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey'],
$this->currentCert['signatureAlgorithm']['algorithm'],
- substr(base64_decode($this->currentCert['signature']), 1),
+ substr($this->currentCert['signature'], 1),
$this->signatureSubject
);
case isset($this->currentCert['publicKeyAndChallenge']):
- return $this->_validateSignature(
+ return $this->validateSignatureHelper(
$this->currentCert['publicKeyAndChallenge']['spki']['algorithm']['algorithm'],
$this->currentCert['publicKeyAndChallenge']['spki']['subjectPublicKey'],
$this->currentCert['signatureAlgorithm']['algorithm'],
- substr(base64_decode($this->currentCert['signature']), 1),
+ substr($this->currentCert['signature'], 1),
$this->signatureSubject
);
case isset($this->currentCert['tbsCertList']):
@@ -2379,11 +1383,11 @@ class X509
if (!isset($signingCert)) {
return false;
}
- return $this->_validateSignature(
+ return $this->validateSignatureHelper(
$signingCert['tbsCertificate']['subjectPublicKeyInfo']['algorithm']['algorithm'],
$signingCert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey'],
$this->currentCert['signatureAlgorithm']['algorithm'],
- substr(base64_decode($this->currentCert['signature']), 1),
+ substr($this->currentCert['signature'], 1),
$this->signatureSubject
);
default:
@@ -2394,7 +1398,8 @@ class X509
/**
* Validates a signature
*
- * Returns true if the signature is verified, false if it is not correct or null on error
+ * Returns true if the signature is verified and false if it is not correct.
+ * If the algorithms are unsupposed an exception is thrown.
*
* @param string $publicKeyAlgorithm
* @param string $publicKey
@@ -2402,15 +1407,17 @@ class X509
* @param string $signature
* @param string $signatureSubject
* @access private
- * @return int
+ * @throws \phpseclib3\Exception\UnsupportedAlgorithmException if the algorithm is unsupported
+ * @return bool
*/
- function _validateSignature($publicKeyAlgorithm, $publicKey, $signatureAlgorithm, $signature, $signatureSubject)
+ private function validateSignatureHelper($publicKeyAlgorithm, $publicKey, $signatureAlgorithm, $signature, $signatureSubject)
{
switch ($publicKeyAlgorithm) {
+ case 'id-RSASSA-PSS':
+ $key = RSA::loadFormat('PSS', $publicKey);
+ break;
case 'rsaEncryption':
- $rsa = new RSA();
- $rsa->loadKey($publicKey);
-
+ $key = RSA::loadFormat('PKCS8', $publicKey);
switch ($signatureAlgorithm) {
case 'md2WithRSAEncryption':
case 'md5WithRSAEncryption':
@@ -2419,21 +1426,51 @@ class X509
case 'sha256WithRSAEncryption':
case 'sha384WithRSAEncryption':
case 'sha512WithRSAEncryption':
- $rsa->setHash(preg_replace('#WithRSAEncryption$#', '', $signatureAlgorithm));
- $rsa->setSignatureMode(RSA::SIGNATURE_PKCS1);
- if (!@$rsa->verify($signatureSubject, $signature)) {
- return false;
- }
+ $key = $key
+ ->withHash(preg_replace('#WithRSAEncryption$#', '', $signatureAlgorithm))
+ ->withPadding(RSA::SIGNATURE_PKCS1);
break;
default:
- return null;
+ throw new UnsupportedAlgorithmException('Signature algorithm unsupported');
+ }
+ break;
+ case 'id-Ed25519':
+ case 'id-Ed448':
+ $key = EC::loadFormat('PKCS8', $publicKey);
+ break;
+ case 'id-ecPublicKey':
+ $key = EC::loadFormat('PKCS8', $publicKey);
+ switch ($signatureAlgorithm) {
+ case 'ecdsa-with-SHA1':
+ case 'ecdsa-with-SHA224':
+ case 'ecdsa-with-SHA256':
+ case 'ecdsa-with-SHA384':
+ case 'ecdsa-with-SHA512':
+ $key = $key
+ ->withHash(preg_replace('#^ecdsa-with-#', '', strtolower($signatureAlgorithm)));
+ break;
+ default:
+ throw new UnsupportedAlgorithmException('Signature algorithm unsupported');
+ }
+ break;
+ case 'id-dsa':
+ $key = DSA::loadFormat('PKCS8', $publicKey);
+ switch ($signatureAlgorithm) {
+ case 'id-dsa-with-sha1':
+ case 'id-dsa-with-sha224':
+ case 'id-dsa-with-sha256':
+ $key = $key
+ ->withHash(preg_replace('#^id-dsa-with-#', '', strtolower($signatureAlgorithm)));
+ break;
+ default:
+ throw new UnsupportedAlgorithmException('Signature algorithm unsupported');
}
break;
default:
- return null;
+ throw new UnsupportedAlgorithmException('Public key algorithm unsupported');
}
- return true;
+ return $key->verify($signatureSubject, $signature);
}
/**
@@ -2446,7 +1483,7 @@ class X509
* @param int $count
* @access public
*/
- static function setRecurLimit($count)
+ public static function setRecurLimit($count)
{
self::$recur_limit = $count;
}
@@ -2456,7 +1493,7 @@ class X509
*
* @access public
*/
- static function disableURLFetch()
+ public static function disableURLFetch()
{
self::$disable_url_fetch = true;
}
@@ -2466,37 +1503,11 @@ class X509
*
* @access public
*/
- static function enableURLFetch()
+ public static function enableURLFetch()
{
self::$disable_url_fetch = false;
}
- /**
- * Reformat public keys
- *
- * Reformats a public key to a format supported by phpseclib (if applicable)
- *
- * @param string $algorithm
- * @param string $key
- * @access private
- * @return string
- */
- function _reformatKey($algorithm, $key)
- {
- switch ($algorithm) {
- case 'rsaEncryption':
- return
- "-----BEGIN RSA PUBLIC KEY-----\r\n" .
- // subjectPublicKey is stored as a bit string in X.509 certs. the first byte of a bit string represents how many bits
- // in the last byte should be ignored. the following only supports non-zero stuff but as none of the X.509 certs Firefox
- // uses as a cert authority actually use a non-zero bit I think it's safe to assume that none do.
- chunk_split(base64_encode(substr(base64_decode($key), 1)), 64) .
- '-----END RSA PUBLIC KEY-----';
- default:
- return $key;
- }
- }
-
/**
* Decodes an IP address
*
@@ -2506,9 +1517,26 @@ class X509
* @access private
* @return string
*/
- function _decodeIP($ip)
+ public static function decodeIP($ip)
{
- return inet_ntop(base64_decode($ip));
+ return inet_ntop($ip);
+ }
+
+ /**
+ * Decodes an IP address in a name constraints extension
+ *
+ * Takes in a base64 encoded "blob" and returns a human readable IP address / mask
+ *
+ * @param string $ip
+ * @access private
+ * @return array
+ */
+ public static function decodeNameConstraintIP($ip)
+ {
+ $size = strlen($ip) >> 1;
+ $mask = substr($ip, $size);
+ $ip = substr($ip, 0, $size);
+ return [inet_ntop($ip), inet_ntop($mask)];
}
/**
@@ -2516,13 +1544,15 @@ class X509
*
* Takes a human readable IP address into a base64-encoded "blob"
*
- * @param string $ip
+ * @param string|array $ip
* @access private
* @return string
*/
- function _encodeIP($ip)
+ public static function encodeIP($ip)
{
- return base64_encode(inet_pton($ip));
+ return is_string($ip) ?
+ inet_pton($ip) :
+ inet_pton($ip[0]) . inet_pton($ip[1]);
}
/**
@@ -2532,7 +1562,7 @@ class X509
* @access private
* @return mixed
*/
- function _translateDNProp($propName)
+ private function translateDNProp($propName)
{
switch (strtolower($propName)) {
case 'id-at-countryname':
@@ -2626,26 +1656,26 @@ class X509
* @access public
* @return bool
*/
- function setDNProp($propName, $propValue, $type = 'utf8String')
+ public function setDNProp($propName, $propValue, $type = 'utf8String')
{
if (empty($this->dn)) {
- $this->dn = array('rdnSequence' => array());
+ $this->dn = ['rdnSequence' => []];
}
- if (($propName = $this->_translateDNProp($propName)) === false) {
+ if (($propName = $this->translateDNProp($propName)) === false) {
return false;
}
foreach ((array) $propValue as $v) {
if (!is_array($v) && isset($type)) {
- $v = array($type => $v);
+ $v = [$type => $v];
}
- $this->dn['rdnSequence'][] = array(
- array(
+ $this->dn['rdnSequence'][] = [
+ [
'type' => $propName,
'value'=> $v
- )
- );
+ ]
+ ];
}
return true;
@@ -2657,13 +1687,13 @@ class X509
* @param string $propName
* @access public
*/
- function removeDNProp($propName)
+ public function removeDNProp($propName)
{
if (empty($this->dn)) {
return;
}
- if (($propName = $this->_translateDNProp($propName)) === false) {
+ if (($propName = $this->translateDNProp($propName)) === false) {
return;
}
@@ -2691,7 +1721,7 @@ class X509
* @return mixed
* @access public
*/
- function getDNProp($propName, $dn = null, $withType = false)
+ public function getDNProp($propName, $dn = null, $withType = false)
{
if (!isset($dn)) {
$dn = $this->dn;
@@ -2701,27 +1731,25 @@ class X509
return false;
}
- if (($propName = $this->_translateDNProp($propName)) === false) {
+ if (($propName = $this->translateDNProp($propName)) === false) {
return false;
}
- $asn1 = new ASN1();
- $asn1->loadOIDs($this->oids);
- $filters = array();
- $filters['value'] = array('type' => ASN1::TYPE_UTF8_STRING);
- $asn1->loadFilters($filters);
- $this->_mapOutDNs($dn, 'rdnSequence', $asn1);
+ $filters = [];
+ $filters['value'] = ['type' => ASN1::TYPE_UTF8_STRING];
+ ASN1::setFilters($filters);
+ $this->mapOutDNs($dn, 'rdnSequence');
$dn = $dn['rdnSequence'];
- $result = array();
+ $result = [];
for ($i = 0; $i < count($dn); $i++) {
if ($dn[$i][0]['type'] == $propName) {
$v = $dn[$i][0]['value'];
if (!$withType) {
if (is_array($v)) {
foreach ($v as $type => $s) {
- $type = array_search($type, $asn1->ANYmap, true);
- if ($type !== false && isset($asn1->stringTypeSize[$type])) {
- $s = $asn1->convert($s, $type);
+ $type = array_search($type, ASN1::ANY_MAP);
+ if ($type !== false && array_key_exists($type, ASN1::STRING_TYPE_SIZE)) {
+ $s = ASN1::convert($s, $type);
if ($s !== false) {
$v = $s;
break;
@@ -2732,10 +1760,10 @@ class X509
$v = array_pop($v); // Always strip data type.
}
} elseif (is_object($v) && $v instanceof Element) {
- $map = $this->_getMapping($propName);
+ $map = $this->getMapping($propName);
if (!is_bool($map)) {
- $decoded = $asn1->decodeBER($v);
- $v = $asn1->asn1map($decoded[0], $map);
+ $decoded = ASN1::decodeBER($v);
+ $v = ASN1::asn1map($decoded[0], $map);
}
}
}
@@ -2755,7 +1783,7 @@ class X509
* @access public
* @return bool
*/
- function setDN($dn, $merge = false, $type = 'utf8String')
+ public function setDN($dn, $merge = false, $type = 'utf8String')
{
if (!$merge) {
$this->dn = null;
@@ -2795,9 +1823,9 @@ class X509
* @param mixed $format optional
* @param array $dn optional
* @access public
- * @return bool
+ * @return array|bool
*/
- function getDN($format = self::DN_ARRAY, $dn = null)
+ public function getDN($format = self::DN_ARRAY, $dn = null)
{
if (!isset($dn)) {
$dn = isset($this->currentCert['tbsCertList']) ? $this->currentCert['tbsCertList']['issuer'] : $this->dn;
@@ -2807,32 +1835,28 @@ class X509
case self::DN_ARRAY:
return $dn;
case self::DN_ASN1:
- $asn1 = new ASN1();
- $asn1->loadOIDs($this->oids);
- $filters = array();
- $filters['rdnSequence']['value'] = array('type' => ASN1::TYPE_UTF8_STRING);
- $asn1->loadFilters($filters);
- $this->_mapOutDNs($dn, 'rdnSequence', $asn1);
- return $asn1->encodeDER($dn, $this->Name);
+ $filters = [];
+ $filters['rdnSequence']['value'] = ['type' => ASN1::TYPE_UTF8_STRING];
+ ASN1::setFilters($filters);
+ $this->mapOutDNs($dn, 'rdnSequence');
+ return ASN1::encodeDER($dn, Maps\Name::MAP);
case self::DN_CANON:
// No SEQUENCE around RDNs and all string values normalized as
// trimmed lowercase UTF-8 with all spacing as one blank.
// constructed RDNs will not be canonicalized
- $asn1 = new ASN1();
- $asn1->loadOIDs($this->oids);
- $filters = array();
- $filters['value'] = array('type' => ASN1::TYPE_UTF8_STRING);
- $asn1->loadFilters($filters);
+ $filters = [];
+ $filters['value'] = ['type' => ASN1::TYPE_UTF8_STRING];
+ ASN1::setFilters($filters);
$result = '';
- $this->_mapOutDNs($dn, 'rdnSequence', $asn1);
+ $this->mapOutDNs($dn, 'rdnSequence');
foreach ($dn['rdnSequence'] as $rdn) {
foreach ($rdn as $i => $attr) {
$attr = &$rdn[$i];
if (is_array($attr['value'])) {
foreach ($attr['value'] as $type => $v) {
- $type = array_search($type, $asn1->ANYmap, true);
- if ($type !== false && isset($asn1->stringTypeSize[$type])) {
- $v = $asn1->convert($v, $type);
+ $type = array_search($type, ASN1::ANY_MAP, true);
+ if ($type !== false && array_key_exists($type, ASN1::STRING_TYPE_SIZE)) {
+ $v = ASN1::convert($v, $type);
if ($v !== false) {
$v = preg_replace('/\s+/', ' ', $v);
$attr['value'] = strtolower(trim($v));
@@ -2842,7 +1866,7 @@ class X509
}
}
}
- $result .= $asn1->encodeDER($rdn, $this->RelativeDistinguishedName);
+ $result .= ASN1::encodeDER($rdn, Maps\RelativeDistinguishedName::MAP);
}
return $result;
case self::DN_HASH:
@@ -2850,20 +1874,18 @@ class X509
$hash = new Hash('sha1');
$hash = $hash->hash($dn);
extract(unpack('Vhash', $hash));
- return strtolower(bin2hex(pack('N', $hash)));
+ return strtolower(Hex::encode(pack('N', $hash)));
}
// Default is to return a string.
$start = true;
$output = '';
- $result = array();
- $asn1 = new ASN1();
- $asn1->loadOIDs($this->oids);
- $filters = array();
- $filters['rdnSequence']['value'] = array('type' => ASN1::TYPE_UTF8_STRING);
- $asn1->loadFilters($filters);
- $this->_mapOutDNs($dn, 'rdnSequence', $asn1);
+ $result = [];
+ $filters = [];
+ $filters['rdnSequence']['value'] = ['type' => ASN1::TYPE_UTF8_STRING];
+ ASN1::setFilters($filters);
+ $this->mapOutDNs($dn, 'rdnSequence');
foreach ($dn['rdnSequence'] as $field) {
$prop = $field[0]['type'];
@@ -2910,9 +1932,9 @@ class X509
}
if (is_array($value)) {
foreach ($value as $type => $v) {
- $type = array_search($type, $asn1->ANYmap, true);
- if ($type !== false && isset($asn1->stringTypeSize[$type])) {
- $v = $asn1->convert($v, $type);
+ $type = array_search($type, ASN1::ANY_MAP, true);
+ if ($type !== false && array_key_exists($type, ASN1::STRING_TYPE_SIZE)) {
+ $v = ASN1::convert($v, $type);
if ($v !== false) {
$value = $v;
break;
@@ -2923,14 +1945,12 @@ class X509
$value = array_pop($value); // Always strip data type.
}
} elseif (is_object($value) && $value instanceof Element) {
- $callback = function ($x) {
- return "\x" . bin2hex($x[0]);
- };
+ $callback = function($x) { return '\x' . bin2hex($x[0]); };
$value = strtoupper(preg_replace_callback('#[^\x20-\x7E]#', $callback, $value->element));
}
$output.= $desc . '=' . $value;
$result[$desc] = isset($result[$desc]) ?
- array_merge((array) $result[$desc], array($value)) :
+ array_merge((array) $result[$desc], [$value]) :
$value;
$start = false;
}
@@ -2945,7 +1965,7 @@ class X509
* @access public
* @return mixed
*/
- function getIssuerDN($format = self::DN_ARRAY)
+ public function getIssuerDN($format = self::DN_ARRAY)
{
switch (true) {
case !isset($this->currentCert) || !is_array($this->currentCert):
@@ -2967,7 +1987,7 @@ class X509
* @access public
* @return mixed
*/
- function getSubjectDN($format = self::DN_ARRAY)
+ public function getSubjectDN($format = self::DN_ARRAY)
{
switch (true) {
case !empty($this->dn):
@@ -2991,7 +2011,7 @@ class X509
* @access public
* @return mixed
*/
- function getIssuerDNProp($propName, $withType = false)
+ public function getIssuerDNProp($propName, $withType = false)
{
switch (true) {
case !isset($this->currentCert) || !is_array($this->currentCert):
@@ -3013,7 +2033,7 @@ class X509
* @access public
* @return mixed
*/
- function getSubjectDNProp($propName, $withType = false)
+ public function getSubjectDNProp($propName, $withType = false)
{
switch (true) {
case !empty($this->dn):
@@ -3035,9 +2055,9 @@ class X509
* @access public
* @return mixed
*/
- function getChain()
+ public function getChain()
{
- $chain = array($this->currentCert);
+ $chain = [$this->currentCert];
if (!is_array($this->currentCert) || !isset($this->currentCert['tbsCertificate'])) {
return false;
@@ -3077,27 +2097,26 @@ class X509
/**
* Set public key
*
- * Key needs to be a \phpseclib\Crypt\RSA object
+ * Key needs to be a \phpseclib3\Crypt\RSA object
*
- * @param object $key
+ * @param PublicKey $key
* @access public
* @return bool
*/
- function setPublicKey($key)
+ public function setPublicKey(PublicKey $key)
{
- $key->setPublicKey();
$this->publicKey = $key;
}
/**
* Set private key
*
- * Key needs to be a \phpseclib\Crypt\RSA object
+ * Key needs to be a \phpseclib3\Crypt\RSA object
*
- * @param object $key
+ * @param PrivateKey $key
* @access public
*/
- function setPrivateKey($key)
+ public function setPrivateKey(PrivateKey $key)
{
$this->privateKey = $key;
}
@@ -3110,7 +2129,7 @@ class X509
* @param string $challenge
* @access public
*/
- function setChallenge($challenge)
+ public function setChallenge($challenge)
{
$this->challenge = $challenge;
}
@@ -3118,20 +2137,25 @@ class X509
/**
* Gets the public key
*
- * Returns a \phpseclib\Crypt\RSA object or a false.
+ * Returns a \phpseclib3\Crypt\RSA object or a false.
*
* @access public
* @return mixed
*/
- function getPublicKey()
+ public function getPublicKey()
{
if (isset($this->publicKey)) {
return $this->publicKey;
}
if (isset($this->currentCert) && is_array($this->currentCert)) {
- foreach (array('tbsCertificate/subjectPublicKeyInfo', 'certificationRequestInfo/subjectPKInfo') as $path) {
- $keyinfo = $this->_subArray($this->currentCert, $path);
+ $paths = [
+ 'tbsCertificate/subjectPublicKeyInfo',
+ 'certificationRequestInfo/subjectPKInfo',
+ 'publicKeyAndChallenge/spki'
+ ];
+ foreach ($paths as $path) {
+ $keyinfo = $this->subArray($this->currentCert, $path);
if (!empty($keyinfo)) {
break;
}
@@ -3145,25 +2169,27 @@ class X509
switch ($keyinfo['algorithm']['algorithm']) {
case 'rsaEncryption':
- $publicKey = new RSA();
- $publicKey->loadKey($key);
- $publicKey->setPublicKey();
- break;
- default:
- return false;
+ return RSA::loadFormat('PKCS8', $key);
+ case 'id-ecPublicKey':
+ case 'id-Ed25519':
+ case 'id-Ed448':
+ return EC::loadFormat('PKCS8', $key);
+ case 'id-dsa':
+ return DSA::loadFormat('PKCS8', $key);
}
- return $publicKey;
+ return false;
}
/**
* Load a Certificate Signing Request
*
* @param string $csr
- * @access public
+ * @param int $mode
* @return mixed
+ * @access public
*/
- function loadCSR($csr, $mode = self::FORMAT_AUTO_DETECT)
+ public function loadCSR($csr, $mode = self::FORMAT_AUTO_DETECT)
{
if (is_array($csr) && isset($csr['certificationRequestInfo'])) {
unset($this->currentCert);
@@ -3180,10 +2206,8 @@ class X509
// see http://tools.ietf.org/html/rfc2986
- $asn1 = new ASN1();
-
if ($mode != self::FORMAT_DER) {
- $newcsr = $this->_extractBER($csr);
+ $newcsr = ASN1::extractBER($csr);
if ($mode == self::FORMAT_PEM && $csr == $newcsr) {
return false;
}
@@ -3196,44 +2220,39 @@ class X509
return false;
}
- $asn1->loadOIDs($this->oids);
- $decoded = $asn1->decodeBER($csr);
+ $decoded = ASN1::decodeBER($csr);
if (empty($decoded)) {
$this->currentCert = false;
return false;
}
- $csr = $asn1->asn1map($decoded[0], $this->CertificationRequest);
+ $csr = ASN1::asn1map($decoded[0], Maps\CertificationRequest::MAP);
if (!isset($csr) || $csr === false) {
$this->currentCert = false;
return false;
}
- $this->_mapInAttributes($csr, 'certificationRequestInfo/attributes', $asn1);
- $this->_mapInDNs($csr, 'certificationRequestInfo/subject/rdnSequence', $asn1);
+ $this->mapInAttributes($csr, 'certificationRequestInfo/attributes');
+ $this->mapInDNs($csr, 'certificationRequestInfo/subject/rdnSequence');
$this->dn = $csr['certificationRequestInfo']['subject'];
$this->signatureSubject = substr($orig, $decoded[0]['content'][0]['start'], $decoded[0]['content'][0]['length']);
- $algorithm = &$csr['certificationRequestInfo']['subjectPKInfo']['algorithm']['algorithm'];
- $key = &$csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey'];
- $key = $this->_reformatKey($algorithm, $key);
-
- switch ($algorithm) {
- case 'rsaEncryption':
- $this->publicKey = new RSA();
- $this->publicKey->loadKey($key);
- $this->publicKey->setPublicKey();
- break;
- default:
- $this->publicKey = null;
- }
+ $key = $csr['certificationRequestInfo']['subjectPKInfo'];
+ $key = ASN1::encodeDER($key, Maps\SubjectPublicKeyInfo::MAP);
+ $csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey'] =
+ "-----BEGIN PUBLIC KEY-----\r\n" .
+ chunk_split(base64_encode($key), 64) .
+ "-----END PUBLIC KEY-----";
$this->currentKeyIdentifier = null;
$this->currentCert = $csr;
+ $this->publicKey = null;
+ $this->publicKey = $this->getPublicKey();
+
return $csr;
}
@@ -3245,47 +2264,38 @@ class X509
* @access public
* @return string
*/
- function saveCSR($csr, $format = self::FORMAT_PEM)
+ public function saveCSR($csr, $format = self::FORMAT_PEM)
{
if (!is_array($csr) || !isset($csr['certificationRequestInfo'])) {
return false;
}
switch (true) {
- case !($algorithm = $this->_subArray($csr, 'certificationRequestInfo/subjectPKInfo/algorithm/algorithm')):
+ case !($algorithm = $this->subArray($csr, 'certificationRequestInfo/subjectPKInfo/algorithm/algorithm')):
case is_object($csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey']):
break;
default:
- switch ($algorithm) {
- case 'rsaEncryption':
- $csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey']
- = base64_encode("\0" . base64_decode(preg_replace('#-.+-|[\r\n]#', '', $csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey'])));
- $csr['certificationRequestInfo']['subjectPKInfo']['algorithm']['parameters'] = null;
- $csr['signatureAlgorithm']['parameters'] = null;
- $csr['certificationRequestInfo']['signature']['parameters'] = null;
- }
+ $csr['certificationRequestInfo']['subjectPKInfo'] = new Element(
+ base64_decode(preg_replace('#-.+-|[\r\n]#', '', $csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey']))
+ );
}
- $asn1 = new ASN1();
-
- $asn1->loadOIDs($this->oids);
-
- $filters = array();
+ $filters = [];
$filters['certificationRequestInfo']['subject']['rdnSequence']['value']
- = array('type' => ASN1::TYPE_UTF8_STRING);
+ = ['type' => ASN1::TYPE_UTF8_STRING];
- $asn1->loadFilters($filters);
+ ASN1::setFilters($filters);
- $this->_mapOutDNs($csr, 'certificationRequestInfo/subject/rdnSequence', $asn1);
- $this->_mapOutAttributes($csr, 'certificationRequestInfo/attributes', $asn1);
- $csr = $asn1->encodeDER($csr, $this->CertificationRequest);
+ $this->mapOutDNs($csr, 'certificationRequestInfo/subject/rdnSequence');
+ $this->mapOutAttributes($csr, 'certificationRequestInfo/attributes');
+ $csr = ASN1::encodeDER($csr, Maps\CertificationRequest::MAP);
switch ($format) {
case self::FORMAT_DER:
return $csr;
// case self::FORMAT_PEM:
default:
- return "-----BEGIN CERTIFICATE REQUEST-----\r\n" . chunk_split(base64_encode($csr), 64) . '-----END CERTIFICATE REQUEST-----';
+ return "-----BEGIN CERTIFICATE REQUEST-----\r\n" . chunk_split(Base64::encode($csr), 64) . '-----END CERTIFICATE REQUEST-----';
}
}
@@ -3296,11 +2306,11 @@ class X509
*
* https://developer.mozilla.org/en-US/docs/HTML/Element/keygen
*
- * @param string $csr
+ * @param string $spkac
* @access public
* @return mixed
*/
- function loadSPKAC($spkac)
+ public function loadSPKAC($spkac)
{
if (is_array($spkac) && isset($spkac['publicKeyAndChallenge'])) {
unset($this->currentCert);
@@ -3312,11 +2322,9 @@ class X509
// see http://www.w3.org/html/wg/drafts/html/master/forms.html#signedpublickeyandchallenge
- $asn1 = new ASN1();
-
// OpenSSL produces SPKAC's that are preceded by the string SPKAC=
$temp = preg_replace('#(?:SPKAC=)|[ \r\n\\\]#', '', $spkac);
- $temp = preg_match('#^[a-zA-Z\d/+]*={0,2}$#', $temp) ? base64_decode($temp) : false;
+ $temp = preg_match('#^[a-zA-Z\d/+]*={0,2}$#', $temp) ? Base64::decode($temp) : false;
if ($temp != false) {
$spkac = $temp;
}
@@ -3327,15 +2335,14 @@ class X509
return false;
}
- $asn1->loadOIDs($this->oids);
- $decoded = $asn1->decodeBER($spkac);
+ $decoded = ASN1::decodeBER($spkac);
if (empty($decoded)) {
$this->currentCert = false;
return false;
}
- $spkac = $asn1->asn1map($decoded[0], $this->SignedPublicKeyAndChallenge);
+ $spkac = ASN1::asn1map($decoded[0], Maps\SignedPublicKeyAndChallenge::MAP);
if (!isset($spkac) || $spkac === false) {
$this->currentCert = false;
@@ -3344,57 +2351,48 @@ class X509
$this->signatureSubject = substr($orig, $decoded[0]['content'][0]['start'], $decoded[0]['content'][0]['length']);
- $algorithm = &$spkac['publicKeyAndChallenge']['spki']['algorithm']['algorithm'];
- $key = &$spkac['publicKeyAndChallenge']['spki']['subjectPublicKey'];
- $key = $this->_reformatKey($algorithm, $key);
-
- switch ($algorithm) {
- case 'rsaEncryption':
- $this->publicKey = new RSA();
- $this->publicKey->loadKey($key);
- $this->publicKey->setPublicKey();
- break;
- default:
- $this->publicKey = null;
- }
+ $key = $spkac['publicKeyAndChallenge']['spki'];
+ $key = ASN1::encodeDER($key, Maps\SubjectPublicKeyInfo::MAP);
+ $spkac['publicKeyAndChallenge']['spki']['subjectPublicKey'] =
+ "-----BEGIN PUBLIC KEY-----\r\n" .
+ chunk_split(base64_encode($key), 64) .
+ "-----END PUBLIC KEY-----";
$this->currentKeyIdentifier = null;
$this->currentCert = $spkac;
+ $this->publicKey = null;
+ $this->publicKey = $this->getPublicKey();
+
return $spkac;
}
/**
* Save a SPKAC CSR request
*
- * @param array $csr
+ * @param array $spkac
* @param int $format optional
* @access public
* @return string
*/
- function saveSPKAC($spkac, $format = self::FORMAT_PEM)
+ public function saveSPKAC($spkac, $format = self::FORMAT_PEM)
{
if (!is_array($spkac) || !isset($spkac['publicKeyAndChallenge'])) {
return false;
}
- $algorithm = $this->_subArray($spkac, 'publicKeyAndChallenge/spki/algorithm/algorithm');
+ $algorithm = $this->subArray($spkac, 'publicKeyAndChallenge/spki/algorithm/algorithm');
switch (true) {
case !$algorithm:
case is_object($spkac['publicKeyAndChallenge']['spki']['subjectPublicKey']):
break;
default:
- switch ($algorithm) {
- case 'rsaEncryption':
- $spkac['publicKeyAndChallenge']['spki']['subjectPublicKey']
- = base64_encode("\0" . base64_decode(preg_replace('#-.+-|[\r\n]#', '', $spkac['publicKeyAndChallenge']['spki']['subjectPublicKey'])));
- }
+ $spkac['publicKeyAndChallenge']['spki'] = new Element(
+ base64_decode(preg_replace('#-.+-|[\r\n]#', '', $spkac['publicKeyAndChallenge']['spki']['subjectPublicKey']))
+ );
}
- $asn1 = new ASN1();
-
- $asn1->loadOIDs($this->oids);
- $spkac = $asn1->encodeDER($spkac, $this->SignedPublicKeyAndChallenge);
+ $spkac = ASN1::encodeDER($spkac, Maps\SignedPublicKeyAndChallenge::MAP);
switch ($format) {
case self::FORMAT_DER:
@@ -3403,7 +2401,7 @@ class X509
default:
// OpenSSL's implementation of SPKAC requires the SPKAC be preceded by SPKAC= and since there are pretty much
// no other SPKAC decoders phpseclib will use that same format
- return 'SPKAC=' . base64_encode($spkac);
+ return 'SPKAC=' . Base64::encode($spkac);
}
}
@@ -3411,10 +2409,11 @@ class X509
* Load a Certificate Revocation List
*
* @param string $crl
- * @access public
+ * @param int $mode
* @return mixed
+ * @access public
*/
- function loadCRL($crl, $mode = self::FORMAT_AUTO_DETECT)
+ public function loadCRL($crl, $mode = self::FORMAT_AUTO_DETECT)
{
if (is_array($crl) && isset($crl['tbsCertList'])) {
$this->currentCert = $crl;
@@ -3422,10 +2421,8 @@ class X509
return $crl;
}
- $asn1 = new ASN1();
-
if ($mode != self::FORMAT_DER) {
- $newcrl = $this->_extractBER($crl);
+ $newcrl = ASN1::extractBER($crl);
if ($mode == self::FORMAT_PEM && $crl == $newcrl) {
return false;
}
@@ -3438,15 +2435,14 @@ class X509
return false;
}
- $asn1->loadOIDs($this->oids);
- $decoded = $asn1->decodeBER($crl);
+ $decoded = ASN1::decodeBER($crl);
if (empty($decoded)) {
$this->currentCert = false;
return false;
}
- $crl = $asn1->asn1map($decoded[0], $this->CertificateList);
+ $crl = ASN1::asn1map($decoded[0], Maps\CertificateList::MAP);
if (!isset($crl) || $crl === false) {
$this->currentCert = false;
return false;
@@ -3454,17 +2450,17 @@ class X509
$this->signatureSubject = substr($orig, $decoded[0]['content'][0]['start'], $decoded[0]['content'][0]['length']);
- $this->_mapInDNs($crl, 'tbsCertList/issuer/rdnSequence', $asn1);
- if ($this->_isSubArrayValid($crl, 'tbsCertList/crlExtensions')) {
- $this->_mapInExtensions($crl, 'tbsCertList/crlExtensions', $asn1);
+ $this->mapInDNs($crl, 'tbsCertList/issuer/rdnSequence');
+ if ($this->isSubArrayValid($crl, 'tbsCertList/crlExtensions')) {
+ $this->mapInExtensions($crl, 'tbsCertList/crlExtensions');
}
- if ($this->_isSubArrayValid($crl, 'tbsCertList/revokedCertificates')) {
- $rclist_ref = &$this->_subArrayUnchecked($crl, 'tbsCertList/revokedCertificates');
+ if ($this->isSubArrayValid($crl, 'tbsCertList/revokedCertificates')) {
+ $rclist_ref = &$this->subArrayUnchecked($crl, 'tbsCertList/revokedCertificates');
if ($rclist_ref) {
$rclist = $crl['tbsCertList']['revokedCertificates'];
foreach ($rclist as $i => $extension) {
- if ($this->_isSubArrayValid($rclist, "$i/crlEntryExtensions", $asn1)) {
- $this->_mapInExtensions($rclist_ref, "$i/crlEntryExtensions", $asn1);
+ if ($this->isSubArrayValid($rclist, "$i/crlEntryExtensions")) {
+ $this->mapInExtensions($rclist_ref, "$i/crlEntryExtensions");
}
}
}
@@ -3484,53 +2480,49 @@ class X509
* @access public
* @return string
*/
- function saveCRL($crl, $format = self::FORMAT_PEM)
+ public function saveCRL($crl, $format = self::FORMAT_PEM)
{
if (!is_array($crl) || !isset($crl['tbsCertList'])) {
return false;
}
- $asn1 = new ASN1();
-
- $asn1->loadOIDs($this->oids);
-
- $filters = array();
+ $filters = [];
$filters['tbsCertList']['issuer']['rdnSequence']['value']
- = array('type' => ASN1::TYPE_UTF8_STRING);
+ = ['type' => ASN1::TYPE_UTF8_STRING];
$filters['tbsCertList']['signature']['parameters']
- = array('type' => ASN1::TYPE_UTF8_STRING);
+ = ['type' => ASN1::TYPE_UTF8_STRING];
$filters['signatureAlgorithm']['parameters']
- = array('type' => ASN1::TYPE_UTF8_STRING);
+ = ['type' => ASN1::TYPE_UTF8_STRING];
if (empty($crl['tbsCertList']['signature']['parameters'])) {
$filters['tbsCertList']['signature']['parameters']
- = array('type' => ASN1::TYPE_NULL);
+ = ['type' => ASN1::TYPE_NULL];
}
if (empty($crl['signatureAlgorithm']['parameters'])) {
$filters['signatureAlgorithm']['parameters']
- = array('type' => ASN1::TYPE_NULL);
+ = ['type' => ASN1::TYPE_NULL];
}
- $asn1->loadFilters($filters);
+ ASN1::setFilters($filters);
- $this->_mapOutDNs($crl, 'tbsCertList/issuer/rdnSequence', $asn1);
- $this->_mapOutExtensions($crl, 'tbsCertList/crlExtensions', $asn1);
- $rclist = &$this->_subArray($crl, 'tbsCertList/revokedCertificates');
+ $this->mapOutDNs($crl, 'tbsCertList/issuer/rdnSequence');
+ $this->mapOutExtensions($crl, 'tbsCertList/crlExtensions');
+ $rclist = &$this->subArray($crl, 'tbsCertList/revokedCertificates');
if (is_array($rclist)) {
foreach ($rclist as $i => $extension) {
- $this->_mapOutExtensions($rclist, "$i/crlEntryExtensions", $asn1);
+ $this->mapOutExtensions($rclist, "$i/crlEntryExtensions");
}
}
- $crl = $asn1->encodeDER($crl, $this->CertificateList);
+ $crl = ASN1::encodeDER($crl, Maps\CertificateList::MAP);
switch ($format) {
case self::FORMAT_DER:
return $crl;
// case self::FORMAT_PEM:
default:
- return "-----BEGIN X509 CRL-----\r\n" . chunk_split(base64_encode($crl), 64) . '-----END X509 CRL-----';
+ return "-----BEGIN X509 CRL-----\r\n" . chunk_split(Base64::encode($crl), 64) . '-----END X509 CRL-----';
}
}
@@ -3544,19 +2536,19 @@ class X509
*
* @param string $date in format date('D, d M Y H:i:s O')
* @access private
- * @return array
+ * @return array|Element
*/
- function _timeField($date)
+ private function timeField($date)
{
if ($date instanceof Element) {
return $date;
}
- $dateObj = new DateTime($date, new DateTimeZone('GMT'));
+ $dateObj = new DateTimeImmutable($date, new DateTimeZone('GMT'));
$year = $dateObj->format('Y'); // the same way ASN1.php parses this
if ($year < 2050) {
- return array('utcTime' => $date);
+ return ['utcTime' => $date];
} else {
- return array('generalTime' => $date);
+ return ['generalTime' => $date];
}
}
@@ -3567,35 +2559,45 @@ class X509
* $subject can be either an existing X.509 cert (if you want to resign it),
* a CSR or something with the DN and public key explicitly set.
*
- * @param \phpseclib\File\X509 $issuer
- * @param \phpseclib\File\X509 $subject
- * @param string $signatureAlgorithm optional
+ * @param \phpseclib3\File\X509 $issuer
+ * @param \phpseclib3\File\X509 $subject
* @access public
* @return mixed
*/
- function sign($issuer, $subject, $signatureAlgorithm = 'sha1WithRSAEncryption')
+ public function sign($issuer, $subject)
{
if (!is_object($issuer->privateKey) || empty($issuer->dn)) {
return false;
}
- if (isset($subject->publicKey) && !($subjectPublicKey = $subject->_formatSubjectPublicKey())) {
+ if (isset($subject->publicKey) && !($subjectPublicKey = $subject->formatSubjectPublicKey())) {
return false;
}
$currentCert = isset($this->currentCert) ? $this->currentCert : null;
- $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject: null;
+ $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject : null;
+ $signatureAlgorithm = self::identifySignatureAlgorithm($issuer->privateKey);
+ if ($signatureAlgorithm != 'id-RSASSA-PSS') {
+ $signatureAlgorithm = ['algorithm' => $signatureAlgorithm];
+ } else {
+ $r = PSS::load($issuer->privateKey->toString('PSS'));
+ $signatureAlgorithm = [
+ 'algorithm' => 'id-RSASSA-PSS',
+ 'parameters' => PSS::savePSSParams($r)
+ ];
+ }
if (isset($subject->currentCert) && is_array($subject->currentCert) && isset($subject->currentCert['tbsCertificate'])) {
$this->currentCert = $subject->currentCert;
- $this->currentCert['tbsCertificate']['signature']['algorithm'] = $signatureAlgorithm;
- $this->currentCert['signatureAlgorithm']['algorithm'] = $signatureAlgorithm;
+ $this->currentCert['tbsCertificate']['signature'] = $signatureAlgorithm;
+ $this->currentCert['signatureAlgorithm'] = $signatureAlgorithm;
+
if (!empty($this->startDate)) {
- $this->currentCert['tbsCertificate']['validity']['notBefore'] = $this->_timeField($this->startDate);
+ $this->currentCert['tbsCertificate']['validity']['notBefore'] = $this->timeField($this->startDate);
}
if (!empty($this->endDate)) {
- $this->currentCert['tbsCertificate']['validity']['notAfter'] = $this->_timeField($this->endDate);
+ $this->currentCert['tbsCertificate']['validity']['notAfter'] = $this->timeField($this->endDate);
}
if (!empty($this->serialNumber)) {
$this->currentCert['tbsCertificate']['serialNumber'] = $this->serialNumber;
@@ -3617,10 +2619,10 @@ class X509
return false;
}
- $startDate = new DateTime('now', new DateTimeZone(@date_default_timezone_get()));
+ $startDate = new DateTimeImmutable('now', new DateTimeZone(@date_default_timezone_get()));
$startDate = !empty($this->startDate) ? $this->startDate : $startDate->format('D, d M Y H:i:s O');
- $endDate = new DateTime('+1 year', new DateTimeZone(@date_default_timezone_get()));
+ $endDate = new DateTimeImmutable('+1 year', new DateTimeZone(@date_default_timezone_get()));
$endDate = !empty($this->endDate) ? $this->endDate : $endDate->format('D, d M Y H:i:s O');
/* "The serial number MUST be a positive integer"
@@ -3634,23 +2636,23 @@ class X509
$this->serialNumber :
new BigInteger(Random::string(20) & ("\x7F" . str_repeat("\xFF", 19)), 256);
- $this->currentCert = array(
+ $this->currentCert = [
'tbsCertificate' =>
- array(
+ [
'version' => 'v3',
'serialNumber' => $serialNumber, // $this->setSerialNumber()
- 'signature' => array('algorithm' => $signatureAlgorithm),
+ 'signature' => $signatureAlgorithm,
'issuer' => false, // this is going to be overwritten later
- 'validity' => array(
- 'notBefore' => $this->_timeField($startDate), // $this->setStartDate()
- 'notAfter' => $this->_timeField($endDate) // $this->setEndDate()
- ),
+ 'validity' => [
+ 'notBefore' => $this->timeField($startDate), // $this->setStartDate()
+ 'notAfter' => $this->timeField($endDate) // $this->setEndDate()
+ ],
'subject' => $subject->dn,
'subjectPublicKeyInfo' => $subjectPublicKey
- ),
- 'signatureAlgorithm' => array('algorithm' => $signatureAlgorithm),
+ ],
+ 'signatureAlgorithm' => $signatureAlgorithm,
'signature' => false // this is going to be overwritten later
- );
+ ];
// Copy extensions from CSR.
$csrexts = $subject->getAttribute('pkcs-9-at-extensionRequest', 0);
@@ -3663,14 +2665,14 @@ class X509
$this->currentCert['tbsCertificate']['issuer'] = $issuer->dn;
if (isset($issuer->currentKeyIdentifier)) {
- $this->setExtension('id-ce-authorityKeyIdentifier', array(
+ $this->setExtension('id-ce-authorityKeyIdentifier', [
//'authorityCertIssuer' => array(
// array(
// 'directoryName' => $issuer->dn
// )
//),
'keyIdentifier' => $issuer->currentKeyIdentifier
- ));
+ ]);
//$extensions = &$this->currentCert['tbsCertificate']['extensions'];
//if (isset($issuer->serialNumber)) {
// $extensions[count($extensions) - 1]['authorityCertSerialNumber'] = $issuer->serialNumber;
@@ -3682,18 +2684,18 @@ class X509
$this->setExtension('id-ce-subjectKeyIdentifier', $subject->currentKeyIdentifier);
}
- $altName = array();
+ $altName = [];
if (isset($subject->domains) && count($subject->domains)) {
- $altName = array_map(array('\phpseclib\File\X509', '_dnsName'), $subject->domains);
+ $altName = array_map(['\phpseclib3\File\X509', 'dnsName'], $subject->domains);
}
if (isset($subject->ipAddresses) && count($subject->ipAddresses)) {
// should an IP address appear as the CN if no domain name is specified? idk
//$ips = count($subject->domains) ? $subject->ipAddresses : array_slice($subject->ipAddresses, 1);
- $ipAddresses = array();
+ $ipAddresses = [];
foreach ($subject->ipAddresses as $ipAddress) {
- $encoded = $subject->_ipAddress($ipAddress);
+ $encoded = $subject->ipAddress($ipAddress);
if ($encoded !== false) {
$ipAddresses[] = $encoded;
}
@@ -3710,36 +2712,37 @@ class X509
if ($this->caFlag) {
$keyUsage = $this->getExtension('id-ce-keyUsage');
if (!$keyUsage) {
- $keyUsage = array();
+ $keyUsage = [];
}
$this->setExtension(
'id-ce-keyUsage',
- array_values(array_unique(array_merge($keyUsage, array('cRLSign', 'keyCertSign'))))
+ array_values(array_unique(array_merge($keyUsage, ['cRLSign', 'keyCertSign'])))
);
$basicConstraints = $this->getExtension('id-ce-basicConstraints');
if (!$basicConstraints) {
- $basicConstraints = array();
+ $basicConstraints = [];
}
$this->setExtension(
'id-ce-basicConstraints',
- array_unique(array_merge(array('cA' => true), $basicConstraints)),
+ array_unique(array_merge(['cA' => true], $basicConstraints)),
true
);
if (!isset($subject->currentKeyIdentifier)) {
- $this->setExtension('id-ce-subjectKeyIdentifier', base64_encode($this->computeKeyIdentifier($this->currentCert)), false, false);
+ $this->setExtension('id-ce-subjectKeyIdentifier', $this->computeKeyIdentifier($this->currentCert), false, false);
}
}
// resync $this->signatureSubject
- // save $tbsCertificate in case there are any \phpseclib\File\ASN1\Element objects in it
+ // save $tbsCertificate in case there are any \phpseclib3\File\ASN1\Element objects in it
$tbsCertificate = $this->currentCert['tbsCertificate'];
$this->loadX509($this->saveX509($this->currentCert));
- $result = $this->_sign($issuer->privateKey, $signatureAlgorithm);
+ $result = $this->currentCert;
+ $this->currentCert['signature'] = $result['signature'] = "\0" . $issuer->privateKey->sign($this->signatureSubject);
$result['tbsCertificate'] = $tbsCertificate;
$this->currentCert = $currentCert;
@@ -3754,24 +2757,20 @@ class X509
* @access public
* @return mixed
*/
- function signCSR($signatureAlgorithm = 'sha1WithRSAEncryption')
+ public function signCSR()
{
if (!is_object($this->privateKey) || empty($this->dn)) {
return false;
}
$origPublicKey = $this->publicKey;
- $class = get_class($this->privateKey);
- $this->publicKey = new $class();
- $this->publicKey->loadKey($this->privateKey->getPublicKey());
- $this->publicKey->setPublicKey();
- if (!($publicKey = $this->_formatSubjectPublicKey())) {
- return false;
- }
+ $this->publicKey = $this->privateKey->getPublicKey();
+ $publicKey = $this->formatSubjectPublicKey();
$this->publicKey = $origPublicKey;
$currentCert = isset($this->currentCert) ? $this->currentCert : null;
- $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject: null;
+ $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject : null;
+ $signatureAlgorithm = self::identifySignatureAlgorithm($this->privateKey);
if (isset($this->currentCert) && is_array($this->currentCert) && isset($this->currentCert['certificationRequestInfo'])) {
$this->currentCert['signatureAlgorithm']['algorithm'] = $signatureAlgorithm;
@@ -3780,24 +2779,25 @@ class X509
}
$this->currentCert['certificationRequestInfo']['subjectPKInfo'] = $publicKey;
} else {
- $this->currentCert = array(
+ $this->currentCert = [
'certificationRequestInfo' =>
- array(
+ [
'version' => 'v1',
'subject' => $this->dn,
'subjectPKInfo' => $publicKey
- ),
- 'signatureAlgorithm' => array('algorithm' => $signatureAlgorithm),
+ ],
+ 'signatureAlgorithm' => ['algorithm' => $signatureAlgorithm],
'signature' => false // this is going to be overwritten later
- );
+ ];
}
// resync $this->signatureSubject
- // save $certificationRequestInfo in case there are any \phpseclib\File\ASN1\Element objects in it
+ // save $certificationRequestInfo in case there are any \phpseclib3\File\ASN1\Element objects in it
$certificationRequestInfo = $this->currentCert['certificationRequestInfo'];
$this->loadCSR($this->saveCSR($this->currentCert));
- $result = $this->_sign($this->privateKey, $signatureAlgorithm);
+ $result = $this->currentCert;
+ $this->currentCert['signature'] = $result['signature'] = "\0" . $this->privateKey->sign($this->signatureSubject);
$result['certificationRequestInfo'] = $certificationRequestInfo;
$this->currentCert = $currentCert;
@@ -3812,25 +2812,20 @@ class X509
* @access public
* @return mixed
*/
- function signSPKAC($signatureAlgorithm = 'sha1WithRSAEncryption')
+ public function signSPKAC()
{
if (!is_object($this->privateKey)) {
return false;
}
$origPublicKey = $this->publicKey;
- $class = get_class($this->privateKey);
- $this->publicKey = new $class();
- $this->publicKey->loadKey($this->privateKey->getPublicKey());
- $this->publicKey->setPublicKey();
- $publicKey = $this->_formatSubjectPublicKey();
- if (!$publicKey) {
- return false;
- }
+ $this->publicKey = $this->privateKey->getPublicKey();
+ $publicKey = $this->formatSubjectPublicKey();
$this->publicKey = $origPublicKey;
$currentCert = isset($this->currentCert) ? $this->currentCert : null;
- $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject: null;
+ $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject : null;
+ $signatureAlgorithm = self::identifySignatureAlgorithm($this->privateKey);
// re-signing a SPKAC seems silly but since everything else supports re-signing why not?
if (isset($this->currentCert) && is_array($this->currentCert) && isset($this->currentCert['publicKeyAndChallenge'])) {
@@ -3841,9 +2836,9 @@ class X509
$this->currentCert['publicKeyAndChallenge']['challenge'] = $this->challenge & str_repeat("\x7F", strlen($this->challenge));
}
} else {
- $this->currentCert = array(
+ $this->currentCert = [
'publicKeyAndChallenge' =>
- array(
+ [
'spki' => $publicKey,
// quoting ,
// "A challenge string that is submitted along with the public key. Defaults to an empty string if not specified."
@@ -3851,18 +2846,19 @@ class X509
// we could alternatively do this instead if we ignored the specs:
// Random::string(8) & str_repeat("\x7F", 8)
'challenge' => !empty($this->challenge) ? $this->challenge : ''
- ),
- 'signatureAlgorithm' => array('algorithm' => $signatureAlgorithm),
+ ],
+ 'signatureAlgorithm' => ['algorithm' => $signatureAlgorithm],
'signature' => false // this is going to be overwritten later
- );
+ ];
}
// resync $this->signatureSubject
- // save $publicKeyAndChallenge in case there are any \phpseclib\File\ASN1\Element objects in it
+ // save $publicKeyAndChallenge in case there are any \phpseclib3\File\ASN1\Element objects in it
$publicKeyAndChallenge = $this->currentCert['publicKeyAndChallenge'];
$this->loadSPKAC($this->saveSPKAC($this->currentCert));
- $result = $this->_sign($this->privateKey, $signatureAlgorithm);
+ $result = $this->currentCert;
+ $this->currentCert['signature'] = $result['signature'] = "\0" . $this->privateKey->sign($this->signatureSubject);
$result['publicKeyAndChallenge'] = $publicKeyAndChallenge;
$this->currentCert = $currentCert;
@@ -3876,13 +2872,12 @@ class X509
*
* $issuer's private key needs to be loaded.
*
- * @param \phpseclib\File\X509 $issuer
- * @param \phpseclib\File\X509 $crl
- * @param string $signatureAlgorithm optional
+ * @param \phpseclib3\File\X509 $issuer
+ * @param \phpseclib3\File\X509 $crl
* @access public
* @return mixed
*/
- function signCRL($issuer, $crl, $signatureAlgorithm = 'sha1WithRSAEncryption')
+ public function signCRL($issuer, $crl)
{
if (!is_object($issuer->privateKey) || empty($issuer->dn)) {
return false;
@@ -3890,8 +2885,9 @@ class X509
$currentCert = isset($this->currentCert) ? $this->currentCert : null;
$signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject : null;
+ $signatureAlgorithm = self::identifySignatureAlgorithm($issuer->privateKey);
- $thisUpdate = new DateTime('now', new DateTimeZone(@date_default_timezone_get()));
+ $thisUpdate = new DateTimeImmutable('now', new DateTimeZone(@date_default_timezone_get()));
$thisUpdate = !empty($this->startDate) ? $this->startDate : $thisUpdate->format('D, d M Y H:i:s O');
if (isset($crl->currentCert) && is_array($crl->currentCert) && isset($crl->currentCert['tbsCertList'])) {
@@ -3899,25 +2895,25 @@ class X509
$this->currentCert['tbsCertList']['signature']['algorithm'] = $signatureAlgorithm;
$this->currentCert['signatureAlgorithm']['algorithm'] = $signatureAlgorithm;
} else {
- $this->currentCert = array(
+ $this->currentCert = [
'tbsCertList' =>
- array(
+ [
'version' => 'v2',
- 'signature' => array('algorithm' => $signatureAlgorithm),
+ 'signature' => ['algorithm' => $signatureAlgorithm],
'issuer' => false, // this is going to be overwritten later
- 'thisUpdate' => $this->_timeField($thisUpdate) // $this->setStartDate()
- ),
- 'signatureAlgorithm' => array('algorithm' => $signatureAlgorithm),
+ 'thisUpdate' => $this->timeField($thisUpdate) // $this->setStartDate()
+ ],
+ 'signatureAlgorithm' => ['algorithm' => $signatureAlgorithm],
'signature' => false // this is going to be overwritten later
- );
+ ];
}
$tbsCertList = &$this->currentCert['tbsCertList'];
$tbsCertList['issuer'] = $issuer->dn;
- $tbsCertList['thisUpdate'] = $this->_timeField($thisUpdate);
+ $tbsCertList['thisUpdate'] = $this->timeField($thisUpdate);
if (!empty($this->endDate)) {
- $tbsCertList['nextUpdate'] = $this->_timeField($this->endDate); // $this->setEndDate()
+ $tbsCertList['nextUpdate'] = $this->timeField($this->endDate); // $this->setEndDate()
} else {
unset($tbsCertList['nextUpdate']);
}
@@ -3962,14 +2958,14 @@ class X509
}
if (isset($issuer->currentKeyIdentifier)) {
- $this->setExtension('id-ce-authorityKeyIdentifier', array(
+ $this->setExtension('id-ce-authorityKeyIdentifier', [
//'authorityCertIssuer' => array(
- // array(
+ // ]
// 'directoryName' => $issuer->dn
- // )
+ // ]
//),
'keyIdentifier' => $issuer->currentKeyIdentifier
- ));
+ ]);
//$extensions = &$tbsCertList['crlExtensions'];
//if (isset($issuer->serialNumber)) {
// $extensions[count($extensions) - 1]['authorityCertSerialNumber'] = $issuer->serialNumber;
@@ -3991,11 +2987,12 @@ class X509
unset($tbsCertList);
// resync $this->signatureSubject
- // save $tbsCertList in case there are any \phpseclib\File\ASN1\Element objects in it
+ // save $tbsCertList in case there are any \phpseclib3\File\ASN1\Element objects in it
$tbsCertList = $this->currentCert['tbsCertList'];
$this->loadCRL($this->saveCRL($this->currentCert));
- $result = $this->_sign($issuer->privateKey, $signatureAlgorithm);
+ $result = $this->currentCert;
+ $this->currentCert['signature'] = $result['signature'] = "\0" . $issuer->privateKey->sign($this->signatureSubject);
$result['tbsCertList'] = $tbsCertList;
$this->currentCert = $currentCert;
@@ -4005,46 +3002,72 @@ class X509
}
/**
- * X.509 certificate signing helper function.
+ * Identify signature algorithm from key settings
*
- * @param object $key
- * @param \phpseclib\File\X509 $subject
- * @param string $signatureAlgorithm
- * @access public
- * @return mixed
+ * @param PrivateKey $key
+ * @access private
+ * @throws \phpseclib3\Exception\UnsupportedAlgorithmException if the algorithm is unsupported
+ * @return string
*/
- function _sign($key, $signatureAlgorithm)
+ private static function identifySignatureAlgorithm(PrivateKey $key)
{
if ($key instanceof RSA) {
- switch ($signatureAlgorithm) {
- case 'md2WithRSAEncryption':
- case 'md5WithRSAEncryption':
- case 'sha1WithRSAEncryption':
- case 'sha224WithRSAEncryption':
- case 'sha256WithRSAEncryption':
- case 'sha384WithRSAEncryption':
- case 'sha512WithRSAEncryption':
- $key->setHash(preg_replace('#WithRSAEncryption$#', '', $signatureAlgorithm));
- $key->setSignatureMode(RSA::SIGNATURE_PKCS1);
-
- $this->currentCert['signature'] = base64_encode("\0" . $key->sign($this->signatureSubject));
- return $this->currentCert;
+ if ($key->getPadding() & RSA::SIGNATURE_PSS) {
+ return 'id-RSASSA-PSS';
}
+ switch ($key->getHash()) {
+ case 'md2':
+ case 'md5':
+ case 'sha1':
+ case 'sha224':
+ case 'sha256':
+ case 'sha384':
+ case 'sha512':
+ return $key->getHash() . 'WithRSAEncryption';
+ }
+ throw new UnsupportedAlgorithmException('The only supported hash algorithms for RSA are: md2, md5, sha1, sha224, sha256, sha384, sha512');
}
- return false;
+ if ($key instanceof DSA) {
+ switch ($key->getHash()) {
+ case 'sha1':
+ case 'sha224':
+ case 'sha256':
+ return 'id-dsa-with-' . $key->getHash();
+ }
+ throw new UnsupportedAlgorithmException('The only supported hash algorithms for DSA are: sha1, sha224, sha256');
+ }
+
+ if ($key instanceof EC) {
+ switch ($key->getCurve()) {
+ case 'Ed25519':
+ case 'Ed448':
+ return 'id-' . $key->getCurve();
+ }
+ switch ($key->getHash()) {
+ case 'sha1':
+ case 'sha224':
+ case 'sha256':
+ case 'sha384':
+ case 'sha512':
+ return 'ecdsa-with-' . strtoupper($key->getHash());
+ }
+ throw new UnsupportedAlgorithmException('The only supported hash algorithms for EC are: sha1, sha224, sha256, sha384, sha512');
+ }
+
+ throw new UnsupportedAlgorithmException('The only supported public key classes are: RSA, DSA, EC');
}
/**
* Set certificate start date
*
- * @param string $date
+ * @param DateTimeInterface|string $date
* @access public
*/
- function setStartDate($date)
+ public function setStartDate($date)
{
- if (!is_object($date) || !is_a($date, 'DateTime')) {
- $date = new DateTime($date, new DateTimeZone(@date_default_timezone_get()));
+ if (!is_object($date) || !($date instanceof DateTimeInterface)) {
+ $date = new DateTimeImmutable($date, new DateTimeZone(@date_default_timezone_get()));
}
$this->startDate = $date->format('D, d M Y H:i:s O');
@@ -4053,10 +3076,10 @@ class X509
/**
* Set certificate end date
*
- * @param string $date
+ * @param DateTimeInterface|string $date
* @access public
*/
- function setEndDate($date)
+ public function setEndDate($date)
{
/*
To indicate that a certificate has no well-defined expiration date,
@@ -4065,14 +3088,13 @@ class X509
-- http://tools.ietf.org/html/rfc5280#section-4.1.2.5
*/
- if (strtolower($date) == 'lifetime') {
+ if (is_string($date) && strtolower($date) === 'lifetime') {
$temp = '99991231235959Z';
- $asn1 = new ASN1();
- $temp = chr(ASN1::TYPE_GENERALIZED_TIME) . $asn1->_encodeLength(strlen($temp)) . $temp;
+ $temp = chr(ASN1::TYPE_GENERALIZED_TIME) . ASN1::encodeLength(strlen($temp)) . $temp;
$this->endDate = new Element($temp);
} else {
- if (!is_object($date) || !is_a($date, 'DateTime')) {
- $date = new DateTime($date, new DateTimeZone(@date_default_timezone_get()));
+ if (!is_object($date) || !($date instanceof DateTimeInterface)) {
+ $date = new DateTimeImmutable($date, new DateTimeZone(@date_default_timezone_get()));
}
$this->endDate = $date->format('D, d M Y H:i:s O');
@@ -4083,10 +3105,10 @@ class X509
* Set Serial Number
*
* @param string $serial
- * @param $base optional
+ * @param int $base optional
* @access public
*/
- function setSerialNumber($serial, $base = -256)
+ public function setSerialNumber($serial, $base = -256)
{
$this->serialNumber = new BigInteger($serial, $base);
}
@@ -4096,7 +3118,7 @@ class X509
*
* @access public
*/
- function makeCA()
+ public function makeCA()
{
$this->caFlag = true;
}
@@ -4113,7 +3135,7 @@ class X509
* @return boolean
* @access private
*/
- function _isSubArrayValid($root, $path)
+ private function isSubArrayValid($root, $path)
{
if (!is_array($root)) {
return false;
@@ -4150,7 +3172,7 @@ class X509
* @access private
* @return array|false
*/
- function &_subArrayUnchecked(&$root, $path, $create = false)
+ private function &subArrayUnchecked(&$root, $path, $create = false)
{
$false = false;
@@ -4160,7 +3182,7 @@ class X509
return $false;
}
- $root[$i] = array();
+ $root[$i] = [];
}
$root = &$root[$i];
@@ -4178,7 +3200,7 @@ class X509
* @access private
* @return array|false
*/
- function &_subArray(&$root, $path, $create = false)
+ private function &subArray(&$root, $path, $create = false)
{
$false = false;
@@ -4196,7 +3218,7 @@ class X509
return $false;
}
- $root[$i] = array();
+ $root[$i] = [];
}
$root = &$root[$i];
@@ -4214,7 +3236,7 @@ class X509
* @access private
* @return array|false
*/
- function &_extensions(&$root, $path = null, $create = false)
+ private function &extensions(&$root, $path = null, $create = false)
{
if (!isset($root)) {
$root = $this->currentCert;
@@ -4232,7 +3254,7 @@ class X509
break;
case isset($root['certificationRequestInfo']):
$pth = 'certificationRequestInfo/attributes';
- $attributes = &$this->_subArray($root, $pth, $create);
+ $attributes = &$this->subArray($root, $pth, $create);
if (is_array($attributes)) {
foreach ($attributes as $key => $value) {
@@ -4243,14 +3265,14 @@ class X509
}
if ($create) {
$key = count($attributes);
- $attributes[] = array('type' => 'pkcs-9-at-extensionRequest', 'value' => array());
+ $attributes[] = ['type' => 'pkcs-9-at-extensionRequest', 'value' => []];
$path = "$pth/$key/value/0";
}
}
break;
}
- $extensions = &$this->_subArray($root, $path, $create);
+ $extensions = &$this->subArray($root, $path, $create);
if (!is_array($extensions)) {
$false = false;
@@ -4268,9 +3290,9 @@ class X509
* @access private
* @return bool
*/
- function _removeExtension($id, $path = null)
+ private function removeExtensionHelper($id, $path = null)
{
- $extensions = &$this->_extensions($this->currentCert, $path);
+ $extensions = &$this->extensions($this->currentCert, $path);
if (!is_array($extensions)) {
return false;
@@ -4303,9 +3325,9 @@ class X509
* @access private
* @return mixed
*/
- function _getExtension($id, $cert = null, $path = null)
+ private function getExtensionHelper($id, $cert = null, $path = null)
{
- $extensions = $this->_extensions($cert, $path);
+ $extensions = $this->extensions($cert, $path);
if (!is_array($extensions)) {
return false;
@@ -4328,10 +3350,10 @@ class X509
* @access private
* @return array
*/
- function _getExtensions($cert = null, $path = null)
+ private function getExtensionsHelper($cert = null, $path = null)
{
- $exts = $this->_extensions($cert, $path);
- $extensions = array();
+ $exts = $this->extensions($cert, $path);
+ $extensions = [];
if (is_array($exts)) {
foreach ($exts as $extension) {
@@ -4353,15 +3375,15 @@ class X509
* @access private
* @return bool
*/
- function _setExtension($id, $value, $critical = false, $replace = true, $path = null)
+ private function setExtensionHelper($id, $value, $critical = false, $replace = true, $path = null)
{
- $extensions = &$this->_extensions($this->currentCert, $path, true);
+ $extensions = &$this->extensions($this->currentCert, $path, true);
if (!is_array($extensions)) {
return false;
}
- $newext = array('extnId' => $id, 'critical' => $critical, 'extnValue' => $value);
+ $newext = ['extnId' => $id, 'critical' => $critical, 'extnValue' => $value];
foreach ($extensions as $key => $value) {
if ($value['extnId'] == $id) {
@@ -4385,9 +3407,9 @@ class X509
* @access public
* @return bool
*/
- function removeExtension($id)
+ public function removeExtension($id)
{
- return $this->_removeExtension($id);
+ return $this->removeExtensionHelper($id);
}
/**
@@ -4397,24 +3419,26 @@ class X509
*
* @param string $id
* @param array $cert optional
+ * @param string $path
* @access public
* @return mixed
*/
- function getExtension($id, $cert = null)
+ public function getExtension($id, $cert = null, $path=null)
{
- return $this->_getExtension($id, $cert);
+ return $this->getExtensionHelper($id, $cert, $path);
}
/**
* Returns a list of all extensions in use in certificate, CSR or CRL
*
* @param array $cert optional
+ * @param string $path optional
* @access public
* @return array
*/
- function getExtensions($cert = null)
+ public function getExtensions($cert = null, $path = null)
{
- return $this->_getExtensions($cert);
+ return $this->getExtensionsHelper($cert, $path);
}
/**
@@ -4427,9 +3451,9 @@ class X509
* @access public
* @return bool
*/
- function setExtension($id, $value, $critical = false, $replace = true)
+ public function setExtension($id, $value, $critical = false, $replace = true)
{
- return $this->_setExtension($id, $value, $critical, $replace);
+ return $this->setExtensionHelper($id, $value, $critical, $replace);
}
/**
@@ -4440,9 +3464,9 @@ class X509
* @access public
* @return bool
*/
- function removeAttribute($id, $disposition = self::ATTR_ALL)
+ public function removeAttribute($id, $disposition = self::ATTR_ALL)
{
- $attributes = &$this->_subArray($this->currentCert, 'certificationRequestInfo/attributes');
+ $attributes = &$this->subArray($this->currentCert, 'certificationRequestInfo/attributes');
if (!is_array($attributes)) {
return false;
@@ -4491,13 +3515,13 @@ class X509
* @access public
* @return mixed
*/
- function getAttribute($id, $disposition = self::ATTR_ALL, $csr = null)
+ public function getAttribute($id, $disposition = self::ATTR_ALL, $csr = null)
{
if (empty($csr)) {
$csr = $this->currentCert;
}
- $attributes = $this->_subArray($csr, 'certificationRequestInfo/attributes');
+ $attributes = $this->subArray($csr, 'certificationRequestInfo/attributes');
if (!is_array($attributes)) {
return false;
@@ -4531,14 +3555,14 @@ class X509
* @access public
* @return array
*/
- function getAttributes($csr = null)
+ public function getAttributes($csr = null)
{
if (empty($csr)) {
$csr = $this->currentCert;
}
- $attributes = $this->_subArray($csr, 'certificationRequestInfo/attributes');
- $attrs = array();
+ $attributes = $this->subArray($csr, 'certificationRequestInfo/attributes');
+ $attrs = [];
if (is_array($attributes)) {
foreach ($attributes as $attribute) {
@@ -4554,13 +3578,13 @@ class X509
*
* @param string $id
* @param mixed $value
- * @param bool $disposition optional
+ * @param int $disposition optional
* @access public
* @return bool
*/
- function setAttribute($id, $value, $disposition = self::ATTR_ALL)
+ public function setAttribute($id, $value, $disposition = self::ATTR_ALL)
{
- $attributes = &$this->_subArray($this->currentCert, 'certificationRequestInfo/attributes', true);
+ $attributes = &$this->subArray($this->currentCert, 'certificationRequestInfo/attributes', true);
if (!is_array($attributes)) {
return false;
@@ -4598,7 +3622,7 @@ class X509
$attributes[$last]['value'][] = $value;
break;
default:
- $attributes[] = array('type' => $id, 'value' => $disposition == self::ATTR_ALL ? $value: array($value));
+ $attributes[] = ['type' => $id, 'value' => $disposition == self::ATTR_ALL ? $value: [$value]];
break;
}
@@ -4613,12 +3637,12 @@ class X509
* @param string $value
* @access public
*/
- function setKeyIdentifier($value)
+ public function setKeyIdentifier($value)
{
if (empty($value)) {
unset($this->currentKeyIdentifier);
} else {
- $this->currentKeyIdentifier = base64_encode($value);
+ $this->currentKeyIdentifier = $value;
}
}
@@ -4630,9 +3654,9 @@ class X509
* recommended methods (4.2.1.2 RFC 3280).
* Highly polymorphic: try to accept all possible forms of key:
* - Key object
- * - \phpseclib\File\X509 object with public or private key defined
+ * - \phpseclib3\File\X509 object with public or private key defined
* - Certificate or CSR array
- * - \phpseclib\File\ASN1\Element object
+ * - \phpseclib3\File\ASN1\Element object
* - PEM or DER string
*
* @param mixed $key optional
@@ -4640,7 +3664,7 @@ class X509
* @access public
* @return string binary key identifier
*/
- function computeKeyIdentifier($key = null, $method = 1)
+ public function computeKeyIdentifier($key = null, $method = 1)
{
if (is_null($key)) {
$key = $this;
@@ -4657,19 +3681,17 @@ class X509
return false;
case $key instanceof Element:
// Assume the element is a bitstring-packed key.
- $asn1 = new ASN1();
- $decoded = $asn1->decodeBER($key->element);
+ $decoded = ASN1::decodeBER($key->element);
if (empty($decoded)) {
return false;
}
- $raw = $asn1->asn1map($decoded[0], array('type' => ASN1::TYPE_BIT_STRING));
+ $raw = ASN1::asn1map($decoded[0], ['type' => ASN1::TYPE_BIT_STRING]);
if (empty($raw)) {
return false;
}
- $raw = base64_decode($raw);
// If the key is private, compute identifier from its corresponding public key.
$key = new RSA();
- if (!$key->loadKey($raw)) {
+ if (!$key->load($raw)) {
return false; // Not an unencrypted RSA key.
}
if ($key->getPrivateKey() !== false) { // If private.
@@ -4688,13 +3710,13 @@ class X509
return $this->computeKeyIdentifier($key->currentCert, $method);
}
return false;
- default: // Should be a key object (i.e.: \phpseclib\Crypt\RSA).
- $key = $key->getPublicKey(RSA::PUBLIC_FORMAT_PKCS1);
+ default: // Should be a key object (i.e.: \phpseclib3\Crypt\RSA).
+ $key = $key->getPublicKey();
break;
}
// If in PEM format, convert to binary.
- $key = $this->_extractBER($key);
+ $key = ASN1::extractBER($key);
// Now we have the key string: compute its sha-1 sum.
$hash = new Hash('sha1');
@@ -4712,32 +3734,34 @@ class X509
* Format a public key as appropriate
*
* @access private
- * @return array
+ * @return array|bool
*/
- function _formatSubjectPublicKey()
+ private function formatSubjectPublicKey()
{
- if ($this->publicKey instanceof RSA) {
- // the following two return statements do the same thing. i dunno.. i just prefer the later for some reason.
- // the former is a good example of how to do fuzzing on the public key
- //return new Element(base64_decode(preg_replace('#-.+-|[\r\n]#', '', $this->publicKey->getPublicKey())));
- return array(
- 'algorithm' => array('algorithm' => 'rsaEncryption'),
- 'subjectPublicKey' => $this->publicKey->getPublicKey(RSA::PUBLIC_FORMAT_PKCS1)
- );
- }
+ $format = $this->publicKey instanceof RSA && ($this->publicKey->getPadding() & RSA::SIGNATURE_PSS) ?
+ 'PSS' :
+ 'PKCS8';
- return false;
+ $publicKey = base64_decode(preg_replace('#-.+-|[\r\n]#', '', $this->publicKey->toString($format)));
+
+ $decoded = ASN1::decodeBER($publicKey);
+ $mapped = ASN1::asn1map($decoded[0], Maps\SubjectPublicKeyInfo::MAP);
+
+ $mapped['subjectPublicKey'] = $this->publicKey->toString($format);
+
+ return $mapped;
}
/**
* Set the domain name's which the cert is to be valid for
*
+ * @param mixed[] ...$domains
* @access public
* @return array
*/
- function setDomain()
+ public function setDomain(...$domains)
{
- $this->domains = func_get_args();
+ $this->domains = $domains;
$this->removeDNProp('id-at-commonName');
$this->setDNProp('id-at-commonName', $this->domains[0]);
}
@@ -4746,11 +3770,11 @@ class X509
* Set the IP Addresses's which the cert is to be valid for
*
* @access public
- * @param string $ipAddress optional
+ * @param mixed[] ...$ipAddresses
*/
- function setIPAddress()
+ public function setIPAddress(...$ipAddresses)
{
- $this->ipAddresses = func_get_args();
+ $this->ipAddresses = $ipAddresses;
/*
if (!isset($this->domains)) {
$this->removeDNProp('id-at-commonName');
@@ -4766,9 +3790,9 @@ class X509
* @param string $domain
* @return array
*/
- function _dnsName($domain)
+ private function dnsName($domain)
{
- return array('dNSName' => $domain);
+ return ['dNSName' => $domain];
}
/**
@@ -4780,9 +3804,9 @@ class X509
* @param string $address
* @return array
*/
- function _iPAddress($address)
+ private function iPAddress($address)
{
- return array('iPAddress' => $address);
+ return ['iPAddress' => $address];
}
/**
@@ -4794,7 +3818,7 @@ class X509
* @access private
* @return int|false
*/
- function _revokedCertificate(&$rclist, $serial, $create = false)
+ private function revokedCertificate(&$rclist, $serial, $create = false)
{
$serial = new BigInteger($serial);
@@ -4809,9 +3833,9 @@ class X509
}
$i = count($rclist);
- $revocationDate = new DateTime('now', new DateTimeZone(@date_default_timezone_get()));
- $rclist[] = array('userCertificate' => $serial,
- 'revocationDate' => $this->_timeField($revocationDate->format('D, d M Y H:i:s O')));
+ $revocationDate = new DateTimeImmutable('now', new DateTimeZone(@date_default_timezone_get()));
+ $rclist[] = ['userCertificate' => $serial,
+ 'revocationDate' => $this->timeField($revocationDate->format('D, d M Y H:i:s O'))];
return $i;
}
@@ -4823,14 +3847,14 @@ class X509
* @access public
* @return bool
*/
- function revoke($serial, $date = null)
+ public function revoke($serial, $date = null)
{
if (isset($this->currentCert['tbsCertList'])) {
- if (is_array($rclist = &$this->_subArray($this->currentCert, 'tbsCertList/revokedCertificates', true))) {
- if ($this->_revokedCertificate($rclist, $serial) === false) { // If not yet revoked
- if (($i = $this->_revokedCertificate($rclist, $serial, true)) !== false) {
+ if (is_array($rclist = &$this->subArray($this->currentCert, 'tbsCertList/revokedCertificates', true))) {
+ if ($this->revokedCertificate($rclist, $serial) === false) { // If not yet revoked
+ if (($i = $this->revokedCertificate($rclist, $serial, true)) !== false) {
if (!empty($date)) {
- $rclist[$i]['revocationDate'] = $this->_timeField($date);
+ $rclist[$i]['revocationDate'] = $this->timeField($date);
}
return true;
@@ -4849,10 +3873,10 @@ class X509
* @access public
* @return bool
*/
- function unrevoke($serial)
+ public function unrevoke($serial)
{
- if (is_array($rclist = &$this->_subArray($this->currentCert, 'tbsCertList/revokedCertificates'))) {
- if (($i = $this->_revokedCertificate($rclist, $serial)) !== false) {
+ if (is_array($rclist = &$this->subArray($this->currentCert, 'tbsCertList/revokedCertificates'))) {
+ if (($i = $this->revokedCertificate($rclist, $serial)) !== false) {
unset($rclist[$i]);
$rclist = array_values($rclist);
return true;
@@ -4869,10 +3893,10 @@ class X509
* @access public
* @return mixed
*/
- function getRevoked($serial)
+ public function getRevoked($serial)
{
- if (is_array($rclist = $this->_subArray($this->currentCert, 'tbsCertList/revokedCertificates'))) {
- if (($i = $this->_revokedCertificate($rclist, $serial)) !== false) {
+ if (is_array($rclist = $this->subArray($this->currentCert, 'tbsCertList/revokedCertificates'))) {
+ if (($i = $this->revokedCertificate($rclist, $serial)) !== false) {
return $rclist[$i];
}
}
@@ -4885,9 +3909,9 @@ class X509
*
* @param array $crl optional
* @access public
- * @return array
+ * @return array|bool
*/
- function listRevoked($crl = null)
+ public function listRevoked($crl = null)
{
if (!isset($crl)) {
$crl = $this->currentCert;
@@ -4897,9 +3921,9 @@ class X509
return false;
}
- $result = array();
+ $result = [];
- if (is_array($rclist = $this->_subArray($crl, 'tbsCertList/revokedCertificates'))) {
+ if (is_array($rclist = $this->subArray($crl, 'tbsCertList/revokedCertificates'))) {
foreach ($rclist as $rc) {
$result[] = $rc['userCertificate']->toString();
}
@@ -4916,11 +3940,11 @@ class X509
* @access public
* @return bool
*/
- function removeRevokedCertificateExtension($serial, $id)
+ public function removeRevokedCertificateExtension($serial, $id)
{
- if (is_array($rclist = &$this->_subArray($this->currentCert, 'tbsCertList/revokedCertificates'))) {
- if (($i = $this->_revokedCertificate($rclist, $serial)) !== false) {
- return $this->_removeExtension($id, "tbsCertList/revokedCertificates/$i/crlEntryExtensions");
+ if (is_array($rclist = &$this->subArray($this->currentCert, 'tbsCertList/revokedCertificates'))) {
+ if (($i = $this->revokedCertificate($rclist, $serial)) !== false) {
+ return $this->removeExtensionHelper($id, "tbsCertList/revokedCertificates/$i/crlEntryExtensions");
}
}
@@ -4938,15 +3962,15 @@ class X509
* @access public
* @return mixed
*/
- function getRevokedCertificateExtension($serial, $id, $crl = null)
+ public function getRevokedCertificateExtension($serial, $id, $crl = null)
{
if (!isset($crl)) {
$crl = $this->currentCert;
}
- if (is_array($rclist = $this->_subArray($crl, 'tbsCertList/revokedCertificates'))) {
- if (($i = $this->_revokedCertificate($rclist, $serial)) !== false) {
- return $this->_getExtension($id, $crl, "tbsCertList/revokedCertificates/$i/crlEntryExtensions");
+ if (is_array($rclist = $this->subArray($crl, 'tbsCertList/revokedCertificates'))) {
+ if (($i = $this->revokedCertificate($rclist, $serial)) !== false) {
+ return $this->getExtension($id, $crl, "tbsCertList/revokedCertificates/$i/crlEntryExtensions");
}
}
@@ -4959,17 +3983,17 @@ class X509
* @param string $serial
* @param array $crl optional
* @access public
- * @return array
+ * @return array|bool
*/
- function getRevokedCertificateExtensions($serial, $crl = null)
+ public function getRevokedCertificateExtensions($serial, $crl = null)
{
if (!isset($crl)) {
$crl = $this->currentCert;
}
- if (is_array($rclist = $this->_subArray($crl, 'tbsCertList/revokedCertificates'))) {
- if (($i = $this->_revokedCertificate($rclist, $serial)) !== false) {
- return $this->_getExtensions($crl, "tbsCertList/revokedCertificates/$i/crlEntryExtensions");
+ if (is_array($rclist = $this->subArray($crl, 'tbsCertList/revokedCertificates'))) {
+ if (($i = $this->revokedCertificate($rclist, $serial)) !== false) {
+ return $this->getExtensions($crl, "tbsCertList/revokedCertificates/$i/crlEntryExtensions");
}
}
@@ -4987,12 +4011,12 @@ class X509
* @access public
* @return bool
*/
- function setRevokedCertificateExtension($serial, $id, $value, $critical = false, $replace = true)
+ public function setRevokedCertificateExtension($serial, $id, $value, $critical = false, $replace = true)
{
if (isset($this->currentCert['tbsCertList'])) {
- if (is_array($rclist = &$this->_subArray($this->currentCert, 'tbsCertList/revokedCertificates', true))) {
- if (($i = $this->_revokedCertificate($rclist, $serial, true)) !== false) {
- return $this->_setExtension($id, $value, $critical, $replace, "tbsCertList/revokedCertificates/$i/crlEntryExtensions");
+ if (is_array($rclist = &$this->subArray($this->currentCert, 'tbsCertList/revokedCertificates', true))) {
+ if (($i = $this->revokedCertificate($rclist, $serial, true)) !== false) {
+ return $this->setExtensionHelper($id, $value, $critical, $replace, "tbsCertList/revokedCertificates/$i/crlEntryExtensions");
}
}
}
@@ -5001,56 +4025,42 @@ class X509
}
/**
- * Extract raw BER from Base64 encoding
+ * Register the mapping for a custom/unsupported extension.
*
- * @access private
- * @param string $str
- * @return string
+ * @param string $id
+ * @param array $mapping
*/
- function _extractBER($str)
+ public static function registerExtension($id, array $mapping)
{
- /* X.509 certs are assumed to be base64 encoded but sometimes they'll have additional things in them
- * above and beyond the ceritificate.
- * ie. some may have the following preceding the -----BEGIN CERTIFICATE----- line:
- *
- * Bag Attributes
- * localKeyID: 01 00 00 00
- * subject=/O=organization/OU=org unit/CN=common name
- * issuer=/O=organization/CN=common name
- */
- $temp = preg_replace('#.*?^-+[^-]+-+[\r\n ]*$#ms', '', $str, 1);
- // remove the -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- stuff
- $temp = preg_replace('#-+[^-]+-+#', '', $temp);
- // remove new lines
- $temp = str_replace(array("\r", "\n", ' '), '', $temp);
- $temp = preg_match('#^[a-zA-Z\d/+]*={0,2}$#', $temp) ? base64_decode($temp) : false;
- return $temp != false ? $temp : $str;
+ if (isset(self::$extensions[$id]) && self::$extensions[$id] !== $mapping) {
+ throw new \RuntimeException(
+ 'Extension ' . $id . ' has already been defined with a different mapping.'
+ );
+ }
+
+ self::$extensions[$id] = $mapping;
}
/**
- * Returns the OID corresponding to a name
+ * Register the mapping for a custom/unsupported extension.
*
- * What's returned in the associative array returned by loadX509() (or load*()) is either a name or an OID if
- * no OID to name mapping is available. The problem with this is that what may be an unmapped OID in one version
- * of phpseclib may not be unmapped in the next version, so apps that are looking at this OID may not be able
- * to work from version to version.
+ * @param string $id
*
- * This method will return the OID if a name is passed to it and if no mapping is avialable it'll assume that
- * what's being passed to it already is an OID and return that instead. A few examples.
- *
- * getOID('2.16.840.1.101.3.4.2.1') == '2.16.840.1.101.3.4.2.1'
- * getOID('id-sha256') == '2.16.840.1.101.3.4.2.1'
- * getOID('zzz') == 'zzz'
- *
- * @access public
- * @return string
+ * @return array|null
*/
- function getOID($name)
+ public static function getRegisteredExtension($id)
{
- static $reverseMap;
- if (!isset($reverseMap)) {
- $reverseMap = array_flip($this->oids);
- }
- return isset($reverseMap[$name]) ? $reverseMap[$name] : $name;
+ return isset(self::$extensions[$id]) ? self::$extensions[$id] : null;
+ }
+
+ /**
+ * Register the mapping for a custom/unsupported extension.
+ *
+ * @param string $id
+ * @param mixed $value
+ */
+ public function setExtensionValue($id, $value)
+ {
+ $this->extensionValues[$id] = $value;
}
}
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/Math/BigInteger.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/Math/BigInteger.php
new file mode 100644
index 000000000..f6ff12ed5
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/Math/BigInteger.php
@@ -0,0 +1,864 @@
+
+ * add($b);
+ *
+ * echo $c->toString(); // outputs 5
+ * ?>
+ *
+ *
+ * @category Math
+ * @package BigInteger
+ * @author Jim Wigginton
+ * @copyright 2017 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ */
+
+namespace phpseclib3\Math;
+
+use phpseclib3\Exception\BadConfigurationException;
+
+/**
+ * Pure-PHP arbitrary precision integer arithmetic library. Supports base-2, base-10, base-16, and base-256
+ * numbers.
+ *
+ * @package BigInteger
+ * @author Jim Wigginton
+ * @access public
+ */
+class BigInteger implements \Serializable
+{
+ /**
+ * Main Engine
+ *
+ * @var string
+ */
+ private static $mainEngine;
+
+ /**
+ * Modular Exponentiation Engine
+ *
+ * @var string
+ */
+ private static $modexpEngine;
+
+ /**
+ * Selected Engines
+ *
+ * @var array
+ */
+ private static $engines;
+
+ /**
+ * The actual BigInteger object
+ *
+ * @var object
+ */
+ private $value;
+
+ /**
+ * Sets engine type.
+ *
+ * Throws an exception if the type is invalid
+ *
+ * @param string $main
+ * @param array $modexps optional
+ */
+ public static function setEngine($main, $modexps = ['DefaultEngine'])
+ {
+ self::$engines = [];
+
+ $fqmain = 'phpseclib3\\Math\\BigInteger\\Engines\\' . $main;
+ if (!class_exists($fqmain) || !method_exists($fqmain, 'isValidEngine')) {
+ throw new \InvalidArgumentException("$main is not a valid engine");
+ }
+ if (!$fqmain::isValidEngine()) {
+ throw new BadConfigurationException("$main is not setup correctly on this system");
+ }
+ self::$mainEngine = $fqmain;
+
+ if (!in_array('Default', $modexps)) {
+ $modexps[] = 'DefaultEngine';
+ }
+
+ $found = false;
+ foreach ($modexps as $modexp) {
+ try {
+ $fqmain::setModExpEngine($modexp);
+ $found = true;
+ break;
+ } catch (\Exception $e) {
+ }
+ }
+
+ if (!$found) {
+ throw new BadConfigurationException("No valid modular exponentiation engine found for $main");
+ }
+
+ self::$modexpEngine = $modexp;
+
+ self::$engines = [$main, $modexp];
+ }
+
+ /**
+ * Returns the engine type
+ *
+ * @return string[]
+ */
+ public static function getEngine()
+ {
+ self::initialize_static_variables();
+
+ return self::$engines;
+ }
+
+ /**
+ * Initialize static variables
+ */
+ private static function initialize_static_variables()
+ {
+ if (!isset(self::$mainEngine)) {
+ $engines = [
+ ['GMP'],
+ ['PHP64', ['OpenSSL']],
+ ['BCMath', ['OpenSSL']],
+ ['PHP32', ['OpenSSL']]
+ ];
+ foreach ($engines as $engine) {
+ try {
+ self::setEngine($engine[0], isset($engine[1]) ? $engine[1] : []);
+ break;
+ } catch (\Exception $e) {
+ }
+ }
+ }
+ }
+
+ /**
+ * Converts base-2, base-10, base-16, and binary strings (base-256) to BigIntegers.
+ *
+ * If the second parameter - $base - is negative, then it will be assumed that the number's are encoded using
+ * two's compliment. The sole exception to this is -10, which is treated the same as 10 is.
+ *
+ * @param int|BigInteger\Engines\Engine $x Base-10 number or base-$base number if $base set.
+ * @param int $base
+ * @return BigInteger
+ */
+ public function __construct($x = 0, $base = 10)
+ {
+ self::initialize_static_variables();
+
+ if ($x instanceof self::$mainEngine) {
+ $this->value = clone $x;
+ } elseif ($x instanceof BigInteger\Engines\Engine) {
+ $this->value = new static("$x");
+ $this->value->setPrecision($x->getPrecision());
+ } else {
+ $this->value = new self::$mainEngine($x, $base);
+ }
+ }
+
+ /**
+ * Converts a BigInteger to a base-10 number.
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ return $this->value->toString();
+ }
+
+ /**
+ * __toString() magic method
+ */
+ public function __toString()
+ {
+ return (string) $this->value;
+ }
+
+ /**
+ * __debugInfo() magic method
+ *
+ * Will be called, automatically, when print_r() or var_dump() are called
+ */
+ public function __debugInfo()
+ {
+ return $this->value->__debugInfo();
+ }
+
+ /**
+ * Converts a BigInteger to a byte string (eg. base-256).
+ *
+ * @param bool $twos_compliment
+ * @return string
+ */
+ public function toBytes($twos_compliment = false)
+ {
+ return $this->value->toBytes($twos_compliment);
+ }
+
+ /**
+ * Converts a BigInteger to a hex string (eg. base-16).
+ *
+ * @param bool $twos_compliment
+ * @return string
+ */
+ public function toHex($twos_compliment = false)
+ {
+ return $this->value->toHex($twos_compliment);
+ }
+
+ /**
+ * Converts a BigInteger to a bit string (eg. base-2).
+ *
+ * Negative numbers are saved as positive numbers, unless $twos_compliment is set to true, at which point, they're
+ * saved as two's compliment.
+ *
+ * @param bool $twos_compliment
+ * @return string
+ */
+ function toBits($twos_compliment = false)
+ {
+ return $this->value->toBits($twos_compliment);
+ }
+
+ /**
+ * Adds two BigIntegers.
+ *
+ * @param BigInteger $y
+ * @return BigInteger
+ */
+ public function add(BigInteger $y)
+ {
+ return new static($this->value->add($y->value));
+ }
+
+ /**
+ * Subtracts two BigIntegers.
+ *
+ * @param BigInteger $y
+ * @return BigInteger
+ */
+ function subtract(BigInteger $y)
+ {
+ return new static($this->value->subtract($y->value));
+ }
+
+ /**
+ * Multiplies two BigIntegers
+ *
+ * @param BigInteger $x
+ * @return BigInteger
+ */
+ public function multiply(BigInteger $x)
+ {
+ return new static($this->value->multiply($x->value));
+ }
+
+ /**
+ * Divides two BigIntegers.
+ *
+ * Returns an array whose first element contains the quotient and whose second element contains the
+ * "common residue". If the remainder would be positive, the "common residue" and the remainder are the
+ * same. If the remainder would be negative, the "common residue" is equal to the sum of the remainder
+ * and the divisor (basically, the "common residue" is the first positive modulo).
+ *
+ * Here's an example:
+ *
+ * divide($b);
+ *
+ * echo $quotient->toString(); // outputs 0
+ * echo "\r\n";
+ * echo $remainder->toString(); // outputs 10
+ * ?>
+ *
+ *
+ * @param BigInteger $y
+ * @return BigInteger[]
+ */
+ public function divide(BigInteger $y)
+ {
+ list($q, $r) = $this->value->divide($y->value);
+ return [
+ new static($q),
+ new static($r)
+ ];
+ }
+
+ /**
+ * Calculates modular inverses.
+ *
+ * Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses.
+ * @return BigInteger
+ * @param BigInteger $n
+ */
+ public function modInverse(BigInteger $n)
+ {
+ return new static($this->value->modInverse($n->value));
+ }
+
+ /**
+ * Calculates modular inverses.
+ *
+ * Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses.
+ * @return BigInteger[]
+ * @param BigInteger $n
+ */
+ public function extendedGCD(BigInteger $n)
+ {
+ extract($this->value->extendedGCD($n->value));
+ /**
+ * @var BigInteger $gcd
+ * @var BigInteger $x
+ * @var BigInteger $y
+ */
+ return [
+ 'gcd' => new static($gcd),
+ 'x' => new static($x),
+ 'y' => new static($y)
+ ];
+ }
+
+ /**
+ * Calculates the greatest common divisor
+ *
+ * Say you have 693 and 609. The GCD is 21.
+ *
+ * @param BigInteger $n
+ * @return BigInteger
+ */
+ public function gcd(BigInteger $n)
+ {
+ return new static($this->value->gcd($n->value));
+ }
+
+ /**
+ * Absolute value.
+ *
+ * @return BigInteger
+ * @access public
+ */
+ public function abs()
+ {
+ return new static($this->value->abs());
+ }
+
+ /**
+ * Set Precision
+ *
+ * Some bitwise operations give different results depending on the precision being used. Examples include left
+ * shift, not, and rotates.
+ *
+ * @param int $bits
+ */
+ public function setPrecision($bits)
+ {
+ $this->value->setPrecision($bits);
+ }
+
+ /**
+ * Get Precision
+ *
+ * Returns the precision if it exists, false if it doesn't
+ *
+ * @return int|bool
+ */
+ public function getPrecision()
+ {
+ return $this->value->getPrecision();
+ }
+
+ /**
+ * Serialize
+ *
+ * Will be called, automatically, when serialize() is called on a BigInteger object.
+ *
+ * phpseclib 1.0 serialized strings look like this:
+ * O:15:"Math_BigInteger":1:{s:3:"hex";s:18:"00ab54a98ceb1f0ad2";}
+ *
+ * phpseclib 3.0 serialized strings look like this:
+ * C:25:"phpseclib\Math\BigInteger":42:{a:1:{s:3:"hex";s:18:"00ab54a98ceb1f0ad2";}}
+ *
+ * @return string
+ */
+ public function serialize()
+ {
+ $val = ['hex' => $this->toHex(true)];
+ $precision = $this->value->getPrecision();
+ if ($precision > 0) {
+ $val['precision'] = $precision;
+ }
+ return serialize($val);
+ }
+
+ /**
+ * Serialize
+ *
+ * Will be called, automatically, when unserialize() is called on a BigInteger object.
+ *
+ * @param string $serialized
+ */
+ public function unserialize($serialized)
+ {
+ $r = unserialize($serialized);
+ $temp = new static($r['hex'], -16);
+ $this->value = $temp->value;
+ if (isset($r['precision'])) {
+ // recalculate $this->bitmask
+ $this->setPrecision($r['precision']);
+ }
+ }
+
+ /**
+ * Performs modular exponentiation.
+ *
+ * @param BigInteger $e
+ * @param BigInteger $n
+ * @return BigInteger
+ */
+ public function powMod(BigInteger $e, BigInteger $n)
+ {
+ return new static($this->value->powMod($e->value, $n->value));
+ }
+
+ /**
+ * Performs modular exponentiation.
+ *
+ * @param BigInteger $e
+ * @param BigInteger $n
+ * @return BigInteger
+ */
+ public function modPow(BigInteger $e, BigInteger $n)
+ {
+ return new static($this->value->modPow($e->value, $n->value));
+ }
+
+ /**
+ * Compares two numbers.
+ *
+ * Although one might think !$x->compare($y) means $x != $y, it, in fact, means the opposite. The reason for this is
+ * demonstrated thusly:
+ *
+ * $x > $y: $x->compare($y) > 0
+ * $x < $y: $x->compare($y) < 0
+ * $x == $y: $x->compare($y) == 0
+ *
+ * Note how the same comparison operator is used. If you want to test for equality, use $x->equals($y).
+ *
+ * {@internal Could return $this->subtract($x), but that's not as fast as what we do do.}
+ *
+ * @param BigInteger $y
+ * @return int in case < 0 if $this is less than $y; > 0 if $this is greater than $y, and 0 if they are equal.
+ * @access public
+ * @see self::equals()
+ */
+ public function compare(BigInteger $y)
+ {
+ return $this->value->compare($y->value);
+ }
+
+ /**
+ * Tests the equality of two numbers.
+ *
+ * If you need to see if one number is greater than or less than another number, use BigInteger::compare()
+ *
+ * @param BigInteger $x
+ * @return bool
+ */
+ public function equals(BigInteger $x)
+ {
+ return $this->value->equals($x->value);
+ }
+
+ /**
+ * Logical Not
+ *
+ * @return BigInteger
+ */
+ public function bitwise_not()
+ {
+ return new static($this->value->bitwise_not());
+ }
+
+ /**
+ * Logical And
+ *
+ * @param BigInteger $x
+ * @return BigInteger
+ */
+ public function bitwise_and(BigInteger $x)
+ {
+ return new static($this->value->bitwise_and($x->value));
+ }
+
+ /**
+ * Logical Or
+ *
+ * @param BigInteger $x
+ * @return BigInteger
+ */
+ public function bitwise_or(BigInteger $x)
+ {
+ return new static($this->value->bitwise_or($x->value));
+ }
+
+ /**
+ * Logical Exclusive Or
+ *
+ * @param BigInteger $x
+ * @return BigInteger
+ */
+ public function bitwise_xor(BigInteger $x)
+ {
+ return new static($this->value->bitwise_xor($x->value));
+ }
+
+ /**
+ * Logical Right Shift
+ *
+ * Shifts BigInteger's by $shift bits, effectively dividing by 2**$shift.
+ *
+ * @param int $shift
+ * @return BigInteger
+ */
+ public function bitwise_rightShift($shift)
+ {
+ return new static($this->value->bitwise_rightShift($shift));
+ }
+
+ /**
+ * Logical Left Shift
+ *
+ * Shifts BigInteger's by $shift bits, effectively multiplying by 2**$shift.
+ *
+ * @param int $shift
+ * @return BigInteger
+ */
+ public function bitwise_leftShift($shift)
+ {
+ return new static($this->value->bitwise_leftShift($shift));
+ }
+
+ /**
+ * Logical Left Rotate
+ *
+ * Instead of the top x bits being dropped they're appended to the shifted bit string.
+ *
+ * @param int $shift
+ * @return BigInteger
+ */
+ public function bitwise_leftRotate($shift)
+ {
+ return new static($this->value->bitwise_leftRotate($shift));
+ }
+
+ /**
+ * Logical Right Rotate
+ *
+ * Instead of the bottom x bits being dropped they're prepended to the shifted bit string.
+ *
+ * @param int $shift
+ * @return BigInteger
+ */
+ public function bitwise_rightRotate($shift)
+ {
+ return new static($this->value->bitwise_rightRotate($shift));
+ }
+
+ /**
+ * Returns the smallest and largest n-bit number
+ *
+ * @param int $bits
+ * @return BigInteger[]
+ */
+ public static function minMaxBits($bits)
+ {
+ self::initialize_static_variables();
+
+ $class = self::$mainEngine;
+ extract($class::minMaxBits($bits));
+ /** @var BigInteger $min
+ * @var BigInteger $max
+ */
+ return [
+ 'min' => new static($min),
+ 'max' => new static($max)
+ ];
+ }
+
+ /**
+ * Return the size of a BigInteger in bits
+ *
+ * @return int
+ */
+ public function getLength()
+ {
+ return $this->value->getLength();
+ }
+
+ /**
+ * Return the size of a BigInteger in bytes
+ *
+ * @return int
+ */
+ public function getLengthInBytes()
+ {
+ return $this->value->getLengthInBytes();
+ }
+
+ /**
+ * Generates a random number of a certain size
+ *
+ * Bit length is equal to $size
+ *
+ * @param int $size
+ * @return BigInteger
+ */
+ public static function random($size)
+ {
+ self::initialize_static_variables();
+
+ $class = self::$mainEngine;
+ return new static($class::random($size));
+ }
+
+ /**
+ * Generates a random prime number of a certain size
+ *
+ * Bit length is equal to $size
+ *
+ * @param int $size
+ * @return BigInteger
+ */
+ public static function randomPrime($size)
+ {
+ self::initialize_static_variables();
+
+ $class = self::$mainEngine;
+ return new static($class::randomPrime($size));
+ }
+
+ /**
+ * Generate a random prime number between a range
+ *
+ * If there's not a prime within the given range, false will be returned.
+ *
+ * @param BigInteger $min
+ * @param BigInteger $max
+ * @return false|BigInteger
+ */
+ public static function randomRangePrime(BigInteger $min, BigInteger $max)
+ {
+ $class = self::$mainEngine;
+ return new static($class::randomRangePrime($min->value, $max->value));
+ }
+
+ /**
+ * Generate a random number between a range
+ *
+ * Returns a random number between $min and $max where $min and $max
+ * can be defined using one of the two methods:
+ *
+ * BigInteger::randomRange($min, $max)
+ * BigInteger::randomRange($max, $min)
+ *
+ * @param BigInteger $min
+ * @param BigInteger $max
+ * @return BigInteger
+ */
+ public static function randomRange(BigInteger $min, BigInteger $max)
+ {
+ $class = self::$mainEngine;
+ return new static($class::randomRange($min->value, $max->value));
+ }
+
+ /**
+ * Checks a numer to see if it's prime
+ *
+ * Assuming the $t parameter is not set, this function has an error rate of 2**-80. The main motivation for the
+ * $t parameter is distributability. BigInteger::randomPrime() can be distributed across multiple pageloads
+ * on a website instead of just one.
+ *
+ * @param int|bool $t
+ * @return bool
+ */
+ public function isPrime($t = false)
+ {
+ return $this->value->isPrime($t);
+ }
+
+ /**
+ * Calculates the nth root of a biginteger.
+ *
+ * Returns the nth root of a positive biginteger, where n defaults to 2
+ *
+ * @param int $n optional
+ * @return BigInteger
+ */
+ public function root($n = 2)
+ {
+ return new static($this->value->root($n));
+ }
+
+ /**
+ * Performs exponentiation.
+ *
+ * @param BigInteger $n
+ * @return BigInteger
+ */
+ public function pow(BigInteger $n)
+ {
+ return new static($this->value->pow($n->value));
+ }
+
+ /**
+ * Return the minimum BigInteger between an arbitrary number of BigIntegers.
+ *
+ * @param BigInteger ...$nums
+ * @return BigInteger
+ */
+ public static function min(BigInteger ...$nums)
+ {
+ $class = self::$mainEngine;
+ $nums = array_map(function($num) { return $num->value; }, $nums);
+ return new static($class::min(...$nums));
+ }
+
+ /**
+ * Return the maximum BigInteger between an arbitrary number of BigIntegers.
+ *
+ * @param BigInteger ...$nums
+ * @return BigInteger
+ */
+ public static function max(BigInteger ...$nums)
+ {
+ $class = self::$mainEngine;
+ $nums = array_map(function($num) { return $num->value; }, $nums);
+ return new static($class::max(...$nums));
+ }
+
+ /**
+ * Tests BigInteger to see if it is between two integers, inclusive
+ *
+ * @param BigInteger $min
+ * @param BigInteger $max
+ * @return bool
+ */
+ public function between(BigInteger $min, BigInteger $max)
+ {
+ return $this->value->between($min->value, $max->value);
+ }
+
+ /**
+ * Clone
+ */
+ public function __clone()
+ {
+ $this->value = clone $this->value;
+ }
+
+ /**
+ * Is Odd?
+ *
+ * @return boolean
+ */
+ public function isOdd()
+ {
+ return $this->value->isOdd();
+ }
+
+ /**
+ * Tests if a bit is set
+ *
+ * @param int $x
+ * @return boolean
+ */
+ public function testBit($x)
+ {
+ return $this->value->testBit($x);
+ }
+
+ /**
+ * Is Negative?
+ *
+ * @return boolean
+ */
+ public function isNegative()
+ {
+ return $this->value->isNegative();
+ }
+
+ /**
+ * Negate
+ *
+ * Given $k, returns -$k
+ *
+ * @return BigInteger
+ */
+ public function negate()
+ {
+ return new static($this->value->negate());
+ }
+
+ /**
+ * Scan for 1 and right shift by that amount
+ *
+ * ie. $s = gmp_scan1($n, 0) and $r = gmp_div_q($n, gmp_pow(gmp_init('2'), $s));
+ *
+ * @param BigInteger $r
+ * @return int
+ */
+ public static function scan1divide(BigInteger $r)
+ {
+ $class = self::$mainEngine;
+ return $class::scan1divide($r->value);
+ }
+
+ /**
+ * Create Recurring Modulo Function
+ *
+ * Sometimes it may be desirable to do repeated modulos with the same number outside of
+ * modular exponentiation
+ *
+ * @return callable
+ */
+ public function createRecurringModuloFunction()
+ {
+ $func = $this->value->createRecurringModuloFunction();
+ return function(BigInteger $x) use ($func) {
+ return new static($func($x->value));
+ };
+ }
+
+ /**
+ * Bitwise Split
+ *
+ * Splits BigInteger's into chunks of $split bits
+ *
+ * @param int $split
+ * @return \phpseclib3\Math\BigInteger[]
+ */
+ public function bitwise_split($split)
+ {
+ return array_map(function($val) {
+ return new static($val);
+ }, $this->value->bitwise_split($split));
+ }
+}
\ No newline at end of file
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath.php
new file mode 100644
index 000000000..b97392432
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath.php
@@ -0,0 +1,742 @@
+
+ * @copyright 2017 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://pear.php.net/package/Math_BigInteger
+ */
+
+namespace phpseclib3\Math\BigInteger\Engines;
+
+use ParagonIE\ConstantTime\Hex;
+use phpseclib3\Exception\BadConfigurationException;
+
+/**
+ * BCMath Engine.
+ *
+ * @package BCMath
+ * @author Jim Wigginton
+ * @access public
+ */
+class BCMath extends Engine
+{
+ /**
+ * Can Bitwise operations be done fast?
+ *
+ * @see parent::bitwise_leftRotate()
+ * @see parent::bitwise_rightRotate()
+ * @access protected
+ */
+ const FAST_BITWISE = false;
+
+ /**
+ * Engine Directory
+ *
+ * @see parent::setModExpEngine
+ * @access protected
+ */
+ const ENGINE_DIR = 'BCMath';
+
+ /**
+ * Modular Exponentiation Engine
+ *
+ * @var string
+ */
+ protected static $modexpEngine;
+
+ /**
+ * Engine Validity Flag
+ *
+ * @var bool
+ */
+ protected static $isValidEngine;
+
+ /**
+ * BigInteger(0)
+ *
+ * @var \phpseclib3\Math\BigInteger\Engines\BCMath
+ */
+ protected static $zero;
+
+ /**
+ * BigInteger(1)
+ *
+ * @var \phpseclib3\Math\BigInteger\Engines\BCMath
+ */
+ protected static $one;
+
+ /**
+ * BigInteger(2)
+ *
+ * @var \phpseclib3\Math\BigInteger\Engines\BCMath
+ */
+ protected static $two;
+
+ /**
+ * Primes > 2 and < 1000
+ *
+ * @var array
+ */
+ protected static $primes;
+
+ /**
+ * Test for engine validity
+ *
+ * @see parent::__construct()
+ * @return bool
+ */
+ public static function isValidEngine()
+ {
+ return extension_loaded('bcmath');
+ }
+
+ /**
+ * Default constructor
+ *
+ * @param mixed $x integer Base-10 number or base-$base number if $base set.
+ * @param int $base
+ * @see parent::__construct()
+ * @return \phpseclib3\Math\BigInteger\Engines\BCMath
+ */
+ public function __construct($x = 0, $base = 10)
+ {
+ if (!isset(self::$isValidEngine)) {
+ self::$isValidEngine = self::isValidEngine();
+ }
+ if (!self::$isValidEngine) {
+ throw new BadConfigurationException('BCMath is not setup correctly on this system');
+ }
+
+ $this->value = '0';
+
+ parent::__construct($x, $base);
+ }
+
+ /**
+ * Initialize a BCMath BigInteger Engine instance
+ *
+ * @param int $base
+ * @see parent::__construct()
+ */
+ protected function initialize($base)
+ {
+ switch (abs($base)) {
+ case 256:
+ // round $len to the nearest 4
+ $len = (strlen($this->value) + 3) & 0xFFFFFFFC;
+
+ $x = str_pad($this->value, $len, chr(0), STR_PAD_LEFT);
+
+ $this->value = '0';
+ for ($i = 0; $i < $len; $i+= 4) {
+ $this->value = bcmul($this->value, '4294967296', 0); // 4294967296 == 2**32
+ $this->value = bcadd($this->value, 0x1000000 * ord($x[$i]) + ((ord($x[$i + 1]) << 16) | (ord($x[$i + 2]) << 8) | ord($x[$i + 3])), 0);
+ }
+
+ if ($this->is_negative) {
+ $this->value = '-' . $this->value;
+ }
+ break;
+ case 16:
+ $x = (strlen($this->value) & 1) ? '0' . $this->value : $this->value;
+ $temp = new self(Hex::decode($x), 256);
+ $this->value = $this->is_negative ? '-' . $temp->value : $temp->value;
+ $this->is_negative = false;
+ break;
+ case 10:
+ // explicitly casting $x to a string is necessary, here, since doing $x[0] on -1 yields different
+ // results then doing it on '-1' does (modInverse does $x[0])
+ $this->value = $this->value === '-' ? '0' : (string) $this->value;
+ }
+ }
+
+ /**
+ * Converts a BigInteger to a base-10 number.
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ if ($this->value === '0') {
+ return '0';
+ }
+
+ return ltrim($this->value, '0');
+ }
+
+ /**
+ * Converts a BigInteger to a byte string (eg. base-256).
+ *
+ * @param bool $twos_compliment
+ * @return string
+ */
+ function toBytes($twos_compliment = false)
+ {
+ if ($twos_compliment) {
+ return $this->toBytesHelper();
+ }
+
+ $value = '';
+ $current = $this->value;
+
+ if ($current[0] == '-') {
+ $current = substr($current, 1);
+ }
+
+ while (bccomp($current, '0', 0) > 0) {
+ $temp = bcmod($current, '16777216');
+ $value = chr($temp >> 16) . chr($temp >> 8) . chr($temp) . $value;
+ $current = bcdiv($current, '16777216', 0);
+ }
+
+ return $this->precision > 0 ?
+ substr(str_pad($value, $this->precision >> 3, chr(0), STR_PAD_LEFT), -($this->precision >> 3)) :
+ ltrim($value, chr(0));
+ }
+
+ /**
+ * Adds two BigIntegers.
+ *
+ * @param BCMath $y
+ * @return BCMath
+ */
+ public function add(BCMath $y)
+ {
+ $temp = new self();
+ $temp->value = bcadd($this->value, $y->value);
+
+ return $this->normalize($temp);
+ }
+
+ /**
+ * Subtracts two BigIntegers.
+ *
+ * @param BCMath $y
+ * @return BCMath
+ */
+ public function subtract(BCMath $y)
+ {
+ $temp = new self();
+ $temp->value = bcsub($this->value, $y->value);
+
+ return $this->normalize($temp);
+ }
+
+ /**
+ * Multiplies two BigIntegers.
+ *
+ * @param BCMath $x
+ * @return BCMath
+ */
+ public function multiply(BCMath $x)
+ {
+ $temp = new self();
+ $temp->value = bcmul($this->value, $x->value);
+
+ return $this->normalize($temp);
+ }
+
+ /**
+ * Divides two BigIntegers.
+ *
+ * Returns an array whose first element contains the quotient and whose second element contains the
+ * "common residue". If the remainder would be positive, the "common residue" and the remainder are the
+ * same. If the remainder would be negative, the "common residue" is equal to the sum of the remainder
+ * and the divisor (basically, the "common residue" is the first positive modulo).
+ *
+ * @param BCMath $y
+ * @return BCMath
+ */
+ public function divide(BCMath $y)
+ {
+ $quotient = new self();
+ $remainder = new self();
+
+ $quotient->value = bcdiv($this->value, $y->value, 0);
+ $remainder->value = bcmod($this->value, $y->value);
+
+ if ($remainder->value[0] == '-') {
+ $remainder->value = bcadd($remainder->value, $y->value[0] == '-' ? substr($y->value, 1) : $y->value, 0);
+ }
+
+ return [$this->normalize($quotient), $this->normalize($remainder)];
+ }
+
+ /**
+ * Calculates modular inverses.
+ *
+ * Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses.
+ *
+ * @return false|BCMath
+ * @param \phpseclib3\Math\BigInteger\Engines\BCMath $n
+ */
+ public function modInverse(BCMath $n)
+ {
+ return $this->modInverseHelper($n);
+ }
+
+ /**
+ * Calculates the greatest common divisor and Bezout's identity.
+ *
+ * Say you have 693 and 609. The GCD is 21. Bezout's identity states that there exist integers x and y such that
+ * 693*x + 609*y == 21. In point of fact, there are actually an infinite number of x and y combinations and which
+ * combination is returned is dependent upon which mode is in use. See
+ * {@link http://en.wikipedia.org/wiki/B%C3%A9zout%27s_identity Bezout's identity - Wikipedia} for more information.
+ *
+ * @param BCMath $n
+ * @return BCMath
+ */
+ public function extendedGCD(BCMath $n)
+ {
+ // it might be faster to use the binary xGCD algorithim here, as well, but (1) that algorithim works
+ // best when the base is a power of 2 and (2) i don't think it'd make much difference, anyway. as is,
+ // the basic extended euclidean algorithim is what we're using.
+
+ $u = $this->value;
+ $v = $n->value;
+
+ $a = '1';
+ $b = '0';
+ $c = '0';
+ $d = '1';
+
+ while (bccomp($v, '0', 0) != 0) {
+ $q = bcdiv($u, $v, 0);
+
+ $temp = $u;
+ $u = $v;
+ $v = bcsub($temp, bcmul($v, $q, 0), 0);
+
+ $temp = $a;
+ $a = $c;
+ $c = bcsub($temp, bcmul($a, $q, 0), 0);
+
+ $temp = $b;
+ $b = $d;
+ $d = bcsub($temp, bcmul($b, $q, 0), 0);
+ }
+
+ return [
+ 'gcd' => $this->normalize(new static($u)),
+ 'x' => $this->normalize(new static($a)),
+ 'y' => $this->normalize(new static($b))
+ ];
+ }
+
+ /**
+ * Calculates the greatest common divisor
+ *
+ * Say you have 693 and 609. The GCD is 21.
+ *
+ * @param BCMath $n
+ * @return BCMath
+ */
+ public function gcd(BCMath $n)
+ {
+ extract($this->extendedGCD($n));
+ /** @var BCMath $gcd */
+ return $gcd;
+ }
+
+ /**
+ * Absolute value.
+ *
+ * @return \phpseclib3\Math\BigInteger\Engines\BCMath
+ */
+ public function abs()
+ {
+ $temp = new static();
+ $temp->value = strlen($this->value) && $this->value[0] == '-' ?
+ substr($this->value, 1) :
+ $this->value;
+
+ return $temp;
+ }
+
+ /**
+ * Logical And
+ *
+ * @param BCMath $x
+ * @return BCMath
+ */
+ public function bitwise_and(BCMath $x)
+ {
+ return $this->bitwiseAndHelper($x);
+ }
+
+ /**
+ * Logical Or
+ *
+ * @param BCMath $x
+ * @return BCMath
+ */
+ public function bitwise_or(BCMath $x)
+ {
+ return $this->bitwiseXorHelper($x);
+ }
+
+ /**
+ * Logical Exclusive Or
+ *
+ * @param BCMath $x
+ * @return BCMath
+ */
+ public function bitwise_xor(BCMath $x)
+ {
+ return $this->bitwiseXorHelper($x);
+ }
+
+ /**
+ * Logical Right Shift
+ *
+ * Shifts BigInteger's by $shift bits, effectively dividing by 2**$shift.
+ *
+ * @param int $shift
+ * @return \phpseclib3\Math\BigInteger\Engines\BCMath
+ */
+ public function bitwise_rightShift($shift)
+ {
+ $temp = new static();
+ $temp->value = bcdiv($this->value, bcpow('2', $shift, 0), 0);
+
+ return $this->normalize($temp);
+ }
+
+ /**
+ * Logical Left Shift
+ *
+ * Shifts BigInteger's by $shift bits, effectively multiplying by 2**$shift.
+ *
+ * @param int $shift
+ * @return \phpseclib3\Math\BigInteger\Engines\BCMath
+ */
+ public function bitwise_leftShift($shift)
+ {
+ $temp = new static();
+ $temp->value = bcmul($this->value, bcpow('2', $shift, 0), 0);
+
+ return $this->normalize($temp);
+ }
+
+ /**
+ * Compares two numbers.
+ *
+ * Although one might think !$x->compare($y) means $x != $y, it, in fact, means the opposite. The reason for this is
+ * demonstrated thusly:
+ *
+ * $x > $y: $x->compare($y) > 0
+ * $x < $y: $x->compare($y) < 0
+ * $x == $y: $x->compare($y) == 0
+ *
+ * Note how the same comparison operator is used. If you want to test for equality, use $x->equals($y).
+ *
+ * {@internal Could return $this->subtract($x), but that's not as fast as what we do do.}
+ *
+ * @param BCMath $y
+ * @return int in case < 0 if $this is less than $y; > 0 if $this is greater than $y, and 0 if they are equal.
+ * @see self::equals()
+ */
+ public function compare(BCMath $y)
+ {
+ return bccomp($this->value, $y->value, 0);
+ }
+
+ /**
+ * Tests the equality of two numbers.
+ *
+ * If you need to see if one number is greater than or less than another number, use BigInteger::compare()
+ *
+ * @param BCMath $x
+ * @return bool
+ */
+ public function equals(BCMath $x)
+ {
+ return $this->value == $x->value;
+ }
+
+ /**
+ * Performs modular exponentiation.
+ *
+ * @param BCMath $e
+ * @param BCMath $n
+ * @return BCMath
+ */
+ public function modPow(BCMath $e, BCMath $n)
+ {
+ return $this->powModOuter($e, $n);
+ }
+
+ /**
+ * Performs modular exponentiation.
+ *
+ * Alias for modPow().
+ *
+ * @param BCMath $e
+ * @param BCMath $n
+ * @return BCMath
+ */
+ public function powMod(BCMath $e, BCMath $n)
+ {
+ return $this->powModOuter($e, $n);
+ }
+
+ /**
+ * Performs modular exponentiation.
+ *
+ * @param BCMath $e
+ * @param BCMath $n
+ * @return BCMath
+ */
+ protected function powModInner(BCMath $e, BCMath $n)
+ {
+ try {
+ $class = self::$modexpEngine;
+ return $class::powModHelper($this, $e, $n, static::class);
+ } catch (\Exception $err) {
+ return BCMath\DefaultEngine::powModHelper($this, $e, $n, static::class);
+ }
+ }
+
+ /**
+ * Normalize
+ *
+ * Removes leading zeros and truncates (if necessary) to maintain the appropriate precision
+ *
+ * @param BCMath $result
+ * @return BCMath
+ */
+ protected function normalize(BCMath $result)
+ {
+ unset($result->reduce);
+
+ $result->precision = $this->precision;
+ $result->bitmask = $this->bitmask;
+
+ if ($result->bitmask !== false) {
+ $result->value = bcmod($result->value, $result->bitmask->value);
+ }
+
+ return $result;
+ }
+
+ /**
+ * Generate a random prime number between a range
+ *
+ * If there's not a prime within the given range, false will be returned.
+ *
+ * @param BCMath $min
+ * @param BCMath $max
+ * @return false|BCMath
+ */
+ public static function randomRangePrime(BCMath $min, BCMath $max)
+ {
+ return self::randomRangePrimeOuter($min, $max);
+ }
+
+ /**
+ * Generate a random number between a range
+ *
+ * Returns a random number between $min and $max where $min and $max
+ * can be defined using one of the two methods:
+ *
+ * BigInteger::randomRange($min, $max)
+ * BigInteger::randomRange($max, $min)
+ *
+ * @param BCMath $min
+ * @param BCMath $max
+ * @return BCMath
+ */
+ public static function randomRange(BCMath $min, BCMath $max)
+ {
+ return self::randomRangeHelper($min, $max);
+ }
+
+ /**
+ * Make the current number odd
+ *
+ * If the current number is odd it'll be unchanged. If it's even, one will be added to it.
+ *
+ * @see self::randomPrime()
+ */
+ protected function make_odd()
+ {
+ if (!$this->isOdd()) {
+ $this->value = bcadd($this->value, '1');
+ }
+ }
+
+ /**
+ * Test the number against small primes.
+ *
+ * @see self::isPrime()
+ */
+ protected function testSmallPrimes()
+ {
+ if ($this->value === '1') {
+ return false;
+ }
+ if ($this->value === '2') {
+ return true;
+ }
+ if ($this->value[strlen($this->value) - 1] % 2 == 0) {
+ return false;
+ }
+
+ $value = $this->value;
+
+ foreach (self::$primes as $prime) {
+ $r = bcmod($this->value, $prime);
+ if ($r == '0') {
+ return $this->value == $prime;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Scan for 1 and right shift by that amount
+ *
+ * ie. $s = gmp_scan1($n, 0) and $r = gmp_div_q($n, gmp_pow(gmp_init('2'), $s));
+ *
+ * @see self::isPrime()
+ * @param BCMath $r
+ * @return int
+ */
+ public static function scan1divide(BCMath $r)
+ {
+ $r_value = &$r->value;
+ $s = 0;
+ // if $n was 1, $r would be 0 and this would be an infinite loop, hence our $this->equals(static::$one) check earlier
+ while ($r_value[strlen($r_value) - 1] % 2 == 0) {
+ $r_value = bcdiv($r_value, '2', 0);
+ ++$s;
+ }
+
+ return $s;
+ }
+
+ /**
+ * Performs exponentiation.
+ *
+ * @param BCMath $n
+ * @return BCMath
+ */
+ public function pow(BCMath $n)
+ {
+ $temp = new self();
+ $temp->value = bcpow($this->value, $n->value);
+
+ return $this->normalize($temp);
+ }
+
+ /**
+ * Return the minimum BigInteger between an arbitrary number of BigIntegers.
+ *
+ * @param BCMath ...$nums
+ * @return BCMath
+ */
+ public static function min(BCMath ...$nums)
+ {
+ return self::minHelper($nums);
+ }
+
+ /**
+ * Return the maximum BigInteger between an arbitrary number of BigIntegers.
+ *
+ * @param BCMath ...$nums
+ * @return BCMath
+ */
+ public static function max(BCMath ...$nums)
+ {
+ return self::maxHelper($nums);
+ }
+
+ /**
+ * Tests BigInteger to see if it is between two integers, inclusive
+ *
+ * @param BCMath $min
+ * @param BCMath $max
+ * @return bool
+ */
+ public function between(BCMath $min, BCMath $max)
+ {
+ return $this->compare($min) >= 0 && $this->compare($max) <= 0;
+ }
+
+ /**
+ * Set Bitmask
+ *
+ * @return Engine
+ * @param int $bits
+ * @see self::setPrecision()
+ */
+ protected static function setBitmask($bits)
+ {
+ $temp = parent::setBitmask($bits);
+ return $temp->add(static::$one);
+ }
+
+ /**
+ * Is Odd?
+ *
+ * @return boolean
+ */
+ public function isOdd()
+ {
+ return $this->value[strlen($this->value) - 1] % 2 == 1;
+ }
+
+ /**
+ * Tests if a bit is set
+ *
+ * @return boolean
+ */
+ public function testBit($x)
+ {
+ return bccomp(
+ bcmod($this->value, bcpow('2', $x + 1, 0), 0),
+ bcpow('2', $x, 0),
+ 0
+ ) >= 0;
+ }
+
+ /**
+ * Is Negative?
+ *
+ * @return boolean
+ */
+ public function isNegative()
+ {
+ return strlen($this->value) && $this->value[0] == '-';
+ }
+
+ /**
+ * Negate
+ *
+ * Given $k, returns -$k
+ *
+ * @return BCMath
+ */
+ public function negate()
+ {
+ $temp = clone $this;
+
+ if (!strlen($temp->value)) {
+ return $temp;
+ }
+
+ $temp->value = $temp->value[0] == '-' ?
+ substr($this->value, 1) :
+ '-' . $this->value;
+
+ return $temp;
+ }
+}
\ No newline at end of file
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Base.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Base.php
new file mode 100644
index 000000000..0e189b707
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Base.php
@@ -0,0 +1,116 @@
+
+ * @copyright 2017 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://pear.php.net/package/Math_BigInteger
+ */
+
+namespace phpseclib3\Math\BigInteger\Engines\BCMath;
+
+use phpseclib3\Math\BigInteger\Engines\BCMath;
+
+/**
+ * Sliding Window Exponentiation Engine
+ *
+ * @package PHP
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class Base extends BCMath
+{
+ /**
+ * Cache constants
+ *
+ * $cache[self::VARIABLE] tells us whether or not the cached data is still valid.
+ *
+ * @access private
+ */
+ const VARIABLE = 0;
+ /**
+ * $cache[self::DATA] contains the cached data.
+ *
+ * @access private
+ */
+ const DATA = 1;
+
+ /**
+ * Test for engine validity
+ *
+ * @return bool
+ */
+ public static function isValidEngine()
+ {
+ return static::class != __CLASS__;
+ }
+
+ /**
+ * Performs modular exponentiation.
+ *
+ * @param \phpseclib3\Math\BigInteger\Engines\BCMath $x
+ * @param \phpseclib3\Math\BigInteger\Engines\BCMath $e
+ * @param \phpseclib3\Math\BigInteger\Engines\BCMath $n
+ * @param string $class
+ * @return \phpseclib3\Math\BigInteger\Engines\BCMath
+ */
+ protected static function powModHelper(BCMath $x, BCMath $e, BCMath $n, $class)
+ {
+ if (empty($e->value)) {
+ $temp = new $class();
+ $temp->value = '1';
+ return $x->normalize($temp);
+ }
+
+ return $x->normalize(static::slidingWindow($x, $e, $n, $class));
+ }
+
+ /**
+ * Modular reduction preparation
+ *
+ * @param string $x
+ * @param string $n
+ * @param string $class
+ * @see self::slidingWindow()
+ * @return string
+ */
+ protected static function prepareReduce($x, $n, $class)
+ {
+ return static::reduce($x, $n);
+ }
+
+ /**
+ * Modular multiply
+ *
+ * @param string $x
+ * @param string $y
+ * @param string $n
+ * @param string $class
+ * @see self::slidingWindow()
+ * @return string
+ */
+ protected static function multiplyReduce($x, $y, $n, $class)
+ {
+ return static::reduce(bcmul($x, $y), $n);
+ }
+
+ /**
+ * Modular square
+ *
+ * @param string $x
+ * @param string $n
+ * @param string $class
+ * @see self::slidingWindow()
+ * @return string
+ */
+ protected static function squareReduce($x, $n, $class)
+ {
+ return static::reduce(bcmul($x, $x), $n);
+ }
+}
\ No newline at end of file
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/BuiltIn.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/BuiltIn.php
new file mode 100644
index 000000000..f312be15e
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/BuiltIn.php
@@ -0,0 +1,44 @@
+
+ * @copyright 2017 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://pear.php.net/package/Math_BigInteger
+ */
+
+namespace phpseclib3\Math\BigInteger\Engines\BCMath;
+
+use phpseclib3\Math\BigInteger\Engines\BCMath;
+
+/**
+ * Built-In BCMath Modular Exponentiation Engine
+ *
+ * @package BCMath
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class BuiltIn extends BCMath
+{
+ /**
+ * Performs modular exponentiation.
+ *
+ * @param BCMath $x
+ * @param BCMath $e
+ * @param BCMath $n
+ * @return BCMath
+ */
+ protected static function powModHelper(BCMath $x, BCMath $e, BCMath $n)
+ {
+ $temp = new BCMath();
+ $temp->value = bcpowmod($x->value, $e->value, $n->value);
+
+ return $x->normalize($temp);
+ }
+}
\ No newline at end of file
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/DefaultEngine.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/DefaultEngine.php
new file mode 100644
index 000000000..a6d175f5c
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/DefaultEngine.php
@@ -0,0 +1,29 @@
+
+ * @copyright 2017 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://pear.php.net/package/Math_BigInteger
+ */
+
+namespace phpseclib3\Math\BigInteger\Engines\BCMath;
+
+use phpseclib3\Math\BigInteger\Engines\BCMath\Reductions\Barrett;
+
+/**
+ * PHP Default Modular Exponentiation Engine
+ *
+ * @package PHP
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class DefaultEngine extends Barrett
+{
+}
\ No newline at end of file
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/OpenSSL.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/OpenSSL.php
new file mode 100644
index 000000000..df7c965d6
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/OpenSSL.php
@@ -0,0 +1,29 @@
+
+ * @copyright 2017 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://pear.php.net/package/Math_BigInteger
+ */
+
+namespace phpseclib3\Math\BigInteger\Engines\BCMath;
+
+use phpseclib3\Math\BigInteger\Engines\OpenSSL as Progenitor;
+
+/**
+ * OpenSSL Modular Exponentiation Engine
+ *
+ * @package BCMath
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class OpenSSL extends Progenitor
+{
+}
\ No newline at end of file
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/Barrett.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/Barrett.php
new file mode 100644
index 000000000..32b16dca6
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/Barrett.php
@@ -0,0 +1,193 @@
+
+ * @copyright 2017 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://pear.php.net/package/Math_BigInteger
+ */
+
+namespace phpseclib3\Math\BigInteger\Engines\BCMath\Reductions;
+
+use phpseclib3\Math\BigInteger\Engines\BCMath\Base;
+
+/**
+ * PHP Barrett Modular Exponentiation Engine
+ *
+ * @package PHP
+ * @author Jim Wigginton
+ * @access public
+ */
+abstract class Barrett extends Base
+{
+ /**
+ * Cache constants
+ *
+ * $cache[self::VARIABLE] tells us whether or not the cached data is still valid.
+ *
+ * @access private
+ */
+ const VARIABLE = 0;
+ /**
+ * $cache[self::DATA] contains the cached data.
+ *
+ * @access private
+ */
+ const DATA = 1;
+
+ /**
+ * Barrett Modular Reduction
+ *
+ * See {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=14 HAC 14.3.3} /
+ * {@link http://math.libtomcrypt.com/files/tommath.pdf#page=165 MPM 6.2.5} for more information. Modified slightly,
+ * so as not to require negative numbers (initially, this script didn't support negative numbers).
+ *
+ * Employs "folding", as described at
+ * {@link http://www.cosic.esat.kuleuven.be/publications/thesis-149.pdf#page=66 thesis-149.pdf#page=66}. To quote from
+ * it, "the idea [behind folding] is to find a value x' such that x (mod m) = x' (mod m), with x' being smaller than x."
+ *
+ * Unfortunately, the "Barrett Reduction with Folding" algorithm described in thesis-149.pdf is not, as written, all that
+ * usable on account of (1) its not using reasonable radix points as discussed in
+ * {@link http://math.libtomcrypt.com/files/tommath.pdf#page=162 MPM 6.2.2} and (2) the fact that, even with reasonable
+ * radix points, it only works when there are an even number of digits in the denominator. The reason for (2) is that
+ * (x >> 1) + (x >> 1) != x / 2 + x / 2. If x is even, they're the same, but if x is odd, they're not. See the in-line
+ * comments for details.
+ *
+ * @param string $n
+ * @param string $m
+ * @return array|string
+ */
+ protected static function reduce($n, $m)
+ {
+ static $cache = [
+ self::VARIABLE => [],
+ self::DATA => []
+ ];
+
+ $m_length = strlen($m);
+
+ if (strlen($n) > 2 * $m_length) {
+ return bcmod($n, $m);
+ }
+
+ // if (m.length >> 1) + 2 <= m.length then m is too small and n can't be reduced
+ if ($m_length < 5) {
+ return self::regularBarrett($n, $m);
+ }
+ // n = 2 * m.length
+
+ if (($key = array_search($m, $cache[self::VARIABLE])) === false) {
+ $key = count($cache[self::VARIABLE]);
+ $cache[self::VARIABLE][] = $m;
+
+ $lhs = '1' . str_repeat('0', $m_length + ($m_length >> 1));
+ $u = bcdiv($lhs, $m, 0);
+ $m1 = bcsub($lhs, bcmul($u, $m));
+
+ $cache[self::DATA][] = [
+ 'u' => $u, // m.length >> 1 (technically (m.length >> 1) + 1)
+ 'm1'=> $m1 // m.length
+ ];
+ } else {
+ extract($cache[self::DATA][$key]);
+ }
+
+ $cutoff = $m_length + ($m_length >> 1);
+
+ $lsd = substr($n, -$cutoff);
+ $msd = substr($n, 0, -$cutoff);
+
+ $temp = bcmul($msd, $m1); // m.length + (m.length >> 1)
+ $n = bcadd($lsd, $temp); // m.length + (m.length >> 1) + 1 (so basically we're adding two same length numbers)
+ //if ($m_length & 1) {
+ // return self::regularBarrett($n, $m);
+ //}
+
+ // (m.length + (m.length >> 1) + 1) - (m.length - 1) == (m.length >> 1) + 2
+ $temp = substr($n, 0, -$m_length + 1);
+ // if even: ((m.length >> 1) + 2) + (m.length >> 1) == m.length + 2
+ // if odd: ((m.length >> 1) + 2) + (m.length >> 1) == (m.length - 1) + 2 == m.length + 1
+ $temp = bcmul($temp, $u);
+ // if even: (m.length + 2) - ((m.length >> 1) + 1) = m.length - (m.length >> 1) + 1
+ // if odd: (m.length + 1) - ((m.length >> 1) + 1) = m.length - (m.length >> 1)
+ $temp = substr($temp, 0, -($m_length >> 1) - 1);
+ // if even: (m.length - (m.length >> 1) + 1) + m.length = 2 * m.length - (m.length >> 1) + 1
+ // if odd: (m.length - (m.length >> 1)) + m.length = 2 * m.length - (m.length >> 1)
+ $temp = bcmul($temp, $m);
+
+ // at this point, if m had an odd number of digits, we'd be subtracting a 2 * m.length - (m.length >> 1) digit
+ // number from a m.length + (m.length >> 1) + 1 digit number. ie. there'd be an extra digit and the while loop
+ // following this comment would loop a lot (hence our calling _regularBarrett() in that situation).
+
+ $result = bcsub($n, $temp);
+
+ //if (bccomp($result, '0') < 0) {
+ if ($result[0] == '-') {
+ $temp = '1' . str_repeat('0', $m_length + 1);
+ $result = bcadd($result, $temp);
+ }
+
+ while (bccomp($result, $m) >= 0) {
+ $result = bcsub($result, $m);
+ }
+
+ return $result;
+ }
+
+ /**
+ * (Regular) Barrett Modular Reduction
+ *
+ * For numbers with more than four digits BigInteger::_barrett() is faster. The difference between that and this
+ * is that this function does not fold the denominator into a smaller form.
+ *
+ * @param string $x
+ * @param string $n
+ * @return string
+ */
+ private static function regularBarrett($x, $n)
+ {
+ static $cache = [
+ self::VARIABLE => [],
+ self::DATA => []
+ ];
+
+ $n_length = strlen($n);
+
+ if (strlen($x) > 2 * $n_length) {
+ return bcmod($x, $n);
+ }
+
+ if (($key = array_search($n, $cache[self::VARIABLE])) === false) {
+ $key = count($cache[self::VARIABLE]);
+ $cache[self::VARIABLE][] = $n;
+ $lhs = '1' . str_repeat('0', 2 * $n_length);
+ $cache[self::DATA][] = bcdiv($lhs, $n, 0);
+ }
+
+ $temp = substr($x, 0, -$n_length + 1);
+ $temp = bcmul($temp, $cache[self::DATA][$key]);
+ $temp = substr($temp, 0, -$n_length - 1);
+
+ $r1 = substr($x, -$n_length - 1);
+ $r2 = substr(bcmul($temp, $n), -$n_length - 1);
+ $result = bcsub($r1, $r2);
+
+ //if (bccomp($result, '0') < 0) {
+ if ($result[0] == '-') {
+ $q = '1' . str_repeat('0', $n_length + 1);
+ $result = bcadd($result, $q);
+ }
+
+ while (bccomp($result, $n) >= 0) {
+ $result = bcsub($result, $n);
+ }
+
+ return $result;
+ }
+}
\ No newline at end of file
diff --git a/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/EvalBarrett.php b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/EvalBarrett.php
new file mode 100644
index 000000000..27530ec7d
--- /dev/null
+++ b/lam/lib/3rdParty/composer/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/EvalBarrett.php
@@ -0,0 +1,117 @@
+
+ * @copyright 2017 Jim Wigginton
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://pear.php.net/package/Math_BigInteger
+ */
+
+namespace phpseclib3\Math\BigInteger\Engines\BCMath\Reductions;
+
+use phpseclib3\Math\BigInteger\Engines\BCMath\Base;
+use phpseclib3\Math\BigInteger\Engines\BCMath;
+
+/**
+ * PHP Barrett Modular Exponentiation Engine
+ *
+ * @package PHP
+ * @author Jim Wigginton