public class SecretUtil extends Object
Destroyable SecretKey for java before 1.8.| Constructor and Description |
|---|
SecretUtil() |
| Modifier and Type | Method and Description |
|---|---|
static SecretKey |
create(byte[] secret,
int offset,
int length,
String algorithm)
Create a secret key.
|
static SecretKey |
create(byte[] secret,
String algorithm)
Creates a secret key.
|
static SecretKey |
create(SecretKey key)
Creates a copy of a secret key.
|
static SecretIvParameterSpec |
createIv(byte[] iv,
int offset,
int length)
Create secret iv paramter (with destroyable implementation).
|
static SecretIvParameterSpec |
createIv(SecretIvParameterSpec iv)
Creates copy of a secret init vector.
|
static void |
destroy(Destroyable destroyable)
Destroy provided security destroyable.
|
static void |
destroy(SecretKey key)
Destroy secret key.
|
static boolean |
isDestroyed(Destroyable destroyable)
Checks if a given destroyable has already been destroyed.
|
static boolean |
isDestroyed(SecretKey key)
Checks if a secret key has already been destroyed.
|
public static void destroy(SecretKey key)
key - secret key to destroy. If null, nothing is destroyed.public static void destroy(Destroyable destroyable)
destroyable - object to destroy. Maybe null.public static boolean isDestroyed(SecretKey key)
key - secret key to check (may be null).true if the key either is null or has been destroyed.public static boolean isDestroyed(Destroyable destroyable)
destroyable - The destroyable to check (may be null).true if the given object either is null or has been destroyed.public static SecretKey create(byte[] secret, String algorithm)
secret - The key material.algorithm - The algorithm that the key is used for. The name
PSK should be used if the key is supposed to
be used with a PSK based TLS handshake.javax.security.auth.Destroyable.public static SecretKey create(byte[] secret, int offset, int length, String algorithm)
secret - The source to copy the key material from.offset - The start index from which the key material should be copied.length - The number of bytes to copy.algorithm - The algorithm that the key is used for. The name
PSK should be used if the key is supposed to
be used with a PSK based TLS handshake.javax.security.auth.Destroyable.public static SecretKey create(SecretKey key)
key - The key to copy (may be null).null if the provided key was null.
The returned key also implements javax.security.auth.Destroyable.public static SecretIvParameterSpec createIv(SecretIvParameterSpec iv)
iv - The init vector to copy (may be null).null if the provided IV was null.public static SecretIvParameterSpec createIv(byte[] iv, int offset, int length)
iv - as byte arrayoffset - offset of iv within the provided byte arraylength - length of ivNullPointerException - if iv is nullIllegalArgumentException - if iv is empty, or len is negative or
offset and length doesn't fit into iv.Copyright © 2023 Eclipse Foundation. All rights reserved.