Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrDestroyed = errors.New("secret: material destroyed")
ErrDestroyed is returned when operations are attempted on a wiped object.
var ErrNonceExhausted = errors.New("secret: nonce space exhausted")
ErrNonceExhausted signals that a counter has produced every possible value.
Functions ¶
func CloneBytes ¶
CloneBytes returns a deep copy of b. It is a convenience helper for callers needing to duplicate sensitive material before mutating it.
Types ¶
type Counter96 ¶
type Counter96 struct {
// contains filtered or unexported fields
}
Counter96 manages 96-bit (12-byte) nonces using a monotonically increasing counter encoded as big-endian bytes.
func NewCounter96 ¶
NewCounter96 constructs a Counter96 initialised to initial.
func (*Counter96) Destroy ¶
func (c *Counter96) Destroy()
Destroy zeroes the counter state and marks it as exhausted.
type Counter192 ¶
type Counter192 struct {
// contains filtered or unexported fields
}
Counter192 manages 192-bit (24-byte) nonces.
func NewCounter192 ¶
func NewCounter192(initial []byte) (*Counter192, error)
NewCounter192 constructs a Counter192 initialised to initial.
func (*Counter192) Destroy ¶
func (c *Counter192) Destroy()
Destroy zeroes the counter state and marks it as exhausted.
func (*Counter192) Next ¶
func (c *Counter192) Next() ([]byte, error)
Next returns the current nonce value and advances the counter.
func (*Counter192) Peek ¶
func (c *Counter192) Peek() ([]byte, error)
Peek returns the next nonce without incrementing the counter.
type Nonce ¶
type Nonce struct {
// contains filtered or unexported fields
}
Nonce represents nonce or IV material tied to a specific length.
type SymmetricKey ¶
type SymmetricKey struct {
// contains filtered or unexported fields
}
SymmetricKey represents key material that is automatically wiped when Destroy is invoked. It provides controlled access to the underlying bytes and ensures best-effort zeroization.
func NewSymmetricKey ¶
func NewSymmetricKey(size int) *SymmetricKey
NewSymmetricKey returns a zeroed symmetric key of the requested size.
func SymmetricKeyFrom ¶
func SymmetricKeyFrom(src []byte) *SymmetricKey
SymmetricKeyFrom copies src into a new SymmetricKey instance.
func (*SymmetricKey) Bytes ¶
func (k *SymmetricKey) Bytes() ([]byte, error)
Bytes returns a copy of the key material.
func (*SymmetricKey) Destroy ¶
func (k *SymmetricKey) Destroy()
Destroy zeros the key material and marks the key as destroyed.
func (*SymmetricKey) Len ¶
func (k *SymmetricKey) Len() int
Len reports the size of the key material in bytes.