Failed Conditions
Push — master ( 072e31...fa6436 )
by Florent
10s
created

RFC5649Test::testWrap7BytesKeyDataWith192BitKEK()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
/*
4
 * The MIT License (MIT)
5
 *
6
 * Copyright (c) 2014-2016 Spomky-Labs
7
 *
8
 * This software may be modified and distributed under the terms
9
 * of the MIT license.  See the LICENSE file for details.
10
 */
11
12
namespace AESKW\Tests;
13
14
use AESKW\A192KW;
15
use PHPUnit\Framework\TestCase;
16
17
/**
18
 * These tests come from the RFCRFC5649Test.
19
 *
20
 * @see https://tools.ietf.org/html/rfc5649#section-6
21
 */
22
final class RFC5649Test extends TestCase
23
{
24
    public function testWrap20BytesKeyDataWith192BitKEK()
25
    {
26
        $kek = hex2bin('5840df6e29b02af1ab493b705bf16ea1ae8338f4dcc176a8');
27
        $key = hex2bin('c37b7e6492584340bed12207808941155068f738');
28
29
        $wrapped = A192KW::wrap($kek, $key, true);
30
        $this->assertEquals(hex2bin('138bdeaa9b8fa7fc61f97742e72248ee5ae6ae5360d1ae6a5f54f373fa543b6a'), $wrapped);
31
        $unwrapped = A192KW::unwrap($kek, $wrapped, true);
32
        $this->assertEquals($key, $unwrapped);
33
    }
34
35
    public function testWrap7BytesKeyDataWith192BitKEK()
36
    {
37
        $kek = hex2bin('5840df6e29b02af1ab493b705bf16ea1ae8338f4dcc176a8');
38
        $key = hex2bin('466f7250617369');
39
40
        $wrapped = A192KW::wrap($kek, $key, true);
41
        $this->assertEquals(hex2bin('afbeb0f07dfbf5419200f2ccb50bb24f'), $wrapped);
42
        $unwrapped = A192KW::unwrap($kek, $wrapped, true);
43
        $this->assertEquals($key, $unwrapped);
44
    }
45
}
46