-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andriy Svirin
committed
Jan 11, 2021
1 parent
7a10113
commit f3481d5
Showing
14 changed files
with
163 additions
and
44 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
...ontracts/BankLetterFormatterInterface.php → ...ntracts/BankLetter/FormatterInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace AndrewSvirin\Ebics\Contracts\BankLetter; | ||
|
||
use AndrewSvirin\Ebics\Contracts\SignatureInterface; | ||
|
||
/** | ||
* EBICS Generate hash for bank letter. | ||
* Strategy pattern. | ||
* | ||
* @license http://www.opensource.org/licenses/mit-license.html MIT License | ||
* @author Andrew Svirin | ||
*/ | ||
interface HashGeneratorInterface | ||
{ | ||
|
||
/** | ||
* Generate hash. | ||
* | ||
* @param SignatureInterface $signature | ||
* | ||
* @return string | ||
*/ | ||
public function generate(SignatureInterface $signature): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/Services/BankLetter/HashGenerator/CertificateHashGenerator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace AndrewSvirin\Ebics\Services\BankLetter\HashGenerator; | ||
|
||
use AndrewSvirin\Ebics\Contracts\BankLetter\HashGeneratorInterface; | ||
use AndrewSvirin\Ebics\Contracts\SignatureInterface; | ||
use AndrewSvirin\Ebics\Services\CryptService; | ||
|
||
/** | ||
* Generate hash for certificate. | ||
* @license http://www.opensource.org/licenses/mit-license.html MIT License | ||
* @author Andrew Svirin | ||
*/ | ||
class CertificateHashGenerator implements HashGeneratorInterface | ||
{ | ||
|
||
/** | ||
* @var CryptService | ||
*/ | ||
private $cryptService; | ||
|
||
public function __construct() | ||
{ | ||
$this->cryptService = new CryptService(); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function generate(SignatureInterface $signature): string | ||
{ | ||
$key = $signature->getCertificateContent(); | ||
|
||
return $this->cryptService->calculateKeyHash($key); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/Services/BankLetter/HashGenerator/PublicKeyHashGenerator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace AndrewSvirin\Ebics\Services\BankLetter\HashGenerator; | ||
|
||
use AndrewSvirin\Ebics\Contracts\BankLetter\HashGeneratorInterface; | ||
use AndrewSvirin\Ebics\Contracts\SignatureInterface; | ||
use AndrewSvirin\Ebics\Services\CryptService; | ||
|
||
/** | ||
* Generate hash for public key. | ||
* | ||
* @license http://www.opensource.org/licenses/mit-license.html MIT License | ||
* @author Andrew Svirin | ||
*/ | ||
class PublicKeyHashGenerator implements HashGeneratorInterface | ||
{ | ||
|
||
/** | ||
* @var CryptService | ||
*/ | ||
private $cryptService; | ||
|
||
public function __construct() | ||
{ | ||
$this->cryptService = new CryptService(); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function generate(SignatureInterface $signature): string | ||
{ | ||
$publicKeyDetails = $this->cryptService->getPublicKeyDetails($signature->getPublicKey()); | ||
|
||
$key = $this->cryptService->calculateKey( | ||
$publicKeyDetails['e'], | ||
$publicKeyDetails['m'] | ||
); | ||
|
||
return $this->cryptService->calculateKeyHash($key); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.