Mastercard / client-encryption-go

Library for Mastercard API compliant payload encryption/decryption.
MIT License
14 stars 8 forks source link

EncryptedPayload elements in the body #19

Closed mikemiller-tawmrm closed 1 month ago

mikemiller-tawmrm commented 2 months ago

I am using the following within a server used for MDES Pre-Digitization cb := field_level_encryption.NewFieldLevelEncryptionConfigBuilder() flconfig, configError := cb.WithDecryptionKey(decryptionKey). WithEncryptionCertificate(encryptionCertificate). WithEncryptionPath("encryptedPayload", "encryptedPayload"). WithDecryptionPath("fundingAccountInfo.encryptedPayload", "fundingAccountInfo.encryptedPayload"). WithEncryptedValueFieldName("encryptedData"). WithEncryptedKeyFieldName("encryptedKey"). WithEncryptionKeyFingerprint(remotecertfingerprint). WithEncryptionKeyFingerprintFieldName("publicKeyFingerprint"). WithIvFieldName("iv"). WithFieldValueEncoding(field_level_encryption.HEX). WithOaepPaddingDigestAlgorithm(reqCryptoInfo.ReqAlgorithm). WithOaepPaddingDigestAlgorithmFieldName("oaepHashingAlgorithm"). //WithOaepPaddingDigestAlgorithmFieldName("oaepPaddingDigestAlgorithm"). Build() We are currently getting this error

2024-09-03T03:02:21,956 [es5stl150158902072791538] [] [Camel (camel-1) thread #1428 - Threads] ERROR c.m.m.i.c.c.IssuerServiceLoggerUtils - Error for provision request id 614978362 com.mastercard.mdes.servicefacade.issuer.decorator.service.exception.IssuerWebMalformedResponseMdesException: The issuer service responded successfully with a malformed entity 3 Client Inbound Response Detail 3 STATUS 200 3 > Connection: keep-alive 3 > Content-Length: 1778 3 > Content-Type: text/plain; charset=utf-8 3 > correlation-id: 23b9fa91469ca129fad39bc01f7a6bb9 3 > Date: Tue, 03 Sep 2024 08:02:21 GMT { "activationMethods" : [ { "type" : "TEXT_TO_CARDHOLDER_NUMBER", "value" : "xxx-xxx-8183" } ], "auxTcis" : [ "Orlando" ], "avsResponse" : "AVS_NOT_SUPPORTED", "cvcResponse" : "NOT_PROCESSED", "decision" : "REQUIRE_ADDITIONAL_AUTHENTICATION", "encryptedPayload" : { "encryptedData" : "5b55afb89ce8cd3e89ac3e7ed497ecd60c7edada7f6a8c113a22b708e71b846fa9ab5b3a00547d78c744031b93f7721f4235f92f412fb6ccfc6f27a0834bd9309d5f73a6c2057bddbd48d0e98b73781905311031b0d0a3bb1804e00117b441404a1e9ea269a5d028909e6c575482d98c2807ce3596ea7fe622d920b5669d37e8a63ce653a77dcbc8bf1d97797ceb4c19b056d37620e57eca87734b75f6b2eb3b68df7ccc34005790ccccbef07f3d461af09a06046086e8d6fa71d33b00b91321a38900497ebda9d983255c08ee3607c4c257e07867f4a183543d63141b199f91d94093dad38e4361b349e85e0ea4965d5ce2ea0d6320b527c3cbe95c0b6a8fe423f30125aa6fe1c2cad5424decfc87e90bc9d183a29e6880760c4bc90ea4971e26f22b0f1f5b04a33cf22e86cabdbff3d382e6c0436a8066682389918b2eeb41", "encryptedKey" : "9cff4554525863a6699fd76d078b1ff79b7c12db5ccdc9c79cdb30adb9ad4792580a6f91268ba65bc8591a7d73346cde2f1cb8ce65a6c44a97a6ce7b2b658929c93615e24638cf5210465150326bfb7bd6db9e1d48945875392f44868a73f6a897800ef1f82c666fd7cc70c881cddf66cb5ad7dd09fc19cc408f79737d0b2f311bfff909514bad68599394e0958b502852fb4c525707061c286a2f5c2748a598a5485a7b7c0b5ea73b3435d294de334d5b3bb4242a3a960ad9adc4de33d9319d58204afe513beed60f1858b7f380cbd1bd1c5b5d32e3e855b9e43f695ce4803a4b7e16c4e603bd2aa972e3387fe7603282857c66b45039bb2875a44f50c3498d", "iv" : "c50ac2a8b7e350eb1a64ea92c9a936e7", "oaepHashingAlgorithm" : "SHA256", "publicKeyFingerprint" : "ca0846ce7f4f2498f2020cd1dc834e2451cd67a3554866b3c4c423620450ef08" }, "issuerProductConfigId" : "UP1234", "panSequenceNumber" : "001", "responseId" : "50a9de53-593a-483c-8f79-442419ec8bbb", "services" : [ "DIGITIZATION" ], "tcis" : [ "Madrid" ], "tokenRequestorId" : "50120834693" }

The suggestion was to change replace oaepPaddingDigestAlgorithm oaepHashingAlgorithm WithOaepPaddingDigestAlgorithmFieldName("oaepHashingAlgorithm"). //WithOaepPaddingDigestAlgorithmFieldName("oaepPaddingDigestAlgorithm"). During my testing this never really was an issue, but I complied. My next real concern is that the test crew will ask "encryptedData" "encryptedKey" "iv" "oaepHashingAlgorithm" "publicKeyFingerprint" to be populated in the clear JSON. So far, I can only get these values to appear within encryptedPayload during encryption.
Is there a way to get these values into the clear JSON prior to encryption?
Should this even be an issue since during my testing I had no issues with encryption or decryption of requests and response. BUT we’re using different code and possibly criteria.

joseph-neeraj commented 1 month ago

This is not currently supported. Do re open if you have more questions.