mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
securejson: decrypt should not modify src
When decrypting a source securejson byte array, should not modify the source and now passes back a new dest byte array.
This commit is contained in:
parent
e13575eaef
commit
b1506a2b09
@ -27,12 +27,13 @@ func Decrypt(payload []byte, secret string) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
iv := payload[saltLength : saltLength+aes.BlockSize]
|
iv := payload[saltLength : saltLength+aes.BlockSize]
|
||||||
payload = payload[saltLength+aes.BlockSize:]
|
payload = payload[saltLength+aes.BlockSize:]
|
||||||
|
payloadDst := make([]byte, len(payload))
|
||||||
|
|
||||||
stream := cipher.NewCFBDecrypter(block, iv)
|
stream := cipher.NewCFBDecrypter(block, iv)
|
||||||
|
|
||||||
// XORKeyStream can work in-place if the two arguments are the same.
|
// XORKeyStream can work in-place if the two arguments are the same.
|
||||||
stream.XORKeyStream(payload, payload)
|
stream.XORKeyStream(payloadDst, payload)
|
||||||
return payload, nil
|
return payloadDst, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Encrypt(payload []byte, secret string) ([]byte, error) {
|
func Encrypt(payload []byte, secret string) ([]byte, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user