[ Index ] |
PHP Cross Reference of DokuWiki |
[Summary view] [Print] [Text view]
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.3 10 * 11 * @author Jim Wigginton <terrafrost@php.net> 12 * @copyright 2016 Jim Wigginton 13 * @license http://www.opensource.org/licenses/mit-license.html MIT License 14 * @link http://phpseclib.sourceforge.net 15 */ 16 17 namespace phpseclib3\Crypt\EC\Formats\Signature; 18 19 use phpseclib3\File\ASN1 as Encoder; 20 use phpseclib3\File\ASN1\Maps\EcdsaSigValue; 21 use phpseclib3\Math\BigInteger; 22 23 /** 24 * ASN1 Signature Handler 25 * 26 * @author Jim Wigginton <terrafrost@php.net> 27 */ 28 abstract class ASN1 29 { 30 /** 31 * Loads a signature 32 * 33 * @param string $sig 34 * @return array 35 */ 36 public static function load($sig) 37 { 38 if (!is_string($sig)) { 39 return false; 40 } 41 42 $decoded = Encoder::decodeBER($sig); 43 if (empty($decoded)) { 44 return false; 45 } 46 $components = Encoder::asn1map($decoded[0], EcdsaSigValue::MAP); 47 48 return $components; 49 } 50 51 /** 52 * Returns a signature in the appropriate format 53 * 54 * @param \phpseclib3\Math\BigInteger $r 55 * @param \phpseclib3\Math\BigInteger $s 56 * @return string 57 */ 58 public static function save(BigInteger $r, BigInteger $s) 59 { 60 return Encoder::encodeDER(compact('r', 's'), EcdsaSigValue::MAP); 61 } 62 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body