RFC5649Test   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A wrap20BytesKeyDataWith192BitKEK() 0 10 1
A wrap7BytesKeyDataWith192BitKEK() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2020 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 AESKW\Tests;
15
16
use AESKW\A192KW;
17
use PHPUnit\Framework\TestCase;
18
19
/**
20
 * These tests come from the RFCRFC5649Test.
21
 *
22
 * @see https://tools.ietf.org/html/rfc5649#section-6
23
 *
24
 * @internal
25
 */
26
final class RFC5649Test extends TestCase
27
{
28
    /**
29
     * @test
30
     */
31
    public function wrap20BytesKeyDataWith192BitKEK(): void
32
    {
33
        $kek = hex2bin('5840df6e29b02af1ab493b705bf16ea1ae8338f4dcc176a8');
34
        $key = hex2bin('c37b7e6492584340bed12207808941155068f738');
35
36
        $wrapped = A192KW::wrap($kek, $key, true);
37
        static::assertEquals(hex2bin('138bdeaa9b8fa7fc61f97742e72248ee5ae6ae5360d1ae6a5f54f373fa543b6a'), $wrapped);
38
        $unwrapped = A192KW::unwrap($kek, $wrapped, true);
39
        static::assertEquals($key, $unwrapped);
40
    }
41
42
    /**
43
     * @test
44
     */
45
    public function wrap7BytesKeyDataWith192BitKEK(): void
46
    {
47
        $kek = hex2bin('5840df6e29b02af1ab493b705bf16ea1ae8338f4dcc176a8');
48
        $key = hex2bin('466f7250617369');
49
50
        $wrapped = A192KW::wrap($kek, $key, true);
51
        static::assertEquals(hex2bin('afbeb0f07dfbf5419200f2ccb50bb24f'), $wrapped);
52
        $unwrapped = A192KW::unwrap($kek, $wrapped, true);
53
        static::assertEquals($key, $unwrapped);
54
    }
55
}
56