public class CryptManager
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static org.apache.logging.log4j.Logger |
LOGGER |
Constructor and Description |
---|
CryptManager() |
Modifier and Type | Method and Description |
---|---|
private static byte[] |
cipherOperation(int opMode,
java.security.Key key,
byte[] data)
Encrypt or decrypt byte[] data using the specified key
|
static javax.crypto.Cipher |
createNetCipherInstance(int opMode,
java.security.Key key)
Creates an Cipher instance using the AES/CFB8/NoPadding algorithm.
|
static javax.crypto.SecretKey |
createNewSharedKey()
Generate a new shared secret AES key from a secure random source
|
private static javax.crypto.Cipher |
createTheCipherInstance(int opMode,
java.lang.String transformation,
java.security.Key key)
Creates the Cipher Instance.
|
static java.security.PublicKey |
decodePublicKey(byte[] encodedKey)
Create a new PublicKey from encoded X.509 data
|
static byte[] |
decryptData(java.security.Key key,
byte[] data)
Decrypt byte[] data with RSA private key
|
static javax.crypto.SecretKey |
decryptSharedKey(java.security.PrivateKey key,
byte[] secretKeyEncrypted)
Decrypt shared secret AES key using RSA private key
|
private static byte[] |
digestOperation(java.lang.String algorithm,
byte[]... data)
Compute a message digest on arbitrary byte[] data
|
static byte[] |
encryptData(java.security.Key key,
byte[] data)
Encrypt byte[] data with RSA public key
|
static java.security.KeyPair |
generateKeyPair()
Generates RSA KeyPair
|
static byte[] |
getServerIdHash(java.lang.String serverId,
java.security.PublicKey publicKey,
javax.crypto.SecretKey secretKey)
Compute a serverId hash for use by sendSessionRequest()
|
public static javax.crypto.SecretKey createNewSharedKey()
public static java.security.KeyPair generateKeyPair()
public static byte[] getServerIdHash(java.lang.String serverId, java.security.PublicKey publicKey, javax.crypto.SecretKey secretKey)
private static byte[] digestOperation(java.lang.String algorithm, byte[]... data)
public static java.security.PublicKey decodePublicKey(byte[] encodedKey)
public static javax.crypto.SecretKey decryptSharedKey(java.security.PrivateKey key, byte[] secretKeyEncrypted)
public static byte[] encryptData(java.security.Key key, byte[] data)
public static byte[] decryptData(java.security.Key key, byte[] data)
private static byte[] cipherOperation(int opMode, java.security.Key key, byte[] data)
private static javax.crypto.Cipher createTheCipherInstance(int opMode, java.lang.String transformation, java.security.Key key)
public static javax.crypto.Cipher createNetCipherInstance(int opMode, java.security.Key key)