Subversion Repositories oidplus

Rev

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

  1. <?php
  2.  
  3. /**
  4.  * PKCS Formatted Key Handler
  5.  *
  6.  * PHP version 5
  7.  *
  8.  * @category  Crypt
  9.  * @package   Common
  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.  *
  21.  * @package RSA
  22.  * @author  Jim Wigginton <terrafrost@php.net>
  23.  * @access  public
  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.      *
  44.      * @access private
  45.      * @var int
  46.      */
  47.     protected static $format = self::MODE_ANY;
  48.  
  49.     /**
  50.      * Require base64-encoded PEM's be supplied
  51.      *
  52.      * @access public
  53.      */
  54.     public static function requirePEM()
  55.     {
  56.         self::$format = self::MODE_PEM;
  57.     }
  58.  
  59.     /**
  60.      * Require raw DER's be supplied
  61.      *
  62.      * @access public
  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.      *
  74.      * @access public
  75.      */
  76.     public static function requireAny()
  77.     {
  78.         self::$format = self::MODE_ANY;
  79.     }
  80. }
  81.