Passed
Pull Request — master (#14)
by Florent
06:01 queued 02:47
created

RFC5649Test::wrap20BytesKeyDataWith192BitKEK()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AESKW\Tests;
6
7
use AESKW\A192KW;
8
use PHPUnit\Framework\TestCase;
9
10
/**
11
 * These tests come from the RFCRFC5649Test.
12
 *
13
 * @see https://tools.ietf.org/html/rfc5649#section-6
14
 *
15
 * @internal
16
 */
17
final class RFC5649Test extends TestCase
18
{
19
    /**
20
     * @test
21
     */
22
    public function wrap20BytesKeyDataWith192BitKEK(): void
23
    {
24
        $kek = hex2bin('5840df6e29b02af1ab493b705bf16ea1ae8338f4dcc176a8');
25
        $key = hex2bin('c37b7e6492584340bed12207808941155068f738');
26
27
        $wrapped = A192KW::wrap($kek, $key, true);
28
        static::assertSame(hex2bin('138bdeaa9b8fa7fc61f97742e72248ee5ae6ae5360d1ae6a5f54f373fa543b6a'), $wrapped);
29
        $unwrapped = A192KW::unwrap($kek, $wrapped, true);
30
        static::assertSame($key, $unwrapped);
31
    }
32
33
    /**
34
     * @test
35
     */
36
    public function wrap7BytesKeyDataWith192BitKEK(): void
37
    {
38
        $kek = hex2bin('5840df6e29b02af1ab493b705bf16ea1ae8338f4dcc176a8');
39
        $key = hex2bin('466f7250617369');
40
41
        $wrapped = A192KW::wrap($kek, $key, true);
42
        static::assertSame(hex2bin('afbeb0f07dfbf5419200f2ccb50bb24f'), $wrapped);
43
        $unwrapped = A192KW::unwrap($kek, $wrapped, true);
44
        static::assertSame($key, $unwrapped);
45
    }
46
}
47