I am using crypto/cipher to encrypt and decrypt password. Client encrypts the password and sends to remote server over the network. When the server receives the password, during decryption, error “cipher: message authentication failed” is seen. This issue is seen only when communication is over the network.
Issue is not seen when client and server are running on the same machine.
I am following standard implementation mentioned in https://golang.org/src/crypto/cipher/gcm.go
Nonce is of length 12 and new nonce is generated everytime using rand function
Encrypt implements " gcm.Seal(nonce, nonce, []byte(passwordStr), nil)"
Decrypt implements " gcm.Open (nil, nonce, encrypted, nil)". Error is encountered in this method.
Let me know if anyone else has faced same issue.
1 Like
skillian
(Sean Killian)
May 2, 2020, 11:29am
2
How are you sending the data from the client to the server?
geosoft1
(George Calianu)
May 2, 2020, 1:05pm
3
If you have the issue only when you send the encrypted string over the network perhaps you should care about encoding the data, eg:
Golang Url Encoding example. Learn How to encode a String into URL Encoded format in Golang. Go's net/url package provides functions like QueryEscape(), PathEscape(), QueryUnescape(), and PathUnescape() to perform URL encoding and decoding.
pkanane
(Pkanane)
May 30, 2020, 10:18pm
4
I have faced the same issue. @nandinimurthy were you able to resolve? and what did you do?
system
(system)
Closed
August 28, 2020, 10:18pm
5
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.