Re: How to secure SDK that facilities payment from one bank to another bank

xracerxx
Regular Visitor

How to secure SDK that facilities payment from one bank to another bank

Hi there, I would like to check how to secure payment from one bank tenant to another bank tenant id with Visa as the facilitator.

Let's say if the bank issuer were to generate a public key and send it to the payment sdk.

The payment SDK generate a shared secret and send it to bank issuer.

Is there a risk such that the bank will actually spoof it.

The parameters required, the tenant details, the mobile number , the countrycode etc to generate a public key which can be understood by the SDK.

2 REPLIES 2
SyedSa
Community Moderator

Re: How to secure SDK that facilities payment from one bank to another bank

Hi @xracerxx, Thank you for reaching out. An agent will get back to you as soon as possible. Until then, if any community member knows a solution, feel free to reply in this thread.

DianaVisaPM
Visa Developer Support Specialist

Re: How to secure SDK that facilities payment from one bank to another bank

Hey @xracerxx,

 

To secure payments from one bank tenant to another using Visa as the facilitator, the process generally involves encryption and secure key exchange mechanisms. Here’s how you can ensure the security of the communication and mitigate the risk of spoofing:

1. Public Key Infrastructure (PKI):
- The bank issuer generates a public-private key pair.
- The public key is shared with the payment SDK securely.
- The private key remains confidential within the bank issuer.

2. Shared Secret Generation:
- The payment SDK generates a shared secret (symmetric key) for encrypting the transaction data.
- This shared secret is then encrypted with the bank issuer’s public key and sent to the bank issuer.
- Only the bank issuer can decrypt this shared secret using its private key.

3. **Mutual Authentication:**
- Ensure mutual authentication between the bank issuer and the payment SDK.
- Both parties should verify each other's identity using digital certificates issued by a trusted Certificate Authority (CA).

4. Transaction Data Encryption:
- Use the shared secret to encrypt sensitive transaction data (e.g., tenant details, mobile number, country code).
- This ensures that only the intended recipient (bank issuer) can decrypt and understand the transaction data.

5. Digital Signatures:
- Use digital signatures to ensure the integrity and authenticity of the transaction data.
- The bank issuer can sign the transaction data with its private key.
- The payment SDK can verify the signature using the bank issuer's public key.

6. Risk Mitigation:
- Implement strong authentication mechanisms (e.g., multi-factor authentication) to prevent unauthorized access.
- Regularly update and manage cryptographic keys and certificates.
- Monitor and log all transactions for any suspicious activities.

 

Here’s a high-level code example demonstrating the key exchange and encryption process:

```python
# START
from cryptography.hazmat.primitives.asymmetric import rsa, padding
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
from cryptography.hazmat.primitives.kdf.hkdf import HKDF
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
import os

# Generate RSA keys for the bank issuer
private_key = rsa.generate_private_key(public_exponent=65537, key_size=2048)
public_key = private_key.public_key()

# Serialize public key to send to the payment SDK
public_pem = public_key.public_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PublicFormat.SubjectPublicKeyInfo
)

# Payment SDK generates a shared secret
shared_secret = os.urandom(32)

# Encrypt the shared secret with the bank issuer's public key
encrypted_shared_secret = public_key.encrypt(
shared_secret,
padding.OAEP(
mgf=padding.MGF1(algorithm=hashes.SHA256()),
algorithm=hashes.SHA256(),
label=None
)
)

# Bank issuer decrypts the shared secret
decrypted_shared_secret = private_key.decrypt(
encrypted_shared_secret,
padding.OAEP(
mgf=padding.MGF1(algorithm=hashes.SHA256()),
algorithm=hashes.SHA256(),
label=None
)
)

# Use the shared secret to encrypt transaction data
transaction_data = b"tenant details, mobile number, country code"
cipher = Cipher(algorithms.AES(shared_secret), modes.GCM(os.urandom(12)))
encryptor = cipher.encryptor()
ciphertext = encryptor.update(transaction_data) + encryptor.finalize()

# The ciphertext can now be securely sent to the bank issuer
# END 
```

 

In this example, the payment SDK encrypts the shared secret with the bank issuer’s public key, ensuring that only the bank issuer can decrypt it using its private key. The shared secret is then used to encrypt transaction data, providing confidentiality and security for the payment process.

 

Ensure you follow best practices for key management and secure communication channels to further mitigate any risks.




Thanks,

Diana



Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.