2016-12-23 16:02:07 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PKCS Formatted Key Handler
|
|
|
|
*
|
|
|
|
* PHP version 5
|
|
|
|
*
|
|
|
|
* @author Jim Wigginton <terrafrost@php.net>
|
|
|
|
* @copyright 2015 Jim Wigginton
|
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
|
|
|
* @link http://phpseclib.sourceforge.net
|
|
|
|
*/
|
|
|
|
|
2022-06-04 15:31:21 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2019-11-07 05:41:40 +00:00
|
|
|
namespace phpseclib3\Crypt\Common\Formats\Keys;
|
2016-12-23 16:02:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* PKCS1 Formatted Key Handler
|
|
|
|
*
|
|
|
|
* @author Jim Wigginton <terrafrost@php.net>
|
|
|
|
*/
|
|
|
|
abstract class PKCS
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Auto-detect the format
|
|
|
|
*/
|
|
|
|
const MODE_ANY = 0;
|
|
|
|
/**
|
|
|
|
* Require base64-encoded PEM's be supplied
|
|
|
|
*/
|
|
|
|
const MODE_PEM = 1;
|
|
|
|
/**
|
|
|
|
* Require raw DER's be supplied
|
|
|
|
*/
|
|
|
|
const MODE_DER = 2;
|
|
|
|
/**#@-*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Is the key a base-64 encoded PEM, DER or should it be auto-detected?
|
|
|
|
*
|
2020-09-09 08:01:39 +00:00
|
|
|
* @var int
|
2016-12-23 16:02:07 +00:00
|
|
|
*/
|
|
|
|
protected static $format = self::MODE_ANY;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Require base64-encoded PEM's be supplied
|
|
|
|
*/
|
2022-06-04 15:31:21 +00:00
|
|
|
public static function requirePEM(): void
|
2016-12-23 16:02:07 +00:00
|
|
|
{
|
|
|
|
self::$format = self::MODE_PEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Require raw DER's be supplied
|
|
|
|
*/
|
2022-06-04 15:31:21 +00:00
|
|
|
public static function requireDER(): void
|
2016-12-23 16:02:07 +00:00
|
|
|
{
|
|
|
|
self::$format = self::MODE_DER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Accept any format and auto detect the format
|
|
|
|
*
|
|
|
|
* This is the default setting
|
|
|
|
*/
|
2022-06-04 15:31:21 +00:00
|
|
|
public static function requireAny(): void
|
2016-12-23 16:02:07 +00:00
|
|
|
{
|
|
|
|
self::$format = self::MODE_ANY;
|
|
|
|
}
|
2022-02-17 02:25:59 +00:00
|
|
|
}
|