[ Index ] |
PHP Cross Reference of DokuWiki |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Raw Signature Handler 5 * 6 * PHP version 5 7 * 8 * Handles signatures as arrays 9 * 10 * @author Jim Wigginton <terrafrost@php.net> 11 * @copyright 2016 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\Signature; 17 18 use phpseclib3\Math\BigInteger; 19 20 /** 21 * Raw Signature Handler 22 * 23 * @author Jim Wigginton <terrafrost@php.net> 24 */ 25 abstract class Raw 26 { 27 /** 28 * Loads a signature 29 * 30 * @param array $sig 31 * @return array|bool 32 */ 33 public static function load($sig) 34 { 35 switch (true) { 36 case !is_array($sig): 37 case !isset($sig['r']) || !isset($sig['s']): 38 case !$sig['r'] instanceof BigInteger: 39 case !$sig['s'] instanceof BigInteger: 40 return false; 41 } 42 43 return [ 44 'r' => $sig['r'], 45 's' => $sig['s'] 46 ]; 47 } 48 49 /** 50 * Returns a signature in the appropriate format 51 * 52 * @param \phpseclib3\Math\BigInteger $r 53 * @param \phpseclib3\Math\BigInteger $s 54 * @return string 55 */ 56 public static function save(BigInteger $r, BigInteger $s) 57 { 58 return compact('r', 's'); 59 } 60 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body