Completed
Push — master ( 5d89d9...b6c216 )
by Robbie
15s queued 10s
created
tests/Store/TestCookieStore.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -7,21 +7,21 @@
 block discarded – undo
7 7
 
8 8
 class TestCookieStore extends CookieStore implements TestOnly
9 9
 {
10
-    /**
11
-     * Override value of 'headers_sent' but only if running tests.
12
-     *
13
-     * Set to true or false, or null to not override
14
-     *
15
-     * @var string
16
-     */
17
-    public static $override_headers_sent = null;
10
+	/**
11
+	 * Override value of 'headers_sent' but only if running tests.
12
+	 *
13
+	 * Set to true or false, or null to not override
14
+	 *
15
+	 * @var string
16
+	 */
17
+	public static $override_headers_sent = null;
18 18
 
19
-    protected function canWrite()
20
-    {
21
-        if (self::$override_headers_sent !== null) {
22
-            return !self::$override_headers_sent;
23
-        }
19
+	protected function canWrite()
20
+	{
21
+		if (self::$override_headers_sent !== null) {
22
+			return !self::$override_headers_sent;
23
+		}
24 24
 
25
-        parent::canWrite();
26
-    }
25
+		parent::canWrite();
26
+	}
27 27
 }
Please login to merge, or discard this patch.
src/Crypto/McryptCrypto.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
     }
36 36
 
37 37
     /**
38
-     * @param $key a per-site secret string which is used as the base encryption key.
39
-     * @param $salt a per-session random string which is used as a salt to generate a per-session key
38
+     * @param string $key a per-site secret string which is used as the base encryption key.
39
+     * @param string $salt a per-session random string which is used as a salt to generate a per-session key
40 40
      *
41 41
      * The base encryption key needs to stay secret. If an attacker ever gets it, they can read their session,
42 42
      * and even modify & re-sign it.
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
      *
88 88
      * @param $data - The encrypted-and-signed message as base64 ASCII
89 89
      *
90
-     * @return bool|string - The decrypted cleartext or false if signature failed
90
+     * @return string|false - The decrypted cleartext or false if signature failed
91 91
      */
92 92
     public function decrypt($data)
93 93
     {
Please login to merge, or discard this patch.
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -8,109 +8,109 @@
 block discarded – undo
8 8
  */
9 9
 class McryptCrypto implements CryptoHandler
10 10
 {
11
-    protected $key;
12
-
13
-    protected $ivSize;
14
-
15
-    protected $keySize;
16
-
17
-    protected $salt;
18
-
19
-    protected $saltedKey;
20
-
21
-    /**
22
-     * @return string
23
-     */
24
-    public function getKey()
25
-    {
26
-        return $this->key;
27
-    }
28
-
29
-    /**
30
-     * @return string
31
-     */
32
-    public function getSalt()
33
-    {
34
-        return $this->salt;
35
-    }
36
-
37
-    /**
38
-     * @param $key a per-site secret string which is used as the base encryption key.
39
-     * @param $salt a per-session random string which is used as a salt to generate a per-session key
40
-     *
41
-     * The base encryption key needs to stay secret. If an attacker ever gets it, they can read their session,
42
-     * and even modify & re-sign it.
43
-     *
44
-     * The salt is a random per-session string that is used with the base encryption key to create a per-session key.
45
-     * This (amongst other things) makes sure an attacker can't use a known-plaintext attack to guess the key.
46
-     *
47
-     * Normally we could create a salt on encryption, send it to the client as part of the session (it doesn't
48
-     * need to remain secret), then use the returned salt to decrypt. But we already have the Session ID which makes
49
-     * a great salt, so no need to generate & handle another one.
50
-     */
51
-    public function __construct($key, $salt)
52
-    {
53
-        $this->ivSize = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
54
-        $this->keySize = mcrypt_get_key_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
55
-
56
-        $this->key = $key;
57
-        $this->salt = $salt;
58
-        $this->saltedKey = hash_pbkdf2('sha256', $this->key, $this->salt, 1000, $this->keySize, true);
59
-    }
60
-
61
-    /**
62
-     * Encrypt and then sign some cleartext
63
-     *
64
-     * @param $cleartext - The cleartext to encrypt and sign
65
-     * @return string - The encrypted-and-signed message as base64 ASCII.
66
-     */
67
-    public function encrypt($cleartext)
68
-    {
69
-        $iv = mcrypt_create_iv($this->ivSize, MCRYPT_DEV_URANDOM);
70
-
71
-        $enc = mcrypt_encrypt(
72
-            MCRYPT_RIJNDAEL_256,
73
-            $this->saltedKey,
74
-            $cleartext,
75
-            MCRYPT_MODE_CBC,
76
-            $iv
77
-        );
78
-
79
-        $hash = hash_hmac('sha256', $enc, $this->saltedKey);
80
-
81
-        return base64_encode($iv . $hash . $enc);
82
-    }
83
-
84
-    /**
85
-     * Check the signature on an encrypted-and-signed message, and if valid
86
-     * decrypt the content
87
-     *
88
-     * @param $data - The encrypted-and-signed message as base64 ASCII
89
-     *
90
-     * @return bool|string - The decrypted cleartext or false if signature failed
91
-     */
92
-    public function decrypt($data)
93
-    {
94
-        $data = base64_decode($data);
95
-
96
-        $iv   = substr($data, 0, $this->ivSize);
97
-        $hash = substr($data, $this->ivSize, 64);
98
-        $enc  = substr($data, $this->ivSize + 64);
99
-
100
-        $cleartext = rtrim(mcrypt_decrypt(
101
-            MCRYPT_RIJNDAEL_256,
102
-            $this->saltedKey,
103
-            $enc,
104
-            MCRYPT_MODE_CBC,
105
-            $iv
106
-        ), "\x00");
107
-
108
-        // Needs to be after decrypt so it always runs, to avoid timing attack
109
-        $gen_hash = hash_hmac('sha256', $enc, $this->saltedKey);
110
-
111
-        if ($gen_hash == $hash) {
112
-            return $cleartext;
113
-        }
114
-        return false;
115
-    }
11
+	protected $key;
12
+
13
+	protected $ivSize;
14
+
15
+	protected $keySize;
16
+
17
+	protected $salt;
18
+
19
+	protected $saltedKey;
20
+
21
+	/**
22
+	 * @return string
23
+	 */
24
+	public function getKey()
25
+	{
26
+		return $this->key;
27
+	}
28
+
29
+	/**
30
+	 * @return string
31
+	 */
32
+	public function getSalt()
33
+	{
34
+		return $this->salt;
35
+	}
36
+
37
+	/**
38
+	 * @param $key a per-site secret string which is used as the base encryption key.
39
+	 * @param $salt a per-session random string which is used as a salt to generate a per-session key
40
+	 *
41
+	 * The base encryption key needs to stay secret. If an attacker ever gets it, they can read their session,
42
+	 * and even modify & re-sign it.
43
+	 *
44
+	 * The salt is a random per-session string that is used with the base encryption key to create a per-session key.
45
+	 * This (amongst other things) makes sure an attacker can't use a known-plaintext attack to guess the key.
46
+	 *
47
+	 * Normally we could create a salt on encryption, send it to the client as part of the session (it doesn't
48
+	 * need to remain secret), then use the returned salt to decrypt. But we already have the Session ID which makes
49
+	 * a great salt, so no need to generate & handle another one.
50
+	 */
51
+	public function __construct($key, $salt)
52
+	{
53
+		$this->ivSize = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
54
+		$this->keySize = mcrypt_get_key_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
55
+
56
+		$this->key = $key;
57
+		$this->salt = $salt;
58
+		$this->saltedKey = hash_pbkdf2('sha256', $this->key, $this->salt, 1000, $this->keySize, true);
59
+	}
60
+
61
+	/**
62
+	 * Encrypt and then sign some cleartext
63
+	 *
64
+	 * @param $cleartext - The cleartext to encrypt and sign
65
+	 * @return string - The encrypted-and-signed message as base64 ASCII.
66
+	 */
67
+	public function encrypt($cleartext)
68
+	{
69
+		$iv = mcrypt_create_iv($this->ivSize, MCRYPT_DEV_URANDOM);
70
+
71
+		$enc = mcrypt_encrypt(
72
+			MCRYPT_RIJNDAEL_256,
73
+			$this->saltedKey,
74
+			$cleartext,
75
+			MCRYPT_MODE_CBC,
76
+			$iv
77
+		);
78
+
79
+		$hash = hash_hmac('sha256', $enc, $this->saltedKey);
80
+
81
+		return base64_encode($iv . $hash . $enc);
82
+	}
83
+
84
+	/**
85
+	 * Check the signature on an encrypted-and-signed message, and if valid
86
+	 * decrypt the content
87
+	 *
88
+	 * @param $data - The encrypted-and-signed message as base64 ASCII
89
+	 *
90
+	 * @return bool|string - The decrypted cleartext or false if signature failed
91
+	 */
92
+	public function decrypt($data)
93
+	{
94
+		$data = base64_decode($data);
95
+
96
+		$iv   = substr($data, 0, $this->ivSize);
97
+		$hash = substr($data, $this->ivSize, 64);
98
+		$enc  = substr($data, $this->ivSize + 64);
99
+
100
+		$cleartext = rtrim(mcrypt_decrypt(
101
+			MCRYPT_RIJNDAEL_256,
102
+			$this->saltedKey,
103
+			$enc,
104
+			MCRYPT_MODE_CBC,
105
+			$iv
106
+		), "\x00");
107
+
108
+		// Needs to be after decrypt so it always runs, to avoid timing attack
109
+		$gen_hash = hash_hmac('sha256', $enc, $this->saltedKey);
110
+
111
+		if ($gen_hash == $hash) {
112
+			return $cleartext;
113
+		}
114
+		return false;
115
+	}
116 116
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@
 block discarded – undo
78 78
 
79 79
         $hash = hash_hmac('sha256', $enc, $this->saltedKey);
80 80
 
81
-        return base64_encode($iv . $hash . $enc);
81
+        return base64_encode($iv.$hash.$enc);
82 82
     }
83 83
 
84 84
     /**
Please login to merge, or discard this patch.
src/Store/DatabaseStore.php 1 patch
Indentation   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -12,137 +12,137 @@
 block discarded – undo
12 12
 class DatabaseStore extends BaseStore
13 13
 {
14 14
 
15
-    /**
16
-     * Determine if the DB is ready to use.
17
-     *
18
-     * @return bool
19
-     * @throws Exception
20
-     */
21
-    protected function isDatabaseReady()
22
-    {
23
-        // Such as during setup of testsession prior to DB connection.
24
-        if (!DB::is_active()) {
25
-            return false;
26
-        }
27
-
28
-        // If we have a DB of the wrong type then complain
29
-        if (!(DB::get_conn() instanceof MySQLDatabase)) {
30
-            throw new Exception('HybridSessions\Store\DatabaseStore currently only works with MySQL databases');
31
-        }
32
-
33
-        // Prevent freakout during dev/build
34
-        return ClassInfo::hasTable('HybridSessionDataObject');
35
-    }
36
-
37
-    public function open($save_path, $name)
38
-    {
39
-        // no-op
40
-    }
41
-
42
-    public function close()
43
-    {
44
-        // no-op
45
-    }
46
-
47
-    public function read($session_id)
48
-    {
49
-        if (!$this->isDatabaseReady()) {
50
-            return null;
51
-        }
52
-
53
-        $query = sprintf(
54
-            'SELECT "Data" FROM "HybridSessionDataObject"
15
+	/**
16
+	 * Determine if the DB is ready to use.
17
+	 *
18
+	 * @return bool
19
+	 * @throws Exception
20
+	 */
21
+	protected function isDatabaseReady()
22
+	{
23
+		// Such as during setup of testsession prior to DB connection.
24
+		if (!DB::is_active()) {
25
+			return false;
26
+		}
27
+
28
+		// If we have a DB of the wrong type then complain
29
+		if (!(DB::get_conn() instanceof MySQLDatabase)) {
30
+			throw new Exception('HybridSessions\Store\DatabaseStore currently only works with MySQL databases');
31
+		}
32
+
33
+		// Prevent freakout during dev/build
34
+		return ClassInfo::hasTable('HybridSessionDataObject');
35
+	}
36
+
37
+	public function open($save_path, $name)
38
+	{
39
+		// no-op
40
+	}
41
+
42
+	public function close()
43
+	{
44
+		// no-op
45
+	}
46
+
47
+	public function read($session_id)
48
+	{
49
+		if (!$this->isDatabaseReady()) {
50
+			return null;
51
+		}
52
+
53
+		$query = sprintf(
54
+			'SELECT "Data" FROM "HybridSessionDataObject"
55 55
             WHERE "SessionID" = \'%s\' AND "Expiry" >= %s',
56
-            Convert::raw2sql($session_id),
57
-            $this->getNow()
58
-        );
56
+			Convert::raw2sql($session_id),
57
+			$this->getNow()
58
+		);
59 59
 
60
-        $result = DB::query($query);
60
+		$result = DB::query($query);
61 61
 
62
-        if ($result && $result->numRecords()) {
63
-            $data = $result->first();
64
-            $decoded = static::binaryDataJsonDecode($data['Data']);
65
-            return is_null($decoded) ? $data['Data'] : $decoded;
66
-        }
67
-    }
62
+		if ($result && $result->numRecords()) {
63
+			$data = $result->first();
64
+			$decoded = static::binaryDataJsonDecode($data['Data']);
65
+			return is_null($decoded) ? $data['Data'] : $decoded;
66
+		}
67
+	}
68 68
 
69
-    public function write($session_id, $session_data)
70
-    {
71
-        if (!$this->isDatabaseReady()) {
72
-            return false;
73
-        }
69
+	public function write($session_id, $session_data)
70
+	{
71
+		if (!$this->isDatabaseReady()) {
72
+			return false;
73
+		}
74 74
 
75
-        $expiry = $this->getNow() + $this->getLifetime();
75
+		$expiry = $this->getNow() + $this->getLifetime();
76 76
 
77
-        DB::query($str = sprintf(
78
-            'INSERT INTO "HybridSessionDataObject" ("SessionID", "Expiry", "Data")
77
+		DB::query($str = sprintf(
78
+			'INSERT INTO "HybridSessionDataObject" ("SessionID", "Expiry", "Data")
79 79
             VALUES (\'%1$s\', %2$u, \'%3$s\')
80 80
             ON DUPLICATE KEY UPDATE "Expiry" = %2$u, "Data" = \'%3$s\'',
81
-            Convert::raw2sql($session_id),
82
-            $expiry,
83
-            Convert::raw2sql(static::binaryDataJsonEncode($session_data))
84
-        ));
85
-
86
-        return true;
87
-    }
88
-
89
-    public function destroy($session_id)
90
-    {
91
-        // NOP
92
-    }
93
-
94
-    public function gc($maxlifetime)
95
-    {
96
-        if (!$this->isDatabaseReady()) {
97
-            return;
98
-        }
99
-
100
-        DB::query(sprintf(
101
-            'DELETE FROM "HybridSessionDataObject" WHERE "Expiry" < %u',
102
-            $this->getNow()
103
-        ));
104
-    }
105
-
106
-    /**
107
-    * Encode binary data into ASCII string (a subset of UTF-8)
108
-    *
109
-    * Silverstripe <= 4.4 does not have a binary db field implementation, so we have to store
110
-    * binary data as text
111
-    *
112
-    * @param string $data This is a binary blob
113
-    *
114
-    * @return string
115
-    */
116
-    public static function binaryDataJsonEncode($data)
117
-    {
118
-        return json_encode([
119
-            self::class,
120
-            base64_encode($data)
121
-        ]);
122
-    }
123
-
124
-    /**
125
-     * Decode ASCII string into original binary data (a php string)
126
-     *
127
-     * Silverstripe <= 4.4 does not have a binary db field implementation, so we have to store
128
-     * binary data as text
129
-     *
130
-     * @param string $text
131
-     *
132
-     * @param null|string
133
-     */
134
-    public static function binaryDataJsonDecode($text)
135
-    {
136
-        $struct = json_decode($text, true, 2);
137
-
138
-        if (!is_array($struct) || count($struct) !== 2) {
139
-            return null;
140
-        }
141
-
142
-        if (!isset($struct[0]) || !isset($struct[1]) || $struct[0] !== self::class) {
143
-            return null;
144
-        }
145
-
146
-        return base64_decode($struct[1]);
147
-    }
81
+			Convert::raw2sql($session_id),
82
+			$expiry,
83
+			Convert::raw2sql(static::binaryDataJsonEncode($session_data))
84
+		));
85
+
86
+		return true;
87
+	}
88
+
89
+	public function destroy($session_id)
90
+	{
91
+		// NOP
92
+	}
93
+
94
+	public function gc($maxlifetime)
95
+	{
96
+		if (!$this->isDatabaseReady()) {
97
+			return;
98
+		}
99
+
100
+		DB::query(sprintf(
101
+			'DELETE FROM "HybridSessionDataObject" WHERE "Expiry" < %u',
102
+			$this->getNow()
103
+		));
104
+	}
105
+
106
+	/**
107
+	 * Encode binary data into ASCII string (a subset of UTF-8)
108
+	 *
109
+	 * Silverstripe <= 4.4 does not have a binary db field implementation, so we have to store
110
+	 * binary data as text
111
+	 *
112
+	 * @param string $data This is a binary blob
113
+	 *
114
+	 * @return string
115
+	 */
116
+	public static function binaryDataJsonEncode($data)
117
+	{
118
+		return json_encode([
119
+			self::class,
120
+			base64_encode($data)
121
+		]);
122
+	}
123
+
124
+	/**
125
+	 * Decode ASCII string into original binary data (a php string)
126
+	 *
127
+	 * Silverstripe <= 4.4 does not have a binary db field implementation, so we have to store
128
+	 * binary data as text
129
+	 *
130
+	 * @param string $text
131
+	 *
132
+	 * @param null|string
133
+	 */
134
+	public static function binaryDataJsonDecode($text)
135
+	{
136
+		$struct = json_decode($text, true, 2);
137
+
138
+		if (!is_array($struct) || count($struct) !== 2) {
139
+			return null;
140
+		}
141
+
142
+		if (!isset($struct[0]) || !isset($struct[1]) || $struct[0] !== self::class) {
143
+			return null;
144
+		}
145
+
146
+		return base64_decode($struct[1]);
147
+	}
148 148
 }
Please login to merge, or discard this patch.
tests/CookieStoreTest.php 2 patches
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -9,69 +9,69 @@
 block discarded – undo
9 9
 
10 10
 class CookieStoreTest extends AbstractTest
11 11
 {
12
-    protected function getStore()
13
-    {
14
-        $store = Injector::inst()->get(CookieStore::class);
15
-        $store->setKey(uniqid());
16
-        $store->open(TempFolder::getTempFolder(BASE_PATH) . '/' . __CLASS__, 'SESSIONCOOKIE');
12
+	protected function getStore()
13
+	{
14
+		$store = Injector::inst()->get(CookieStore::class);
15
+		$store->setKey(uniqid());
16
+		$store->open(TempFolder::getTempFolder(BASE_PATH) . '/' . __CLASS__, 'SESSIONCOOKIE');
17 17
 
18
-        return $store;
19
-    }
18
+		return $store;
19
+	}
20 20
 
21
-    public function testStoreLargeData()
22
-    {
23
-        $session = uniqid();
24
-        $store = $this->getStore();
21
+	public function testStoreLargeData()
22
+	{
23
+		$session = uniqid();
24
+		$store = $this->getStore();
25 25
 
26
-        // Test new session is blank
27
-        $result = $store->read($session);
28
-        $this->assertEmpty($result);
26
+		// Test new session is blank
27
+		$result = $store->read($session);
28
+		$this->assertEmpty($result);
29 29
 
30
-        // Save data against session
31
-        $data1 = array(
32
-            'Large' => str_repeat('A', 600),
33
-            'Content' => str_repeat('B', 600)
34
-        );
35
-        $store->write($session, serialize($data1));
36
-        $result = $store->read($session);
30
+		// Save data against session
31
+		$data1 = array(
32
+			'Large' => str_repeat('A', 600),
33
+			'Content' => str_repeat('B', 600)
34
+		);
35
+		$store->write($session, serialize($data1));
36
+		$result = $store->read($session);
37 37
 
38
-        // Cookies should not try to store data that large
39
-        $this->assertEmpty($result);
40
-    }
38
+		// Cookies should not try to store data that large
39
+		$this->assertEmpty($result);
40
+	}
41 41
 
42
-    /**
43
-     * Ensure that subsequent reads without the necessary write do not report data
44
-     */
45
-    public function testReadInvalidatesData()
46
-    {
47
-        $session = uniqid();
48
-        $store = $this->getStore();
42
+	/**
43
+	 * Ensure that subsequent reads without the necessary write do not report data
44
+	 */
45
+	public function testReadInvalidatesData()
46
+	{
47
+		$session = uniqid();
48
+		$store = $this->getStore();
49 49
 
50
-        // Test new session is blank
51
-        $result = $store->read($session);
52
-        $this->assertEmpty($result);
50
+		// Test new session is blank
51
+		$result = $store->read($session);
52
+		$this->assertEmpty($result);
53 53
 
54
-        // Save data against session
55
-        $data1 = array(
56
-            'Color' => 'red',
57
-            'Animal' => 'elephant'
58
-        );
59
-        $store->write($session, serialize($data1));
60
-        $result = $store->read($session);
61
-        $this->assertEquals($data1, unserialize($result));
54
+		// Save data against session
55
+		$data1 = array(
56
+			'Color' => 'red',
57
+			'Animal' => 'elephant'
58
+		);
59
+		$store->write($session, serialize($data1));
60
+		$result = $store->read($session);
61
+		$this->assertEquals($data1, unserialize($result));
62 62
 
63
-        // Since we have read the data into the result, the application could modify this content
64
-        // and be unable to write it back due to headers being sent. We should thus assume
65
-        // that subsequent reads without a successful write do not purport to have valid data
66
-        $data1['Color'] = 'blue';
67
-        $result = $store->read($session);
68
-        $this->assertEmpty($result);
63
+		// Since we have read the data into the result, the application could modify this content
64
+		// and be unable to write it back due to headers being sent. We should thus assume
65
+		// that subsequent reads without a successful write do not purport to have valid data
66
+		$data1['Color'] = 'blue';
67
+		$result = $store->read($session);
68
+		$this->assertEmpty($result);
69 69
 
70
-        // Check that writing to cookie fails after headers are sent and these results remain
71
-        // invalidated
72
-        TestCookieStore::$override_headers_sent = true;
73
-        $store->write($session, serialize($data1));
74
-        $result = $store->read($session);
75
-        $this->assertEmpty($result);
76
-    }
70
+		// Check that writing to cookie fails after headers are sent and these results remain
71
+		// invalidated
72
+		TestCookieStore::$override_headers_sent = true;
73
+		$store->write($session, serialize($data1));
74
+		$result = $store->read($session);
75
+		$this->assertEmpty($result);
76
+	}
77 77
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
     {
14 14
         $store = Injector::inst()->get(CookieStore::class);
15 15
         $store->setKey(uniqid());
16
-        $store->open(TempFolder::getTempFolder(BASE_PATH) . '/' . __CLASS__, 'SESSIONCOOKIE');
16
+        $store->open(TempFolder::getTempFolder(BASE_PATH).'/'.__CLASS__, 'SESSIONCOOKIE');
17 17
 
18 18
         return $store;
19 19
     }
Please login to merge, or discard this patch.
tests/OpenSSLCryptoTest.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -10,17 +10,17 @@
 block discarded – undo
10 10
  */
11 11
 class OpenSSLCryptoTest extends SapphireTest
12 12
 {
13
-    public function testIntegrity()
14
-    {
15
-        $key = random_bytes(8);
16
-        $salt = random_bytes(16);
13
+	public function testIntegrity()
14
+	{
15
+		$key = random_bytes(8);
16
+		$salt = random_bytes(16);
17 17
 
18
-        $handler = new OpenSSLCrypto($key, $salt);
18
+		$handler = new OpenSSLCrypto($key, $salt);
19 19
 
20
-        for ($i = 0; $i < 1000; ++$i) {
21
-            $data = random_bytes(1024 * 4);
20
+		for ($i = 0; $i < 1000; ++$i) {
21
+			$data = random_bytes(1024 * 4);
22 22
 
23
-            $this->assertEquals($data, $handler->decrypt($handler->encrypt($data)));
24
-        }
25
-    }
23
+			$this->assertEquals($data, $handler->decrypt($handler->encrypt($data)));
24
+		}
25
+	}
26 26
 }
Please login to merge, or discard this patch.
tests/DatabaseStoreTest.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -9,29 +9,29 @@
 block discarded – undo
9 9
 
10 10
 class DatabaseStoreTest extends AbstractTest
11 11
 {
12
-    protected function setUp()
13
-    {
14
-        parent::setUp();
15
-
16
-        if (!DB::get_conn() instanceof MySQLDatabase) {
17
-            $this->markTestSkipped('Only MySQL databases are supported');
18
-        }
19
-    }
20
-
21
-    protected function getStore()
22
-    {
23
-        $store = Injector::inst()->get(DatabaseStore::class);
24
-        $store->setKey(uniqid());
25
-
26
-        return $store;
27
-    }
28
-
29
-    public function testDataCodecIntegrity()
30
-    {
31
-        for ($i = 0; $i < 1000; ++$i) {
32
-            $data = random_bytes(1024 * 4);
33
-
34
-            $this->assertEquals($data, DatabaseStore::binaryDataJsonDecode(DatabaseStore::binaryDataJsonEncode($data)));
35
-        }
36
-    }
12
+	protected function setUp()
13
+	{
14
+		parent::setUp();
15
+
16
+		if (!DB::get_conn() instanceof MySQLDatabase) {
17
+			$this->markTestSkipped('Only MySQL databases are supported');
18
+		}
19
+	}
20
+
21
+	protected function getStore()
22
+	{
23
+		$store = Injector::inst()->get(DatabaseStore::class);
24
+		$store->setKey(uniqid());
25
+
26
+		return $store;
27
+	}
28
+
29
+	public function testDataCodecIntegrity()
30
+	{
31
+		for ($i = 0; $i < 1000; ++$i) {
32
+			$data = random_bytes(1024 * 4);
33
+
34
+			$this->assertEquals($data, DatabaseStore::binaryDataJsonDecode(DatabaseStore::binaryDataJsonEncode($data)));
35
+		}
36
+	}
37 37
 }
Please login to merge, or discard this patch.
tests/McryptCryptoTest.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -11,28 +11,28 @@
 block discarded – undo
11 11
  */
12 12
 class McryptCryptoTest extends SapphireTest
13 13
 {
14
-    public function testIntegrity()
15
-    {
16
-        $this->markTestSkipped(
17
-            'McryptCrypto is losing zero bytes at the end of messages: ' .
18
-            'https://github.com/silverstripe/silverstripe-hybridsessions/issues/53'
19
-        );
20
-
21
-        $error_reporting = ini_set('error_reporting', (int) ini_get('error_reporting') & ~E_DEPRECATED);
22
-
23
-        try {
24
-            $key = random_bytes(8);
25
-            $salt = random_bytes(16);
26
-
27
-            $handler = new McryptCrypto($key, $salt);
28
-
29
-            for ($i = 0; $i < 1000; ++$i) {
30
-                $data = random_bytes(1024 * 4);
31
-
32
-                $this->assertEquals($data, $handler->decrypt($handler->encrypt($data)));
33
-            }
34
-        } finally {
35
-            ini_set('error_reporting', $error_reporting);
36
-        }
37
-    }
14
+	public function testIntegrity()
15
+	{
16
+		$this->markTestSkipped(
17
+			'McryptCrypto is losing zero bytes at the end of messages: ' .
18
+			'https://github.com/silverstripe/silverstripe-hybridsessions/issues/53'
19
+		);
20
+
21
+		$error_reporting = ini_set('error_reporting', (int) ini_get('error_reporting') & ~E_DEPRECATED);
22
+
23
+		try {
24
+			$key = random_bytes(8);
25
+			$salt = random_bytes(16);
26
+
27
+			$handler = new McryptCrypto($key, $salt);
28
+
29
+			for ($i = 0; $i < 1000; ++$i) {
30
+				$data = random_bytes(1024 * 4);
31
+
32
+				$this->assertEquals($data, $handler->decrypt($handler->encrypt($data)));
33
+			}
34
+		} finally {
35
+			ini_set('error_reporting', $error_reporting);
36
+		}
37
+	}
38 38
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
     public function testIntegrity()
15 15
     {
16 16
         $this->markTestSkipped(
17
-            'McryptCrypto is losing zero bytes at the end of messages: ' .
17
+            'McryptCrypto is losing zero bytes at the end of messages: '.
18 18
             'https://github.com/silverstripe/silverstripe-hybridsessions/issues/53'
19 19
         );
20 20
 
Please login to merge, or discard this patch.