java.lang.Object
org.apache.derby.impl.drda.DecryptionManager
- public class DecryptionManager
- extends java.lang.Object
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.
|
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. |
byte[] |
obtainPublicKey()
This method generates the public key and returns it. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
modulusBytes__
private static final byte[] modulusBytes__
modulus__
private static final java.math.BigInteger modulus__
baseBytes__
private static final byte[] baseBytes__
base__
private static final java.math.BigInteger base__
exponential_length__
private static final int exponential_length__
- See Also:
- Constant Field Values
keyPairGenerator_
private java.security.KeyPairGenerator keyPairGenerator_
keyPair_
private java.security.KeyPair keyPair_
keyAgreement_
private javax.crypto.KeyAgreement keyAgreement_
paramSpec_
private javax.crypto.spec.DHParameterSpec paramSpec_
DecryptionManager
public DecryptionManager()
throws java.sql.SQLException
- EncryptionManager constructor. In this constructor,DHParameterSpec,
KeyPairGenerator, KeyPair, and KeyAgreement are initialized.
obtainPublicKey
public byte[] obtainPublicKey()
- This method generates the public key and returns it. This
shared public key is the application server's connection key and will
be exchanged with the application requester's connection key. This connection
key will be put in the sectkn in ACCSECRD command and send to the application
requester.
calculateDecryptionToken
private byte[] calculateDecryptionToken(int securityMechanism,
byte[] initVector)
- This method is used to calculate the decryption token. DES encrypts the
data using a token and the generated shared private key. The token used
depends on the type of security mechanism being used:
USRENCPWD - The userid is used as the token. The USRID is zero-padded to
8 bytes if less than 8 bytes or truncated to 8 bytes if greater than 8 bytes.
EUSRIDPWD - The middle 8 bytes of the server's connection key is used as
the token. Decryption needs to use exactly the same token as encryption.
decryptData
public byte[] decryptData(byte[] cipherText,
int securityMechanism,
byte[] initVector,
byte[] sourcePublicKey)
throws java.sql.SQLException
- 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. Then it returns the
decrypted data in a byte array.