Subversion Repositories oidplus

Rev

Rev 846 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
827 daniel-mar 1
<?php
2
 
3
/**
4
 * PKCS Formatted Key Handler
5
 *
6
 * PHP version 5
7
 *
874 daniel-mar 8
 * @category  Crypt
9
 * @package   Common
827 daniel-mar 10
 * @author    Jim Wigginton <terrafrost@php.net>
11
 * @copyright 2015 Jim Wigginton
12
 * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
13
 * @link      http://phpseclib.sourceforge.net
14
 */
15
 
16
namespace phpseclib3\Crypt\Common\Formats\Keys;
17
 
18
/**
19
 * PKCS1 Formatted Key Handler
20
 *
874 daniel-mar 21
 * @package RSA
827 daniel-mar 22
 * @author  Jim Wigginton <terrafrost@php.net>
874 daniel-mar 23
 * @access  public
827 daniel-mar 24
 */
25
abstract class PKCS
26
{
27
    /**
28
     * Auto-detect the format
29
     */
30
    const MODE_ANY = 0;
31
    /**
32
     * Require base64-encoded PEM's be supplied
33
     */
34
    const MODE_PEM = 1;
35
    /**
36
     * Require raw DER's be supplied
37
     */
38
    const MODE_DER = 2;
39
    /**#@-*/
40
 
41
    /**
42
     * Is the key a base-64 encoded PEM, DER or should it be auto-detected?
43
     *
874 daniel-mar 44
     * @access private
827 daniel-mar 45
     * @var int
46
     */
47
    protected static $format = self::MODE_ANY;
48
 
49
    /**
50
     * Require base64-encoded PEM's be supplied
51
     *
874 daniel-mar 52
     * @access public
827 daniel-mar 53
     */
54
    public static function requirePEM()
55
    {
56
        self::$format = self::MODE_PEM;
57
    }
58
 
59
    /**
60
     * Require raw DER's be supplied
61
     *
874 daniel-mar 62
     * @access public
827 daniel-mar 63
     */
64
    public static function requireDER()
65
    {
66
        self::$format = self::MODE_DER;
67
    }
68
 
69
    /**
70
     * Accept any format and auto detect the format
71
     *
72
     * This is the default setting
73
     *
874 daniel-mar 74
     * @access public
827 daniel-mar 75
     */
76
    public static function requireAny()
77
    {
78
        self::$format = self::MODE_ANY;
79
    }
80
}