3 use PHPUnit\Framework\TestCase;
5 require_once
'cutrusted.i';
15 $this->test_credential =
"s0m3p@ssw0rd!";
16 $this->key_suffix =
"venfBWHOrtest839";
17 $this->test_iv =
"oY0i74hthwNoF90l";
20 function test_default_credentials_encryptions() {
23 list($ciphertext_openssl,
24 $iv_enc_openssl) = EncryptCredentials($this->test_credential,
29 if(function_exists(
"DecryptCredentialsOpenssl")) {
33 $obtained_decrypted_text_openssl = DecryptCredentialsOpenssl($ciphertext_openssl,
38 $obtained_decrypted_text_openssl = DecryptCredentials($ciphertext_openssl,
43 $this->assertEquals($obtained_decrypted_text_openssl, $this->test_credential);
46 if(function_exists(
"EncryptCredentialsMcrypt") && function_exists(
"DecryptCredentialsMcrypt")) {
49 list($ciphertext, $iv_enc) = EncryptCredentialsMcrypt($this->test_credential,
55 $this->assertEquals($ciphertext_openssl, $ciphertext);
58 $obtained_decrypted_text = DecryptCredentialsMcrypt($ciphertext,
61 $this->assertEquals($obtained_decrypted_text, $this->test_credential);
68 if(function_exists(
"DecryptCredentialsMcrypt")) {
69 $obtained_decrypted_text_mcrypt = DecryptCredentialsMcrypt($ciphertext_openssl,
72 $this->assertEquals($obtained_decrypted_text_mcrypt, $this->test_credential);
83 if(function_exists(
"EncryptCredentialsMcrypt")) {
86 $iv_enc) = EncryptCredentialsMcrypt($this->test_credential,
91 $iv_enc) = EncryptCredentials($this->test_credential,
97 $obtained_decrypted_text = DecryptCredentials($ciphertext,
101 $this->assertEquals($obtained_decrypted_text, $this->test_credential);
104 function tearDown() {
115 $this->Cu =
"SCRUBCU";
116 $this->key_suffix = sha1($this->Cu.
":testkeysuffix");
118 $this->hcu_standard_encryption_mode_for_parm =
"aes-256-cbc";
119 $this->hcu_standard_auth_hash_algo =
"sha256";
122 $this->trusted_data = HCU_JsonEncode(
123 array(
"pilot" =>
"1",
124 "pilotUser" =>
"11221122-33bc-5f5b-aggc-c91eef53e9e1",
125 "pilotPass" =>
"Am1HcuHcuHc6LFuhaU3Dg",
126 "piloturl" =>
"https:\/\/demo.demo.com\/services\/resources.ashx\/fis\/HomeCuXyCu\/consumers",
127 "pilotlender" =>
"HomeCuXyCU\u201dN7q\u2206\u00ba\u20acm\u02da\u02da\u00d38\u203a\u203a=\u00c1\u00f7\u00f9}\u02db[\u25caw\u03c0\u00d5\u00d5\u2022\u00a2w\u00a8\u203a\u204a\u2039\u212b\u00f4\u2023",
128 "pilotsso" =>
"https:\/\/demo.demo.com\/partners\/HomeCuXyCu\/loginconsumer.aspx",
134 "hcuLogging" =>
"-1"));
138 $this->expected_trusted_data_openssl_ecb_cipher_base64 =
"G1qPAyD/VutfubF97UN2cD7VDl0x9w86k4nvU8lLa77ILiZTqYXH9sBNEyyMMU0m4z3TRUQ/Q3GLK3CSrZBCvuN5x74Yw8Ryp5sx+WcnC2Q00AttHkiM+3vnvF0sCPi9pHGrdbIp8E7SN+N4FZzkdG7beIaoJcwvZp3ovIItMhxcUVmThrVusM3vl377w6hsN7DTtmIS2RBDTvDGxx7A7EsGEP1LulOYDblk9hX9KXdGPaaJ651hYAHuYDDe6B4QuYVJMu50vh1J9FKM6HjaQytyXVWbZqeku5S8su1RQa9Wc9BLf+UzNySw+6MNyRnEmCIc9olUsHVJwcbAeW+m5CcM/YiEGI1WW/rfeBbVy2B2n2WVvb+rF+JtcsXO5XOb8Axl3fKfyCePvdIP2tfMD+uCa0C7xJUeaJsGao6I9McBY7GgE6ze7QH4BjYcHhs1sKUKPM82sCBKXMaBAhj4xaD4d+TkujQ1uOvASTOPN8CGbvIdiNkITaWLbjjVgRoWb/HeAdAZbLP/zu5DWDiLCg2xAnzDNxyixHceK9+dDt4ZKA+3/S7i4EEPcMKPpF/hEUOPMVmfGSB8OX07v+Wklduhl1+5zxOremvhcvEos2j44kYKmMRGSR+SviAt2gBejPXSSntY2cDvbEnLWtZLgtkID4s+jcA3anMCV9AQh3EfPG0y1a7tThk4tpEmZfOt0y0LZYEHcJ4fFgiheLQJGuGPHiiykOb6vsSN8ZIM4FeqtilXx+fIF7tfIXBcXWUHln4VfvyQoEh/Iq189hCokFli5/P1fXq6X1JehKZCOv/Bm4ZXntSldD3A2BVV87Fs/MLEOFewG4oCUqnmRGQ+4Q==";
142 $this->expected_trusted_data_mcrypt_ecb_cipher_base64 =
"WsKpzTsT7rsUMfhrEWlHjFsgCINnlGPPdzpzZ6YR8CTdIi+XTgscznsaUi6OtqwbT9UXLfS9HvcmzbX5EZHrxxo21XfY6pFAXcIArigtZVYCiqoBXxgYZki9+SiFIgzuaM8Py8ktxdJFep4DaukNOPoGXzUBF1umqjtB/rZqLASjQdTR+yxurzpG4YzXMuhcfg3MZBfR+Wc4+GY1+XdYs5NrOGKN3ntt3Tw0Ifug8rzHdknoLY1HxRIlIPRhVrgHGCNo3TDU8sgCPPg3fRHdChHBsfCbHPOGaDxx03fllxTrvM9D4YemIEftspPXGq2U7AZqswxwrUN/EAobG9z8ffpSdy5SSO7ZvxhAMJWz6n0TzFJn/LsEMrP4NYbijJ55sAPiocC4PzWCCn9ADIQ2nqpg5JNbGhIYn0fb1fwLOjXxZitd+grZn2PlCJ5zm1q4Nt3PYmzI9q8EAxhsihCNB8/gzrgxrPXYnesz4qnBvq+xEo5et9IH2l6rjy4QFM/2qAuVDS4J52xEhIjG8e9lqfooHEwnEJ4cQzeaiyMilDT4kOQ2jZjSOIip4QvlYnC4okY1SxYUrhvnv8GigU1iSs9yZRhdzD9k2hXrczk1cU5QoJy4sHd05DIe9x/7KWxC9va6NjCvbdwHDS9moEt2D5255LM3AI1OScG280cyizUQAnpOFt/jeIL8dBNNZDzjgHesrLSLtEiMdniL4xylCqBbdFMjh6LQ+4SbbDe+eU8kQFKBPUewcDt5CwEHLbYp+RVyyX8cEkfIL5pJpfCxv6OCoPR5ZTwTGGSDTTLYzaM=";
152 if(function_exists(
"parmencrypt_mcrypt")) {
157 $obtained_ciphertext_mcrypt = parmencrypt_mcrypt($this->trusted_data,
160 $this->assertEquals($obtained_ciphertext_mcrypt,
161 $this->expected_trusted_data_mcrypt_ecb_cipher_base64);
164 $obtained_decrypted_data_mcrypt = parmdecrypt($obtained_ciphertext_mcrypt,
166 $cipher_method=
"aes-256-ecb");
168 $this->assertEquals($obtained_decrypted_data_mcrypt,
169 $this->trusted_data);
176 $obtained_ciphertext_openssl = parmencrypt($this->trusted_data,
178 $cipher_method=
"aes-256-ecb");
179 $this->assertEquals($obtained_ciphertext_openssl,
180 $this->expected_trusted_data_openssl_ecb_cipher_base64);
183 $obtained_decrypted_data_openssl = parmdecrypt($obtained_ciphertext_openssl,
185 $cipher_method=
"aes-256-ecb");
186 $this->assertEquals($obtained_decrypted_data_openssl, $this->trusted_data);
189 if(function_exists(
"paramencrypt_mcrypt")) {
190 $this->assertEquals($obtained_decrypted_data_openssl, $obtained_decrypted_data_mcrypt);
200 $this->assertEquals($this->hcu_standard_encryption_mode_for_parm, PARMENCDEC_CIPHER_MODE);
201 $this->assertEquals($this->hcu_standard_auth_hash_algo, PARMENCDEC_AUTH_HASH_ALGO);
210 $openssl_ciphertext = parmencrypt($this->trusted_data,
213 $obtained_decrypted_text = parmdecrypt($openssl_ciphertext,
216 $this->assertEquals($obtained_decrypted_text, $this->trusted_data);
228 $openssl_aes_256_modes = array(
"aes-256-ctr",
236 $previous_decrypted_data =
"";
237 foreach($openssl_aes_256_modes as $aes_cipher_mode) {
238 $openssl_ciphertext =
"";
239 $obtained_decrypted_text =
"";
242 $openssl_ciphertext = parmencrypt($this->trusted_data,
244 $cipher_method=$aes_cipher_mode);
249 $obtained_decrypted_text = parmdecrypt($openssl_ciphertext,
251 $cipher_method=$aes_cipher_mode);
253 $this->assertEquals($obtained_decrypted_text, $this->trusted_data);
255 if ($previous_decrypted_data !=
"") {
256 $this->assertEquals($previous_decrypted_data, $obtained_decrypted_text);
259 $previous_decrypted_dat = $obtained_decrypted_text;
test_credentials_encryption_mcrypt_comptability()
test_parmecrypt_mcrypt_to_openssl_transition_with_ecb()
test_current_standard_openssl_encryption_mode()
test_parm_with_current_default_encryption_mode()
test_current_openssl_encryption_mode_agnostic_nature_parm()