Skip to content

Commit

Permalink
Merge pull request #276 from BoulangerV/OX6-156-Change_hash_calculation
Browse files Browse the repository at this point in the history
OX6-156: Update hash method
  • Loading branch information
janteuber authored Feb 5, 2024
2 parents 0b2fde5 + dc0ac27 commit 8075be7
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 50 deletions.
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

0 comments on commit 8075be7

Please sign in to comment.