Package net.handle.security
Class HdlSecurityProvider
java.lang.Object
net.handle.security.HdlSecurityProvider
- Direct Known Subclasses:
GenericProvider
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongenerateDHKeyPair
(int keySize) abstract byte[]
generateSecretKey
(int keyAlg) Generate and encode a secret key for use with the given algorithmgetCipher
(int algorithm, byte[] secretKey, int direction) Deprecated.abstract Cipher
getCipher
(int algorithm, byte[] secretKey, int direction, byte[] iv, int majorProtocolVersion, int minorProtocolVersion) Construct and return a Cipher object, initialized to either decrypt or encrypt using the given algorithm and secret key.byte[]
getDESKeyFromDH
(DHPublicKey pub, DHPrivateKey priv) static final HdlSecurityProvider
abstract int
getIvSize
(int algorithm, int majorProtocolVersion, int minorProtocolVersion) Returns the length in bytes of the initialization vector used by the cipher generated by getCipher().byte[]
getKeyFromDH
(DHPublicKey pub, DHPrivateKey priv, int algorithm) Using the given diffie-hellman key pair, generate a secret key with the given algorithm.
-
Field Details
-
ENCRYPT_ALG_DES
public static final int ENCRYPT_ALG_DES- See Also:
-
ENCRYPT_ALG_DESEDE
public static final int ENCRYPT_ALG_DESEDE- See Also:
-
ENCRYPT_ALG_AES
public static final int ENCRYPT_ALG_AES- See Also:
-
-
Constructor Details
-
HdlSecurityProvider
public HdlSecurityProvider()
-
-
Method Details
-
getInstance
-
getCipher
@Deprecated public Cipher getCipher(int algorithm, byte[] secretKey, int direction) throws Exception Deprecated.UsegetCipher(int,byte[],int,byte[],int,int)
in order to specify protocol version.- Throws:
Exception
-
getCipher
public abstract Cipher getCipher(int algorithm, byte[] secretKey, int direction, byte[] iv, int majorProtocolVersion, int minorProtocolVersion) throws Exception Construct and return a Cipher object, initialized to either decrypt or encrypt using the given algorithm and secret key. The direction parameter must be either Cipher.ENCRYPT_MODE or Cipher.DECRYPT_MODE. The algorithm parameter should be one of the HdlSecurityProvider.ENCRYPT_ALG_* constants. iv is the initialization vector, needed for decrypting with CBC.- Throws:
Exception
-
getIvSize
public abstract int getIvSize(int algorithm, int majorProtocolVersion, int minorProtocolVersion) Returns the length in bytes of the initialization vector used by the cipher generated by getCipher(). Returns 0 if no initialization vector. -
generateSecretKey
Generate and encode a secret key for use with the given algorithm- Throws:
Exception
-
generateDHKeyPair
- Throws:
Exception
-
generateDHKeyPair
- Throws:
Exception
-
getDESKeyFromDH
- Throws:
Exception
-
getKeyFromDH
Using the given diffie-hellman key pair, generate a secret key with the given algorithm. The first four bytes of the secret key will identify the algorithm for the secret key (DES, AES, DESede)- Throws:
Exception
-
getCipher(int,byte[],int,byte[],int,int)
in order to specify protocol version.