Skip to content

Commit

Permalink
kubernetes-sigs#3668: Remove txt-encryption nonce, for prevent issues…
Browse files Browse the repository at this point in the history
… with txt records deletion

Signed-off-by: Viacheslav Sychov <[email protected]>
  • Loading branch information
vsychov committed Jul 23, 2023
1 parent bc61d4d commit 3178cae
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions endpoint/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ import (
"compress/gzip"
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/base64"
"fmt"
"io"

log "github.com/sirupsen/logrus"
"strings"
)

// EncryptText gzip input data and encrypts it using the supplied AES key
Expand All @@ -43,9 +41,10 @@ func EncryptText(text string, aesKey []byte, nonceEncoded []byte) (string, error

nonce := make([]byte, gcm.NonceSize())
if nonceEncoded == nil {
if _, err = io.ReadFull(rand.Reader, nonce); err != nil {
return "", err
}
// this reduces cryptographic strength, but in a given location with this type of data, this should not be fatal
// it's need for be able to generate same encryption string, for same labels, for more details see issue:
// https://github.com/kubernetes-sigs/external-dns/issues/3668
nonce = []byte(strings.Repeat("0", gcm.NonceSize()))
} else {
if _, err = base64.StdEncoding.Decode(nonce, nonceEncoded); err != nil {
return "", err
Expand Down

0 comments on commit 3178cae

Please sign in to comment.