File: Keys.php

package info (click to toggle)
php-lcobucci-jwt 5.5.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,304 kB
  • sloc: php: 6,674; makefile: 49
file content (73 lines) | stat: -rw-r--r-- 2,876 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
declare(strict_types=1);

namespace Lcobucci\JWT\Tests;

use Lcobucci\JWT\Signer\Key;
use PHPUnit\Framework\Attributes as PHPUnit;

trait Keys
{
    /** @var array<string, Key> */
    protected static array $rsaKeys;

    /** @var array<string, Key> */
    protected static array $ecdsaKeys;

    /** @var array<string, Key> */
    protected static array $eddsaKeys;

    #[PHPUnit\BeforeClass]
    public static function createRsaKeys(): void
    {
        if (isset(static::$rsaKeys)) {
            return;
        }

        static::$rsaKeys = [
            'private'           => Key\InMemory::file(__DIR__ . '/_keys/rsa/private.key'),
            'public'            => Key\InMemory::file(__DIR__ . '/_keys/rsa/public.key'),
            'encrypted-private' => Key\InMemory::file(__DIR__ . '/_keys/rsa/encrypted-private.key', 'testing'),
            'encrypted-public'  => Key\InMemory::file(__DIR__ . '/_keys/rsa/encrypted-public.key'),
            'private_short'     => Key\InMemory::file(__DIR__ . '/_keys/rsa/private_512.key'),
            'public_short'      => Key\InMemory::file(__DIR__ . '/_keys/rsa/public_512.key'),
        ];
    }

    #[PHPUnit\BeforeClass]
    public static function createEcdsaKeys(): void
    {
        if (isset(static::$ecdsaKeys)) {
            return;
        }

        static::$ecdsaKeys = [
            'private'        => Key\InMemory::file(__DIR__ . '/_keys/ecdsa/private.key'),
            'private-params' => Key\InMemory::file(__DIR__ . '/_keys/ecdsa/private2.key'),
            'public1'        => Key\InMemory::file(__DIR__ . '/_keys/ecdsa/public1.key'),
            'public2'        => Key\InMemory::file(__DIR__ . '/_keys/ecdsa/public2.key'),
            'public-params'  => Key\InMemory::file(__DIR__ . '/_keys/ecdsa/public3.key'),
            'private_ec384'  => Key\InMemory::file(__DIR__ . '/_keys/ecdsa/private_ec384.key'),
            'public_ec384'   => Key\InMemory::file(__DIR__ . '/_keys/ecdsa/public_ec384.key'),
            'private_ec512'  => Key\InMemory::file(__DIR__ . '/_keys/ecdsa/private_ec512.key'),
            'public_ec512'   => Key\InMemory::file(__DIR__ . '/_keys/ecdsa/public_ec512.key'),
            'public2_ec512'  => Key\InMemory::file(__DIR__ . '/_keys/ecdsa/public2_ec512.key'),
        ];
    }

    #[PHPUnit\BeforeClass]
    public static function createEddsaKeys(): void
    {
        if (isset(static::$eddsaKeys)) {
            return;
        }

        static::$eddsaKeys = [
            'private' => Key\InMemory::base64Encoded(
                'K3NWT0XqaH+4jgi42gQmHnFE+HTPVhFYi3u4DFJ3OpRHRMt/aGRBoKD/Pt5H/iYgGCla7Q04CdjOUpLSrjZhtg==',
            ),
            'public1' => Key\InMemory::base64Encoded('R0TLf2hkQaCg/z7eR/4mIBgpWu0NOAnYzlKS0q42YbY='),
            'public2' => Key\InMemory::base64Encoded('8uLLzCdMrIWcOrAxS/fteYyJhWIGH+wav2fNz8NZhvI='),
        ];
    }
}