2121use EbicsApi \Ebics \Exceptions \PasswordEbicsException ;
2222use EbicsApi \Ebics \Factories \BufferFactory ;
2323use EbicsApi \Ebics \Factories \CertificateX509Factory ;
24+ use EbicsApi \Ebics \Factories \Crypt \AESFactory ;
2425use EbicsApi \Ebics \Factories \Crypt \BigIntegerFactory ;
26+ use EbicsApi \Ebics \Factories \Crypt \RSAFactory ;
2527use EbicsApi \Ebics \Factories \DocumentFactory ;
2628use EbicsApi \Ebics \Factories \EbicsExceptionFactory ;
2729use EbicsApi \Ebics \Factories \EbicsFactoryV24 ;
3537use EbicsApi \Ebics \Handlers \OrderDataHandler ;
3638use EbicsApi \Ebics \Handlers \ResponseHandler ;
3739use EbicsApi \Ebics \Models \Bank ;
40+ use EbicsApi \Ebics \Models \Crypt \Key ;
41+ use EbicsApi \Ebics \Models \Crypt \KeyPair ;
3842use EbicsApi \Ebics \Models \DownloadOrderResult ;
3943use EbicsApi \Ebics \Models \DownloadSegment ;
4044use EbicsApi \Ebics \Models \DownloadTransaction ;
5054use EbicsApi \Ebics \Models \X509 \ContentX509Generator ;
5155use EbicsApi \Ebics \Services \CryptService ;
5256use EbicsApi \Ebics \Services \CurlHttpClient ;
57+ use EbicsApi \Ebics \Services \KeyStorageLocator ;
58+ use EbicsApi \Ebics \Services \RandomService ;
5359use EbicsApi \Ebics \Services \SchemaValidator ;
5460use EbicsApi \Ebics \Services \XmlService ;
5561use EbicsApi \Ebics \Services \ZipService ;
@@ -104,10 +110,12 @@ public function __construct(Bank $bank, User $user, Keyring $keyring, array $opt
104110 throw new LogicException (sprintf ('Version "%s" is not implemented ' , $ keyring ->getVersion ()));
105111 }
106112
113+ $ rsaFactory = new RSAFactory ($ options ['rsa_class_map ' ] ?? null );
114+
107115 $ this ->segmentFactory = new SegmentFactory ();
108- $ this ->cryptService = new CryptService ();
116+ $ this ->cryptService = new CryptService ($ rsaFactory , new AESFactory (), new RandomService () );
109117 $ this ->zipService = new ZipService ();
110- $ this ->signatureFactory = new SignatureFactory ();
118+ $ this ->signatureFactory = new SignatureFactory ($ rsaFactory );
111119 $ this ->bufferFactory = new BufferFactory ($ options ['buffer_filename ' ] ?? 'php://memory ' );
112120
113121 $ this ->orderDataHandler = $ ebicsFactory ->createOrderDataHandler (
@@ -1330,10 +1338,9 @@ private function createUserSignature(string $type, ?array $details = null): Sign
13301338 $ keyPair = $ this ->cryptService ->generateKeyPair ($ this ->keyring ->getPassword ());
13311339 $ certificateGenerator = $ this ->keyring ->getCertificateGenerator ();
13321340 } else {
1333- $ keyPair = $ this ->cryptService ->changePrivateKeyPassword (
1334- $ details ['privatekey ' ],
1335- $ details ['password ' ],
1336- $ this ->keyring ->getPassword ()
1341+ $ keyPair = new KeyPair (
1342+ new Key ($ details ['publickey ' ], $ details ['publickey_type ' ]),
1343+ new Key ($ details ['privatekey ' ], $ details ['privatekey_type ' ])
13371344 );
13381345 $ certificateGenerator = new ContentX509Generator ();
13391346 $ certificateGenerator ->setAContent ($ details ['certificate ' ]);
@@ -1393,7 +1400,10 @@ public function checkKeyring(): bool
13931400 public function changeKeyringPassword (string $ newPassword ): void
13941401 {
13951402 $ keyPair = $ this ->cryptService ->changePrivateKeyPassword (
1396- $ this ->keyring ->getUserSignatureA ()->getPrivateKey (),
1403+ new KeyPair (
1404+ $ this ->keyring ->getUserSignatureA ()->getPublicKey (),
1405+ $ this ->keyring ->getUserSignatureA ()->getPrivateKey ()
1406+ ),
13971407 $ this ->keyring ->getPassword (),
13981408 $ newPassword
13991409 );
@@ -1407,7 +1417,10 @@ public function changeKeyringPassword(string $newPassword): void
14071417 $ this ->keyring ->setUserSignatureA ($ signature );
14081418
14091419 $ keyPair = $ this ->cryptService ->changePrivateKeyPassword (
1410- $ this ->keyring ->getUserSignatureX ()->getPrivateKey (),
1420+ new KeyPair (
1421+ $ this ->keyring ->getUserSignatureX ()->getPublicKey (),
1422+ $ this ->keyring ->getUserSignatureX ()->getPrivateKey ()
1423+ ),
14111424 $ this ->keyring ->getPassword (),
14121425 $ newPassword
14131426 );
@@ -1421,7 +1434,10 @@ public function changeKeyringPassword(string $newPassword): void
14211434 $ this ->keyring ->setUserSignatureX ($ signature );
14221435
14231436 $ keyPair = $ this ->cryptService ->changePrivateKeyPassword (
1424- $ this ->keyring ->getUserSignatureE ()->getPrivateKey (),
1437+ new KeyPair (
1438+ $ this ->keyring ->getUserSignatureE ()->getPublicKey (),
1439+ $ this ->keyring ->getUserSignatureE ()->getPrivateKey ()
1440+ ),
14251441 $ this ->keyring ->getPassword (),
14261442 $ newPassword
14271443 );
0 commit comments