Update website
This commit is contained in:
parent
4413528994
commit
1d90fbf296
6865 changed files with 1091082 additions and 0 deletions
61
admin/phpMyAdmin/vendor/fgrosse/phpasn1/CHANGELOG.md
vendored
Normal file
61
admin/phpMyAdmin/vendor/fgrosse/phpasn1/CHANGELOG.md
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
#### v2.5.0 (2022-12)
|
||||
* Support PHP 8.2 [#99](https://github.com/fgrosse/PHPASN1/pull/99)
|
||||
* PHP 8 compatibility fix for DateTime::getLastErrors [#98](https://github.com/fgrosse/PHPASN1/pull/98)
|
||||
* Support more OIDs [#95](https://github.com/fgrosse/PHPASN1/pull/95)
|
||||
* FINAL RELEASE. Library is now no longer actively maintained and marked as archived on GitHub
|
||||
|
||||
#### v2.4.0 (2021-12)
|
||||
* Drop support for PHP 7.0 [#89](https://github.com/fgrosse/PHPASN1/pull/89)
|
||||
|
||||
#### v2.3.1 (2021-12)
|
||||
* Add `#[\ReturnTypeWillChange]` attributes for PHP 8.1 compatibility [#87](https://github.com/fgrosse/PHPASN1/pull/87)
|
||||
|
||||
#### v2.3.0 (2021-04)
|
||||
* Allow creating an unsigned CSR and adding the signature later [#82](https://github.com/fgrosse/PHPASN1/pull/82)
|
||||
|
||||
#### v2.2.0 (2020-08)
|
||||
* support polyfills for bcmath and gmp, and add a composer.json
|
||||
suggestion for the `phpseclib/bcmath_polyfill` for servers unable
|
||||
to install PHP the gmp or bcmath extensions.
|
||||
|
||||
#### v.2.1.1 & &v.2.0.2 (2018-12)
|
||||
* add stricter validation around some structures, highlighed
|
||||
by wycheproof test suite
|
||||
|
||||
#### v.2.1.0 (2018-03)
|
||||
* add support for `bcmath` extension (making `gmp` optional) [#68](https://github.com/fgrosse/PHPASN1/pull/68)
|
||||
|
||||
#### v.2.0.1 & v.1.5.3 (2017-12)
|
||||
* add .gitattributes file to prevent examples and tests to be installed via composer when --prefer-dist was set
|
||||
|
||||
#### v.2.0.0 (2017-08)
|
||||
* rename `FG\ASN1\Object` to `FG\ASN1\ASNObject` because `Object` is a special class name in the next major PHP release
|
||||
- when you upgrade you have to adapt all corresponding `use` and `extends` statements as well as type hints and all
|
||||
usages of `Object::fromBinary(…)`.
|
||||
* generally drop PHP 5.6 support
|
||||
|
||||
#### v.1.5.2 (2016-10-29)
|
||||
* allow empty octet strings
|
||||
|
||||
#### v.1.5.1 (2015-10-02)
|
||||
* add keywords to composer.json (this is a version on its own so the keywords are found on a stable version at packagist.org)
|
||||
|
||||
#### v.1.5.0 (2015-10-30)
|
||||
* fix a bug that would prevent you from decoding context specific tags on multiple objects [#57](https://github.com/fgrosse/PHPASN1/issues/57)
|
||||
- `ExplicitlyTaggedObject::__construct` does now accept multiple objects to be tagged with a single tag
|
||||
- `ExplicitlyTaggedObject::getContent` will now always return an array (even if only one object is tagged)
|
||||
|
||||
#### v.1.4.2 (2015-09-29)
|
||||
* fix a bug that would prevent you from decoding empty tagged objects [#57](https://github.com/fgrosse/PHPASN1/issues/57)
|
||||
|
||||
#### v.1.4.1
|
||||
* improve exception messages and general error handling [#55](https ://github.com/fgrosse/PHPASN1/pull/55)
|
||||
|
||||
#### v.1.4.0
|
||||
* **require PHP 5.6**
|
||||
* support big integers (closes #1 and #37)
|
||||
* enforce one code style via [styleci.io][9]
|
||||
* track code coverage via [coveralls.io][10]
|
||||
* replace obsolete `FG\ASN1\Exception\GeneralException` with `\Exception`
|
||||
* `Construct` (`Sequence`, `Set`) does now implement `ArrayAccess`, `Countable` and `Iterator` so its easier to use
|
||||
* add [`TemplateParser`][11]
|
19
admin/phpMyAdmin/vendor/fgrosse/phpasn1/LICENSE
vendored
Normal file
19
admin/phpMyAdmin/vendor/fgrosse/phpasn1/LICENSE
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 2012-2015 Friedrich Große <friedrich.grosse@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
169
admin/phpMyAdmin/vendor/fgrosse/phpasn1/README.md
vendored
Normal file
169
admin/phpMyAdmin/vendor/fgrosse/phpasn1/README.md
vendored
Normal file
|
@ -0,0 +1,169 @@
|
|||
PHPASN1
|
||||
=======
|
||||
|
||||
[](https://github.com/fgrosse/PHPASN1/actions/workflows/phpunit.yml)
|
||||
[](https://travis-ci.org/fgrosse/PHPASN1)
|
||||
[](https://coveralls.io/github/fgrosse/PHPASN1?branch=master)
|
||||
|
||||
[](https://packagist.org/packages/fgrosse/phpasn1)
|
||||
[](https://packagist.org/packages/fgrosse/phpasn1)
|
||||
[](https://packagist.org/packages/fgrosse/phpasn1)
|
||||
[](https://packagist.org/packages/fgrosse/phpasn1)
|
||||
|
||||
---
|
||||
|
||||
<h2><span style="color:red">Notice: This library is no longer actively maintained!</span></h2>
|
||||
If you are currently using PHPASN1, this might not be an immediate problem for you, since this library was always rather stable.
|
||||
|
||||
However, you are advised to migrate to alternative packages to ensure that your applications remain functional also with newer PHP versions.
|
||||
|
||||
---
|
||||
|
||||
A PHP Framework that allows you to encode and decode arbitrary [ASN.1][3] structures
|
||||
using the [ITU-T X.690 Encoding Rules][4].
|
||||
This encoding is very frequently used in [X.509 PKI environments][5] or the communication between heterogeneous computer systems.
|
||||
|
||||
The API allows you to encode ASN.1 structures to create binary data such as certificate
|
||||
signing requests (CSR), X.509 certificates or certificate revocation lists (CRL).
|
||||
PHPASN1 can also read [BER encoded][6] binary data into separate PHP objects that can be manipulated by the user and reencoded afterwards.
|
||||
|
||||
The **changelog** can now be found at [CHANGELOG.md](CHANGELOG.md).
|
||||
|
||||
## Dependencies
|
||||
|
||||
PHPASN1 requires at least `PHP 7.0` and either the `gmp` or `bcmath` extension.
|
||||
Support for older PHP versions (i.e. PHP 5.6) was dropped starting with `v2.0`.
|
||||
If you must use an outdated PHP version consider using [PHPASN v1.5][13].
|
||||
|
||||
For the loading of object identifier names directly from the web [curl][7] is used.
|
||||
|
||||
## Installation
|
||||
|
||||
The preferred way to install this library is to rely on [Composer][2]:
|
||||
|
||||
```bash
|
||||
$ composer require fgrosse/phpasn1
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Encoding ASN.1 Structures
|
||||
|
||||
PHPASN1 offers you a class for each of the implemented ASN.1 universal types.
|
||||
The constructors should be pretty self explanatory so you should have no big trouble getting started.
|
||||
All data will be encoded using [DER encoding][8]
|
||||
|
||||
```php
|
||||
use FG\ASN1\OID;
|
||||
use FG\ASN1\Universal\Integer;
|
||||
use FG\ASN1\Universal\Boolean;
|
||||
use FG\ASN1\Universal\Enumerated;
|
||||
use FG\ASN1\Universal\IA5String;
|
||||
use FG\ASN1\Universal\ObjectIdentifier;
|
||||
use FG\ASN1\Universal\PrintableString;
|
||||
use FG\ASN1\Universal\Sequence;
|
||||
use FG\ASN1\Universal\Set;
|
||||
use FG\ASN1\Universal\NullObject;
|
||||
|
||||
$integer = new Integer(123456);
|
||||
$boolean = new Boolean(true);
|
||||
$enum = new Enumerated(1);
|
||||
$ia5String = new IA5String('Hello world');
|
||||
|
||||
$asnNull = new NullObject();
|
||||
$objectIdentifier1 = new ObjectIdentifier('1.2.250.1.16.9');
|
||||
$objectIdentifier2 = new ObjectIdentifier(OID::RSA_ENCRYPTION);
|
||||
$printableString = new PrintableString('Foo bar');
|
||||
|
||||
$sequence = new Sequence($integer, $boolean, $enum, $ia5String);
|
||||
$set = new Set($sequence, $asnNull, $objectIdentifier1, $objectIdentifier2, $printableString);
|
||||
|
||||
$myBinary = $sequence->getBinary();
|
||||
$myBinary .= $set->getBinary();
|
||||
|
||||
echo base64_encode($myBinary);
|
||||
```
|
||||
|
||||
|
||||
### Decoding binary data
|
||||
|
||||
Decoding BER encoded binary data is just as easy as encoding it:
|
||||
|
||||
```php
|
||||
use FG\ASN1\ASNObject;
|
||||
|
||||
$base64String = ...
|
||||
$binaryData = base64_decode($base64String);
|
||||
$asnObject = ASNObject::fromBinary($binaryData);
|
||||
|
||||
|
||||
// do stuff
|
||||
```
|
||||
|
||||
If you already know exactly how your expected data should look like you can use the `FG\ASN1\TemplateParser`:
|
||||
|
||||
```php
|
||||
use FG\ASN1\TemplateParser;
|
||||
|
||||
// first define your template
|
||||
$template = [
|
||||
Identifier::SEQUENCE => [
|
||||
Identifier::SET => [
|
||||
Identifier::OBJECT_IDENTIFIER,
|
||||
Identifier::SEQUENCE => [
|
||||
Identifier::INTEGER,
|
||||
Identifier::BITSTRING,
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
// if your binary data is not matching the template you provided this will throw an `\Exception`:
|
||||
$parser = new TemplateParser();
|
||||
$object = $parser->parseBinary($data, $template);
|
||||
|
||||
// there is also a convenience function if you parse binary data from base64:
|
||||
$object = $parser->parseBase64($data, $template);
|
||||
```
|
||||
|
||||
You can use this function to make sure your data has exactly the format you are expecting.
|
||||
|
||||
### Navigating decoded data
|
||||
|
||||
All constructed classes (i.e. `Sequence` and `Set`) can be navigated by array access or using an iterator.
|
||||
You can find examples
|
||||
[here](https://github.com/fgrosse/PHPASN1/blob/f6442cadda9d36f3518c737e32f28300a588b777/tests/ASN1/Universal/SequenceTest.php#L148-148),
|
||||
[here](https://github.com/fgrosse/PHPASN1/blob/f6442cadda9d36f3518c737e32f28300a588b777/tests/ASN1/Universal/SequenceTest.php#L121) and
|
||||
[here](https://github.com/fgrosse/PHPASN1/blob/f6442cadda9d36f3518c737e32f28300a588b777/tests/ASN1/TemplateParserTest.php#L45).
|
||||
|
||||
|
||||
### Give me more examples!
|
||||
|
||||
To see some example usage of the API classes or some generated output check out the [examples](https://github.com/fgrosse/PHPASN1/tree/master/examples).
|
||||
|
||||
|
||||
### How do I contribute?
|
||||
|
||||
This project is no longer maintained and thus does not accept any new contributions.
|
||||
|
||||
### Thanks
|
||||
|
||||
To [all contributors][1] so far!
|
||||
|
||||
## License
|
||||
|
||||
This library is distributed under the [MIT License](LICENSE).
|
||||
|
||||
[1]: https://github.com/fgrosse/PHPASN1/graphs/contributors
|
||||
[2]: https://getcomposer.org/
|
||||
[3]: http://www.itu.int/ITU-T/asn1/
|
||||
[4]: http://www.itu.int/ITU-T/recommendations/rec.aspx?rec=x.690
|
||||
[5]: http://en.wikipedia.org/wiki/X.509
|
||||
[6]: http://en.wikipedia.org/wiki/X.690#BER_encoding
|
||||
[7]: http://php.net/manual/en/book.curl.php
|
||||
[8]: http://en.wikipedia.org/wiki/X.690#DER_encoding
|
||||
[9]: https://styleci.io
|
||||
[10]: https://coveralls.io/github/fgrosse/PHPASN1
|
||||
[11]: https://github.com/fgrosse/PHPASN1/blob/master/tests/ASN1/TemplateParserTest.php#L16
|
||||
[12]: https://groups.google.com/d/forum/phpasn1
|
||||
[13]: https://packagist.org/packages/fgrosse/phpasn1#1.5.2
|
49
admin/phpMyAdmin/vendor/fgrosse/phpasn1/composer.json
vendored
Normal file
49
admin/phpMyAdmin/vendor/fgrosse/phpasn1/composer.json
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
{
|
||||
"name": "fgrosse/phpasn1",
|
||||
"description": "A PHP Framework that allows you to encode and decode arbitrary ASN.1 structures using the ITU-T X.690 Encoding Rules.",
|
||||
"type": "library",
|
||||
"homepage": "https://github.com/FGrosse/PHPASN1",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Friedrich Große",
|
||||
"email": "friedrich.grosse@gmail.com",
|
||||
"homepage": "https://github.com/FGrosse",
|
||||
"role": "Author"
|
||||
},
|
||||
{
|
||||
"name": "All contributors",
|
||||
"homepage": "https://github.com/FGrosse/PHPASN1/contributors"
|
||||
}
|
||||
],
|
||||
"keywords": [ "x690", "x.690", "x.509", "x509", "asn1", "asn.1", "ber", "der", "binary", "encoding", "decoding" ],
|
||||
|
||||
"require": {
|
||||
"php": "^7.1 || ^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
|
||||
"php-coveralls/php-coveralls": "~2.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-gmp": "GMP is the preferred extension for big integer calculations",
|
||||
"ext-bcmath": "BCmath is the fallback extension for big integer calculations",
|
||||
"phpseclib/bcmath_compat": "BCmath polyfill for servers where neither GMP nor BCmath is available",
|
||||
"ext-curl": "For loading OID information from the web if they have not bee defined statically"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"FG\\": "lib/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"FG\\Test\\": "tests/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.0.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
355
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/ASNObject.php
vendored
Normal file
355
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/ASNObject.php
vendored
Normal file
|
@ -0,0 +1,355 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1;
|
||||
|
||||
use FG\ASN1\Exception\ParserException;
|
||||
use FG\ASN1\Universal\BitString;
|
||||
use FG\ASN1\Universal\Boolean;
|
||||
use FG\ASN1\Universal\Enumerated;
|
||||
use FG\ASN1\Universal\GeneralizedTime;
|
||||
use FG\ASN1\Universal\Integer;
|
||||
use FG\ASN1\Universal\NullObject;
|
||||
use FG\ASN1\Universal\ObjectIdentifier;
|
||||
use FG\ASN1\Universal\RelativeObjectIdentifier;
|
||||
use FG\ASN1\Universal\OctetString;
|
||||
use FG\ASN1\Universal\Sequence;
|
||||
use FG\ASN1\Universal\Set;
|
||||
use FG\ASN1\Universal\UTCTime;
|
||||
use FG\ASN1\Universal\IA5String;
|
||||
use FG\ASN1\Universal\PrintableString;
|
||||
use FG\ASN1\Universal\NumericString;
|
||||
use FG\ASN1\Universal\UTF8String;
|
||||
use FG\ASN1\Universal\UniversalString;
|
||||
use FG\ASN1\Universal\CharacterString;
|
||||
use FG\ASN1\Universal\GeneralString;
|
||||
use FG\ASN1\Universal\VisibleString;
|
||||
use FG\ASN1\Universal\GraphicString;
|
||||
use FG\ASN1\Universal\BMPString;
|
||||
use FG\ASN1\Universal\T61String;
|
||||
use FG\ASN1\Universal\ObjectDescriptor;
|
||||
use FG\Utility\BigInteger;
|
||||
use LogicException;
|
||||
|
||||
/**
|
||||
* Class ASNObject is the base class for all concrete ASN.1 objects.
|
||||
*/
|
||||
abstract class ASNObject implements Parsable
|
||||
{
|
||||
private $contentLength;
|
||||
private $nrOfLengthOctets;
|
||||
|
||||
/**
|
||||
* Must return the number of octets of the content part.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
abstract protected function calculateContentLength();
|
||||
|
||||
/**
|
||||
* Encode the object using DER encoding.
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/X.690#DER_encoding
|
||||
*
|
||||
* @return string the binary representation of an objects value
|
||||
*/
|
||||
abstract protected function getEncodedValue();
|
||||
|
||||
/**
|
||||
* Return the content of this object in a non encoded form.
|
||||
* This can be used to print the value in human readable form.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
abstract public function getContent();
|
||||
|
||||
/**
|
||||
* Return the object type octet.
|
||||
* This should use the class constants of Identifier.
|
||||
*
|
||||
* @see Identifier
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
abstract public function getType();
|
||||
|
||||
/**
|
||||
* Returns all identifier octets. If an inheriting class models a tag with
|
||||
* the long form identifier format, it MUST reimplement this method to
|
||||
* return all octets of the identifier.
|
||||
*
|
||||
* @throws LogicException If the identifier format is long form
|
||||
*
|
||||
* @return string Identifier as a set of octets
|
||||
*/
|
||||
public function getIdentifier()
|
||||
{
|
||||
$firstOctet = $this->getType();
|
||||
|
||||
if (Identifier::isLongForm($firstOctet)) {
|
||||
throw new LogicException(sprintf('Identifier of %s uses the long form and must therefor override "ASNObject::getIdentifier()".', get_class($this)));
|
||||
}
|
||||
|
||||
return chr($firstOctet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode this object using DER encoding.
|
||||
*
|
||||
* @return string the full binary representation of the complete object
|
||||
*/
|
||||
public function getBinary()
|
||||
{
|
||||
$result = $this->getIdentifier();
|
||||
$result .= $this->createLengthPart();
|
||||
$result .= $this->getEncodedValue();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function createLengthPart()
|
||||
{
|
||||
$contentLength = $this->getContentLength();
|
||||
$nrOfLengthOctets = $this->getNumberOfLengthOctets($contentLength);
|
||||
|
||||
if ($nrOfLengthOctets == 1) {
|
||||
return chr($contentLength);
|
||||
} else {
|
||||
// the first length octet determines the number subsequent length octets
|
||||
$lengthOctets = chr(0x80 | ($nrOfLengthOctets - 1));
|
||||
for ($shiftLength = 8 * ($nrOfLengthOctets - 2); $shiftLength >= 0; $shiftLength -= 8) {
|
||||
$lengthOctets .= chr($contentLength >> $shiftLength);
|
||||
}
|
||||
|
||||
return $lengthOctets;
|
||||
}
|
||||
}
|
||||
|
||||
protected function getNumberOfLengthOctets($contentLength = null)
|
||||
{
|
||||
if (!isset($this->nrOfLengthOctets)) {
|
||||
if ($contentLength == null) {
|
||||
$contentLength = $this->getContentLength();
|
||||
}
|
||||
|
||||
$this->nrOfLengthOctets = 1;
|
||||
if ($contentLength > 127) {
|
||||
do { // long form
|
||||
$this->nrOfLengthOctets++;
|
||||
$contentLength = $contentLength >> 8;
|
||||
} while ($contentLength > 0);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->nrOfLengthOctets;
|
||||
}
|
||||
|
||||
protected function getContentLength()
|
||||
{
|
||||
if (!isset($this->contentLength)) {
|
||||
$this->contentLength = $this->calculateContentLength();
|
||||
}
|
||||
|
||||
return $this->contentLength;
|
||||
}
|
||||
|
||||
protected function setContentLength($newContentLength)
|
||||
{
|
||||
$this->contentLength = $newContentLength;
|
||||
$this->getNumberOfLengthOctets($newContentLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the length of the whole object (including the identifier and length octets).
|
||||
*/
|
||||
public function getObjectLength()
|
||||
{
|
||||
$nrOfIdentifierOctets = strlen($this->getIdentifier());
|
||||
$contentLength = $this->getContentLength();
|
||||
$nrOfLengthOctets = $this->getNumberOfLengthOctets($contentLength);
|
||||
|
||||
return $nrOfIdentifierOctets + $nrOfLengthOctets + $contentLength;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->getContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the ASN.1 Type of this object.
|
||||
*
|
||||
* @see Identifier::getName()
|
||||
*/
|
||||
public function getTypeName()
|
||||
{
|
||||
return Identifier::getName($this->getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $binaryData
|
||||
* @param int $offsetIndex
|
||||
*
|
||||
* @throws ParserException
|
||||
*
|
||||
* @return \FG\ASN1\ASNObject
|
||||
*/
|
||||
public static function fromBinary(&$binaryData, &$offsetIndex = 0)
|
||||
{
|
||||
if (strlen($binaryData) <= $offsetIndex) {
|
||||
throw new ParserException('Can not parse binary from data: Offset index larger than input size', $offsetIndex);
|
||||
}
|
||||
|
||||
$identifierOctet = ord($binaryData[$offsetIndex]);
|
||||
if (Identifier::isContextSpecificClass($identifierOctet) && Identifier::isConstructed($identifierOctet)) {
|
||||
return ExplicitlyTaggedObject::fromBinary($binaryData, $offsetIndex);
|
||||
}
|
||||
|
||||
switch ($identifierOctet) {
|
||||
case Identifier::BITSTRING:
|
||||
return BitString::fromBinary($binaryData, $offsetIndex);
|
||||
case Identifier::BOOLEAN:
|
||||
return Boolean::fromBinary($binaryData, $offsetIndex);
|
||||
case Identifier::ENUMERATED:
|
||||
return Enumerated::fromBinary($binaryData, $offsetIndex);
|
||||
case Identifier::INTEGER:
|
||||
return Integer::fromBinary($binaryData, $offsetIndex);
|
||||
case Identifier::NULL:
|
||||
return NullObject::fromBinary($binaryData, $offsetIndex);
|
||||
case Identifier::OBJECT_IDENTIFIER:
|
||||
return ObjectIdentifier::fromBinary($binaryData, $offsetIndex);
|
||||
case Identifier::RELATIVE_OID:
|
||||
return RelativeObjectIdentifier::fromBinary($binaryData, $offsetIndex);
|
||||
case Identifier::OCTETSTRING:
|
||||
return OctetString::fromBinary($binaryData, $offsetIndex);
|
||||
case Identifier::SEQUENCE:
|
||||
return Sequence::fromBinary($binaryData, $offsetIndex);
|
||||
case Identifier::SET:
|
||||
return Set::fromBinary($binaryData, $offsetIndex);
|
||||
case Identifier::UTC_TIME:
|
||||
return UTCTime::fromBinary($binaryData, $offsetIndex);
|
||||
case Identifier::GENERALIZED_TIME:
|
||||
return GeneralizedTime::fromBinary($binaryData, $offsetIndex);
|
||||
case Identifier::IA5_STRING:
|
||||
return IA5String::fromBinary($binaryData, $offsetIndex);
|
||||
case Identifier::PRINTABLE_STRING:
|
||||
return PrintableString::fromBinary($binaryData, $offsetIndex);
|
||||
case Identifier::NUMERIC_STRING:
|
||||
return NumericString::fromBinary($binaryData, $offsetIndex);
|
||||
case Identifier::UTF8_STRING:
|
||||
return UTF8String::fromBinary($binaryData, $offsetIndex);
|
||||
case Identifier::UNIVERSAL_STRING:
|
||||
return UniversalString::fromBinary($binaryData, $offsetIndex);
|
||||
case Identifier::CHARACTER_STRING:
|
||||
return CharacterString::fromBinary($binaryData, $offsetIndex);
|
||||
case Identifier::GENERAL_STRING:
|
||||
return GeneralString::fromBinary($binaryData, $offsetIndex);
|
||||
case Identifier::VISIBLE_STRING:
|
||||
return VisibleString::fromBinary($binaryData, $offsetIndex);
|
||||
case Identifier::GRAPHIC_STRING:
|
||||
return GraphicString::fromBinary($binaryData, $offsetIndex);
|
||||
case Identifier::BMP_STRING:
|
||||
return BMPString::fromBinary($binaryData, $offsetIndex);
|
||||
case Identifier::T61_STRING:
|
||||
return T61String::fromBinary($binaryData, $offsetIndex);
|
||||
case Identifier::OBJECT_DESCRIPTOR:
|
||||
return ObjectDescriptor::fromBinary($binaryData, $offsetIndex);
|
||||
default:
|
||||
// At this point the identifier may be >1 byte.
|
||||
if (Identifier::isConstructed($identifierOctet)) {
|
||||
return new UnknownConstructedObject($binaryData, $offsetIndex);
|
||||
} else {
|
||||
$identifier = self::parseBinaryIdentifier($binaryData, $offsetIndex);
|
||||
$lengthOfUnknownObject = self::parseContentLength($binaryData, $offsetIndex);
|
||||
$offsetIndex += $lengthOfUnknownObject;
|
||||
|
||||
return new UnknownObject($identifier, $lengthOfUnknownObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static function parseIdentifier($identifierOctet, $expectedIdentifier, $offsetForExceptionHandling)
|
||||
{
|
||||
if (is_string($identifierOctet) || is_numeric($identifierOctet) == false) {
|
||||
$identifierOctet = ord($identifierOctet);
|
||||
}
|
||||
|
||||
if ($identifierOctet != $expectedIdentifier) {
|
||||
$message = 'Can not create an '.Identifier::getName($expectedIdentifier).' from an '.Identifier::getName($identifierOctet);
|
||||
throw new ParserException($message, $offsetForExceptionHandling);
|
||||
}
|
||||
}
|
||||
|
||||
protected static function parseBinaryIdentifier($binaryData, &$offsetIndex)
|
||||
{
|
||||
if (strlen($binaryData) <= $offsetIndex) {
|
||||
throw new ParserException('Can not parse identifier from data: Offset index larger than input size', $offsetIndex);
|
||||
}
|
||||
|
||||
$identifier = $binaryData[$offsetIndex++];
|
||||
|
||||
if (Identifier::isLongForm(ord($identifier)) == false) {
|
||||
return $identifier;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
if (strlen($binaryData) <= $offsetIndex) {
|
||||
throw new ParserException('Can not parse identifier (long form) from data: Offset index larger than input size', $offsetIndex);
|
||||
}
|
||||
$nextOctet = $binaryData[$offsetIndex++];
|
||||
$identifier .= $nextOctet;
|
||||
|
||||
if ((ord($nextOctet) & 0x80) === 0) {
|
||||
// the most significant bit is 0 to we have reached the end of the identifier
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $identifier;
|
||||
}
|
||||
|
||||
protected static function parseContentLength(&$binaryData, &$offsetIndex, $minimumLength = 0)
|
||||
{
|
||||
if (strlen($binaryData) <= $offsetIndex) {
|
||||
throw new ParserException('Can not parse content length from data: Offset index larger than input size', $offsetIndex);
|
||||
}
|
||||
|
||||
$contentLength = ord($binaryData[$offsetIndex++]);
|
||||
if (($contentLength & 0x80) != 0) {
|
||||
// bit 8 is set -> this is the long form
|
||||
$nrOfLengthOctets = $contentLength & 0x7F;
|
||||
$contentLength = BigInteger::create(0x00);
|
||||
for ($i = 0; $i < $nrOfLengthOctets; $i++) {
|
||||
if (strlen($binaryData) <= $offsetIndex) {
|
||||
throw new ParserException('Can not parse content length (long form) from data: Offset index larger than input size', $offsetIndex);
|
||||
}
|
||||
$contentLength = $contentLength->shiftLeft(8)->add(ord($binaryData[$offsetIndex++]));
|
||||
}
|
||||
|
||||
if ($contentLength->compare(PHP_INT_MAX) > 0) {
|
||||
throw new ParserException("Can not parse content length from data: length > maximum integer", $offsetIndex);
|
||||
}
|
||||
|
||||
$contentLength = $contentLength->toInteger();
|
||||
}
|
||||
|
||||
if ($contentLength < $minimumLength) {
|
||||
throw new ParserException('A '.get_called_class()." should have a content length of at least {$minimumLength}. Extracted length was {$contentLength}", $offsetIndex);
|
||||
}
|
||||
|
||||
$lenDataRemaining = strlen($binaryData) - $offsetIndex;
|
||||
|
||||
if ($lenDataRemaining < $contentLength) {
|
||||
throw new ParserException("Content length {$contentLength} exceeds remaining data length {$lenDataRemaining}", $offsetIndex);
|
||||
}
|
||||
|
||||
return $contentLength;
|
||||
}
|
||||
}
|
136
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/AbstractString.php
vendored
Normal file
136
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/AbstractString.php
vendored
Normal file
|
@ -0,0 +1,136 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1;
|
||||
|
||||
use Exception;
|
||||
|
||||
abstract class AbstractString extends ASNObject implements Parsable
|
||||
{
|
||||
/** @var string */
|
||||
protected $value;
|
||||
private $checkStringForIllegalChars = true;
|
||||
private $allowedCharacters = [];
|
||||
|
||||
/**
|
||||
* The abstract base class for ASN.1 classes which represent some string of character.
|
||||
*
|
||||
* @param string $string
|
||||
*/
|
||||
public function __construct($string)
|
||||
{
|
||||
$this->value = $string;
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
protected function allowCharacter($character)
|
||||
{
|
||||
$this->allowedCharacters[] = $character;
|
||||
}
|
||||
|
||||
protected function allowCharacters(...$characters)
|
||||
{
|
||||
foreach ($characters as $character) {
|
||||
$this->allowedCharacters[] = $character;
|
||||
}
|
||||
}
|
||||
|
||||
protected function allowNumbers()
|
||||
{
|
||||
foreach (range('0', '9') as $char) {
|
||||
$this->allowedCharacters[] = (string) $char;
|
||||
}
|
||||
}
|
||||
|
||||
protected function allowAllLetters()
|
||||
{
|
||||
$this->allowSmallLetters();
|
||||
$this->allowCapitalLetters();
|
||||
}
|
||||
|
||||
protected function allowSmallLetters()
|
||||
{
|
||||
foreach (range('a', 'z') as $char) {
|
||||
$this->allowedCharacters[] = $char;
|
||||
}
|
||||
}
|
||||
|
||||
protected function allowCapitalLetters()
|
||||
{
|
||||
foreach (range('A', 'Z') as $char) {
|
||||
$this->allowedCharacters[] = $char;
|
||||
}
|
||||
}
|
||||
|
||||
protected function allowSpaces()
|
||||
{
|
||||
$this->allowedCharacters[] = ' ';
|
||||
}
|
||||
|
||||
protected function allowAll()
|
||||
{
|
||||
$this->checkStringForIllegalChars = false;
|
||||
}
|
||||
|
||||
protected function calculateContentLength()
|
||||
{
|
||||
return strlen($this->value);
|
||||
}
|
||||
|
||||
protected function getEncodedValue()
|
||||
{
|
||||
if ($this->checkStringForIllegalChars) {
|
||||
$this->checkString();
|
||||
}
|
||||
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
protected function checkString()
|
||||
{
|
||||
$stringLength = $this->getContentLength();
|
||||
for ($i = 0; $i < $stringLength; $i++) {
|
||||
if (in_array($this->value[$i], $this->allowedCharacters) == false) {
|
||||
$typeName = Identifier::getName($this->getType());
|
||||
throw new Exception("Could not create a {$typeName} from the character sequence '{$this->value}'.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function fromBinary(&$binaryData, &$offsetIndex = 0)
|
||||
{
|
||||
$parsedObject = new static('');
|
||||
|
||||
self::parseIdentifier($binaryData[$offsetIndex], $parsedObject->getType(), $offsetIndex++);
|
||||
$contentLength = self::parseContentLength($binaryData, $offsetIndex);
|
||||
$string = substr($binaryData, $offsetIndex, $contentLength);
|
||||
$offsetIndex += $contentLength;
|
||||
|
||||
$parsedObject->value = $string;
|
||||
$parsedObject->setContentLength($contentLength);
|
||||
return $parsedObject;
|
||||
}
|
||||
|
||||
public static function isValid($string)
|
||||
{
|
||||
$testObject = new static($string);
|
||||
try {
|
||||
$testObject->checkString();
|
||||
|
||||
return true;
|
||||
} catch (Exception $exception) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
78
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/AbstractTime.php
vendored
Normal file
78
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/AbstractTime.php
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1;
|
||||
|
||||
use DateInterval;
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
use Exception;
|
||||
|
||||
abstract class AbstractTime extends ASNObject
|
||||
{
|
||||
/** @var DateTime */
|
||||
protected $value;
|
||||
|
||||
public function __construct($dateTime = null, $dateTimeZone = 'UTC')
|
||||
{
|
||||
if ($dateTime == null || is_string($dateTime)) {
|
||||
$timeZone = new DateTimeZone($dateTimeZone);
|
||||
$dateTimeObject = new DateTime($dateTime, $timeZone);
|
||||
if ($dateTimeObject == false) {
|
||||
$errorMessage = $this->getLastDateTimeErrors();
|
||||
$className = Identifier::getName($this->getType());
|
||||
throw new Exception(sprintf("Could not create %s from date time string '%s': %s", $className, $dateTime, $errorMessage));
|
||||
}
|
||||
$dateTime = $dateTimeObject;
|
||||
} elseif (!$dateTime instanceof DateTime) {
|
||||
throw new Exception('Invalid first argument for some instance of AbstractTime constructor');
|
||||
}
|
||||
|
||||
$this->value = $dateTime;
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
protected function getLastDateTimeErrors()
|
||||
{
|
||||
$messages = '';
|
||||
$lastErrors = DateTime::getLastErrors() ?: ['errors' => []];
|
||||
foreach ($lastErrors['errors'] as $errorMessage) {
|
||||
$messages .= "{$errorMessage}, ";
|
||||
}
|
||||
|
||||
return substr($messages, 0, -2);
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->value->format("Y-m-d\tH:i:s");
|
||||
}
|
||||
|
||||
protected static function extractTimeZoneData(&$binaryData, &$offsetIndex, DateTime $dateTime)
|
||||
{
|
||||
$sign = $binaryData[$offsetIndex++];
|
||||
$timeOffsetHours = intval(substr($binaryData, $offsetIndex, 2));
|
||||
$timeOffsetMinutes = intval(substr($binaryData, $offsetIndex + 2, 2));
|
||||
$offsetIndex += 4;
|
||||
|
||||
$interval = new DateInterval("PT{$timeOffsetHours}H{$timeOffsetMinutes}M");
|
||||
if ($sign == '+') {
|
||||
$dateTime->sub($interval);
|
||||
} else {
|
||||
$dateTime->add($interval);
|
||||
}
|
||||
|
||||
return $dateTime;
|
||||
}
|
||||
}
|
63
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Base128.php
vendored
Normal file
63
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Base128.php
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
namespace FG\ASN1;
|
||||
|
||||
use FG\Utility\BigInteger;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* A base-128 decoder.
|
||||
*/
|
||||
class Base128
|
||||
{
|
||||
/**
|
||||
* @param int $value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function encode($value)
|
||||
{
|
||||
$value = BigInteger::create($value);
|
||||
$octets = chr($value->modulus(0x80)->toInteger());
|
||||
|
||||
$value = $value->shiftRight(7);
|
||||
while ($value->compare(0) > 0) {
|
||||
$octets .= chr(0x80 | $value->modulus(0x80)->toInteger());
|
||||
$value = $value->shiftRight(7);
|
||||
}
|
||||
|
||||
return strrev($octets);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $octets
|
||||
*
|
||||
* @throws InvalidArgumentException if the given octets represent a malformed base-128 value or the decoded value would exceed the the maximum integer length
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function decode($octets)
|
||||
{
|
||||
$bitsPerOctet = 7;
|
||||
$value = BigInteger::create(0);
|
||||
$i = 0;
|
||||
|
||||
while (true) {
|
||||
if (!isset($octets[$i])) {
|
||||
throw new InvalidArgumentException(sprintf('Malformed base-128 encoded value (0x%s).', strtoupper(bin2hex($octets)) ?: '0'));
|
||||
}
|
||||
|
||||
$octet = ord($octets[$i++]);
|
||||
|
||||
$l1 = $value->shiftLeft($bitsPerOctet);
|
||||
$r1 = $octet & 0x7f;
|
||||
$value = $l1->add($r1);
|
||||
|
||||
if (0 === ($octet & 0x80)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (string)$value;
|
||||
}
|
||||
}
|
35
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Composite/AttributeTypeAndValue.php
vendored
Normal file
35
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Composite/AttributeTypeAndValue.php
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Composite;
|
||||
|
||||
use FG\ASN1\ASNObject;
|
||||
use FG\ASN1\Universal\Sequence;
|
||||
use FG\ASN1\Universal\ObjectIdentifier;
|
||||
|
||||
class AttributeTypeAndValue extends Sequence
|
||||
{
|
||||
/**
|
||||
* @param ObjectIdentifier|string $objIdentifier
|
||||
* @param \FG\ASN1\ASNObject $value
|
||||
*/
|
||||
public function __construct($objIdentifier, ASNObject $value)
|
||||
{
|
||||
if ($objIdentifier instanceof ObjectIdentifier == false) {
|
||||
$objIdentifier = new ObjectIdentifier($objIdentifier);
|
||||
}
|
||||
parent::__construct($objIdentifier, $value);
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->children[0].': '.$this->children[1];
|
||||
}
|
||||
}
|
37
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Composite/RDNString.php
vendored
Normal file
37
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Composite/RDNString.php
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Composite;
|
||||
|
||||
use FG\ASN1\Universal\PrintableString;
|
||||
use FG\ASN1\Universal\IA5String;
|
||||
use FG\ASN1\Universal\UTF8String;
|
||||
|
||||
class RDNString extends RelativeDistinguishedName
|
||||
{
|
||||
/**
|
||||
* @param string|\FG\ASN1\Universal\ObjectIdentifier $objectIdentifierString
|
||||
* @param string|\FG\ASN1\ASNObject $value
|
||||
*/
|
||||
public function __construct($objectIdentifierString, $value)
|
||||
{
|
||||
if (PrintableString::isValid($value)) {
|
||||
$value = new PrintableString($value);
|
||||
} else {
|
||||
if (IA5String::isValid($value)) {
|
||||
$value = new IA5String($value);
|
||||
} else {
|
||||
$value = new UTF8String($value);
|
||||
}
|
||||
}
|
||||
|
||||
parent::__construct($objectIdentifierString, $value);
|
||||
}
|
||||
}
|
50
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Composite/RelativeDistinguishedName.php
vendored
Normal file
50
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Composite/RelativeDistinguishedName.php
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Composite;
|
||||
|
||||
use FG\ASN1\Exception\NotImplementedException;
|
||||
use FG\ASN1\ASNObject;
|
||||
use FG\ASN1\Universal\Set;
|
||||
|
||||
class RelativeDistinguishedName extends Set
|
||||
{
|
||||
/**
|
||||
* @param string|\FG\ASN1\Universal\ObjectIdentifier $objIdentifierString
|
||||
* @param \FG\ASN1\ASNObject $value
|
||||
*/
|
||||
public function __construct($objIdentifierString, ASNObject $value)
|
||||
{
|
||||
// TODO: This does only support one element in the RelativeDistinguishedName Set but it it is defined as follows:
|
||||
// RelativeDistinguishedName ::= SET SIZE (1..MAX) OF AttributeTypeAndValue
|
||||
parent::__construct(new AttributeTypeAndValue($objIdentifierString, $value));
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
/** @var \FG\ASN1\ASNObject $firstObject */
|
||||
$firstObject = $this->children[0];
|
||||
return $firstObject->__toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* At the current version this code can not work since the implementation of Construct requires
|
||||
* the class to support a constructor without arguments.
|
||||
*
|
||||
* @deprecated this function is not yet implemented! Feel free to submit a pull request on github
|
||||
* @param string $binaryData
|
||||
* @param int $offsetIndex
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public static function fromBinary(&$binaryData, &$offsetIndex = 0)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
202
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Construct.php
vendored
Normal file
202
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Construct.php
vendored
Normal file
|
@ -0,0 +1,202 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1;
|
||||
|
||||
use ArrayAccess;
|
||||
use ArrayIterator;
|
||||
use Countable;
|
||||
use FG\ASN1\Exception\ParserException;
|
||||
use Iterator;
|
||||
|
||||
abstract class Construct extends ASNObject implements Countable, ArrayAccess, Iterator, Parsable
|
||||
{
|
||||
/** @var \FG\ASN1\ASNObject[] */
|
||||
protected $children;
|
||||
private $iteratorPosition;
|
||||
|
||||
/**
|
||||
* @param \FG\ASN1\ASNObject[] $children the variadic type hint is commented due to https://github.com/facebook/hhvm/issues/4858
|
||||
*/
|
||||
public function __construct(/* HH_FIXME[4858]: variadic + strict */ ...$children)
|
||||
{
|
||||
$this->children = $children;
|
||||
$this->iteratorPosition = 0;
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
return $this->children;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function rewind()
|
||||
{
|
||||
$this->iteratorPosition = 0;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current()
|
||||
{
|
||||
return $this->children[$this->iteratorPosition];
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key()
|
||||
{
|
||||
return $this->iteratorPosition;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function next()
|
||||
{
|
||||
$this->iteratorPosition++;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function valid()
|
||||
{
|
||||
return isset($this->children[$this->iteratorPosition]);
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return array_key_exists($offset, $this->children);
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return $this->children[$offset];
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
if ($offset === null) {
|
||||
$offset = count($this->children);
|
||||
}
|
||||
|
||||
$this->children[$offset] = $value;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
unset($this->children[$offset]);
|
||||
}
|
||||
|
||||
protected function calculateContentLength()
|
||||
{
|
||||
$length = 0;
|
||||
foreach ($this->children as $component) {
|
||||
$length += $component->getObjectLength();
|
||||
}
|
||||
|
||||
return $length;
|
||||
}
|
||||
|
||||
protected function getEncodedValue()
|
||||
{
|
||||
$result = '';
|
||||
foreach ($this->children as $component) {
|
||||
$result .= $component->getBinary();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function addChild(ASNObject $child)
|
||||
{
|
||||
$this->children[] = $child;
|
||||
}
|
||||
|
||||
public function addChildren(array $children)
|
||||
{
|
||||
foreach ($children as $child) {
|
||||
$this->addChild($child);
|
||||
}
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
$nrOfChildren = $this->getNumberOfChildren();
|
||||
$childString = $nrOfChildren == 1 ? 'child' : 'children';
|
||||
|
||||
return "[{$nrOfChildren} {$childString}]";
|
||||
}
|
||||
|
||||
public function getNumberOfChildren()
|
||||
{
|
||||
return count($this->children);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \FG\ASN1\ASNObject[]
|
||||
*/
|
||||
public function getChildren()
|
||||
{
|
||||
return $this->children;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \FG\ASN1\ASNObject
|
||||
*/
|
||||
public function getFirstChild()
|
||||
{
|
||||
return $this->children[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $binaryData
|
||||
* @param int $offsetIndex
|
||||
*
|
||||
* @throws Exception\ParserException
|
||||
*
|
||||
* @return Construct|static
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public static function fromBinary(&$binaryData, &$offsetIndex = 0)
|
||||
{
|
||||
$parsedObject = new static();
|
||||
self::parseIdentifier($binaryData[$offsetIndex], $parsedObject->getType(), $offsetIndex++);
|
||||
$contentLength = self::parseContentLength($binaryData, $offsetIndex);
|
||||
$startIndex = $offsetIndex;
|
||||
|
||||
$children = [];
|
||||
$octetsToRead = $contentLength;
|
||||
while ($octetsToRead > 0) {
|
||||
$newChild = ASNObject::fromBinary($binaryData, $offsetIndex);
|
||||
$octetsToRead -= $newChild->getObjectLength();
|
||||
$children[] = $newChild;
|
||||
}
|
||||
|
||||
if ($octetsToRead !== 0) {
|
||||
throw new ParserException("Sequence length incorrect", $startIndex);
|
||||
}
|
||||
|
||||
$parsedObject->addChildren($children);
|
||||
$parsedObject->setContentLength($contentLength);
|
||||
|
||||
return $parsedObject;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function count($mode = COUNT_NORMAL)
|
||||
{
|
||||
return count($this->children, $mode);
|
||||
}
|
||||
|
||||
public function getIterator()
|
||||
{
|
||||
return new ArrayIterator($this->children);
|
||||
}
|
||||
}
|
15
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Exception/NotImplementedException.php
vendored
Normal file
15
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Exception/NotImplementedException.php
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Exception;
|
||||
|
||||
class NotImplementedException extends \Exception
|
||||
{
|
||||
}
|
29
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Exception/ParserException.php
vendored
Normal file
29
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Exception/ParserException.php
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Exception;
|
||||
|
||||
class ParserException extends \Exception
|
||||
{
|
||||
private $errorMessage;
|
||||
private $offset;
|
||||
|
||||
public function __construct($errorMessage, $offset)
|
||||
{
|
||||
$this->errorMessage = $errorMessage;
|
||||
$this->offset = $offset;
|
||||
parent::__construct("ASN.1 Parser Exception at offset {$this->offset}: {$this->errorMessage}");
|
||||
}
|
||||
|
||||
public function getOffset()
|
||||
{
|
||||
return $this->offset;
|
||||
}
|
||||
}
|
131
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/ExplicitlyTaggedObject.php
vendored
Normal file
131
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/ExplicitlyTaggedObject.php
vendored
Normal file
|
@ -0,0 +1,131 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1;
|
||||
|
||||
use FG\ASN1\Exception\ParserException;
|
||||
|
||||
/**
|
||||
* Class ExplicitlyTaggedObject decorate an inner object with an additional tag that gives information about
|
||||
* its context specific meaning.
|
||||
*
|
||||
* Explanation taken from A Layman's Guide to a Subset of ASN.1, BER, and DER:
|
||||
* >>> An RSA Laboratories Technical Note
|
||||
* >>> Burton S. Kaliski Jr.
|
||||
* >>> Revised November 1, 1993
|
||||
*
|
||||
* [...]
|
||||
* Explicitly tagged types are derived from other types by adding an outer tag to the underlying type.
|
||||
* In effect, explicitly tagged types are structured types consisting of one component, the underlying type.
|
||||
* Explicit tagging is denoted by the ASN.1 keywords [class number] EXPLICIT (see Section 5.2).
|
||||
* [...]
|
||||
*
|
||||
* @see http://luca.ntop.org/Teaching/Appunti/asn1.html
|
||||
*/
|
||||
class ExplicitlyTaggedObject extends ASNObject
|
||||
{
|
||||
/** @var \FG\ASN1\ASNObject[] */
|
||||
private $decoratedObjects;
|
||||
private $tag;
|
||||
|
||||
/**
|
||||
* @param int $tag
|
||||
* @param \FG\ASN1\ASNObject $objects,...
|
||||
*/
|
||||
public function __construct($tag, /* HH_FIXME[4858]: variadic + strict */ ...$objects)
|
||||
{
|
||||
$this->tag = $tag;
|
||||
$this->decoratedObjects = $objects;
|
||||
}
|
||||
|
||||
protected function calculateContentLength()
|
||||
{
|
||||
$length = 0;
|
||||
foreach ($this->decoratedObjects as $object) {
|
||||
$length += $object->getObjectLength();
|
||||
}
|
||||
|
||||
return $length;
|
||||
}
|
||||
|
||||
protected function getEncodedValue()
|
||||
{
|
||||
$encoded = '';
|
||||
foreach ($this->decoratedObjects as $object) {
|
||||
$encoded .= $object->getBinary();
|
||||
}
|
||||
|
||||
return $encoded;
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
return $this->decoratedObjects;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
switch ($length = count($this->decoratedObjects)) {
|
||||
case 0:
|
||||
return "Context specific empty object with tag [{$this->tag}]";
|
||||
case 1:
|
||||
$decoratedType = Identifier::getShortName($this->decoratedObjects[0]->getType());
|
||||
return "Context specific $decoratedType with tag [{$this->tag}]";
|
||||
default:
|
||||
return "$length context specific objects with tag [{$this->tag}]";
|
||||
}
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return ord($this->getIdentifier());
|
||||
}
|
||||
|
||||
public function getIdentifier()
|
||||
{
|
||||
$identifier = Identifier::create(Identifier::CLASS_CONTEXT_SPECIFIC, true, $this->tag);
|
||||
|
||||
return is_int($identifier) ? chr($identifier) : $identifier;
|
||||
}
|
||||
|
||||
public function getTag()
|
||||
{
|
||||
return $this->tag;
|
||||
}
|
||||
|
||||
public static function fromBinary(&$binaryData, &$offsetIndex = 0)
|
||||
{
|
||||
$identifier = self::parseBinaryIdentifier($binaryData, $offsetIndex);
|
||||
$firstIdentifierOctet = ord($identifier);
|
||||
assert(Identifier::isContextSpecificClass($firstIdentifierOctet), 'identifier octet should indicate context specific class');
|
||||
assert(Identifier::isConstructed($firstIdentifierOctet), 'identifier octet should indicate constructed object');
|
||||
$tag = Identifier::getTagNumber($identifier);
|
||||
|
||||
$totalContentLength = self::parseContentLength($binaryData, $offsetIndex);
|
||||
$remainingContentLength = $totalContentLength;
|
||||
|
||||
$offsetIndexOfDecoratedObject = $offsetIndex;
|
||||
$decoratedObjects = [];
|
||||
|
||||
while ($remainingContentLength > 0) {
|
||||
$nextObject = ASNObject::fromBinary($binaryData, $offsetIndex);
|
||||
$remainingContentLength -= $nextObject->getObjectLength();
|
||||
$decoratedObjects[] = $nextObject;
|
||||
}
|
||||
|
||||
if ($remainingContentLength != 0) {
|
||||
throw new ParserException("Context-Specific explicitly tagged object [$tag] starting at offset $offsetIndexOfDecoratedObject specifies a length of $totalContentLength octets but $remainingContentLength remain after parsing the content", $offsetIndexOfDecoratedObject);
|
||||
}
|
||||
|
||||
$parsedObject = new self($tag, ...$decoratedObjects);
|
||||
$parsedObject->setContentLength($totalContentLength);
|
||||
return $parsedObject;
|
||||
}
|
||||
}
|
339
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Identifier.php
vendored
Normal file
339
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Identifier.php
vendored
Normal file
|
@ -0,0 +1,339 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* The Identifier encodes the ASN.1 tag (class and number) of the type of a data value.
|
||||
*
|
||||
* Every identifier whose number is in the range 0 to 30 has the following structure:
|
||||
*
|
||||
* Bits: 8 7 6 5 4 3 2 1
|
||||
* | Class | P/C | Tag number |
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
*
|
||||
* Bits 8 and 7 define the class of this type ( Universal, Application, Context-specific or Private).
|
||||
* Bit 6 encoded whether this type is primitive or constructed
|
||||
* The remaining bits 5 - 1 encode the tag number
|
||||
*/
|
||||
class Identifier
|
||||
{
|
||||
const CLASS_UNIVERSAL = 0x00;
|
||||
const CLASS_APPLICATION = 0x01;
|
||||
const CLASS_CONTEXT_SPECIFIC = 0x02;
|
||||
const CLASS_PRIVATE = 0x03;
|
||||
|
||||
const EOC = 0x00; // unsupported for now
|
||||
const BOOLEAN = 0x01;
|
||||
const INTEGER = 0x02;
|
||||
const BITSTRING = 0x03;
|
||||
const OCTETSTRING = 0x04;
|
||||
const NULL = 0x05;
|
||||
const OBJECT_IDENTIFIER = 0x06;
|
||||
const OBJECT_DESCRIPTOR = 0x07;
|
||||
const EXTERNAL = 0x08; // unsupported for now
|
||||
const REAL = 0x09; // unsupported for now
|
||||
const ENUMERATED = 0x0A;
|
||||
const EMBEDDED_PDV = 0x0B; // unsupported for now
|
||||
const UTF8_STRING = 0x0C;
|
||||
const RELATIVE_OID = 0x0D;
|
||||
// value 0x0E and 0x0F are reserved for future use
|
||||
|
||||
const SEQUENCE = 0x30;
|
||||
const SET = 0x31;
|
||||
const NUMERIC_STRING = 0x12;
|
||||
const PRINTABLE_STRING = 0x13;
|
||||
const T61_STRING = 0x14; // sometimes referred to as TeletextString
|
||||
const VIDEOTEXT_STRING = 0x15;
|
||||
const IA5_STRING = 0x16;
|
||||
const UTC_TIME = 0x17;
|
||||
const GENERALIZED_TIME = 0x18;
|
||||
const GRAPHIC_STRING = 0x19;
|
||||
const VISIBLE_STRING = 0x1A;
|
||||
const GENERAL_STRING = 0x1B;
|
||||
const UNIVERSAL_STRING = 0x1C;
|
||||
const CHARACTER_STRING = 0x1D; // Unrestricted character type
|
||||
const BMP_STRING = 0x1E;
|
||||
|
||||
const LONG_FORM = 0x1F;
|
||||
const IS_CONSTRUCTED = 0x20;
|
||||
|
||||
/**
|
||||
* Creates an identifier. Short form identifiers are returned as integers
|
||||
* for BC, long form identifiers will be returned as a string of octets.
|
||||
*
|
||||
* @param int $class
|
||||
* @param bool $isConstructed
|
||||
* @param int $tagNumber
|
||||
*
|
||||
* @throws Exception if the given arguments are invalid
|
||||
*
|
||||
* @return int|string
|
||||
*/
|
||||
public static function create($class, $isConstructed, $tagNumber)
|
||||
{
|
||||
if (!is_numeric($class) || $class < self::CLASS_UNIVERSAL || $class > self::CLASS_PRIVATE) {
|
||||
throw new Exception(sprintf('Invalid class %d given', $class));
|
||||
}
|
||||
|
||||
if (!is_bool($isConstructed)) {
|
||||
throw new Exception("\$isConstructed must be a boolean value ($isConstructed given)");
|
||||
}
|
||||
|
||||
$tagNumber = self::makeNumeric($tagNumber);
|
||||
if ($tagNumber < 0) {
|
||||
throw new Exception(sprintf('Invalid $tagNumber %d given. You can only use positive integers.', $tagNumber));
|
||||
}
|
||||
|
||||
if ($tagNumber < self::LONG_FORM) {
|
||||
return ($class << 6) | ($isConstructed << 5) | $tagNumber;
|
||||
}
|
||||
|
||||
$firstOctet = ($class << 6) | ($isConstructed << 5) | self::LONG_FORM;
|
||||
|
||||
// Tag numbers formatted in long form are base-128 encoded. See X.609#8.1.2.4
|
||||
return chr($firstOctet).Base128::encode($tagNumber);
|
||||
}
|
||||
|
||||
public static function isConstructed($identifierOctet)
|
||||
{
|
||||
return ($identifierOctet & self::IS_CONSTRUCTED) === self::IS_CONSTRUCTED;
|
||||
}
|
||||
|
||||
public static function isLongForm($identifierOctet)
|
||||
{
|
||||
return ($identifierOctet & self::LONG_FORM) === self::LONG_FORM;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the mapped ASN.1 type with a preceding "ASN.1 ".
|
||||
*
|
||||
* Example: ASN.1 Octet String
|
||||
*
|
||||
* @see Identifier::getShortName()
|
||||
*
|
||||
* @param int|string $identifier
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName($identifier)
|
||||
{
|
||||
$identifierOctet = self::makeNumeric($identifier);
|
||||
|
||||
$typeName = static::getShortName($identifier);
|
||||
|
||||
if (($identifierOctet & self::LONG_FORM) < self::LONG_FORM) {
|
||||
$typeName = "ASN.1 {$typeName}";
|
||||
}
|
||||
|
||||
return $typeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the short version of the type name.
|
||||
*
|
||||
* If the given identifier octet can be mapped to a known universal type this will
|
||||
* return its name. Else Identifier::getClassDescription() is used to retrieve
|
||||
* information about the identifier.
|
||||
*
|
||||
* @see Identifier::getName()
|
||||
* @see Identifier::getClassDescription()
|
||||
*
|
||||
* @param int|string $identifier
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getShortName($identifier)
|
||||
{
|
||||
$identifierOctet = self::makeNumeric($identifier);
|
||||
|
||||
switch ($identifierOctet) {
|
||||
case self::EOC:
|
||||
return 'End-of-contents octet';
|
||||
case self::BOOLEAN:
|
||||
return 'Boolean';
|
||||
case self::INTEGER:
|
||||
return 'Integer';
|
||||
case self::BITSTRING:
|
||||
return 'Bit String';
|
||||
case self::OCTETSTRING:
|
||||
return 'Octet String';
|
||||
case self::NULL:
|
||||
return 'NULL';
|
||||
case self::OBJECT_IDENTIFIER:
|
||||
return 'Object Identifier';
|
||||
case self::OBJECT_DESCRIPTOR:
|
||||
return 'Object Descriptor';
|
||||
case self::EXTERNAL:
|
||||
return 'External Type';
|
||||
case self::REAL:
|
||||
return 'Real';
|
||||
case self::ENUMERATED:
|
||||
return 'Enumerated';
|
||||
case self::EMBEDDED_PDV:
|
||||
return 'Embedded PDV';
|
||||
case self::UTF8_STRING:
|
||||
return 'UTF8 String';
|
||||
case self::RELATIVE_OID:
|
||||
return 'Relative OID';
|
||||
case self::SEQUENCE:
|
||||
return 'Sequence';
|
||||
case self::SET:
|
||||
return 'Set';
|
||||
case self::NUMERIC_STRING:
|
||||
return 'Numeric String';
|
||||
case self::PRINTABLE_STRING:
|
||||
return 'Printable String';
|
||||
case self::T61_STRING:
|
||||
return 'T61 String';
|
||||
case self::VIDEOTEXT_STRING:
|
||||
return 'Videotext String';
|
||||
case self::IA5_STRING:
|
||||
return 'IA5 String';
|
||||
case self::UTC_TIME:
|
||||
return 'UTC Time';
|
||||
case self::GENERALIZED_TIME:
|
||||
return 'Generalized Time';
|
||||
case self::GRAPHIC_STRING:
|
||||
return 'Graphic String';
|
||||
case self::VISIBLE_STRING:
|
||||
return 'Visible String';
|
||||
case self::GENERAL_STRING:
|
||||
return 'General String';
|
||||
case self::UNIVERSAL_STRING:
|
||||
return 'Universal String';
|
||||
case self::CHARACTER_STRING:
|
||||
return 'Character String';
|
||||
case self::BMP_STRING:
|
||||
return 'BMP String';
|
||||
|
||||
case 0x0E:
|
||||
return 'RESERVED (0x0E)';
|
||||
case 0x0F:
|
||||
return 'RESERVED (0x0F)';
|
||||
|
||||
case self::LONG_FORM:
|
||||
default:
|
||||
$classDescription = self::getClassDescription($identifier);
|
||||
|
||||
if (is_int($identifier)) {
|
||||
$identifier = chr($identifier);
|
||||
}
|
||||
|
||||
return "$classDescription (0x".strtoupper(bin2hex($identifier)).')';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a textual description of the information encoded in a given identifier octet.
|
||||
*
|
||||
* The first three (most significant) bytes are evaluated to determine if this is a
|
||||
* constructed or primitive type and if it is either universal, application, context-specific or
|
||||
* private.
|
||||
*
|
||||
* Example:
|
||||
* Constructed context-specific
|
||||
* Primitive universal
|
||||
*
|
||||
* @param int|string $identifier
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getClassDescription($identifier)
|
||||
{
|
||||
$identifierOctet = self::makeNumeric($identifier);
|
||||
|
||||
if (self::isConstructed($identifierOctet)) {
|
||||
$classDescription = 'Constructed ';
|
||||
} else {
|
||||
$classDescription = 'Primitive ';
|
||||
}
|
||||
$classBits = $identifierOctet >> 6;
|
||||
switch ($classBits) {
|
||||
case self::CLASS_UNIVERSAL:
|
||||
$classDescription .= 'universal';
|
||||
break;
|
||||
case self::CLASS_APPLICATION:
|
||||
$classDescription .= 'application';
|
||||
break;
|
||||
case self::CLASS_CONTEXT_SPECIFIC:
|
||||
$tagNumber = self::getTagNumber($identifier);
|
||||
$classDescription = "[$tagNumber] Context-specific";
|
||||
break;
|
||||
case self::CLASS_PRIVATE:
|
||||
$classDescription .= 'private';
|
||||
break;
|
||||
|
||||
default:
|
||||
return "INVALID IDENTIFIER OCTET: {$identifierOctet}";
|
||||
}
|
||||
|
||||
return $classDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|string $identifier
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getTagNumber($identifier)
|
||||
{
|
||||
$firstOctet = self::makeNumeric($identifier);
|
||||
$tagNumber = $firstOctet & self::LONG_FORM;
|
||||
|
||||
if ($tagNumber < self::LONG_FORM) {
|
||||
return $tagNumber;
|
||||
}
|
||||
|
||||
if (is_numeric($identifier)) {
|
||||
$identifier = chr($identifier);
|
||||
}
|
||||
return Base128::decode(substr($identifier, 1));
|
||||
}
|
||||
|
||||
public static function isUniversalClass($identifier)
|
||||
{
|
||||
$identifier = self::makeNumeric($identifier);
|
||||
|
||||
return $identifier >> 6 == self::CLASS_UNIVERSAL;
|
||||
}
|
||||
|
||||
public static function isApplicationClass($identifier)
|
||||
{
|
||||
$identifier = self::makeNumeric($identifier);
|
||||
|
||||
return $identifier >> 6 == self::CLASS_APPLICATION;
|
||||
}
|
||||
|
||||
public static function isContextSpecificClass($identifier)
|
||||
{
|
||||
$identifier = self::makeNumeric($identifier);
|
||||
|
||||
return $identifier >> 6 == self::CLASS_CONTEXT_SPECIFIC;
|
||||
}
|
||||
|
||||
public static function isPrivateClass($identifier)
|
||||
{
|
||||
$identifier = self::makeNumeric($identifier);
|
||||
|
||||
return $identifier >> 6 == self::CLASS_PRIVATE;
|
||||
}
|
||||
|
||||
private static function makeNumeric($identifierOctet)
|
||||
{
|
||||
if (!is_numeric($identifierOctet)) {
|
||||
return ord($identifierOctet);
|
||||
} else {
|
||||
return $identifierOctet;
|
||||
}
|
||||
}
|
||||
}
|
1023
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/OID.php
vendored
Normal file
1023
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/OID.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
32
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Parsable.php
vendored
Normal file
32
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Parsable.php
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1;
|
||||
|
||||
use FG\ASN1\Exception\ParserException;
|
||||
|
||||
/**
|
||||
* The Parsable interface describes classes that can be parsed from their binary DER representation.
|
||||
*/
|
||||
interface Parsable
|
||||
{
|
||||
/**
|
||||
* Parse an instance of this class from its binary DER encoded representation.
|
||||
*
|
||||
* @param string $binaryData
|
||||
* @param int $offsetIndex the offset at which parsing of the $binaryData is started. This parameter ill be modified
|
||||
* to contain the offset index of the next object after this object has been parsed
|
||||
*
|
||||
* @throws ParserException if the given binary data is either invalid or not currently supported
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function fromBinary(&$binaryData, &$offsetIndex = null);
|
||||
}
|
70
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/TemplateParser.php
vendored
Normal file
70
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/TemplateParser.php
vendored
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1;
|
||||
|
||||
use Exception;
|
||||
use FG\ASN1\Exception\ParserException;
|
||||
use FG\ASN1\Universal\Sequence;
|
||||
|
||||
class TemplateParser
|
||||
{
|
||||
/**
|
||||
* @param string $data
|
||||
* @param array $template
|
||||
* @return \FG\ASN1\ASNObject|Sequence
|
||||
* @throws ParserException if there was an issue parsing
|
||||
*/
|
||||
public function parseBase64($data, array $template)
|
||||
{
|
||||
// TODO test with invalid data
|
||||
return $this->parseBinary(base64_decode($data), $template);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $binary
|
||||
* @param array $template
|
||||
* @return \FG\ASN1\ASNObject|Sequence
|
||||
* @throws ParserException if there was an issue parsing
|
||||
*/
|
||||
public function parseBinary($binary, array $template)
|
||||
{
|
||||
$parsedObject = ASNObject::fromBinary($binary);
|
||||
|
||||
foreach ($template as $key => $value) {
|
||||
$this->validate($parsedObject, $key, $value);
|
||||
}
|
||||
|
||||
return $parsedObject;
|
||||
}
|
||||
|
||||
private function validate(ASNObject $object, $key, $value)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
$this->assertTypeId($key, $object);
|
||||
|
||||
/* @var Construct $object */
|
||||
foreach ($value as $key => $child) {
|
||||
$this->validate($object->current(), $key, $child);
|
||||
$object->next();
|
||||
}
|
||||
} else {
|
||||
$this->assertTypeId($value, $object);
|
||||
}
|
||||
}
|
||||
|
||||
private function assertTypeId($expectedTypeId, ASNObject $object)
|
||||
{
|
||||
$actualType = $object->getType();
|
||||
if ($expectedTypeId != $actualType) {
|
||||
throw new Exception("Expected type ($expectedTypeId) does not match actual type ($actualType");
|
||||
}
|
||||
}
|
||||
}
|
41
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/BMPString.php
vendored
Normal file
41
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/BMPString.php
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Universal;
|
||||
|
||||
use FG\ASN1\AbstractString;
|
||||
use FG\ASN1\Identifier;
|
||||
|
||||
class BMPString extends AbstractString
|
||||
{
|
||||
/**
|
||||
* Creates a new ASN.1 BMP String.
|
||||
*
|
||||
* BMPString is a subtype of UniversalString that has its own
|
||||
* unique tag and contains only the characters in the
|
||||
* Basic Multilingual Plane (those corresponding to the first
|
||||
* 64K-2 cells, less cells whose encoding is used to address
|
||||
* characters outside the Basic Multilingual Plane) of ISO/IEC 10646-1.
|
||||
*
|
||||
* TODO The encodable characters of this type are not yet checked.
|
||||
*
|
||||
* @param string $string
|
||||
*/
|
||||
public function __construct($string)
|
||||
{
|
||||
$this->value = $string;
|
||||
$this->allowAll();
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return Identifier::BMP_STRING;
|
||||
}
|
||||
}
|
88
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/BitString.php
vendored
Normal file
88
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/BitString.php
vendored
Normal file
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Universal;
|
||||
|
||||
use Exception;
|
||||
use FG\ASN1\Exception\ParserException;
|
||||
use FG\ASN1\Parsable;
|
||||
use FG\ASN1\Identifier;
|
||||
|
||||
class BitString extends OctetString implements Parsable
|
||||
{
|
||||
private $nrOfUnusedBits;
|
||||
|
||||
/**
|
||||
* Creates a new ASN.1 BitString object.
|
||||
*
|
||||
* @param string|int $value Either the hexadecimal value as a string (spaces are allowed - leading 0x is optional) or a numeric value
|
||||
* @param int $nrOfUnusedBits the number of unused bits in the last octet [optional].
|
||||
*
|
||||
* @throws Exception if the second parameter is no positive numeric value
|
||||
*/
|
||||
public function __construct($value, $nrOfUnusedBits = 0)
|
||||
{
|
||||
parent::__construct($value);
|
||||
|
||||
if (!is_numeric($nrOfUnusedBits) || $nrOfUnusedBits < 0) {
|
||||
throw new Exception('BitString: second parameter needs to be a positive number (or zero)!');
|
||||
}
|
||||
|
||||
$this->nrOfUnusedBits = $nrOfUnusedBits;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return Identifier::BITSTRING;
|
||||
}
|
||||
|
||||
protected function calculateContentLength()
|
||||
{
|
||||
// add one to the length for the first octet which encodes the number of unused bits in the last octet
|
||||
return parent::calculateContentLength() + 1;
|
||||
}
|
||||
|
||||
protected function getEncodedValue()
|
||||
{
|
||||
// the first octet determines the number of unused bits
|
||||
$nrOfUnusedBitsOctet = chr($this->nrOfUnusedBits);
|
||||
$actualContent = parent::getEncodedValue();
|
||||
|
||||
return $nrOfUnusedBitsOctet.$actualContent;
|
||||
}
|
||||
|
||||
public function getNumberOfUnusedBits()
|
||||
{
|
||||
return $this->nrOfUnusedBits;
|
||||
}
|
||||
|
||||
public static function fromBinary(&$binaryData, &$offsetIndex = 0)
|
||||
{
|
||||
self::parseIdentifier($binaryData[$offsetIndex], Identifier::BITSTRING, $offsetIndex++);
|
||||
$contentLength = self::parseContentLength($binaryData, $offsetIndex, 2);
|
||||
|
||||
$nrOfUnusedBits = ord($binaryData[$offsetIndex]);
|
||||
$value = substr($binaryData, $offsetIndex + 1, $contentLength - 1);
|
||||
|
||||
if ($nrOfUnusedBits > 7 || // no less than 1 used, otherwise non-minimal
|
||||
($contentLength - 1) == 1 && $nrOfUnusedBits > 0 || // content length only 1, no
|
||||
(ord($value[strlen($value)-1])&((1<<$nrOfUnusedBits)-1)) != 0 // unused bits set
|
||||
) {
|
||||
throw new ParserException("Can not parse bit string with invalid padding", $offsetIndex);
|
||||
}
|
||||
|
||||
$offsetIndex += $contentLength;
|
||||
|
||||
$parsedObject = new self(bin2hex($value), $nrOfUnusedBits);
|
||||
$parsedObject->setContentLength($contentLength);
|
||||
|
||||
return $parsedObject;
|
||||
}
|
||||
}
|
75
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/Boolean.php
vendored
Normal file
75
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/Boolean.php
vendored
Normal file
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Universal;
|
||||
|
||||
use FG\ASN1\ASNObject;
|
||||
use FG\ASN1\Parsable;
|
||||
use FG\ASN1\Identifier;
|
||||
use FG\ASN1\Exception\ParserException;
|
||||
|
||||
class Boolean extends ASNObject implements Parsable
|
||||
{
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* @param bool $value
|
||||
*/
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return Identifier::BOOLEAN;
|
||||
}
|
||||
|
||||
protected function calculateContentLength()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
protected function getEncodedValue()
|
||||
{
|
||||
if ($this->value == false) {
|
||||
return chr(0x00);
|
||||
} else {
|
||||
return chr(0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
if ($this->value == true) {
|
||||
return 'TRUE';
|
||||
} else {
|
||||
return 'FALSE';
|
||||
}
|
||||
}
|
||||
|
||||
public static function fromBinary(&$binaryData, &$offsetIndex = 0)
|
||||
{
|
||||
self::parseIdentifier($binaryData[$offsetIndex], Identifier::BOOLEAN, $offsetIndex++);
|
||||
$contentLength = self::parseContentLength($binaryData, $offsetIndex);
|
||||
|
||||
if ($contentLength != 1) {
|
||||
throw new ParserException("An ASN.1 Boolean should not have a length other than one. Extracted length was {$contentLength}", $offsetIndex);
|
||||
}
|
||||
|
||||
$value = ord($binaryData[$offsetIndex++]);
|
||||
$booleanValue = $value == 0xFF ? true : false;
|
||||
|
||||
$parsedObject = new self($booleanValue);
|
||||
$parsedObject->setContentLength($contentLength);
|
||||
|
||||
return $parsedObject;
|
||||
}
|
||||
}
|
28
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/CharacterString.php
vendored
Normal file
28
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/CharacterString.php
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Universal;
|
||||
|
||||
use FG\ASN1\AbstractString;
|
||||
use FG\ASN1\Identifier;
|
||||
|
||||
class CharacterString extends AbstractString
|
||||
{
|
||||
public function __construct($string)
|
||||
{
|
||||
$this->value = $string;
|
||||
$this->allowAll();
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return Identifier::CHARACTER_STRING;
|
||||
}
|
||||
}
|
21
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/Enumerated.php
vendored
Normal file
21
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/Enumerated.php
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Universal;
|
||||
|
||||
use FG\ASN1\Identifier;
|
||||
|
||||
class Enumerated extends Integer
|
||||
{
|
||||
public function getType()
|
||||
{
|
||||
return Identifier::ENUMERATED;
|
||||
}
|
||||
}
|
34
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/GeneralString.php
vendored
Normal file
34
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/GeneralString.php
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Universal;
|
||||
|
||||
use FG\ASN1\AbstractString;
|
||||
use FG\ASN1\Identifier;
|
||||
|
||||
class GeneralString extends AbstractString
|
||||
{
|
||||
/**
|
||||
* Creates a new ASN.1 GeneralString.
|
||||
* TODO The encodable characters of this type are not yet checked.
|
||||
*
|
||||
* @param string $string
|
||||
*/
|
||||
public function __construct($string)
|
||||
{
|
||||
$this->value = $string;
|
||||
$this->allowAll();
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return Identifier::GENERAL_STRING;
|
||||
}
|
||||
}
|
134
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/GeneralizedTime.php
vendored
Normal file
134
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/GeneralizedTime.php
vendored
Normal file
|
@ -0,0 +1,134 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Universal;
|
||||
|
||||
use FG\ASN1\AbstractTime;
|
||||
use FG\ASN1\Parsable;
|
||||
use FG\ASN1\Identifier;
|
||||
use FG\ASN1\Exception\ParserException;
|
||||
|
||||
/**
|
||||
* This ASN.1 universal type contains date and time information according to ISO 8601.
|
||||
*
|
||||
* The type consists of values representing:
|
||||
* a) a calendar date, as defined in ISO 8601; and
|
||||
* b) a time of day, to any of the precisions defined in ISO 8601, except for the hours value 24 which shall not be used; and
|
||||
* c) the local time differential factor as defined in ISO 8601.
|
||||
*
|
||||
* Decoding of this type will accept the Basic Encoding Rules (BER)
|
||||
* The encoding will comply with the Distinguished Encoding Rules (DER).
|
||||
*/
|
||||
class GeneralizedTime extends AbstractTime implements Parsable
|
||||
{
|
||||
private $microseconds;
|
||||
|
||||
public function __construct($dateTime = null, $dateTimeZone = 'UTC')
|
||||
{
|
||||
parent::__construct($dateTime, $dateTimeZone);
|
||||
$this->microseconds = $this->value->format('u');
|
||||
if ($this->containsFractionalSecondsElement()) {
|
||||
// DER requires us to remove trailing zeros
|
||||
$this->microseconds = preg_replace('/([1-9]+)0+$/', '$1', $this->microseconds);
|
||||
}
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return Identifier::GENERALIZED_TIME;
|
||||
}
|
||||
|
||||
protected function calculateContentLength()
|
||||
{
|
||||
$contentSize = 15; // YYYYMMDDHHmmSSZ
|
||||
|
||||
if ($this->containsFractionalSecondsElement()) {
|
||||
$contentSize += 1 + strlen($this->microseconds);
|
||||
}
|
||||
|
||||
return $contentSize;
|
||||
}
|
||||
|
||||
public function containsFractionalSecondsElement()
|
||||
{
|
||||
return intval($this->microseconds) > 0;
|
||||
}
|
||||
|
||||
protected function getEncodedValue()
|
||||
{
|
||||
$encodedContent = $this->value->format('YmdHis');
|
||||
if ($this->containsFractionalSecondsElement()) {
|
||||
$encodedContent .= ".{$this->microseconds}";
|
||||
}
|
||||
|
||||
return $encodedContent.'Z';
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
if ($this->containsFractionalSecondsElement()) {
|
||||
return $this->value->format("Y-m-d\tH:i:s.uP");
|
||||
} else {
|
||||
return $this->value->format("Y-m-d\tH:i:sP");
|
||||
}
|
||||
}
|
||||
|
||||
public static function fromBinary(&$binaryData, &$offsetIndex = 0)
|
||||
{
|
||||
self::parseIdentifier($binaryData[$offsetIndex], Identifier::GENERALIZED_TIME, $offsetIndex++);
|
||||
$lengthOfMinimumTimeString = 14; // YYYYMMDDHHmmSS
|
||||
$contentLength = self::parseContentLength($binaryData, $offsetIndex, $lengthOfMinimumTimeString);
|
||||
$maximumBytesToRead = $contentLength;
|
||||
|
||||
$format = 'YmdGis';
|
||||
$content = substr($binaryData, $offsetIndex, $contentLength);
|
||||
$dateTimeString = substr($content, 0, $lengthOfMinimumTimeString);
|
||||
$offsetIndex += $lengthOfMinimumTimeString;
|
||||
$maximumBytesToRead -= $lengthOfMinimumTimeString;
|
||||
|
||||
if ($contentLength == $lengthOfMinimumTimeString) {
|
||||
$localTimeZone = new \DateTimeZone(date_default_timezone_get());
|
||||
$dateTime = \DateTime::createFromFormat($format, $dateTimeString, $localTimeZone);
|
||||
} else {
|
||||
if ($binaryData[$offsetIndex] == '.') {
|
||||
$maximumBytesToRead--; // account for the '.'
|
||||
$nrOfFractionalSecondElements = 1; // account for the '.'
|
||||
|
||||
while ($maximumBytesToRead > 0
|
||||
&& $binaryData[$offsetIndex + $nrOfFractionalSecondElements] != '+'
|
||||
&& $binaryData[$offsetIndex + $nrOfFractionalSecondElements] != '-'
|
||||
&& $binaryData[$offsetIndex + $nrOfFractionalSecondElements] != 'Z') {
|
||||
$nrOfFractionalSecondElements++;
|
||||
$maximumBytesToRead--;
|
||||
}
|
||||
|
||||
$dateTimeString .= substr($binaryData, $offsetIndex, $nrOfFractionalSecondElements);
|
||||
$offsetIndex += $nrOfFractionalSecondElements;
|
||||
$format .= '.u';
|
||||
}
|
||||
|
||||
$dateTime = \DateTime::createFromFormat($format, $dateTimeString, new \DateTimeZone('UTC'));
|
||||
|
||||
if ($maximumBytesToRead > 0) {
|
||||
if ($binaryData[$offsetIndex] == '+'
|
||||
|| $binaryData[$offsetIndex] == '-') {
|
||||
$dateTime = static::extractTimeZoneData($binaryData, $offsetIndex, $dateTime);
|
||||
} elseif ($binaryData[$offsetIndex++] != 'Z') {
|
||||
throw new ParserException('Invalid ISO 8601 Time String', $offsetIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$parsedObject = new self($dateTime);
|
||||
$parsedObject->setContentLength($contentLength);
|
||||
|
||||
return $parsedObject;
|
||||
}
|
||||
}
|
34
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/GraphicString.php
vendored
Normal file
34
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/GraphicString.php
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Universal;
|
||||
|
||||
use FG\ASN1\AbstractString;
|
||||
use FG\ASN1\Identifier;
|
||||
|
||||
class GraphicString extends AbstractString
|
||||
{
|
||||
/**
|
||||
* Creates a new ASN.1 Graphic String.
|
||||
* TODO The encodable characters of this type are not yet checked.
|
||||
*
|
||||
* @param string $string
|
||||
*/
|
||||
public function __construct($string)
|
||||
{
|
||||
$this->value = $string;
|
||||
$this->allowAll();
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return Identifier::GRAPHIC_STRING;
|
||||
}
|
||||
}
|
35
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/IA5String.php
vendored
Normal file
35
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/IA5String.php
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Universal;
|
||||
|
||||
use FG\ASN1\AbstractString;
|
||||
use FG\ASN1\Identifier;
|
||||
|
||||
/**
|
||||
* The International Alphabet No.5 (IA5) references the encoding of the ASCII characters.
|
||||
*
|
||||
* Each character in the data is encoded as 1 byte.
|
||||
*/
|
||||
class IA5String extends AbstractString
|
||||
{
|
||||
public function __construct($string)
|
||||
{
|
||||
parent::__construct($string);
|
||||
for ($i = 1; $i < 128; $i++) {
|
||||
$this->allowCharacter(chr($i));
|
||||
}
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return Identifier::IA5_STRING;
|
||||
}
|
||||
}
|
130
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/Integer.php
vendored
Normal file
130
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/Integer.php
vendored
Normal file
|
@ -0,0 +1,130 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Universal;
|
||||
|
||||
use Exception;
|
||||
use FG\Utility\BigInteger;
|
||||
use FG\ASN1\Exception\ParserException;
|
||||
use FG\ASN1\ASNObject;
|
||||
use FG\ASN1\Parsable;
|
||||
use FG\ASN1\Identifier;
|
||||
|
||||
class Integer extends ASNObject implements Parsable
|
||||
{
|
||||
/** @var int */
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* @param int $value
|
||||
*
|
||||
* @throws Exception if the value is not numeric
|
||||
*/
|
||||
public function __construct($value)
|
||||
{
|
||||
if (is_numeric($value) == false) {
|
||||
throw new Exception("Invalid VALUE [{$value}] for ASN1_INTEGER");
|
||||
}
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return Identifier::INTEGER;
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
protected function calculateContentLength()
|
||||
{
|
||||
return strlen($this->getEncodedValue());
|
||||
}
|
||||
|
||||
protected function getEncodedValue()
|
||||
{
|
||||
$value = BigInteger::create($this->value, 10);
|
||||
$negative = $value->compare(0) < 0;
|
||||
if ($negative) {
|
||||
$value = $value->absoluteValue();
|
||||
$limit = 0x80;
|
||||
} else {
|
||||
$limit = 0x7f;
|
||||
}
|
||||
|
||||
$mod = 0xff+1;
|
||||
$values = [];
|
||||
while($value->compare($limit) > 0) {
|
||||
$values[] = $value->modulus($mod)->toInteger();
|
||||
$value = $value->shiftRight(8);
|
||||
}
|
||||
|
||||
$values[] = $value->modulus($mod)->toInteger();
|
||||
$numValues = count($values);
|
||||
|
||||
if ($negative) {
|
||||
for ($i = 0; $i < $numValues; $i++) {
|
||||
$values[$i] = 0xff - $values[$i];
|
||||
}
|
||||
for ($i = 0; $i < $numValues; $i++) {
|
||||
$values[$i] += 1;
|
||||
if ($values[$i] <= 0xff) {
|
||||
break;
|
||||
}
|
||||
assert($i != $numValues - 1);
|
||||
$values[$i] = 0;
|
||||
}
|
||||
if ($values[$numValues - 1] == 0x7f) {
|
||||
$values[] = 0xff;
|
||||
}
|
||||
}
|
||||
$values = array_reverse($values);
|
||||
$r = pack("C*", ...$values);
|
||||
return $r;
|
||||
}
|
||||
|
||||
private static function ensureMinimalEncoding($binaryData, $offsetIndex)
|
||||
{
|
||||
// All the first nine bits cannot equal 0 or 1, which would
|
||||
// be non-minimal encoding for positive and negative integers respectively
|
||||
if ((ord($binaryData[$offsetIndex]) == 0x00 && (ord($binaryData[$offsetIndex+1]) & 0x80) == 0) ||
|
||||
(ord($binaryData[$offsetIndex]) == 0xff && (ord($binaryData[$offsetIndex+1]) & 0x80) == 0x80)) {
|
||||
throw new ParserException("Integer not minimally encoded", $offsetIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public static function fromBinary(&$binaryData, &$offsetIndex = 0)
|
||||
{
|
||||
$parsedObject = new static(0);
|
||||
self::parseIdentifier($binaryData[$offsetIndex], $parsedObject->getType(), $offsetIndex++);
|
||||
$contentLength = self::parseContentLength($binaryData, $offsetIndex, 1);
|
||||
|
||||
if ($contentLength > 1) {
|
||||
self::ensureMinimalEncoding($binaryData, $offsetIndex);
|
||||
}
|
||||
$isNegative = (ord($binaryData[$offsetIndex]) & 0x80) != 0x00;
|
||||
$number = BigInteger::create(ord($binaryData[$offsetIndex++]) & 0x7F);
|
||||
|
||||
for ($i = 0; $i < $contentLength - 1; $i++) {
|
||||
$number = $number->multiply(0x100)->add(ord($binaryData[$offsetIndex++]));
|
||||
}
|
||||
|
||||
if ($isNegative) {
|
||||
$number = $number->subtract(BigInteger::create(2)->toPower(8 * $contentLength - 1));
|
||||
}
|
||||
|
||||
$parsedObject = new static((string)$number);
|
||||
$parsedObject->setContentLength($contentLength);
|
||||
|
||||
return $parsedObject;
|
||||
}
|
||||
}
|
54
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/NullObject.php
vendored
Normal file
54
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/NullObject.php
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Universal;
|
||||
|
||||
use FG\ASN1\ASNObject;
|
||||
use FG\ASN1\Parsable;
|
||||
use FG\ASN1\Identifier;
|
||||
use FG\ASN1\Exception\ParserException;
|
||||
|
||||
class NullObject extends ASNObject implements Parsable
|
||||
{
|
||||
public function getType()
|
||||
{
|
||||
return Identifier::NULL;
|
||||
}
|
||||
|
||||
protected function calculateContentLength()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected function getEncodedValue()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
return 'NULL';
|
||||
}
|
||||
|
||||
public static function fromBinary(&$binaryData, &$offsetIndex = 0)
|
||||
{
|
||||
self::parseIdentifier($binaryData[$offsetIndex], Identifier::NULL, $offsetIndex++);
|
||||
$contentLength = self::parseContentLength($binaryData, $offsetIndex);
|
||||
|
||||
if ($contentLength != 0) {
|
||||
throw new ParserException("An ASN.1 Null should not have a length other than zero. Extracted length was {$contentLength}", $offsetIndex);
|
||||
}
|
||||
|
||||
$parsedObject = new self();
|
||||
$parsedObject->setContentLength(0);
|
||||
|
||||
return $parsedObject;
|
||||
}
|
||||
}
|
38
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/NumericString.php
vendored
Normal file
38
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/NumericString.php
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Universal;
|
||||
|
||||
use FG\ASN1\AbstractString;
|
||||
use FG\ASN1\Identifier;
|
||||
|
||||
class NumericString extends AbstractString
|
||||
{
|
||||
/**
|
||||
* Creates a new ASN.1 NumericString.
|
||||
*
|
||||
* The following characters are permitted:
|
||||
* Digits 0,1, ... 9
|
||||
* SPACE (space)
|
||||
*
|
||||
* @param string $string
|
||||
*/
|
||||
public function __construct($string)
|
||||
{
|
||||
$this->value = $string;
|
||||
$this->allowNumbers();
|
||||
$this->allowSpaces();
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return Identifier::NUMERIC_STRING;
|
||||
}
|
||||
}
|
26
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/ObjectDescriptor.php
vendored
Normal file
26
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/ObjectDescriptor.php
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Universal;
|
||||
|
||||
use FG\ASN1\Identifier;
|
||||
|
||||
class ObjectDescriptor extends GraphicString
|
||||
{
|
||||
public function __construct($objectDescription)
|
||||
{
|
||||
parent::__construct($objectDescription);
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return Identifier::OBJECT_DESCRIPTOR;
|
||||
}
|
||||
}
|
138
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/ObjectIdentifier.php
vendored
Normal file
138
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/ObjectIdentifier.php
vendored
Normal file
|
@ -0,0 +1,138 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Universal;
|
||||
|
||||
use Exception;
|
||||
use FG\ASN1\Base128;
|
||||
use FG\ASN1\OID;
|
||||
use FG\ASN1\ASNObject;
|
||||
use FG\ASN1\Parsable;
|
||||
use FG\ASN1\Identifier;
|
||||
use FG\ASN1\Exception\ParserException;
|
||||
|
||||
class ObjectIdentifier extends ASNObject implements Parsable
|
||||
{
|
||||
protected $subIdentifiers;
|
||||
protected $value;
|
||||
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->subIdentifiers = explode('.', $value);
|
||||
$nrOfSubIdentifiers = count($this->subIdentifiers);
|
||||
|
||||
for ($i = 0; $i < $nrOfSubIdentifiers; $i++) {
|
||||
if (is_numeric($this->subIdentifiers[$i])) {
|
||||
// enforce the integer type
|
||||
$this->subIdentifiers[$i] = intval($this->subIdentifiers[$i]);
|
||||
} else {
|
||||
throw new Exception("[{$value}] is no valid object identifier (sub identifier ".($i + 1).' is not numeric)!');
|
||||
}
|
||||
}
|
||||
|
||||
// Merge the first to arcs of the OID registration tree (per ASN definition!)
|
||||
if ($nrOfSubIdentifiers >= 2) {
|
||||
$this->subIdentifiers[1] = ($this->subIdentifiers[0] * 40) + $this->subIdentifiers[1];
|
||||
unset($this->subIdentifiers[0]);
|
||||
}
|
||||
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return Identifier::OBJECT_IDENTIFIER;
|
||||
}
|
||||
|
||||
protected function calculateContentLength()
|
||||
{
|
||||
$length = 0;
|
||||
foreach ($this->subIdentifiers as $subIdentifier) {
|
||||
do {
|
||||
$subIdentifier = $subIdentifier >> 7;
|
||||
$length++;
|
||||
} while ($subIdentifier > 0);
|
||||
}
|
||||
|
||||
return $length;
|
||||
}
|
||||
|
||||
protected function getEncodedValue()
|
||||
{
|
||||
$encodedValue = '';
|
||||
foreach ($this->subIdentifiers as $subIdentifier) {
|
||||
$encodedValue .= Base128::encode($subIdentifier);
|
||||
}
|
||||
|
||||
return $encodedValue;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return OID::getName($this->value);
|
||||
}
|
||||
|
||||
public static function fromBinary(&$binaryData, &$offsetIndex = 0)
|
||||
{
|
||||
self::parseIdentifier($binaryData[$offsetIndex], Identifier::OBJECT_IDENTIFIER, $offsetIndex++);
|
||||
$contentLength = self::parseContentLength($binaryData, $offsetIndex, 1);
|
||||
|
||||
$firstOctet = ord($binaryData[$offsetIndex++]);
|
||||
$oidString = floor($firstOctet / 40).'.'.($firstOctet % 40);
|
||||
$oidString .= '.'.self::parseOid($binaryData, $offsetIndex, $contentLength - 1);
|
||||
|
||||
$parsedObject = new self($oidString);
|
||||
$parsedObject->setContentLength($contentLength);
|
||||
|
||||
return $parsedObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses an object identifier except for the first octet, which is parsed
|
||||
* differently. This way relative object identifiers can also be parsed
|
||||
* using this.
|
||||
*
|
||||
* @param $binaryData
|
||||
* @param $offsetIndex
|
||||
* @param $octetsToRead
|
||||
*
|
||||
* @throws ParserException
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected static function parseOid(&$binaryData, &$offsetIndex, $octetsToRead)
|
||||
{
|
||||
$oid = '';
|
||||
|
||||
while ($octetsToRead > 0) {
|
||||
$octets = '';
|
||||
|
||||
do {
|
||||
if (0 === $octetsToRead) {
|
||||
throw new ParserException('Malformed ASN.1 Object Identifier', $offsetIndex - 1);
|
||||
}
|
||||
|
||||
$octetsToRead--;
|
||||
$octet = $binaryData[$offsetIndex++];
|
||||
$octets .= $octet;
|
||||
} while (ord($octet) & 0x80);
|
||||
|
||||
$oid .= sprintf('%d.', Base128::decode($octets));
|
||||
}
|
||||
|
||||
// Remove trailing '.'
|
||||
return substr($oid, 0, -1) ?: '';
|
||||
}
|
||||
}
|
91
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/OctetString.php
vendored
Normal file
91
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/OctetString.php
vendored
Normal file
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Universal;
|
||||
|
||||
use Exception;
|
||||
use FG\ASN1\ASNObject;
|
||||
use FG\ASN1\Parsable;
|
||||
use FG\ASN1\Identifier;
|
||||
|
||||
class OctetString extends ASNObject implements Parsable
|
||||
{
|
||||
protected $value;
|
||||
|
||||
public function __construct($value)
|
||||
{
|
||||
if (is_string($value)) {
|
||||
// remove gaps between hex digits
|
||||
$value = preg_replace('/\s|0x/', '', $value);
|
||||
} elseif (is_numeric($value)) {
|
||||
$value = dechex($value);
|
||||
} elseif ($value === null) {
|
||||
return;
|
||||
} else {
|
||||
throw new Exception('OctetString: unrecognized input type!');
|
||||
}
|
||||
|
||||
if (strlen($value) % 2 != 0) {
|
||||
// transform values like 1F2 to 01F2
|
||||
$value = '0'.$value;
|
||||
}
|
||||
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return Identifier::OCTETSTRING;
|
||||
}
|
||||
|
||||
protected function calculateContentLength()
|
||||
{
|
||||
return strlen($this->value) / 2;
|
||||
}
|
||||
|
||||
protected function getEncodedValue()
|
||||
{
|
||||
$value = $this->value;
|
||||
$result = '';
|
||||
|
||||
//Actual content
|
||||
while (strlen($value) >= 2) {
|
||||
// get the hex value byte by byte from the string and and add it to binary result
|
||||
$result .= chr(hexdec(substr($value, 0, 2)));
|
||||
$value = substr($value, 2);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
return strtoupper($this->value);
|
||||
}
|
||||
|
||||
public function getBinaryContent()
|
||||
{
|
||||
return $this->getEncodedValue();
|
||||
}
|
||||
|
||||
public static function fromBinary(&$binaryData, &$offsetIndex = 0)
|
||||
{
|
||||
self::parseIdentifier($binaryData[$offsetIndex], Identifier::OCTETSTRING, $offsetIndex++);
|
||||
$contentLength = self::parseContentLength($binaryData, $offsetIndex);
|
||||
|
||||
$value = substr($binaryData, $offsetIndex, $contentLength);
|
||||
$offsetIndex += $contentLength;
|
||||
|
||||
$parsedObject = new self(bin2hex($value));
|
||||
$parsedObject->setContentLength($contentLength);
|
||||
|
||||
return $parsedObject;
|
||||
}
|
||||
}
|
53
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/PrintableString.php
vendored
Normal file
53
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/PrintableString.php
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Universal;
|
||||
|
||||
use FG\ASN1\AbstractString;
|
||||
use FG\ASN1\Identifier;
|
||||
|
||||
class PrintableString extends AbstractString
|
||||
{
|
||||
/**
|
||||
* Creates a new ASN.1 PrintableString.
|
||||
*
|
||||
* The ITU-T X.680 Table 8 permits the following characters:
|
||||
* Latin capital letters A,B, ... Z
|
||||
* Latin small letters a,b, ... z
|
||||
* Digits 0,1, ... 9
|
||||
* SPACE (space)
|
||||
* APOSTROPHE '
|
||||
* LEFT PARENTHESIS (
|
||||
* RIGHT PARENTHESIS )
|
||||
* PLUS SIGN +
|
||||
* COMMA ,
|
||||
* HYPHEN-MINUS -
|
||||
* FULL STOP .
|
||||
* SOLIDUS /
|
||||
* COLON :
|
||||
* EQUALS SIGN =
|
||||
* QUESTION MARK ?
|
||||
*
|
||||
* @param string $string
|
||||
*/
|
||||
public function __construct($string)
|
||||
{
|
||||
$this->value = $string;
|
||||
$this->allowNumbers();
|
||||
$this->allowAllLetters();
|
||||
$this->allowSpaces();
|
||||
$this->allowCharacters("'", '(', ')', '+', '-', '.', ',', '/', ':', '=', '?');
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return Identifier::PRINTABLE_STRING;
|
||||
}
|
||||
}
|
57
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/RelativeObjectIdentifier.php
vendored
Normal file
57
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/RelativeObjectIdentifier.php
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Universal;
|
||||
|
||||
use Exception;
|
||||
use FG\ASN1\Parsable;
|
||||
use FG\ASN1\Identifier;
|
||||
use FG\ASN1\Exception\ParserException;
|
||||
|
||||
class RelativeObjectIdentifier extends ObjectIdentifier implements Parsable
|
||||
{
|
||||
public function __construct($subIdentifiers)
|
||||
{
|
||||
$this->value = $subIdentifiers;
|
||||
$this->subIdentifiers = explode('.', $subIdentifiers);
|
||||
$nrOfSubIdentifiers = count($this->subIdentifiers);
|
||||
|
||||
for ($i = 0; $i < $nrOfSubIdentifiers; $i++) {
|
||||
if (is_numeric($this->subIdentifiers[$i])) {
|
||||
// enforce the integer type
|
||||
$this->subIdentifiers[$i] = intval($this->subIdentifiers[$i]);
|
||||
} else {
|
||||
throw new Exception("[{$subIdentifiers}] is no valid object identifier (sub identifier ".($i + 1).' is not numeric)!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return Identifier::RELATIVE_OID;
|
||||
}
|
||||
|
||||
public static function fromBinary(&$binaryData, &$offsetIndex = 0)
|
||||
{
|
||||
self::parseIdentifier($binaryData[$offsetIndex], Identifier::RELATIVE_OID, $offsetIndex++);
|
||||
$contentLength = self::parseContentLength($binaryData, $offsetIndex, 1);
|
||||
|
||||
try {
|
||||
$oidString = self::parseOid($binaryData, $offsetIndex, $contentLength);
|
||||
} catch (ParserException $e) {
|
||||
throw new ParserException('Malformed ASN.1 Relative Object Identifier', $e->getOffset());
|
||||
}
|
||||
|
||||
$parsedObject = new self($oidString);
|
||||
$parsedObject->setContentLength($contentLength);
|
||||
|
||||
return $parsedObject;
|
||||
}
|
||||
}
|
23
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/Sequence.php
vendored
Normal file
23
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/Sequence.php
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Universal;
|
||||
|
||||
use FG\ASN1\Construct;
|
||||
use FG\ASN1\Parsable;
|
||||
use FG\ASN1\Identifier;
|
||||
|
||||
class Sequence extends Construct implements Parsable
|
||||
{
|
||||
public function getType()
|
||||
{
|
||||
return Identifier::SEQUENCE;
|
||||
}
|
||||
}
|
21
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/Set.php
vendored
Normal file
21
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/Set.php
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Universal;
|
||||
|
||||
use FG\ASN1\Identifier;
|
||||
|
||||
class Set extends Sequence
|
||||
{
|
||||
public function getType()
|
||||
{
|
||||
return Identifier::SET;
|
||||
}
|
||||
}
|
36
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/T61String.php
vendored
Normal file
36
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/T61String.php
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Universal;
|
||||
|
||||
use FG\ASN1\AbstractString;
|
||||
use FG\ASN1\Identifier;
|
||||
|
||||
class T61String extends AbstractString
|
||||
{
|
||||
/**
|
||||
* Creates a new ASN.1 T61 String.
|
||||
* TODO The encodable characters of this type are not yet checked.
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/ITU_T.61
|
||||
*
|
||||
* @param string $string
|
||||
*/
|
||||
public function __construct($string)
|
||||
{
|
||||
$this->value = $string;
|
||||
$this->allowAll();
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return Identifier::T61_STRING;
|
||||
}
|
||||
}
|
77
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/UTCTime.php
vendored
Normal file
77
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/UTCTime.php
vendored
Normal file
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Universal;
|
||||
|
||||
use FG\ASN1\AbstractTime;
|
||||
use FG\ASN1\Parsable;
|
||||
use FG\ASN1\Identifier;
|
||||
use FG\ASN1\Exception\ParserException;
|
||||
|
||||
/**
|
||||
* This ASN.1 universal type contains the calendar date and time.
|
||||
*
|
||||
* The precision is one minute or one second and optionally a
|
||||
* local time differential from coordinated universal time.
|
||||
*
|
||||
* Decoding of this type will accept the Basic Encoding Rules (BER)
|
||||
* The encoding will comply with the Distinguished Encoding Rules (DER).
|
||||
*/
|
||||
class UTCTime extends AbstractTime implements Parsable
|
||||
{
|
||||
public function getType()
|
||||
{
|
||||
return Identifier::UTC_TIME;
|
||||
}
|
||||
|
||||
protected function calculateContentLength()
|
||||
{
|
||||
return 13; // Content is a string o the following format: YYMMDDhhmmssZ (13 octets)
|
||||
}
|
||||
|
||||
protected function getEncodedValue()
|
||||
{
|
||||
return $this->value->format('ymdHis').'Z';
|
||||
}
|
||||
|
||||
public static function fromBinary(&$binaryData, &$offsetIndex = 0)
|
||||
{
|
||||
self::parseIdentifier($binaryData[$offsetIndex], Identifier::UTC_TIME, $offsetIndex++);
|
||||
$contentLength = self::parseContentLength($binaryData, $offsetIndex, 11);
|
||||
|
||||
$format = 'ymdGi';
|
||||
$dateTimeString = substr($binaryData, $offsetIndex, 10);
|
||||
$offsetIndex += 10;
|
||||
|
||||
// extract optional seconds part
|
||||
if ($binaryData[$offsetIndex] != 'Z'
|
||||
&& $binaryData[$offsetIndex] != '+'
|
||||
&& $binaryData[$offsetIndex] != '-') {
|
||||
$dateTimeString .= substr($binaryData, $offsetIndex, 2);
|
||||
$offsetIndex += 2;
|
||||
$format .= 's';
|
||||
}
|
||||
|
||||
$dateTime = \DateTime::createFromFormat($format, $dateTimeString, new \DateTimeZone('UTC'));
|
||||
|
||||
// extract time zone settings
|
||||
if ($binaryData[$offsetIndex] == '+'
|
||||
|| $binaryData[$offsetIndex] == '-') {
|
||||
$dateTime = static::extractTimeZoneData($binaryData, $offsetIndex, $dateTime);
|
||||
} elseif ($binaryData[$offsetIndex++] != 'Z') {
|
||||
throw new ParserException('Invalid UTC String', $offsetIndex);
|
||||
}
|
||||
|
||||
$parsedObject = new self($dateTime);
|
||||
$parsedObject->setContentLength($contentLength);
|
||||
|
||||
return $parsedObject;
|
||||
}
|
||||
}
|
34
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/UTF8String.php
vendored
Normal file
34
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/UTF8String.php
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Universal;
|
||||
|
||||
use FG\ASN1\AbstractString;
|
||||
use FG\ASN1\Identifier;
|
||||
|
||||
class UTF8String extends AbstractString
|
||||
{
|
||||
/**
|
||||
* Creates a new ASN.1 Universal String.
|
||||
* TODO The encodable characters of this type are not yet checked.
|
||||
*
|
||||
* @param string $string
|
||||
*/
|
||||
public function __construct($string)
|
||||
{
|
||||
$this->value = $string;
|
||||
$this->allowAll();
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return Identifier::UTF8_STRING;
|
||||
}
|
||||
}
|
36
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/UniversalString.php
vendored
Normal file
36
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/UniversalString.php
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Universal;
|
||||
|
||||
use FG\ASN1\AbstractString;
|
||||
use FG\ASN1\Identifier;
|
||||
|
||||
class UniversalString extends AbstractString
|
||||
{
|
||||
/**
|
||||
* Creates a new ASN.1 Universal String.
|
||||
* TODO The encodable characters of this type are not yet checked.
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/Universal_Character_Set
|
||||
*
|
||||
* @param string $string
|
||||
*/
|
||||
public function __construct($string)
|
||||
{
|
||||
$this->value = $string;
|
||||
$this->allowAll();
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return Identifier::UNIVERSAL_STRING;
|
||||
}
|
||||
}
|
34
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/VisibleString.php
vendored
Normal file
34
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/Universal/VisibleString.php
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1\Universal;
|
||||
|
||||
use FG\ASN1\AbstractString;
|
||||
use FG\ASN1\Identifier;
|
||||
|
||||
class VisibleString extends AbstractString
|
||||
{
|
||||
/**
|
||||
* Creates a new ASN.1 Visible String.
|
||||
* TODO The encodable characters of this type are not yet checked.
|
||||
*
|
||||
* @param string $string
|
||||
*/
|
||||
public function __construct($string)
|
||||
{
|
||||
$this->value = $string;
|
||||
$this->allowAll();
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return Identifier::VISIBLE_STRING;
|
||||
}
|
||||
}
|
59
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/UnknownConstructedObject.php
vendored
Normal file
59
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/UnknownConstructedObject.php
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1;
|
||||
|
||||
class UnknownConstructedObject extends Construct
|
||||
{
|
||||
private $identifier;
|
||||
private $contentLength;
|
||||
|
||||
/**
|
||||
* @param string $binaryData
|
||||
* @param int $offsetIndex
|
||||
*
|
||||
* @throws \FG\ASN1\Exception\ParserException
|
||||
*/
|
||||
public function __construct($binaryData, &$offsetIndex)
|
||||
{
|
||||
$this->identifier = self::parseBinaryIdentifier($binaryData, $offsetIndex);
|
||||
$this->contentLength = self::parseContentLength($binaryData, $offsetIndex);
|
||||
|
||||
$children = [];
|
||||
$octetsToRead = $this->contentLength;
|
||||
while ($octetsToRead > 0) {
|
||||
$newChild = ASNObject::fromBinary($binaryData, $offsetIndex);
|
||||
$octetsToRead -= $newChild->getObjectLength();
|
||||
$children[] = $newChild;
|
||||
}
|
||||
|
||||
parent::__construct(...$children);
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return ord($this->identifier);
|
||||
}
|
||||
|
||||
public function getIdentifier()
|
||||
{
|
||||
return $this->identifier;
|
||||
}
|
||||
|
||||
protected function calculateContentLength()
|
||||
{
|
||||
return $this->contentLength;
|
||||
}
|
||||
|
||||
protected function getEncodedValue()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
59
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/UnknownObject.php
vendored
Normal file
59
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/ASN1/UnknownObject.php
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\ASN1;
|
||||
|
||||
class UnknownObject extends ASNObject
|
||||
{
|
||||
/** @var string */
|
||||
private $value;
|
||||
|
||||
private $identifier;
|
||||
|
||||
/**
|
||||
* @param string|int $identifier Either the first identifier octet as int or all identifier bytes as a string
|
||||
* @param int $contentLength
|
||||
*/
|
||||
public function __construct($identifier, $contentLength)
|
||||
{
|
||||
if (is_int($identifier)) {
|
||||
$identifier = chr($identifier);
|
||||
}
|
||||
|
||||
$this->identifier = $identifier;
|
||||
$this->value = "Unparsable Object ({$contentLength} bytes)";
|
||||
$this->setContentLength($contentLength);
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return ord($this->identifier[0]);
|
||||
}
|
||||
|
||||
public function getIdentifier()
|
||||
{
|
||||
return $this->identifier;
|
||||
}
|
||||
|
||||
protected function calculateContentLength()
|
||||
{
|
||||
return $this->getContentLength();
|
||||
}
|
||||
|
||||
protected function getEncodedValue()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
195
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/Utility/BigInteger.php
vendored
Normal file
195
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/Utility/BigInteger.php
vendored
Normal file
|
@ -0,0 +1,195 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\Utility;
|
||||
|
||||
/**
|
||||
* Class BigInteger
|
||||
* Utility class to remove dependence on a single large number library. Not intended for external use, this class only
|
||||
* implements the functionality needed throughout this project.
|
||||
*
|
||||
* Instances are immutable, all operations return a new instance with the result.
|
||||
*
|
||||
* @package FG\Utility
|
||||
* @internal
|
||||
*/
|
||||
abstract class BigInteger
|
||||
{
|
||||
/**
|
||||
* Force a preference on the underlying big number implementation, useful for testing.
|
||||
* @var string|null
|
||||
*/
|
||||
private static $_prefer;
|
||||
|
||||
public static function setPrefer($prefer = null)
|
||||
{
|
||||
self::$_prefer = $prefer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a BigInteger instance based off the base 10 string or an integer.
|
||||
* @param string|int $val
|
||||
* @return BigInteger
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public static function create($val)
|
||||
{
|
||||
if (self::$_prefer) {
|
||||
switch (self::$_prefer) {
|
||||
case 'gmp':
|
||||
$ret = new BigIntegerGmp();
|
||||
break;
|
||||
case 'bcmath':
|
||||
$ret = new BigIntegerBcmath();
|
||||
break;
|
||||
default:
|
||||
throw new \UnexpectedValueException('Unknown number implementation: ' . self::$_prefer);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// autodetect
|
||||
if (function_exists('gmp_add')) {
|
||||
$ret = new BigIntegerGmp();
|
||||
}
|
||||
elseif (function_exists('bcadd')) {
|
||||
$ret = new BigIntegerBcmath();
|
||||
} else {
|
||||
throw new \RuntimeException('Requires GMP or bcmath extension.');
|
||||
}
|
||||
}
|
||||
|
||||
if (is_int($val)) {
|
||||
$ret->_fromInteger($val);
|
||||
}
|
||||
else {
|
||||
// convert to string, if not already one
|
||||
$val = (string)$val;
|
||||
|
||||
// validate string
|
||||
if (!preg_match('/^-?[0-9]+$/', $val)) {
|
||||
throw new \InvalidArgumentException('Expects a string representation of an integer.');
|
||||
}
|
||||
$ret->_fromString($val);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* BigInteger constructor.
|
||||
* Prevent directly instantiating object, use BigInteger::create instead.
|
||||
*/
|
||||
protected function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Subclasses must provide clone functionality.
|
||||
* @return BigInteger
|
||||
*/
|
||||
abstract public function __clone();
|
||||
|
||||
/**
|
||||
* Assign the instance value from base 10 string.
|
||||
* @param string $str
|
||||
*/
|
||||
abstract protected function _fromString($str);
|
||||
|
||||
/**
|
||||
* Assign the instance value from an integer type.
|
||||
* @param int $integer
|
||||
*/
|
||||
abstract protected function _fromInteger($integer);
|
||||
|
||||
/**
|
||||
* Must provide string implementation that returns base 10 number.
|
||||
* @return string
|
||||
*/
|
||||
abstract public function __toString();
|
||||
|
||||
/* INFORMATIONAL FUNCTIONS */
|
||||
|
||||
/**
|
||||
* Return integer, if possible. Throws an exception if the number can not be represented as a native integer.
|
||||
* @return int
|
||||
* @throws \OverflowException
|
||||
*/
|
||||
abstract public function toInteger();
|
||||
|
||||
/**
|
||||
* Is represented integer negative?
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function isNegative();
|
||||
|
||||
/**
|
||||
* Compare the integer with $number, returns a negative integer if $this is less than number, returns 0 if $this is
|
||||
* equal to number and returns a positive integer if $this is greater than number.
|
||||
* @param BigInteger|string|int $number
|
||||
* @return int
|
||||
*/
|
||||
abstract public function compare($number);
|
||||
|
||||
/* MODIFY */
|
||||
|
||||
/**
|
||||
* Add another integer $b and returns the result.
|
||||
* @param BigInteger|string|int $b
|
||||
* @return BigInteger
|
||||
*/
|
||||
abstract public function add($b);
|
||||
|
||||
/**
|
||||
* Subtract $b from $this and returns the result.
|
||||
* @param BigInteger|string|int $b
|
||||
* @return BigInteger
|
||||
*/
|
||||
abstract public function subtract($b);
|
||||
|
||||
/**
|
||||
* Multiply value.
|
||||
* @param BigInteger|string|int $b
|
||||
* @return BigInteger
|
||||
*/
|
||||
abstract public function multiply($b);
|
||||
|
||||
/**
|
||||
* The value $this modulus $b.
|
||||
* @param BigInteger|string|int $b
|
||||
* @return BigInteger
|
||||
*/
|
||||
abstract public function modulus($b);
|
||||
|
||||
/**
|
||||
* Raise $this to the power of $b and returns the result.
|
||||
* @param BigInteger|string|int $b
|
||||
* @return BigInteger
|
||||
*/
|
||||
abstract public function toPower($b);
|
||||
|
||||
/**
|
||||
* Shift the value to the right by a set number of bits and returns the result.
|
||||
* @param int $bits
|
||||
* @return BigInteger
|
||||
*/
|
||||
abstract public function shiftRight($bits = 8);
|
||||
|
||||
/**
|
||||
* Shift the value to the left by a set number of bits and returns the result.
|
||||
* @param int $bits
|
||||
* @return BigInteger
|
||||
*/
|
||||
abstract public function shiftLeft($bits = 8);
|
||||
|
||||
/**
|
||||
* Returns the absolute value.
|
||||
* @return BigInteger
|
||||
*/
|
||||
abstract public function absoluteValue();
|
||||
}
|
133
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/Utility/BigIntegerBcmath.php
vendored
Normal file
133
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/Utility/BigIntegerBcmath.php
vendored
Normal file
|
@ -0,0 +1,133 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\Utility;
|
||||
|
||||
/**
|
||||
* Class BigIntegerBcmath
|
||||
* Integer representation of big numbers using the bcmath library to perform large operations.
|
||||
* @package FG\Utility
|
||||
* @internal
|
||||
*/
|
||||
class BigIntegerBcmath extends BigInteger
|
||||
{
|
||||
protected $_str;
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
// nothing needed to copy
|
||||
}
|
||||
|
||||
protected function _fromString($str)
|
||||
{
|
||||
$this->_str = (string)$str;
|
||||
}
|
||||
|
||||
protected function _fromInteger($integer)
|
||||
{
|
||||
$this->_str = (string)$integer;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->_str;
|
||||
}
|
||||
|
||||
public function toInteger()
|
||||
{
|
||||
if ($this->compare(PHP_INT_MAX) > 0 || $this->compare(PHP_INT_MIN) < 0) {
|
||||
throw new \OverflowException(sprintf('Can not represent %s as integer.', $this->_str));
|
||||
}
|
||||
return (int)$this->_str;
|
||||
}
|
||||
|
||||
public function isNegative()
|
||||
{
|
||||
return bccomp($this->_str, '0', 0) < 0;
|
||||
}
|
||||
|
||||
protected function _unwrap($number)
|
||||
{
|
||||
if ($number instanceof self) {
|
||||
return $number->_str;
|
||||
}
|
||||
return $number;
|
||||
}
|
||||
|
||||
public function compare($number)
|
||||
{
|
||||
return bccomp($this->_str, $this->_unwrap($number), 0);
|
||||
}
|
||||
|
||||
public function add($b)
|
||||
{
|
||||
$ret = new self();
|
||||
$ret->_str = bcadd($this->_str, $this->_unwrap($b), 0);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function subtract($b)
|
||||
{
|
||||
$ret = new self();
|
||||
$ret->_str = bcsub($this->_str, $this->_unwrap($b), 0);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function multiply($b)
|
||||
{
|
||||
$ret = new self();
|
||||
$ret->_str = bcmul($this->_str, $this->_unwrap($b), 0);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function modulus($b)
|
||||
{
|
||||
$ret = new self();
|
||||
if ($this->isNegative()) {
|
||||
// bcmod handles negative numbers differently
|
||||
$b = $this->_unwrap($b);
|
||||
$ret->_str = bcsub($b, bcmod(bcsub('0', $this->_str, 0), $b), 0);
|
||||
}
|
||||
else {
|
||||
$ret->_str = bcmod($this->_str, $this->_unwrap($b));
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function toPower($b)
|
||||
{
|
||||
$ret = new self();
|
||||
$ret->_str = bcpow($this->_str, $this->_unwrap($b), 0);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function shiftRight($bits = 8)
|
||||
{
|
||||
$ret = new self();
|
||||
$ret->_str = bcdiv($this->_str, bcpow('2', $bits));
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function shiftLeft($bits = 8) {
|
||||
$ret = new self();
|
||||
$ret->_str = bcmul($this->_str, bcpow('2', $bits));
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function absoluteValue()
|
||||
{
|
||||
$ret = new self();
|
||||
if (-1 === bccomp($this->_str, '0', 0)) {
|
||||
$ret->_str = bcsub('0', $this->_str, 0);
|
||||
}
|
||||
else {
|
||||
$ret->_str = $this->_str;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
133
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/Utility/BigIntegerGmp.php
vendored
Normal file
133
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/Utility/BigIntegerGmp.php
vendored
Normal file
|
@ -0,0 +1,133 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\Utility;
|
||||
|
||||
/**
|
||||
* Class BigIntegerGmp
|
||||
* Integer representation of big numbers using the GMP extension to perform operations.
|
||||
* @package FG\Utility
|
||||
* @internal
|
||||
*/
|
||||
class BigIntegerGmp extends BigInteger
|
||||
{
|
||||
/**
|
||||
* Resource handle.
|
||||
* @var \GMP
|
||||
*/
|
||||
protected $_rh;
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$this->_rh = gmp_add($this->_rh, 0);
|
||||
}
|
||||
|
||||
protected function _fromString($str)
|
||||
{
|
||||
$this->_rh = gmp_init($str, 10);
|
||||
}
|
||||
|
||||
protected function _fromInteger($integer)
|
||||
{
|
||||
$this->_rh = gmp_init($integer, 10);
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return gmp_strval($this->_rh, 10);
|
||||
}
|
||||
|
||||
public function toInteger()
|
||||
{
|
||||
if ($this->compare(PHP_INT_MAX) > 0 || $this->compare(PHP_INT_MIN) < 0) {
|
||||
throw new \OverflowException(sprintf('Can not represent %s as integer.', $this));
|
||||
}
|
||||
return gmp_intval($this->_rh);
|
||||
}
|
||||
|
||||
public function isNegative()
|
||||
{
|
||||
return gmp_sign($this->_rh) === -1;
|
||||
}
|
||||
|
||||
protected function _unwrap($number)
|
||||
{
|
||||
if ($number instanceof self) {
|
||||
return $number->_rh;
|
||||
}
|
||||
return $number;
|
||||
}
|
||||
|
||||
public function compare($number)
|
||||
{
|
||||
return gmp_cmp($this->_rh, $this->_unwrap($number));
|
||||
}
|
||||
|
||||
public function add($b)
|
||||
{
|
||||
$ret = new self();
|
||||
$ret->_rh = gmp_add($this->_rh, $this->_unwrap($b));
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function subtract($b)
|
||||
{
|
||||
$ret = new self();
|
||||
$ret->_rh = gmp_sub($this->_rh, $this->_unwrap($b));
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function multiply($b)
|
||||
{
|
||||
$ret = new self();
|
||||
$ret->_rh = gmp_mul($this->_rh, $this->_unwrap($b));
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function modulus($b)
|
||||
{
|
||||
$ret = new self();
|
||||
$ret->_rh = gmp_mod($this->_rh, $this->_unwrap($b));
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function toPower($b)
|
||||
{
|
||||
if ($b instanceof self) {
|
||||
// gmp_pow accepts just an integer
|
||||
if ($b->compare(PHP_INT_MAX) > 0) {
|
||||
throw new \UnexpectedValueException('Unable to raise to power greater than PHP_INT_MAX.');
|
||||
}
|
||||
$b = gmp_intval($b->_rh);
|
||||
}
|
||||
$ret = new self();
|
||||
$ret->_rh = gmp_pow($this->_rh, $b);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function shiftRight($bits=8)
|
||||
{
|
||||
$ret = new self();
|
||||
$ret->_rh = gmp_div($this->_rh, gmp_pow(2, $bits));
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function shiftLeft($bits=8)
|
||||
{
|
||||
$ret = new self();
|
||||
$ret->_rh = gmp_mul($this->_rh, gmp_pow(2, $bits));
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function absoluteValue()
|
||||
{
|
||||
$ret = new self();
|
||||
$ret->_rh = gmp_abs($this->_rh);
|
||||
return $ret;
|
||||
}
|
||||
}
|
22
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/X509/AlgorithmIdentifier.php
vendored
Normal file
22
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/X509/AlgorithmIdentifier.php
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\X509;
|
||||
|
||||
use FG\ASN1\Universal\NullObject;
|
||||
use FG\ASN1\Composite\AttributeTypeAndValue;
|
||||
|
||||
class AlgorithmIdentifier extends AttributeTypeAndValue
|
||||
{
|
||||
public function __construct($objectIdentifierString)
|
||||
{
|
||||
parent::__construct($objectIdentifierString, new NullObject());
|
||||
}
|
||||
}
|
68
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/X509/CSR/Attributes.php
vendored
Normal file
68
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/X509/CSR/Attributes.php
vendored
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\X509\CSR;
|
||||
|
||||
use FG\ASN1\ASNObject;
|
||||
use FG\X509\CertificateExtensions;
|
||||
use FG\ASN1\OID;
|
||||
use FG\ASN1\Parsable;
|
||||
use FG\ASN1\Construct;
|
||||
use FG\ASN1\Identifier;
|
||||
use FG\ASN1\Universal\Set;
|
||||
use FG\ASN1\Universal\Sequence;
|
||||
use FG\ASN1\Universal\ObjectIdentifier;
|
||||
|
||||
class Attributes extends Construct implements Parsable
|
||||
{
|
||||
public function getType()
|
||||
{
|
||||
return 0xA0;
|
||||
}
|
||||
|
||||
public function addAttribute($objectIdentifier, Set $attribute)
|
||||
{
|
||||
if (is_string($objectIdentifier)) {
|
||||
$objectIdentifier = new ObjectIdentifier($objectIdentifier);
|
||||
}
|
||||
$attributeSequence = new Sequence($objectIdentifier, $attribute);
|
||||
$attributeSequence->getNumberOfLengthOctets(); // length and number of length octets is calculated
|
||||
$this->addChild($attributeSequence);
|
||||
}
|
||||
|
||||
public static function fromBinary(&$binaryData, &$offsetIndex = 0)
|
||||
{
|
||||
self::parseIdentifier($binaryData[$offsetIndex], 0xA0, $offsetIndex++);
|
||||
$contentLength = self::parseContentLength($binaryData, $offsetIndex);
|
||||
$octetsToRead = $contentLength;
|
||||
|
||||
$parsedObject = new self();
|
||||
while ($octetsToRead > 0) {
|
||||
$initialOffset = $offsetIndex; // used to calculate how much bits have been read
|
||||
self::parseIdentifier($binaryData[$offsetIndex], Identifier::SEQUENCE, $offsetIndex++);
|
||||
self::parseContentLength($binaryData, $offsetIndex);
|
||||
|
||||
$objectIdentifier = ObjectIdentifier::fromBinary($binaryData, $offsetIndex);
|
||||
$oidString = $objectIdentifier->getContent();
|
||||
if ($oidString == OID::PKCS9_EXTENSION_REQUEST) {
|
||||
$attribute = CertificateExtensions::fromBinary($binaryData, $offsetIndex);
|
||||
} else {
|
||||
$attribute = ASNObject::fromBinary($binaryData, $offsetIndex);
|
||||
}
|
||||
|
||||
$parsedObject->addAttribute($objectIdentifier, $attribute);
|
||||
$octetsToRead -= ($offsetIndex - $initialOffset);
|
||||
}
|
||||
|
||||
$parsedObject->setContentLength($contentLength);
|
||||
|
||||
return $parsedObject;
|
||||
}
|
||||
}
|
159
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/X509/CSR/CSR.php
vendored
Normal file
159
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/X509/CSR/CSR.php
vendored
Normal file
|
@ -0,0 +1,159 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\X509\CSR;
|
||||
|
||||
use FG\ASN1\OID;
|
||||
use FG\ASN1\Universal\Integer;
|
||||
use FG\ASN1\Universal\BitString;
|
||||
use FG\ASN1\Universal\Sequence;
|
||||
use FG\X509\CertificateSubject;
|
||||
use FG\X509\AlgorithmIdentifier;
|
||||
use FG\X509\PublicKey;
|
||||
|
||||
class CSR extends Sequence
|
||||
{
|
||||
const CSR_VERSION_NR = 0;
|
||||
|
||||
protected $subject;
|
||||
protected $publicKey;
|
||||
protected $signature;
|
||||
protected $signatureAlgorithm;
|
||||
|
||||
protected $startSequence;
|
||||
|
||||
/**
|
||||
* @param string $commonName
|
||||
* @param string $email
|
||||
* @param string $organization
|
||||
* @param string $locality
|
||||
* @param string $state
|
||||
* @param string $country
|
||||
* @param string $organizationalUnit
|
||||
* @param string $publicKey
|
||||
* @param string $signature
|
||||
* @param string $signatureAlgorithm
|
||||
*/
|
||||
public function __construct($commonName, $email, $organization, $locality, $state, $country, $organizationalUnit, $publicKey, $signature = null, $signatureAlgorithm = OID::SHA1_WITH_RSA_SIGNATURE)
|
||||
{
|
||||
$this->subject = new CertificateSubject(
|
||||
$commonName,
|
||||
$email,
|
||||
$organization,
|
||||
$locality,
|
||||
$state,
|
||||
$country,
|
||||
$organizationalUnit
|
||||
);
|
||||
$this->publicKey = $publicKey;
|
||||
$this->signature = $signature;
|
||||
$this->signatureAlgorithm = $signatureAlgorithm;
|
||||
|
||||
if (isset($signature)) {
|
||||
$this->createCSRSequence();
|
||||
}
|
||||
}
|
||||
|
||||
protected function createCSRSequence()
|
||||
{
|
||||
$versionNr = new Integer(self::CSR_VERSION_NR);
|
||||
$publicKey = new PublicKey($this->publicKey);
|
||||
$signature = new BitString($this->signature);
|
||||
$signatureAlgorithm = new AlgorithmIdentifier($this->signatureAlgorithm);
|
||||
|
||||
$certRequestInfo = new Sequence($versionNr, $this->subject, $publicKey);
|
||||
|
||||
// Clear the underlying Construct
|
||||
$this->rewind();
|
||||
$this->children = [];
|
||||
$this->addChild($certRequestInfo);
|
||||
$this->addChild($signatureAlgorithm);
|
||||
$this->addChild($signature);
|
||||
}
|
||||
|
||||
public function getSignatureSubject()
|
||||
{
|
||||
$versionNr = new Integer(self::CSR_VERSION_NR);
|
||||
$publicKey = new PublicKey($this->publicKey);
|
||||
|
||||
$certRequestInfo = new Sequence($versionNr, $this->subject, $publicKey);
|
||||
return $certRequestInfo->getBinary();
|
||||
}
|
||||
|
||||
public function setSignature($signature, $signatureAlgorithm = OID::SHA1_WITH_RSA_SIGNATURE)
|
||||
{
|
||||
$this->signature = $signature;
|
||||
$this->signatureAlgorithm = $signatureAlgorithm;
|
||||
|
||||
$this->createCSRSequence();
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
$tmp = base64_encode($this->getBinary());
|
||||
|
||||
for ($i = 0; $i < strlen($tmp); $i++) {
|
||||
if (($i + 2) % 65 == 0) {
|
||||
$tmp = substr($tmp, 0, $i + 1)."\n".substr($tmp, $i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
$result = '-----BEGIN CERTIFICATE REQUEST-----'.PHP_EOL;
|
||||
$result .= $tmp.PHP_EOL;
|
||||
$result .= '-----END CERTIFICATE REQUEST-----';
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getVersion()
|
||||
{
|
||||
return self::CSR_VERSION_NR;
|
||||
}
|
||||
|
||||
public function getOrganizationName()
|
||||
{
|
||||
return $this->subject->getOrganization();
|
||||
}
|
||||
|
||||
public function getLocalName()
|
||||
{
|
||||
return $this->subject->getLocality();
|
||||
}
|
||||
|
||||
public function getState()
|
||||
{
|
||||
return $this->subject->getState();
|
||||
}
|
||||
|
||||
public function getCountry()
|
||||
{
|
||||
return $this->subject->getCountry();
|
||||
}
|
||||
|
||||
public function getOrganizationalUnit()
|
||||
{
|
||||
return $this->subject->getOrganizationalUnit();
|
||||
}
|
||||
|
||||
public function getPublicKey()
|
||||
{
|
||||
return $this->publicKey;
|
||||
}
|
||||
|
||||
public function getSignature()
|
||||
{
|
||||
return $this->signature;
|
||||
}
|
||||
|
||||
public function getSignatureAlgorithm()
|
||||
{
|
||||
return $this->signatureAlgorithm;
|
||||
}
|
||||
}
|
100
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/X509/CertificateExtensions.php
vendored
Normal file
100
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/X509/CertificateExtensions.php
vendored
Normal file
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\X509;
|
||||
|
||||
use FG\ASN1\Exception\ParserException;
|
||||
use FG\ASN1\OID;
|
||||
use FG\ASN1\ASNObject;
|
||||
use FG\ASN1\Parsable;
|
||||
use FG\ASN1\Identifier;
|
||||
use FG\ASN1\Universal\OctetString;
|
||||
use FG\ASN1\Universal\Set;
|
||||
use FG\ASN1\Universal\Sequence;
|
||||
use FG\ASN1\Universal\ObjectIdentifier;
|
||||
use FG\X509\SAN\SubjectAlternativeNames;
|
||||
|
||||
class CertificateExtensions extends Set implements Parsable
|
||||
{
|
||||
private $innerSequence;
|
||||
private $extensions = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->innerSequence = new Sequence();
|
||||
parent::__construct($this->innerSequence);
|
||||
}
|
||||
|
||||
public function addSubjectAlternativeNames(SubjectAlternativeNames $sans)
|
||||
{
|
||||
$this->addExtension(OID::CERT_EXT_SUBJECT_ALT_NAME, $sans);
|
||||
}
|
||||
|
||||
private function addExtension($oidString, ASNObject $extension)
|
||||
{
|
||||
$sequence = new Sequence();
|
||||
$sequence->addChild(new ObjectIdentifier($oidString));
|
||||
$sequence->addChild($extension);
|
||||
|
||||
$this->innerSequence->addChild($sequence);
|
||||
$this->extensions[] = $extension;
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
return $this->extensions;
|
||||
}
|
||||
|
||||
public static function fromBinary(&$binaryData, &$offsetIndex = 0)
|
||||
{
|
||||
self::parseIdentifier($binaryData[$offsetIndex], Identifier::SET, $offsetIndex++);
|
||||
self::parseContentLength($binaryData, $offsetIndex);
|
||||
|
||||
$tmpOffset = $offsetIndex;
|
||||
$extensions = Sequence::fromBinary($binaryData, $offsetIndex);
|
||||
$tmpOffset += 1 + $extensions->getNumberOfLengthOctets();
|
||||
|
||||
$parsedObject = new self();
|
||||
foreach ($extensions as $extension) {
|
||||
if ($extension->getType() != Identifier::SEQUENCE) {
|
||||
//FIXME wrong offset index
|
||||
throw new ParserException('Could not parse Certificate Extensions: Expected ASN.1 Sequence but got '.$extension->getTypeName(), $offsetIndex);
|
||||
}
|
||||
|
||||
$tmpOffset += 1 + $extension->getNumberOfLengthOctets();
|
||||
$children = $extension->getChildren();
|
||||
if (count($children) < 2) {
|
||||
throw new ParserException('Could not parse Certificate Extensions: Needs at least two child elements per extension sequence (object identifier and octet string)', $tmpOffset);
|
||||
}
|
||||
/** @var \FG\ASN1\ASNObject $objectIdentifier */
|
||||
$objectIdentifier = $children[0];
|
||||
|
||||
/** @var OctetString $octetString */
|
||||
$octetString = $children[1];
|
||||
|
||||
if ($objectIdentifier->getType() != Identifier::OBJECT_IDENTIFIER) {
|
||||
throw new ParserException('Could not parse Certificate Extensions: Expected ASN.1 Object Identifier but got '.$extension->getTypeName(), $tmpOffset);
|
||||
}
|
||||
|
||||
$tmpOffset += $objectIdentifier->getObjectLength();
|
||||
|
||||
if ($objectIdentifier->getContent() == OID::CERT_EXT_SUBJECT_ALT_NAME) {
|
||||
$sans = SubjectAlternativeNames::fromBinary($binaryData, $tmpOffset);
|
||||
$parsedObject->addSubjectAlternativeNames($sans);
|
||||
} else {
|
||||
// can now only parse SANs. There might be more in the future
|
||||
$tmpOffset += $octetString->getObjectLength();
|
||||
}
|
||||
}
|
||||
|
||||
$parsedObject->getBinary(); // Determine the number of content octets and object sizes once (just to let the equality unit tests pass :/ )
|
||||
return $parsedObject;
|
||||
}
|
||||
}
|
108
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/X509/CertificateSubject.php
vendored
Normal file
108
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/X509/CertificateSubject.php
vendored
Normal file
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\X509;
|
||||
|
||||
use FG\ASN1\Composite\RelativeDistinguishedName;
|
||||
use FG\ASN1\Identifier;
|
||||
use FG\ASN1\OID;
|
||||
use FG\ASN1\Parsable;
|
||||
use FG\ASN1\Composite\RDNString;
|
||||
use FG\ASN1\Universal\Sequence;
|
||||
|
||||
class CertificateSubject extends Sequence implements Parsable
|
||||
{
|
||||
private $commonName;
|
||||
private $email;
|
||||
private $organization;
|
||||
private $locality;
|
||||
private $state;
|
||||
private $country;
|
||||
private $organizationalUnit;
|
||||
|
||||
/**
|
||||
* @param string $commonName
|
||||
* @param string $email
|
||||
* @param string $organization
|
||||
* @param string $locality
|
||||
* @param string $state
|
||||
* @param string $country
|
||||
* @param string $organizationalUnit
|
||||
*/
|
||||
public function __construct($commonName, $email, $organization, $locality, $state, $country, $organizationalUnit)
|
||||
{
|
||||
parent::__construct(
|
||||
new RDNString(OID::COUNTRY_NAME, $country),
|
||||
new RDNString(OID::STATE_OR_PROVINCE_NAME, $state),
|
||||
new RDNString(OID::LOCALITY_NAME, $locality),
|
||||
new RDNString(OID::ORGANIZATION_NAME, $organization),
|
||||
new RDNString(OID::OU_NAME, $organizationalUnit),
|
||||
new RDNString(OID::COMMON_NAME, $commonName),
|
||||
new RDNString(OID::PKCS9_EMAIL, $email)
|
||||
);
|
||||
|
||||
$this->commonName = $commonName;
|
||||
$this->email = $email;
|
||||
$this->organization = $organization;
|
||||
$this->locality = $locality;
|
||||
$this->state = $state;
|
||||
$this->country = $country;
|
||||
$this->organizationalUnit = $organizationalUnit;
|
||||
}
|
||||
|
||||
public function getCommonName()
|
||||
{
|
||||
return $this->commonName;
|
||||
}
|
||||
|
||||
public function getEmail()
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function getOrganization()
|
||||
{
|
||||
return $this->organization;
|
||||
}
|
||||
|
||||
public function getLocality()
|
||||
{
|
||||
return $this->locality;
|
||||
}
|
||||
|
||||
public function getState()
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
public function getCountry()
|
||||
{
|
||||
return $this->country;
|
||||
}
|
||||
|
||||
public function getOrganizationalUnit()
|
||||
{
|
||||
return $this->organizationalUnit;
|
||||
}
|
||||
|
||||
public static function fromBinary(&$binaryData, &$offsetIndex = 0)
|
||||
{
|
||||
self::parseIdentifier($binaryData[$offsetIndex], Identifier::SEQUENCE, $offsetIndex++);
|
||||
$contentLength = self::parseContentLength($binaryData, $offsetIndex);
|
||||
|
||||
$names = [];
|
||||
$octetsToRead = $contentLength;
|
||||
while ($octetsToRead > 0) {
|
||||
$relativeDistinguishedName = RelativeDistinguishedName::fromBinary($binaryData, $offsetIndex);
|
||||
$octetsToRead -= $relativeDistinguishedName->getObjectLength();
|
||||
$names[] = $relativeDistinguishedName;
|
||||
}
|
||||
}
|
||||
}
|
35
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/X509/PrivateKey.php
vendored
Normal file
35
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/X509/PrivateKey.php
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\X509;
|
||||
|
||||
use FG\ASN1\OID;
|
||||
use FG\ASN1\Universal\NullObject;
|
||||
use FG\ASN1\Universal\Sequence;
|
||||
use FG\ASN1\Universal\BitString;
|
||||
use FG\ASN1\Universal\ObjectIdentifier;
|
||||
|
||||
class PrivateKey extends Sequence
|
||||
{
|
||||
/**
|
||||
* @param string $hexKey
|
||||
* @param \FG\ASN1\ASNObject|string $algorithmIdentifierString
|
||||
*/
|
||||
public function __construct($hexKey, $algorithmIdentifierString = OID::RSA_ENCRYPTION)
|
||||
{
|
||||
parent::__construct(
|
||||
new Sequence(
|
||||
new ObjectIdentifier($algorithmIdentifierString),
|
||||
new NullObject()
|
||||
),
|
||||
new BitString($hexKey)
|
||||
);
|
||||
}
|
||||
}
|
35
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/X509/PublicKey.php
vendored
Normal file
35
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/X509/PublicKey.php
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\X509;
|
||||
|
||||
use FG\ASN1\OID;
|
||||
use FG\ASN1\Universal\NullObject;
|
||||
use FG\ASN1\Universal\Sequence;
|
||||
use FG\ASN1\Universal\BitString;
|
||||
use FG\ASN1\Universal\ObjectIdentifier;
|
||||
|
||||
class PublicKey extends Sequence
|
||||
{
|
||||
/**
|
||||
* @param string $hexKey
|
||||
* @param \FG\ASN1\ASNObject|string $algorithmIdentifierString
|
||||
*/
|
||||
public function __construct($hexKey, $algorithmIdentifierString = OID::RSA_ENCRYPTION)
|
||||
{
|
||||
parent::__construct(
|
||||
new Sequence(
|
||||
new ObjectIdentifier($algorithmIdentifierString),
|
||||
new NullObject()
|
||||
),
|
||||
new BitString($hexKey)
|
||||
);
|
||||
}
|
||||
}
|
28
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/X509/SAN/DNSName.php
vendored
Normal file
28
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/X509/SAN/DNSName.php
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\X509\SAN;
|
||||
|
||||
use FG\ASN1\Universal\GeneralString;
|
||||
|
||||
class DNSName extends GeneralString
|
||||
{
|
||||
const IDENTIFIER = 0x82; // not sure yet why this is the identifier used in SAN extensions
|
||||
|
||||
public function __construct($dnsNameString)
|
||||
{
|
||||
parent::__construct($dnsNameString);
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return self::IDENTIFIER;
|
||||
}
|
||||
}
|
73
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/X509/SAN/IPAddress.php
vendored
Normal file
73
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/X509/SAN/IPAddress.php
vendored
Normal file
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\X509\SAN;
|
||||
|
||||
use FG\ASN1\ASNObject;
|
||||
use FG\ASN1\Parsable;
|
||||
use FG\ASN1\Exception\ParserException;
|
||||
|
||||
class IPAddress extends ASNObject implements Parsable
|
||||
{
|
||||
const IDENTIFIER = 0x87; // not sure yet why this is the identifier used in SAN extensions
|
||||
|
||||
/** @var string */
|
||||
private $value;
|
||||
|
||||
public function __construct($ipAddressString)
|
||||
{
|
||||
$this->value = $ipAddressString;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return self::IDENTIFIER;
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
protected function calculateContentLength()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
protected function getEncodedValue()
|
||||
{
|
||||
$ipParts = explode('.', $this->value);
|
||||
$binary = chr($ipParts[0]);
|
||||
$binary .= chr($ipParts[1]);
|
||||
$binary .= chr($ipParts[2]);
|
||||
$binary .= chr($ipParts[3]);
|
||||
|
||||
return $binary;
|
||||
}
|
||||
|
||||
public static function fromBinary(&$binaryData, &$offsetIndex = 0)
|
||||
{
|
||||
self::parseIdentifier($binaryData[$offsetIndex], self::IDENTIFIER, $offsetIndex++);
|
||||
$contentLength = self::parseContentLength($binaryData, $offsetIndex);
|
||||
if ($contentLength != 4) {
|
||||
throw new ParserException("A FG\\X509\SAN\IPAddress should have a content length of 4. Extracted length was {$contentLength}", $offsetIndex);
|
||||
}
|
||||
|
||||
$ipAddressString = ord($binaryData[$offsetIndex++]).'.';
|
||||
$ipAddressString .= ord($binaryData[$offsetIndex++]).'.';
|
||||
$ipAddressString .= ord($binaryData[$offsetIndex++]).'.';
|
||||
$ipAddressString .= ord($binaryData[$offsetIndex++]);
|
||||
|
||||
$parsedObject = new self($ipAddressString);
|
||||
$parsedObject->getObjectLength();
|
||||
|
||||
return $parsedObject;
|
||||
}
|
||||
}
|
96
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/X509/SAN/SubjectAlternativeNames.php
vendored
Normal file
96
admin/phpMyAdmin/vendor/fgrosse/phpasn1/lib/X509/SAN/SubjectAlternativeNames.php
vendored
Normal file
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the PHPASN1 library.
|
||||
*
|
||||
* Copyright © Friedrich Große <friedrich.grosse@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace FG\X509\SAN;
|
||||
|
||||
use FG\ASN1\Exception\ParserException;
|
||||
use FG\ASN1\ASNObject;
|
||||
use FG\ASN1\OID;
|
||||
use FG\ASN1\Parsable;
|
||||
use FG\ASN1\Identifier;
|
||||
use FG\ASN1\Universal\Sequence;
|
||||
|
||||
/**
|
||||
* See section 8.3.2.1 of ITU-T X.509.
|
||||
*/
|
||||
class SubjectAlternativeNames extends ASNObject implements Parsable
|
||||
{
|
||||
private $alternativeNamesSequence;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->alternativeNamesSequence = new Sequence();
|
||||
}
|
||||
|
||||
protected function calculateContentLength()
|
||||
{
|
||||
return $this->alternativeNamesSequence->getObjectLength();
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return Identifier::OCTETSTRING;
|
||||
}
|
||||
|
||||
public function addDomainName(DNSName $domainName)
|
||||
{
|
||||
$this->alternativeNamesSequence->addChild($domainName);
|
||||
}
|
||||
|
||||
public function addIP(IPAddress $ip)
|
||||
{
|
||||
$this->alternativeNamesSequence->addChild($ip);
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
return $this->alternativeNamesSequence->getContent();
|
||||
}
|
||||
|
||||
protected function getEncodedValue()
|
||||
{
|
||||
return $this->alternativeNamesSequence->getBinary();
|
||||
}
|
||||
|
||||
public static function fromBinary(&$binaryData, &$offsetIndex = 0)
|
||||
{
|
||||
self::parseIdentifier($binaryData[$offsetIndex], Identifier::OCTETSTRING, $offsetIndex++);
|
||||
$contentLength = self::parseContentLength($binaryData, $offsetIndex);
|
||||
|
||||
if ($contentLength < 2) {
|
||||
throw new ParserException('Can not parse Subject Alternative Names: The Sequence within the octet string after the Object identifier '.OID::CERT_EXT_SUBJECT_ALT_NAME." is too short ({$contentLength} octets)", $offsetIndex);
|
||||
}
|
||||
|
||||
$offsetOfSequence = $offsetIndex;
|
||||
$sequence = Sequence::fromBinary($binaryData, $offsetIndex);
|
||||
$offsetOfSequence += $sequence->getNumberOfLengthOctets() + 1;
|
||||
|
||||
if ($sequence->getObjectLength() != $contentLength) {
|
||||
throw new ParserException('Can not parse Subject Alternative Names: The Sequence length does not match the length of the surrounding octet string', $offsetIndex);
|
||||
}
|
||||
|
||||
$parsedObject = new self();
|
||||
/** @var \FG\ASN1\ASNObject $object */
|
||||
foreach ($sequence as $object) {
|
||||
if ($object->getType() == DNSName::IDENTIFIER) {
|
||||
$domainName = DNSName::fromBinary($binaryData, $offsetOfSequence);
|
||||
$parsedObject->addDomainName($domainName);
|
||||
} elseif ($object->getType() == IPAddress::IDENTIFIER) {
|
||||
$ip = IPAddress::fromBinary($binaryData, $offsetOfSequence);
|
||||
$parsedObject->addIP($ip);
|
||||
} else {
|
||||
throw new ParserException('Could not parse Subject Alternative Name: Only DNSName and IP SANs are currently supported', $offsetIndex);
|
||||
}
|
||||
}
|
||||
|
||||
$parsedObject->getBinary(); // Determine the number of content octets and object sizes once (just to let the equality unit tests pass :/ )
|
||||
return $parsedObject;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue