|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.derby.impl.drda.DecryptionManager
class DecryptionManager
This class is used to decrypt password and/or userid. It uses Diffie_Hellman algorithm to get the publick key and secret key, and then DES encryption is done using certain token (based on security mechanism) and this side's own public key. Basically, this class is called when using a security mechanism that encrypts user ID and password (eusridpwd). This class uses IBM JCE to do Diffie_Hellman algorithm and DES encryption.
Field Summary | |
---|---|
private static java.math.BigInteger |
base__
|
private static byte[] |
baseBytes__
|
private static int |
exponential_length__
|
private static char[] |
hex_table
RESOLVE: * The methods and static vars below should go into some 'shared' * package when the capability is put back in (StringUtil.java) |
private javax.crypto.KeyAgreement |
keyAgreement_
|
private java.security.KeyPair |
keyPair_
|
private java.security.KeyPairGenerator |
keyPairGenerator_
|
private static java.math.BigInteger |
modulus__
|
private static byte[] |
modulusBytes__
|
private javax.crypto.spec.DHParameterSpec |
paramSpec_
|
private static int |
SECMEC_USRSSBPWD_SEED_LEN
|
private static java.lang.String |
SHA_1_PRNG_ALGORITHM
|
Constructor Summary | |
---|---|
DecryptionManager()
EncryptionManager constructor. |
Method Summary | |
---|---|
private byte[] |
calculateDecryptionToken(int securityMechanism,
byte[] initVector)
This method is used to calculate the decryption token. |
byte[] |
decryptData(byte[] cipherText,
int securityMechanism,
byte[] initVector,
byte[] sourcePublicKey)
This method generates a secret key using the application requester's public key, and decrypts the usreid/password with the middle 8 bytes of the generated secret key and a decryption token. |
protected static byte[] |
generateSeed()
This method generates an 8-Byte random seed. |
byte[] |
obtainPublicKey()
This method generates the public key and returns it. |
protected static byte[] |
toHexByte(java.lang.String str,
int offset,
int length)
Convert a string into a byte array in hex format. |
protected static java.lang.String |
toHexString(byte[] data,
int offset,
int length)
Convert a byte array to a String with a hexidecimal format. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final byte[] modulusBytes__
private static final java.math.BigInteger modulus__
private static final byte[] baseBytes__
private static final java.math.BigInteger base__
private static final int exponential_length__
private java.security.KeyPairGenerator keyPairGenerator_
private java.security.KeyPair keyPair_
private javax.crypto.KeyAgreement keyAgreement_
private javax.crypto.spec.DHParameterSpec paramSpec_
private static final java.lang.String SHA_1_PRNG_ALGORITHM
private static final int SECMEC_USRSSBPWD_SEED_LEN
private static char[] hex_table
Constructor Detail |
---|
DecryptionManager() throws java.sql.SQLException
java.sql.SQLException
- that wraps any errorMethod Detail |
---|
public byte[] obtainPublicKey()
private byte[] calculateDecryptionToken(int securityMechanism, byte[] initVector)
securityMechanism
- security mechanisminitVector
- userid or server(this side)'s connection key
public byte[] decryptData(byte[] cipherText, int securityMechanism, byte[] initVector, byte[] sourcePublicKey) throws java.sql.SQLException
cipherText
- The byte array form userid/password to decrypt.securityMechanism
- security mechanisminitVector
- The byte array which is used to calculate the
decryption token for initializing the ciphersourcePublicKey
- application requester (encrypter)'s public key.
java.sql.SQLException
protected static byte[] generateSeed() throws java.sql.SQLException
java.sql.SQLException
protected static java.lang.String toHexString(byte[] data, int offset, int length)
b & 0xf0
),
the second character represents the low nibble (b & 0x0f
).
data[offset]
is represented by the first two characters in the returned String.
data
- byte arrayoffset
- starting byte (zero based) to convert.length
- number of bytes to convert.
protected static byte[] toHexByte(java.lang.String str, int offset, int length)
b & 0xf0
),
the second byte
represents the low nibble (b & 0x0f
).
str.charAt(0)
is represented by the first two bytes
in the returned String.
str
- stringoffset
- starting character (zero based) to convert.length
- number of characters to convert.
|
Built on Thu 2012-03-29 21:53:33+0000, from revision ??? | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |