File tree 2 files changed +14
-15
lines changed
2 files changed +14
-15
lines changed Original file line number Diff line number Diff line change @@ -81,17 +81,4 @@ private function __construct($bytes)
81
81
$ this ->key_bytes = $ bytes ;
82
82
}
83
83
84
- /**
85
- * INTERNAL USE ONLY: Constructs a Key object from a string of raw bytes.
86
- *
87
- * @param $bytes
88
- *
89
- * @return \Defuse\Crypto\Key
90
- *
91
- * @internal
92
- */
93
- public static function loadFromRawBytesForTestingPurposesOnlyInsecure ($ bytes )
94
- {
95
- return new Key ($ bytes );
96
- }
97
84
}
Original file line number Diff line number Diff line change 6
6
7
7
class BackwardsCompatibilityTest extends PHPUnit_Framework_TestCase
8
8
{
9
+
10
+ /* helper function to create a key with raw bytes */
11
+ public function keyHelper ($ rawkey ) {
12
+ $ key = Key::createNewRandomKey ();
13
+ $ func = function ($ bytes ) {
14
+ $ this ->key_bytes = $ bytes ;
15
+ };
16
+ $ helper = $ func ->bindTo ($ key ,$ key );
17
+ $ helper ($ rawkey );
18
+ return $ key ;
19
+ }
20
+
9
21
/**
10
22
* @expectedException \Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException
11
23
* @expectedExceptionMessage invalid hex encoding
@@ -25,7 +37,7 @@ public function testDecryptLegacyWithWrongMethodStraightUpHex()
25
37
/* Make it try to parse the binary as hex. */
26
38
$ plain = Crypto::decrypt (
27
39
$ cipher ,
28
- Key:: loadFromRawBytesForTestingPurposesOnlyInsecure (
40
+ $ this -> keyHelper (
29
41
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F" .
30
42
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"
31
43
),
@@ -52,7 +64,7 @@ public function testDecryptLegacyWithWrongMethodStraightUpBinary()
52
64
/* This time, treat the binary as binary. */
53
65
$ plain = Crypto::decrypt (
54
66
$ cipher ,
55
- Key:: loadFromRawBytesForTestingPurposesOnlyInsecure (
67
+ $ this -> keyHelper (
56
68
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F" .
57
69
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"
58
70
),
You can’t perform that action at this time.
0 commit comments