Cryptographic Algorithms
| Purpose | Algorithm |
|---|---|
| Symmetric payload encryption | AES/ECB/PKCS7Padding |
| Session key encryption | RSA/ECB/PKCS1Padding |
| Session key generation | Java KeyGenerator (or equivalent) |
| Digital signature | SHA1withRSA |
| Key encoding in envelope | keyEnc → HEX; jsonEnc → Base64; sign → HEX |
Key Exchange Overview
The security model depends on each party holding an RSA key pair:- You (merchant): Generate your own RSA key pair. Keep your private key secret on your servers. Provide your public key to Gcashier Pay during onboarding.
- Gcashier Pay: Provides you with its public key. Gcashier Pay holds the corresponding private key internally.
Outgoing Message: Encryption & Signing Flow
When you send a request to Gcashier Pay, follow these steps in order:Compose the inner JSON plaintext
Build the complete inner JSON object (containing
head and body) as a UTF-8 string. This is the plaintext you will sign and then encrypt.Sign the plaintext
Sign the UTF-8 JSON string with your RSA private key using the SHA1withRSA algorithm. Encode the resulting signature bytes as a HEX string — this becomes the
sign field.Generate an AES session key
Use a cryptographically secure key generator (e.g., Java’s
KeyGenerator for AES) to produce a random AES session key for this request. Encode the raw key bytes as Base64 — this is your intermediate SK.Encrypt the JSON payload
Encrypt the UTF-8 JSON plaintext using
SK with AES/ECB/PKCS7Padding. Encode the resulting ciphertext as Base64 — this becomes the jsonEnc field.Encrypt the session key
Encrypt
SK (the Base64 string) using Gcashier Pay’s RSA public key with RSA/ECB/PKCS1Padding. Encode the result as a HEX string — this becomes the keyEnc field.Incoming Message: Decryption & Verification Flow
When you receive a response from Gcashier Pay or a webhook callback, reverse the process:Recover the AES session key
HEX-decode
keyEnc to get the encrypted session key bytes. Decrypt those bytes using your RSA private key with RSA/ECB/PKCS1Padding to recover the Base64-encoded SK.Decrypt the payload
Base64-decode both
jsonEnc and SK. Use SK to AES-decrypt the ciphertext with AES/ECB/PKCS7Padding and UTF-8 decode the result to obtain the inner JSON plaintext.Generating Your RSA Key Pair
You need a 2048-bit RSA key pair. Generate one using either of the methods below.Windows
Download the Gcashier Pay RSA key-generation tool and follow the instructions bundled with it. The tool outputs a PKCS#8 private key file and a matching public key file.macOS / Linux (OpenSSL)
Run the following three commands in sequence. The intermediate file intmp/ is the raw RSA key; the final files are the formatted PKCS#8 private key and the X.509 public key you provide to Gcashier Pay.
rsa_private_key_2048.pem— your PKCS#8 private key. Never share or commit this file.rsa_public_key_2048.pem— your public key. Submit this to Gcashier Pay during onboarding.
Gcashier Pay will send you its own public key (
gcashier_public_key.pem or equivalent) after onboarding is complete. Store it securely; you need it to encrypt outgoing session keys and to verify incoming signatures.