SecretKey
A cryptographic secret key (symmetric key or shared secret) with memory clearing on disposal.
This is a specialized SecureByteString representing symmetric key material or shared secrets.
Instances of this class hold raw secret key material in an internal buffer. When the key is no longer needed, callers should invoke destroy or close, or use Kotlin's use extension. Upon disposal, the internal key material is overwritten with zeros using ByteArray.secureZero.
As a secondary safety net, an automatic cleaner (KeyDisposer) is registered at creation to zero the memory when the object becomes unreachable, guarding against leaks if close is inadvertently omitted.
Parameters
the initial key material. A defensive copy is stored.
Constructors
Creates a secret key from an existing SecureByteString.
Functions
Throws IllegalStateException if this byte string has been destroyed.
Returns true if this byte string is not empty.
Returns a defensive copy of the underlying bytes as a ByteArray.
Converts this SecureByteString to a SecretKey.