Skip to content

Commit 479b6a3

Browse files
committed
Changed options for createUserSignatures.
1 parent 91876ae commit 479b6a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+771
-302
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.5
2+
3+
* Changed `options` for `createUserSignatures`.
4+
15
## 2.4
26

37
* Fixed HVE order type.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ use EbicsApi\Ebics\Models\X509\BankX509Generator;
5757
// Prepare `workspace` dir in the __PATH_TO_WORKSPACES_DIR__ manually.
5858
// "__EBICS_VERSION__" should have value "VERSION_30" for EBICS 3.0
5959
$keyringPath = __PATH_TO_WORKSPACES_DIR__ . '/workspace/keyring.json';
60-
$keyringManager = new FileKeyringManager(new KeyringFactory);
60+
$keyringManager = new FileKeyringManager();
6161
if (is_file($keyringPath)) {
6262
$keyring = $keyringManager->loadKeyring($keyringPath, __PASSWORD__, __EBICS_VERSION__);
6363
} else {

src/Builders/CustomerCreditTransfer/CustomerCreditTransferBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ private function createCreditTransferTransactionElement(
219219
$xmlEndToEndId->nodeValue = $endToEndId;
220220
} else {
221221
$xmlEndToEndId->nodeValue = $this->randomService->uniqueIdWithDate(
222-
'pete'.str_pad((string)$nbOfTxs, 2, '0')
222+
'pete' . str_pad((string)$nbOfTxs, 2, '0')
223223
);
224224
}
225225
$xmlPmtId->appendChild($xmlEndToEndId);
@@ -246,7 +246,7 @@ private function createCreditTransferTransactionElement(
246246
//update PmtInf
247247
$nbOfTxsList = $xpath->query('//CstmrCdtTrfInitn/PmtInf/NbOfTxs');
248248
$xmlNbOfTxs = DOMHelper::safeItem($nbOfTxsList);
249-
$xmlNbOfTxs->nodeValue = (string) $nbOfTxs;
249+
$xmlNbOfTxs->nodeValue = (string)$nbOfTxs;
250250

251251
$ctrlSumList = $xpath->query('//CstmrCdtTrfInitn/PmtInf/CtrlSum');
252252
$xmlCtrlSum = DOMHelper::safeItem($ctrlSumList);

src/Builders/CustomerDirectDebit/CustomerDirectDebitBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public function addTransaction(
252252
$xmlEndToEndId->nodeValue = $endToEndId;
253253
} else {
254254
$xmlEndToEndId->nodeValue = $this->randomService->uniqueIdWithDate(
255-
'pete'.str_pad((string)$nbOfTxs, 2, '0')
255+
'pete' . str_pad((string)$nbOfTxs, 2, '0')
256256
);
257257
}
258258

src/Contracts/Crypt/RSAInterface.php

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
*/
1414
interface RSAInterface
1515
{
16-
1716
/**
1817
* @return BigIntegerInterface
1918
*/
@@ -45,7 +44,7 @@ public function getModulus(): BigIntegerInterface;
4544
*
4645
* @return bool
4746
*/
48-
public function setPublicKey($key = false);
47+
public function setPublicKey($key = false): bool;
4948

5049
/**
5150
* Sets the password
@@ -57,7 +56,7 @@ public function setPublicKey($key = false);
5756
*
5857
* @return void
5958
*/
60-
public function setPassword($password = null);
59+
public function setPassword($password = null): void;
6160

6261
/**
6362
* Loads a public or private key
@@ -69,7 +68,7 @@ public function setPassword($password = null);
6968
*
7069
* @return bool
7170
*/
72-
public function loadKey($key, $type = false);
71+
public function loadKey($key, $type = false): bool;
7372

7473
/**
7574
* Decryption
@@ -78,7 +77,7 @@ public function loadKey($key, $type = false);
7877
*
7978
* @return string
8079
*/
81-
public function decrypt(string $ciphertext);
80+
public function decrypt(string $ciphertext): string;
8281

8382
/**
8483
* Encryption
@@ -91,7 +90,7 @@ public function decrypt(string $ciphertext);
9190
*
9291
* @return string
9392
*/
94-
public function encrypt(string $plaintext);
93+
public function encrypt(string $plaintext): string;
9594

9695
/**
9796
* Determines the public key format.
@@ -100,7 +99,7 @@ public function encrypt(string $plaintext);
10099
*
101100
* @return void
102101
*/
103-
public function setPublicKeyFormat(int $format);
102+
public function setPublicKeyFormat(int $format): void;
104103

105104
/**
106105
* Determines the private key format.
@@ -109,7 +108,7 @@ public function setPublicKeyFormat(int $format);
109108
*
110109
* @return void
111110
*/
112-
public function setPrivateKeyFormat(int $format);
111+
public function setPrivateKeyFormat(int $format): void;
113112

114113
/**
115114
* Determines which hashing function should be used.
@@ -121,7 +120,7 @@ public function setPrivateKeyFormat(int $format);
121120
*
122121
* @return void
123122
*/
124-
public function setHash(string $hash);
123+
public function setHash(string $hash): void;
125124

126125
/**
127126
* Determines which hashing function should be used for the mask generation function
@@ -133,7 +132,7 @@ public function setHash(string $hash);
133132
*
134133
* @return void
135134
*/
136-
public function setMGFHash($hash);
135+
public function setMGFHash($hash): void;
137136

138137
/**
139138
* Create public / private key pair.
@@ -158,7 +157,7 @@ public function createKey(int $bits = 1024, $timeout = false, array $partial = [
158157
*
159158
* @return string|null
160159
*/
161-
public function getPublicKey(int $type = RSA::PUBLIC_FORMAT_PKCS8);
160+
public function getPublicKey(int $type = RSA::PUBLIC_FORMAT_PKCS8): ?string;
162161

163162
/**
164163
* Returns the private key
@@ -167,9 +166,9 @@ public function getPublicKey(int $type = RSA::PUBLIC_FORMAT_PKCS8);
167166
*
168167
* @param int $type optional
169168
*
170-
* @return mixed
169+
* @return string|null
171170
*/
172-
public function getPrivateKey(int $type = RSA::PUBLIC_FORMAT_PKCS1);
171+
public function getPrivateKey(int $type = RSA::PUBLIC_FORMAT_PKCS1): ?string;
173172

174173
/**
175174
* Create a signature
@@ -178,7 +177,7 @@ public function getPrivateKey(int $type = RSA::PUBLIC_FORMAT_PKCS1);
178177
*
179178
* @return string|null
180179
*/
181-
public function sign(string $message);
180+
public function sign(string $message): ?string;
182181

183182
/**
184183
* Set Signature Mode
@@ -189,7 +188,7 @@ public function sign(string $message);
189188
*
190189
* @return void
191190
*/
192-
public function setSignatureMode($mode);
191+
public function setSignatureMode($mode): void;
193192

194193
/**
195194
* EMSA-PKCS1-V1_5-ENCODE
@@ -201,7 +200,7 @@ public function setSignatureMode($mode);
201200
*
202201
* @return string
203202
*/
204-
public function emsaPkcs1V15Encode($m, $emLen = null);
203+
public function emsaPkcs1V15Encode($m, $emLen = null): string;
205204

206205
/**
207206
* EMSA-PSS-ENCODE
@@ -213,7 +212,7 @@ public function emsaPkcs1V15Encode($m, $emLen = null);
213212
*
214213
* @return string
215214
*/
216-
public function emsaPssEncode($m, $emBits = null);
215+
public function emsaPssEncode($m, $emBits = null): string;
217216

218217
/**
219218
* EMSA-PSS-VERIFY
@@ -226,16 +225,16 @@ public function emsaPssEncode($m, $emBits = null);
226225
* @param int|null $emBits
227226
* @return bool
228227
*/
229-
public function emsaPssVerify($m, $em, $emBits = null);
228+
public function emsaPssVerify($m, $em, $emBits = null): bool;
230229

231230
/**
232231
* Change password for private key.
233232
*
234-
* @param string $privateKey
233+
* @param KeyPair $keyPair
235234
* @param string $oldPassword
236235
* @param string $newPassword
237236
*
238237
* @return KeyPair
239238
*/
240-
public function changePassword($privateKey, $oldPassword, $newPassword): KeyPair;
239+
public function changePassword($keyPair, $oldPassword, $newPassword): KeyPair;
241240
}

src/Contracts/EbicsClientInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ interface EbicsClientInterface
3535

3636
/**
3737
* Create user signatures A, E and X on first launch.
38-
* @param array|null $options Setup to specify custom certificate, private_key and version
38+
* @param array|null $options Setup to specify custom certificate, private, public keys and version
3939
* for Electronic Signature, Authorization and Identification, Encryption details.
4040
*/
4141
public function createUserSignatures(?array $options = null): void;
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
3+
namespace EbicsApi\Ebics\Contracts;
4+
5+
use EbicsApi\Ebics\Models\Crypt\Key;
6+
7+
/**
8+
* KeyStorageInterface.
9+
*
10+
* @license http://www.opensource.org/licenses/mit-license.html MIT License
11+
* @author Andrew Svirin
12+
*/
13+
interface KeyStorageInterface
14+
{
15+
/**
16+
* Write public key to storage.
17+
*
18+
* @param Key $key
19+
*
20+
* @return string
21+
*/
22+
public function writePublicKey(Key $key): string;
23+
24+
/**
25+
* Read public key from storage.
26+
*
27+
* @param string $key
28+
*
29+
* @return Key
30+
*/
31+
public function readPublicKey(string $key): Key;
32+
33+
/**
34+
* Write private key to storage.
35+
*
36+
* @param Key $key
37+
*
38+
* @return string
39+
*/
40+
public function writePrivateKey(Key $key): string;
41+
42+
/**
43+
* Read private key from storage.
44+
*
45+
* @param string $key
46+
*
47+
* @return Key
48+
*/
49+
public function readPrivateKey(string $key): Key;
50+
51+
/**
52+
* Write certificate to storage.
53+
*
54+
* @param string $certificate
55+
*
56+
* @return string
57+
*/
58+
public function writeCertificate(string $certificate): string;
59+
60+
/**
61+
* Read certificate from storage.
62+
*
63+
* @param string $certificate
64+
*
65+
* @return string
66+
*/
67+
public function readCertificate(string $certificate): string;
68+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace EbicsApi\Ebics\Contracts;
4+
5+
/**
6+
* KeyStorageLocatorInterface.
7+
*
8+
* @license http://www.opensource.org/licenses/mit-license.html MIT License
9+
* @author Andrew Svirin
10+
*/
11+
interface KeyStorageLocatorInterface
12+
{
13+
public const LOCATE_STRING = 'string';
14+
15+
/**
16+
* Find appropriate key storage.
17+
*
18+
* @param mixed|string $value
19+
*
20+
* @return KeyStorageInterface
21+
*/
22+
public function locate($value): KeyStorageInterface;
23+
24+
/**
25+
* Get key storage.
26+
*
27+
* @param string $key
28+
*
29+
* @return KeyStorageInterface
30+
*/
31+
public function get(string $key): KeyStorageInterface;
32+
}

src/Contracts/SignatureInterface.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace EbicsApi\Ebics\Contracts;
44

5+
use EbicsApi\Ebics\Models\Crypt\Key;
6+
57
/**
68
* EBICS SignatureInterface representation.
79
*
@@ -26,14 +28,14 @@ interface SignatureInterface
2628
public function getType(): string;
2729

2830
/**
29-
* @return string
31+
* @return Key
3032
*/
31-
public function getPublicKey(): string;
33+
public function getPublicKey(): Key;
3234

3335
/**
34-
* @return string|null
36+
* @return Key|null
3537
*/
36-
public function getPrivateKey(): ?string;
38+
public function getPrivateKey(): ?Key;
3739

3840
/**
3941
* @param string|null $certificateContent

src/EbicsBankLetter.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use EbicsApi\Ebics\Contracts\BankLetter\FormatterInterface;
66
use EbicsApi\Ebics\Factories\BankLetterFactory;
77
use EbicsApi\Ebics\Factories\CertificateX509Factory;
8+
use EbicsApi\Ebics\Factories\Crypt\AESFactory;
9+
use EbicsApi\Ebics\Factories\Crypt\RSAFactory;
810
use EbicsApi\Ebics\Factories\EbicsFactoryV24;
911
use EbicsApi\Ebics\Factories\EbicsFactoryV25;
1012
use EbicsApi\Ebics\Factories\EbicsFactoryV30;
@@ -18,6 +20,8 @@
1820
use EbicsApi\Ebics\Services\BankLetter\Formatter\TxtBankLetterFormatter;
1921
use EbicsApi\Ebics\Services\BankLetterService;
2022
use EbicsApi\Ebics\Services\CryptService;
23+
use EbicsApi\Ebics\Services\KeyStorageLocator;
24+
use EbicsApi\Ebics\Services\RandomService;
2125
use LogicException;
2226

2327
/**
@@ -33,9 +37,13 @@ final class EbicsBankLetter
3337
private BankLetterFactory $bankLetterFactory;
3438
private CryptService $cryptService;
3539

36-
public function __construct()
40+
public function __construct(array $options = [])
3741
{
38-
$this->cryptService = new CryptService();
42+
$this->cryptService = new CryptService(
43+
new RSAFactory($options['rsa_class_map'] ?? null),
44+
new AESFactory(),
45+
new RandomService()
46+
);
3947
$this->bankLetterService = new BankLetterService(
4048
$this->cryptService,
4149
new SignatureBankLetterFactory(),

0 commit comments

Comments
 (0)