public class SecureUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
VERSION
The version of our security protocol (for backwards compatability with older clients).
|
| Constructor and Description |
|---|
SecureUtil() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
ciphersSupported(PrivateKey key)
Returns true if we can generate our ciphers.
|
static boolean |
ciphersSupported(PublicKey key)
Returns true if we can generate our ciphers.
|
static byte[] |
createRandomKey(int length)
Creates a random key.
|
static byte[] |
decryptBytes(PrivateKey key,
byte[] encrypted,
byte[] salt)
Decrypts a secret key and checks for tailing salt.
|
static byte[] |
encryptBytes(PublicKey key,
byte[] secret,
byte[] salt)
Encrypts a secret key and salt with a public key.
|
static KeyPair |
genRSAKeyPair(int bits)
Creates an RSA key pair.
|
static Cipher |
getAESCipher(int mode,
byte[] key)
Creates our AES cipher.
|
static Cipher |
getRSACipher(int mode,
Key key)
Creates our RSA cipher.
|
static Cipher |
getRSACipher(PrivateKey key)
Creates our RSA cipher.
|
static Cipher |
getRSACipher(PublicKey key)
Creates our RSA cipher.
|
static String |
RSAKeyToString(PrivateKey key)
Converts an key to a string suitable for a properties file.
|
static String |
RSAKeyToString(PublicKey key)
Converts an key to a string suitable for a properties file.
|
static PrivateKey |
stringToRSAPrivateKey(String str)
Creates a private key from the supplied string.
|
static PublicKey |
stringToRSAPublicKey(String str)
Creates a public key from the supplied string.
|
static byte[] |
xorBytes(byte[] data,
byte[] key)
XORs a byte array against a key.
|
public static final int VERSION
public static Cipher getAESCipher(int mode, byte[] key)
public static Cipher getRSACipher(PrivateKey key)
public static KeyPair genRSAKeyPair(int bits)
public static String RSAKeyToString(PublicKey key)
public static String RSAKeyToString(PrivateKey key)
public static PublicKey stringToRSAPublicKey(String str)
public static PrivateKey stringToRSAPrivateKey(String str)
public static boolean ciphersSupported(PrivateKey key)
public static boolean ciphersSupported(PublicKey key)
public static byte[] createRandomKey(int length)
public static byte[] encryptBytes(PublicKey key, byte[] secret, byte[] salt)
public static byte[] decryptBytes(PrivateKey key, byte[] encrypted, byte[] salt)
public static byte[] xorBytes(byte[] data,
byte[] key)
Copyright © 2015. All rights reserved.