]> Cypherpunks.ru repositories - gogost.git/blobdiff - mgm/slice.go
go.cypherpunks.ru namespace usage
[gogost.git] / mgm / slice.go
diff --git a/mgm/slice.go b/mgm/slice.go
new file mode 100644 (file)
index 0000000..d2086cc
--- /dev/null
@@ -0,0 +1,13 @@
+package mgm
+
+// Taken from go/src/crypto/cipher/gcm.go
+func sliceForAppend(in []byte, n int) (head, tail []byte) {
+       if total := len(in) + n; cap(in) >= total {
+               head = in[:total]
+       } else {
+               head = make([]byte, total)
+               copy(head, in)
+       }
+       tail = head[len(in):]
+       return
+}