Class Zeroization
java.lang.Object
co.ankatech.ankasecure.keymanagement.security.Zeroization
Centralized zeroization helpers for the ANKASecure Key Management SDK secure-memory layer.
All buffers passed in are overwritten in place using Arrays.fill(byte[], byte) and
Arrays.fill(char[], char), which is the only portable mechanism available on the JVM.
JIT register spills, JVM string interning, and library-internal pools are NOT addressed by
these methods.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voiddestroyIfPossible(Object obj) CallsDestroyable.destroy()if the supplied object implementsDestroyableand is not yet destroyed.static voidzeroize(byte[] buf) Overwrites every element with0x00.static voidzeroize(char[] buf) Overwrites every element with the space character' '.
-
Method Details
-
zeroize
public static void zeroize(byte[] buf) Overwrites every element with0x00. Null-safe (no-op onnull).- Parameters:
buf- the buffer to zeroize; may benull
-
zeroize
public static void zeroize(char[] buf) Overwrites every element with the space character' '. Null-safe (no-op onnull).Space-fill (rather than
0x00) is a deliberate choice: spaces are visible in heap dumps as printable text, making accidental retention easier to spot during forensic analysis. The security guarantee is identical — the original sensitive content is replaced.- Parameters:
buf- the buffer to zeroize; may benull
-
destroyIfPossible
CallsDestroyable.destroy()if the supplied object implementsDestroyableand is not yet destroyed. SwallowsDestroyFailedException, which the JDK throws by default forSecretKeySpecand several library types.Null-safe: passing
nullis a no-op.- Parameters:
obj- the object to destroy if possible; may benull
-