[ 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\Key; 15 16 use Assert\Assertion; 17 18 class OkpKey extends Key 19 { 20 public const CURVE_X25519 = 4; 21 public const CURVE_X448 = 5; 22 public const CURVE_ED25519 = 6; 23 public const CURVE_ED448 = 7; 24 25 private const SUPPORTED_CURVES = [ 26 self::CURVE_X25519, 27 self::CURVE_X448, 28 self::CURVE_ED25519, 29 self::CURVE_ED448, 30 ]; 31 32 public const DATA_CURVE = -1; 33 public const DATA_X = -2; 34 public const DATA_D = -4; 35 36 public function __construct(array $data) 37 { 38 parent::__construct($data); 39 Assertion::eq($data[self::TYPE], self::TYPE_OKP, 'Invalid OKP key. The key type does not correspond to an OKP key'); 40 Assertion::keyExists($data, self::DATA_CURVE, 'Invalid EC2 key. The curve is missing'); 41 Assertion::keyExists($data, self::DATA_X, 'Invalid OKP key. The x coordinate is missing'); 42 Assertion::inArray((int) $data[self::DATA_CURVE], self::SUPPORTED_CURVES, 'The curve is not supported'); 43 } 44 45 public function x(): string 46 { 47 return $this->get(self::DATA_X); 48 } 49 50 public function isPrivate(): bool 51 { 52 return \array_key_exists(self::DATA_D, $this->getData()); 53 } 54 55 public function d(): string 56 { 57 Assertion::true($this->isPrivate(), 'The key is not private'); 58 59 return $this->get(self::DATA_D); 60 } 61 62 public function curve(): int 63 { 64 return (int) $this->get(self::DATA_CURVE); 65 } 66 }
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 |