1 | <?php |
||
28 | $kek = hex2bin('000102030405060708090A0B0C0D0E0F'); |
||
29 | $data = hex2bin('1FA68B0A8112B447AEF34BD8FB5A7B829D3E862371D2CFE4'); |
||
30 | |||
31 | A128KW::unwrap($kek, $data); |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * @test |
||
36 | */ |
||
37 | public function a128KWBadKeySize(): void |
||
38 | { |
||
39 | $this->expectExceptionMessage('Bad key size'); |
||
40 | $this->expectException(InvalidArgumentException::class); |
||
41 | $kek = hex2bin('00010203040506070809101112131415'); |
||
42 | $data = hex2bin('0011223344'); |
||
43 | |||
44 | A128KW::wrap($kek, $data); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @test |
||
49 | */ |
||
50 | public function a128KWEmptyKey(): void |
||
51 | { |
||
52 | $this->expectExceptionMessage('Bad key size'); |
||
53 | $this->expectException(InvalidArgumentException::class); |
||
54 | $kek = hex2bin('00010203040506070809101112131415'); |
||
55 | $data = hex2bin(''); |
||
56 | |||
57 | A128KW::wrap($kek, $data, true); |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * @test |
||
62 | */ |
||
63 | public function a128KWIntegrityNotVerified(): void |
||
64 | { |
||
65 | $this->expectExceptionMessage('Integrity check failed'); |
||
66 | $this->expectException(InvalidArgumentException::class); |
||
67 | $kek = hex2bin('5840df6e29b02af1ab493b705bf16ea1ae8338f4dcc176a8'); |
||
68 | $data = hex2bin('138bdeaa9b8fa7fc61f97742e72248ee5ae6ae5360d1ae6a5f54f373fa543b6b'); |
||
69 | |||
70 | A192KW::unwrap($kek, $data, true); |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * @test |
||
75 | */ |
||
76 | public function wrap64BitsKeyDataWith128BitKEK(): void |
||
77 | { |
||
78 | $this->expectExceptionMessage('Bad data'); |
||
79 | $this->expectException(InvalidArgumentException::class); |
||
80 | $kek = hex2bin('000102030405060708090A0B0C0D0E0F'); |
||
81 | $data = hex2bin('F4740052E82A2251'); |
||
82 | |||
83 | A128KW::unwrap($kek, $data); |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * @test |
||
88 | */ |
||
89 | public function badData(): void |
||
90 | { |
||
91 | $this->expectExceptionMessage('Integrity check failed'); |
||
92 | $this->expectException(InvalidArgumentException::class); |
||
93 | $kek = hex2bin('000102030405060708090A0B0C0D0E0F'); |
||
94 | $data = hex2bin('F4740052E82A225174CE86FBD7B805E6'); |
||
95 | |||
96 | A128KW::unwrap($kek, $data); |
||
97 | } |
||
98 | } |
||
99 |