diff options
Diffstat (limited to 'crypto/key.go')
| -rw-r--r-- | crypto/key.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/crypto/key.go b/crypto/key.go index 2220652..77adc95 100644 --- a/crypto/key.go +++ b/crypto/key.go @@ -195,6 +195,16 @@ func (key *Key) UnsafeToCString() unsafe.Pointer { return data } +// Clone creates a key as a copy of another one. +func (key *Key) Clone() (*Key, error) { + newKey, err := NewBlankKey(key.Len()) + if err != nil { + return nil, err + } + copy(newKey.data, key.data) + return newKey, nil +} + // NewKeyFromCString creates of a copy of some C string's data in a key. Note // that the original C string is not modified at all, so steps must be taken to // ensure that this original copy is secured. |