Skip to content

Commit 9ad6e10

Browse files
committed
feature/python-sdk-psd2: Added two new function definitions to security.py.
1 parent e06520c commit 9ad6e10

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

bunq/sdk/security/security.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import typing
77
from base64 import b64encode
88
from hashlib import sha1
9-
from typing import Dict
9+
from typing import Dict, List
1010

1111
from Cryptodome import Cipher
1212
from Cryptodome import Random
@@ -112,6 +112,16 @@ def _should_sign_request_header(header_name: str) -> bool:
112112
return False
113113

114114

115+
def generate_signature(string_to_sign: str, key_pair: RsaKey) -> str:
116+
bytes_to_sign = string_to_sign.encode()
117+
signer = PKCS1_v1_5.new(key_pair)
118+
digest = SHA256.new()
119+
digest.update(bytes_to_sign)
120+
sign = signer.sign(digest)
121+
122+
return b64encode(sign)
123+
124+
115125
def encrypt(api_context: ApiContext,
116126
request_bytes: bytes,
117127
custom_headers: Dict[str, str]) -> bytes:
@@ -210,3 +220,7 @@ def _should_sign_response_header(header_name: str) -> bool:
210220
return True
211221

212222
return False
223+
224+
225+
def get_certificate_chain_string(all_chain_certificate: List[str]):
226+
return _DELIMITER_NEWLINE.join(all_chain_certificate)

0 commit comments

Comments
 (0)