-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KeyPair encryption and decryption generated garbage characters at the beginning #1632
Comments
The fact that the first 16 bytes are incorrect, but the remainder of the message is correctly decrypted using a CBC cipher shows that your are using an incorrect nonce for decryption. The nonce is created as a random set of 16 bytes in each instance of your program meaning that each server will create a different random nonce. You mention that you send the public key in the request, but make no mention of also sending the nonce value. You need to also send the nonce in the request since there is no other way for the receiving server to determine the correct nonce to use for decryption |
`public class KeyPairCryptoHandler {
}`
Im having two servers and communicating between those two servers. While sending a request to server, i ll send public key in the request itself. Will encrypt the Response using that public key and send it to the client server. The client will decrypt the response with the private key it has. But im getting garbage characters at the begging. Please help with this.
Sample code using above class:
ServerA:
ServerB
Actual decrypted string:
Expected decrypted string:
how to resolve this?
The text was updated successfully, but these errors were encountered: