CI_Encryption: Fix some errors and add unit tests for hkdf()
diff --git a/system/libraries/Encryption.php b/system/libraries/Encryption.php
index 6e71d6e..4258aee 100644
--- a/system/libraries/Encryption.php
+++ b/system/libraries/Encryption.php
@@ -125,15 +125,6 @@
 
 		$this->initialize($params);
 
-		if (empty($this->_driver))
-		{
-			$this->_driver = ($this->_drivers['mcrypt'] === TRUE)
-				? 'mcrypt'
-				: 'openssl';
-
-			log_message('debug', "Encryption: Auto-configured driver '".$params['driver']."'.");
-		}
-
 		isset($this->_key) OR $this->_key = config_item('encryption_key');
 		if (empty($this->_key))
 		{
@@ -172,6 +163,15 @@
 			}
 		}
 
+		if (empty($this->_driver))
+		{
+			$this->_driver = ($this->_drivers['mcrypt'] === TRUE)
+				? 'mcrypt'
+				: 'openssl';
+
+			log_message('debug', "Encryption: Auto-configured driver '".$this->_driver."'.");
+		}
+
 		empty($params['key']) OR $this->_key = $params['key'];
 		$this->{'_'.$this->_driver.'_initialize'}($params);
 		return $this;
@@ -807,7 +807,7 @@
 	 */
 	public function __get($key)
 	{
-		return in_array($key, array('cipher', 'mode', 'driver', 'drivers'), TRUE)
+		return in_array($key, array('cipher', 'mode', 'driver', 'drivers', 'digests'), TRUE)
 			? $this->{'_'.$key}
 			: NULL;
 	}