client
Class Cryptography

java.lang.Object
  extended by client.Cryptography

final class Cryptography
extends java.lang.Object

Provides methods for de- and encrypting messages.

Author:
Karl-Peter Fuchs

Field Summary
private  javax.crypto.Cipher asymmetricCipher
          Cipher for asymmetric cryptography.
private static InternalInformationPortController internalInformationPort
          Reference on component InternalInformationPortController.
private  javax.crypto.KeyGenerator keyGenerator
          Key generator for symmetric cryptography and hash algorithm.
private static java.util.logging.Logger LOGGER
          Logger used to log and display information.
private  int NUMBER_OF_MIXES_IN_CASCADE
          Number of mixes in the cascade.
private  java.security.Key[] PUBLIC_KEYS_OF_MIXES
          Public keys of the cascade's mixes.
private  javax.crypto.spec.IvParameterSpec[] sessionIVs
          Initialization vectors for the ciphers for each of the cascade's mixes.
private  javax.crypto.SecretKey[] sessionKeys
          Session keys for the cascade's mixes.
private  javax.crypto.Cipher[] symmetricDecryptCiphers
          Session (decrypt) ciphers for each of the cascade's mixes.
private  javax.crypto.Cipher[] symmetricEncryptCiphers
          Session (encrypt) ciphers for each of the cascade's mixes.
 
Constructor Summary
protected Cryptography(java.security.Key[] publicKeysOfMixes)
          Generates a new Cryptography object that can be used to de- and encrypting messages (using the bypassed keys).
 
Method Summary
protected  byte[] decryptReply(byte[] reply)
          Decrypts the bypassed reply.
protected  Message encryptMessage(Message plaintextMessage, int positionOfMixInCascade)
          Encrypts the bypassed message (hybridly) for the specified mix.
private static java.lang.String getProperty(java.lang.String key)
          Simply used to shorten method calls (calls internalInformationPort.getProperty(key)).
protected  javax.crypto.spec.IvParameterSpec getSessionIVOfMix(int positionOfMixInCascade)
          Returns the specified mix' initialization vector.
protected  javax.crypto.SecretKey getSessionKeyOfMix(int positionOfMixInCascade)
          Returns the specified mix' session key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

internalInformationPort

private static InternalInformationPortController internalInformationPort
Reference on component InternalInformationPortController. Used to display and/or log data and read general settings.


LOGGER

private static final java.util.logging.Logger LOGGER
Logger used to log and display information.


NUMBER_OF_MIXES_IN_CASCADE

private final int NUMBER_OF_MIXES_IN_CASCADE
Number of mixes in the cascade.


asymmetricCipher

private javax.crypto.Cipher asymmetricCipher
Cipher for asymmetric cryptography.


keyGenerator

private javax.crypto.KeyGenerator keyGenerator
Key generator for symmetric cryptography and hash algorithm.


PUBLIC_KEYS_OF_MIXES

private final java.security.Key[] PUBLIC_KEYS_OF_MIXES
Public keys of the cascade's mixes. The first mix' key is found at PUBLIC_KEYS_OF_MIXES[0].


sessionKeys

private javax.crypto.SecretKey[] sessionKeys
Session keys for the cascade's mixes. The key for the first mix is found at sessionKeys[0].


sessionIVs

private javax.crypto.spec.IvParameterSpec[] sessionIVs
Initialization vectors for the ciphers for each of the cascade's mixes. The initialization vector for the first mix is found at sessionIVs[0].

See Also:
symmetricEncryptCiphers, symmetricDecryptCiphers

symmetricEncryptCiphers

private javax.crypto.Cipher[] symmetricEncryptCiphers
Session (encrypt) ciphers for each of the cascade's mixes. The cipher for the first mix is found at symmetricEncryptCiphers[0].


symmetricDecryptCiphers

private javax.crypto.Cipher[] symmetricDecryptCiphers
Session (decrypt) ciphers for each of the cascade's mixes. The cipher for the first mix is found at symmetricEncryptCiphers[0].

Constructor Detail

Cryptography

protected Cryptography(java.security.Key[] publicKeysOfMixes)
Generates a new Cryptography object that can be used to de- and encrypting messages (using the bypassed keys).

Parameters:
publicKeysOfMixes - Public keys of the cascade's mixes. The first mix' key must be located at publicKeysOfMixes[0].
Method Detail

getSessionKeyOfMix

protected javax.crypto.SecretKey getSessionKeyOfMix(int positionOfMixInCascade)
Returns the specified mix' session key.

Parameters:
positionOfMixInCascade - The mix' position in the cascade, who's session key shall be returned.
Returns:
The specified mix' session key.

getSessionIVOfMix

protected javax.crypto.spec.IvParameterSpec getSessionIVOfMix(int positionOfMixInCascade)
Returns the specified mix' initialization vector.

Parameters:
positionOfMixInCascade - The mix' position in the cascade, who's initialization vector shall be returned.
Returns:
The specified mix' initialization vector.

encryptMessage

protected Message encryptMessage(Message plaintextMessage,
                                 int positionOfMixInCascade)
Encrypts the bypassed message (hybridly) for the specified mix.

Parameters:
positionOfMixInCascade - The mix' position in the cascade, the message shall be encrypted for.
plaintextMessage - The message to be encrypted.
Returns:
The (hybridly) encrypted message.

decryptReply

protected byte[] decryptReply(byte[] reply)
Decrypts the bypassed reply.

Parameters:
reply - The reply to be decrypted.
Returns:
The decrypted reply.

getProperty

private static java.lang.String getProperty(java.lang.String key)
Simply used to shorten method calls (calls internalInformationPort.getProperty(key)). Returns the property with the specified key from the property file.

Parameters:
key - The property key.
Returns:
The property with the specified key in the property file.