[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 declare(strict_types=1); 4 5 /* 6 * The MIT License (MIT) 7 * 8 * Copyright (c) 2014-2019 Spomky-Labs 9 * 10 * This software may be modified and distributed under the terms 11 * of the MIT license. See the LICENSE file for details. 12 */ 13 14 namespace Cose\Algorithm\Signature\ECDSA; 15 16 use Cose\Key\Ec2Key; 17 use Cose\Key\Key; 18 19 final class ES256 extends ECDSA 20 { 21 public const ID = -7; 22 23 public static function identifier(): int 24 { 25 return self::ID; 26 } 27 28 public function sign(string $data, Key $key): string 29 { 30 $signature = parent::sign($data, $key); 31 32 return ECSignature::fromAsn1($signature, $this->getSignaturePartLength()); 33 } 34 35 public function verify(string $data, Key $key, string $signature): bool 36 { 37 if (mb_strlen($signature, '8bit') !== $this->getSignaturePartLength()) { 38 @trigger_error('Since v2.1, the method "verify" will only accept raw ECDSA signature in v3.0 and ASN.1 structures will be rejected', E_USER_DEPRECATED); 39 } else { 40 $signature = ECSignature::toAsn1($signature, $this->getSignaturePartLength()); 41 } 42 43 return parent::verify($data, $key, $signature); 44 } 45 46 protected function getHashAlgorithm(): int 47 { 48 return OPENSSL_ALGO_SHA256; 49 } 50 51 protected function getCurve(): int 52 { 53 return Ec2Key::CURVE_P256; 54 } 55 56 protected function getSignaturePartLength(): int 57 { 58 return 64; 59 } 60 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |