Skip to content

Conversation

@mateusmrangel
Copy link

Hello everyone
With this merge request, the lib will support MasterCard encryption. See the usage on the mastercard_encryption/mastercard_encryption_test.go file.
I used as a base the Java implementation of the client-encryption library

@mateusmrangel
Copy link
Author

@danny-gallagher
Copy link
Contributor

danny-gallagher commented Sep 5, 2023

Hi @mateusmrangel,

Thanks for creating this PR! There are a couple of things that will need to be added before we can merge this PR.

  • If you take a look in "http_client_interceptor.go", you can see that we provide an interceptor which can be used alongside an openapi generated client to intercept and encrypt a request before it enters transit. We'll need to add support in this interceptor for Field Level Encryption.
  • The README will need to be updated to reflect the new Field Level Encryption functionality. (See the java library for how this should look)
  • The tests for this new addition should test all of the components of the library that the java library does.

If you have any questions, please feel free to reach out!

@karen-avetisyan-mc karen-avetisyan-mc marked this pull request as draft September 5, 2023 14:46
@karen-avetisyan-mc karen-avetisyan-mc marked this pull request as ready for review September 5, 2023 14:46
@karen-avetisyan-mc karen-avetisyan-mc marked this pull request as draft September 5, 2023 14:46
@mateusmrangel
Copy link
Author

Hi @mateusmrangel,

Thanks for creating this PR! There are a couple of things that will need to be added before we can merge this PR.

  • If you take a look in "http_client_interceptor.go", you can see that we provide an interceptor which can be used alongside an openapi generated client to intercept and encrypt a request before it enters transit. We'll need to add support in this interceptor for Field Level Encryption.
  • The README will need to be updated to reflect the new Field Level Encryption functionality. (See the java library for how this should look)
  • The tests for this new addition should test all of the components of the library that the java library does.

If you have any questions, please feel free to reach out!

Ok, I am going to work on it

encryptedPayload := EncryptPayload(payload, flConfig, params)
fmt.Println(encryptedPayload)

decryptedPayload := DecryptPayload(encryptedPayload, flConfig, params)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'params' for decrypting the payload should be extracted from the actual request body/headers as they are in our other libraries.

func Generate(config *FieldLevelEncryptionConfig) *FieldLevelEncryptionParams {
//// Generate a random IV
ivParameterSpec := aes_encryption.GenerateCEK(16 * 8)
ivSpecValue := utils.HexUrlEncode(ivParameterSpec)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In our other libraries (Java for example), we allow the user to specify the FieldValueEncoding through the config. In your implementation it's hard coded to always use Hex.

return jsonPayload.String()
}

func decryptPayloadPath(jsonPayload *gabs.Container, jsonPathIn string, jsonPathOut string, params *field_level_encryption.FieldLevelEncryptionParams) *gabs.Container {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'jsonPathOut' isn't used in this function. This property should be used to include the encrypted payload in a specific path in the payload (See the Java encryption library)

Copy link
Contributor

@danny-gallagher danny-gallagher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In our other libraries, it's possible to include the encryption properties in the header of a request/response. You can see this functionality in the Java library for reference.

The functionality for this library should be identical to all of our other libraries.
You can include all the tests that are in our Java encryption library to ensure you're covering all possible cases.

@danny-gallagher
Copy link
Contributor

Addressing this PR in the following PR: #14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants