java.lang.Object
edu.iu.crypt.EphemeralKeys
Generates ephemeral keys.
Ephemeral keys are generated using JDK 21 compliant
standard algorithms with registered JCE
providers
-
Method Summary
Modifier and TypeMethodDescriptionstatic final byte[]
contentEncryptionKey
(int size) Generates a content encryption key for AES/GCM.static final byte[]
contentEncryptionKey
(String mac, int size) Generates a content encryption key.static final KeyPair
ec
(AlgorithmParameterSpec param) Generates a random Elliptic Curve (EC) key.static final byte[]
rand
(int bytes) Securely generates pseudorandom data.static final KeyPair
Generates a random RSA keystatic final byte[]
Generates a random secret key.
-
Method Details
-
rand
public static final byte[] rand(int bytes) Securely generates pseudorandom data.- Parameters:
bytes
- number of bytes to generate- Returns:
- securely generated pseudorandom data.
-
secret
Generates a random secret key.- Parameters:
algorithm
-KeyGenerator
algorithmsize
- key size in bits- Returns:
- AES key
-
ec
Generates a random Elliptic Curve (EC) key.- Parameters:
param
- EC parameter spec- Returns:
KeyPair
-
rsa
Generates a random RSA key- Parameters:
algorithm
- RSA KeyPairGenerator algorithm: RSA or RSASSA-PSSsize
- RSA key size in bits- Returns:
KeyPair
-
contentEncryptionKey
public static final byte[] contentEncryptionKey(int size) Generates a content encryption key for AES/GCM.- Parameters:
size
- key size- Returns:
- content encryption key
-
contentEncryptionKey
Generates a content encryption key.- Parameters:
mac
- MAC algorithm for AES/CBC/HMAC; null for AES/GCMsize
- key size- Returns:
- content encryption key
-