Package com.iizix.server.client
Class DHKey
java.lang.Object
com.iizix.server.client.DHKey
Class used to generate a 2048 bits key for password transport over unsecured HTTP transactions.
- Author:
- Christopher Mindus
- Constructor SummaryConstructors
- Method SummaryModifier and TypeMethodDescription- void- assignClientPublicKey- (String publicKey) Assigns the Client's public key.- byte[]Decrypts an encoded string from the client using the two public keys.- void- encrypt- (byte[] data, SendTransaction sendTrans) Encrypts and appends the bytes to the SendTransaction.- static IvParameterSpecGets the IV parameter.Gets the Server's public key.
- Constructor Details- DHKeypublic DHKey()Constructs the instance creating the server's key only. The client "Alice" public key must be provided later.
 
- Method Details- getIvParameterSpecGets the IV parameter.
- assignClientPublicKeyAssigns the Client's public key.- Parameters:
- publicKey- The "Alice" public key as a hexadecimal number.
- Throws:
- IllegalArgumentException- If the public key is invalid.
 
- getServerPublicKeyGets the Server's public key.- Returns:
- The server's public key as a hexadecimal number.
 
- encryptEncrypts and appends the bytes to the SendTransaction.- Parameters:
- data- The data to encrypt.
- sendTrans- The send transaction.
- Throws:
- Exception- For errors.
 
- decryptpublic byte[] decrypt- (String clientPublicKey, String encryptedString) throws InvalidKeyException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, UnsupportedEncodingException Decrypts an encoded string from the client using the two public keys.- Parameters:
- clientPublicKey- The client public key.
- encryptedString- The encrypted string encoded as a Base 64 string.
- Returns:
- The decrypted string.
- Throws:
- InvalidAlgorithmParameterException
- InvalidKeyException
- NoSuchPaddingException
- NoSuchAlgorithmException
- BadPaddingException
- IllegalBlockSizeException
- UnsupportedEncodingException