Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OX6-156: Update hash method #276

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions application/views/admin/tpl/fcpayone_main.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,6 @@
</dd>
<div class="spacer"></div>
</dl>
<dl>
<dt>
<select name="confstrs[sFCPOHashMethod]">
<option value="md5" [{if $confstrs.sFCPOHashMethod == "md5"}]SELECTED[{/if}]>md5</option>
<option value="sha2-384" [{if $confstrs.sFCPOHashMethod == "sha2-384"}]SELECTED[{/if}]>sha2-384 (empfohlen)</option>
</select>
[{oxinputhelp ident="FCPO_HELP_HASH_METHOD"}]
</dt>
<dd>
[{oxmultilang ident="FCPO_HASH_METHOD"}]
</dd>
<div class="spacer"></div>
</dl>
</div>
</div>

Expand Down
8 changes: 0 additions & 8 deletions core/fcpayone_events.php
Original file line number Diff line number Diff line change
Expand Up @@ -1018,14 +1018,6 @@ public static function deactivatePaymethods()
public static function setDefaultConfigValues()
{
$oConfig = self::$_oFcpoHelper->fcpoGetConfig();
$blIsUpdate = self::isUpdate();
$blHashMethodSet = (bool) $oConfig->getConfigParam('sFCPOHashMethod');

if (!$blHashMethodSet && $blIsUpdate) {
$oConfig->saveShopConfVar('str', 'sFCPOHashMethod', 'md5');
} else if (!$blHashMethodSet) {
$oConfig->saveShopConfVar('str', 'sFCPOHashMethod', 'sha2-384');
}

if (!$oConfig->getConfigParam('sFCPOAddresscheck')) {
$oConfig->saveShopConfVar('str', 'sFCPOAddresscheck', 'NO');
Expand Down
30 changes: 3 additions & 27 deletions extend/application/controllers/fcPayOnePaymentView.php
Original file line number Diff line number Diff line change
Expand Up @@ -832,8 +832,6 @@ public function fcGetLangId()
*/
public function getHashCC($sType = '')
{
$oConfig = $this->_oFcpoHelper->fcpoGetConfig();
$sFCPOHashMethod = $oConfig->getConfigParam('sFCPOHashMethod');
$sKey = $this->getPortalKey();

$sData =
Expand All @@ -846,13 +844,7 @@ public function getHashCC($sType = '')
'JSON' .
'yes';

$sHashMD5 = md5($sData.$sKey);
$sHashSha2 = hash_hmac('sha384', $sData, $sKey);

$sHash = ($sFCPOHashMethod == 'sha2-384')
? $sHashSha2 : $sHashMD5;

return $sHash;
return hash_hmac('sha384', $sData, $sKey);
}

/**
Expand Down Expand Up @@ -939,8 +931,6 @@ public function fcpoGetActiveThemePath() {
*/
public function getHashELVWithChecktype()
{
$oConfig = $this->_oFcpoHelper->fcpoGetConfig();
$sFCPOHashMethod = $oConfig->getConfigParam('sFCPOHashMethod');
$sKey = $this->getPortalKey();

$sData =
Expand All @@ -953,13 +943,7 @@ public function getHashELVWithChecktype()
'bankaccountcheck' .
'JSON';

$sHashMD5 = md5($sData.$sKey);
$sHashSha2 = hash_hmac('sha384', $sData, $sKey);

$sHash = ($sFCPOHashMethod == 'sha2-384')
? $sHashSha2 : $sHashMD5;

return $sHash;
return hash_hmac('sha384', $sData, $sKey);
}

/**
Expand All @@ -969,8 +953,6 @@ public function getHashELVWithChecktype()
*/
public function getHashELVWithoutChecktype()
{
$oConfig = $this->_oFcpoHelper->fcpoGetConfig();
$sFCPOHashMethod = $oConfig->getConfigParam('sFCPOHashMethod');
$sKey = $this->getPortalKey();

$sData =
Expand All @@ -982,13 +964,7 @@ public function getHashELVWithoutChecktype()
'bankaccountcheck' .
'JSON';

$sHashMD5 = md5($sData.$sKey);
$sHashSha2 = hash_hmac('sha384', $sData, $sKey);

$sHash = ($sFCPOHashMethod == 'sha2-384')
? $sHashSha2 : $sHashMD5;

return $sHash;
return hash_hmac('sha384', $sData, $sKey);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ public function test_getHashELVWithChecktype_Coverage()
$oTestObject->expects($this->any())->method('getPortalId')->will($this->returnValue('somePortalId'));
$oTestObject->expects($this->any())->method('getPortalKey')->will($this->returnValue('somePortalKey'));

$sExpectHash = md5('someSubaccountIdsomeChecktypesomeEncodingsomeMerchantIdtestsomePortalIdbankaccountcheckJSONsomePortalKey');
$sExpectHash = hash_hmac('sha384', 'someSubaccountIdsomeChecktypesomeEncodingsomeMerchantIdtestsomePortalIdbankaccountcheckJSON', 'somePortalKey');

$this->assertEquals($sExpectHash, $this->invokeMethod($oTestObject, 'getHashELVWithChecktype'));
}
Expand Down Expand Up @@ -1131,7 +1131,7 @@ public function test_getHashELVWithoutChecktype_Coverage()
$oTestObject->expects($this->any())->method('getPortalId')->will($this->returnValue('somePortalId'));
$oTestObject->expects($this->any())->method('getPortalKey')->will($this->returnValue('somePortalKey'));

$sExpectHash = md5('someSubaccountIdsomeEncodingsomeMerchantIdtestsomePortalIdbankaccountcheckJSONsomePortalKey');
$sExpectHash = hash_hmac('sha384', 'someSubaccountIdsomeEncodingsomeMerchantIdtestsomePortalIdbankaccountcheckJSON', 'somePortalKey');

$this->assertEquals($sExpectHash, $this->invokeMethod($oTestObject, 'getHashELVWithoutChecktype'));
}
Expand Down
Loading