Skip to content

Commit

Permalink
fix(aes-encryption): support plain txt and url safe base64 strings
Browse files Browse the repository at this point in the history
Signed-off-by: ivan katliarchuk <[email protected]>
  • Loading branch information
ivankatliarchuk committed Dec 28, 2024
1 parent e964a66 commit ad226ca
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions docs/registry/txt.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ wildcard domains will have invalid domain syntax and be rejected by most provide

## Encryption

Registry TXT records may contain information, such as the internal ingress name or namespace, considered sensitive, , which attackers could exploit to gather information about your infrastructure.
Registry TXT records may contain information, such as the internal ingress name or namespace, considered sensitive, , which attackers could exploit to gather information about your infrastructure.
By encrypting TXT records, you can protect this information from unauthorized access.

Encryption is enabled by using the `--txt-encrypt-enabled` flag. The 32-byte AES-256-GCM encryption
Expand Down Expand Up @@ -78,14 +78,25 @@ import (
)

func main() {
key := []byte("testtesttesttesttesttesttesttest")
encrypted, _ := endpoint.EncryptText(
"heritage=external-dns,external-dns/owner=example,external-dns/resource=ingress/default/example",
key,
nil,
)
decrypted, _, _ := endpoint.DecryptText(encrypted, key)
fmt.Println(decrypted)
keys := []string{
"ZPitL0NGVQBZbTD6DwXJzD8RiStSazzYXQsdUowLURY=", // safe base64 url encoded 44 bytes and 32 when decoded
"01234567890123456789012345678901", // plain txt 32 bytes
"passphrasewhichneedstobe32bytes!", // plain txt 32 bytes
}

for _, k := range keys {
key := []byte(k)
encrypted, _ := endpoint.EncryptText(
"heritage=external-dns,external-dns/owner=example,external-dns/resource=ingress/default/example",
key,
nil,
)
decrypted, _, err := endpoint.DecryptText(encrypted, key)
if err != nil {
fmt.Println("Error decrypting:", err, "for key:", k)
}
fmt.Println(decrypted)
}
}
```

Expand Down

0 comments on commit ad226ca

Please sign in to comment.