Skip to main content

Cryptography Inventory

This page lists the gateway code paths that use cryptography, what primitive or protocol is involved, and whether the implementation is delegated to a vetted library or assembled in gateway code.

Summary

Gateway code should not implement cryptographic primitives. The code may assemble protocol-specific inputs, choose encodings, and call platform/library APIs. Private-key PEM parsing must stay centralized in PemPrivateKeys.

AreaLocationPrimitive/protocolImplemented by librariesImplemented by gateway
Apple Pay token decryptservices/online-txn/.../ApplePayTokenDecryptor.ktCMS signature, X.509 path validation, ECDH P-256, SHA-256 KDF, AES-256-GCMBouncyCastle CMS, Java cert APIs, JCA KeyAgreement, JCA Cipher, JCA MessageDigestToken JSON extraction, Apple signed-content byte assembly, Apple KDF input assembly, Apple OID enforcement
Apple Pay mTLS session validationservices/online-txn/.../WalletService.ktTLS client certificate authJava KeyStore, KeyManagerFactory, TrustManagerFactory, SSLContext, HttpsURLConnectionLoads configured cert/key, validates Apple validation URL policy, builds Apple request JSON
Apple Pay merchant registrationservices/management/.../WalletProvisioningService.ktTLS client certificate authJava TLS/key APIsLoads configured cert/key, builds Apple registration JSON
Private-key PEM parsinglibs/security/.../PemPrivateKeys.ktRSA PKCS#8, EC P-256 SEC 1/PKCS#8BouncyCastle PEMParser/JcaPEMKeyConverter, JCA KeyFactoryCentralized type enforcement and SEC 1 P-256 normalization
Webhook delivery signatureslibs/security/.../SignedWebhookDeliveryClient.ktHMAC-SHA256JCA MacBuilds timestamp.payload, encodes Pinpoint as Base64 and Peak as lower hex
TypeScript SDK webhook verificationsdks/typescript/gateway-sdk/.../webhook-verifier.tsHMAC-SHA256Web Crypto APIBuilds timestamp.payload, lower-hex encoding, constant-time string compare
Kotlin SDK webhook verificationsdks/kotlin/gateway-sdk-core/.../WebhookVerifier.ktHMAC-SHA256Platform JCA/CommonCrypto actualsBuilds timestamp.payload, constant-time string compare
Webhook secret storagelibs/security/.../KmsEncryptionService.ktEnvelope encryption, AES-256-GCM, Cloud KMS key wrappingJCA Cipher, SecureRandom, Google Cloud KMSwrappedDEK:iv:ciphertext storage format, legacy plaintext fallback metric
OAuth signing key loadingservices/auth/.../AuthorizationServerConfig.ktRSA signing key materialPemPrivateKeys, JCA KeyFactory, Spring Authorization Server/Nimbus JWT stackDerives public key from private key and stable kid
Device proof of possessionservices/auth/.../DeviceEnrollmentService.ktECDSA/RSA signature verificationJCA Signature, JCA KeyFactoryChooses algorithm from public key type, decodes SPKI public key
XTMS vendor authlibs/xtms-client/.../XtmsAuthSigner.ktVendor SHA-256 signature schemeJCA MessageDigestBuilds vendor-specified sorted parameter string
Gift card lookup hashingservices/processing/.../GiftCardSupport.ktHMAC-SHA256, BCryptJCA Mac, Spring BCryptPasswordEncoderOrganization-scoped key derivation string for card hash
Android SmartConnect local storagesdks/kotlin/gateway-sdk-android/.../EncryptedSnapshotStorage.ktAES-256-GCM local snapshot encryptionJCA Cipher, SecureRandomLocal wrapper format and file persistence
Operational fingerprintsTokenHasher, PiiRedactor, idempotency/rate limitingSHA-256 hashesJCA MessageDigestTruncation/hex encoding for logs and identifiers

Guardrails

  • New private-key parsing must go through PemPrivateKeys.
  • The pre-commit hook centralized-private-key-parsing blocks direct PKCS8EncodedKeySpec, PEMParser, or JcaPEMKeyConverter use outside PemPrivateKeys.
  • Webhook signatures must use HMAC-SHA256 over timestamp.payload.
  • Peak webhook signatures are lower hex. Pinpoint compatibility signatures remain Base64.
  • KMS legacy plaintext decrypts increment gateway.kms.decrypt_legacy_plaintext.total; any non-zero value means stored secrets still need rotation.

Review Checklist

When adding or changing crypto code:

  1. Identify the external protocol or standard being implemented.
  2. Use JCA, BouncyCastle, Web Crypto, Cloud KMS, TLS, or Spring security primitives; do not hand-roll primitives.
  3. Keep key parsing, hex encoding, and constant-time comparisons in shared helpers where module boundaries allow it.
  4. Add a regression test with the real protocol shape, including optional fields that affect signed content.
  5. Document any compatibility encoding, such as Base64 versus hex signatures.