[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Signature/ -> ASN1.php (source)

   1  <?php
   2  
   3  /**
   4   * ASN1 Signature Handler
   5   *
   6   * PHP version 5
   7   *
   8   * Handles signatures in the format described in
   9   * https://tools.ietf.org/html/rfc3279#section-2.2.2
  10   *
  11   * @category  Crypt
  12   * @package   Common
  13   * @author    Jim Wigginton <[email protected]>
  14   * @copyright 2016 Jim Wigginton
  15   * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
  16   * @link      http://phpseclib.sourceforge.net
  17   */
  18  
  19  namespace phpseclib3\Crypt\DSA\Formats\Signature;
  20  
  21  use phpseclib3\File\ASN1 as Encoder;
  22  use phpseclib3\File\ASN1\Maps;
  23  use phpseclib3\Math\BigInteger;
  24  
  25  /**
  26   * ASN1 Signature Handler
  27   *
  28   * @package Common
  29   * @author  Jim Wigginton <[email protected]>
  30   * @access  public
  31   */
  32  abstract class ASN1
  33  {
  34      /**
  35       * Loads a signature
  36       *
  37       * @access public
  38       * @param string $sig
  39       * @return array|bool
  40       */
  41      public static function load($sig)
  42      {
  43          if (!is_string($sig)) {
  44              return false;
  45          }
  46  
  47          $decoded = Encoder::decodeBER($sig);
  48          if (empty($decoded)) {
  49              return false;
  50          }
  51          $components = Encoder::asn1map($decoded[0], Maps\DssSigValue::MAP);
  52  
  53          return $components;
  54      }
  55  
  56      /**
  57       * Returns a signature in the appropriate format
  58       *
  59       * @access public
  60       * @param \phpseclib3\Math\BigInteger $r
  61       * @param \phpseclib3\Math\BigInteger $s
  62       * @return string
  63       */
  64      public static function save(BigInteger $r, BigInteger $s)
  65      {
  66          return Encoder::encodeDER(compact('r', 's'), Maps\DssSigValue::MAP);
  67      }
  68  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer