aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-03-11 11:21:06 +0100
committerOnur Gündüz <ogunduz@gmail.com>2026-03-11 11:21:06 +0100
commit91cf2dcc55e4b7ecd69817d1e390ae6e96e46a88 (patch)
treea9a91aacec7a7e243a491b9240c1d4bd01ab2ba2
parent6e37bc1f2755ef2e2270d2c1cb988d14ff6d0957 (diff)
downloadnoise-91cf2dcc55e4b7ecd69817d1e390ae6e96e46a88.tar.gz
noise-91cf2dcc55e4b7ecd69817d1e390ae6e96e46a88.zip
Add Key method to CipherState for key retrieval
-rw-r--r--cipher.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/cipher.go b/cipher.go
index 057cf97..6b0266e 100644
--- a/cipher.go
+++ b/cipher.go
@@ -121,3 +121,13 @@ func (cs *CipherState) Clear() {
cs.aead = nil
cs.nonce = 0
}
+
+// Key returns a copy of the cipher key.
+func (cs *CipherState) Key() []byte {
+ if cs.key == nil {
+ return nil
+ }
+ key := make([]byte, len(cs.key))
+ copy(key, cs.key)
+ return key
+}