Package org.activecomponents.udp
Class SymCipherManagement
- java.lang.Object
-
- org.activecomponents.udp.SymCipherManagement
-
public class SymCipherManagement extends java.lang.ObjectManagement for keying and maintaining the symmetric encryption.
-
-
Field Summary
Fields Modifier and Type Field Description protected byteactivesymcipherCurrently active symcipher.protected intcipherclassidID of class used as cipher for symmetric encryption.protected java.lang.reflect.Constructor<?>cipherconConstructor for creating new ISymCipher objects.protected static java.lang.String[]CIPHERSAvailable cipher suites, order is important, only append please.protected KeyExchangeGeneratorkeyexgenGenerator for key exchanges.protected IKeyExchangekxThe key exchange.protected java.util.concurrent.atomic.AtomicLongmessageidcounterCounters for message IDs.protected java.util.concurrent.atomic.AtomicLongpacketidcounterCounters for packet IDs, must be greater than Long.MIN_VALUE to allow replay identification to work.protected longremainingbytesBytes remaining before rekeying.
-
Constructor Summary
Constructors Constructor Description SymCipherManagement(int cipherclassid, KeyExchangeGenerator keyexgen)Creates the management object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcreateKx()Creates a key exchange object.voidcreateSymCipherSuite(byte cipherid, byte[] symkey)Creates a symmetric cipher suite.voiddestroyKx()Destroys the key exchange object.voiddestroySymCipherSuite(byte cipherid)Destroys a symmetric cipher.bytegetActiveSymCipherId()Gets the currently active symmetric cipher ID.SymCipherSuitegetActiveSymCipherSuite()Gets the currently active symmetric cipher suite.intgetCipherClassId()Returns the ID of the selected cipher class.IKeyExchangegetKx()Returns current key exchange object.longgetRemainingBytes()Returns bytes remaining before rekeying.SymCipherSuitegetSymCipherSuite(byte cipherid)Gets a symmetric cipher suite.voidrefreshRemainingBytes()Refreshes the remaining bytes after rekeying.voidsetActiveSymCipherId(byte cipherid)Sets the currently active symmetric cipher ID.voidsubtractRemainingBytes(long bytes)Subtracts a number of bytes from the remaining bytes.
-
-
-
Field Detail
-
CIPHERS
protected static final java.lang.String[] CIPHERS
Available cipher suites, order is important, only append please.
-
cipherclassid
protected int cipherclassid
ID of class used as cipher for symmetric encryption.
-
ciphercon
protected java.lang.reflect.Constructor<?> ciphercon
Constructor for creating new ISymCipher objects.
-
keyexgen
protected KeyExchangeGenerator keyexgen
Generator for key exchanges.
-
packetidcounter
protected java.util.concurrent.atomic.AtomicLong packetidcounter
Counters for packet IDs, must be greater than Long.MIN_VALUE to allow replay identification to work.
-
messageidcounter
protected java.util.concurrent.atomic.AtomicLong messageidcounter
Counters for message IDs.
-
remainingbytes
protected long remainingbytes
Bytes remaining before rekeying.
-
activesymcipher
protected byte activesymcipher
Currently active symcipher.
-
kx
protected IKeyExchange kx
The key exchange.
-
-
Constructor Detail
-
SymCipherManagement
public SymCipherManagement(int cipherclassid, KeyExchangeGenerator keyexgen)Creates the management object.- Parameters:
symcipherclass- The symmetric cipher class used for encryption.keyexgen- Generator for key exchange objects.
-
-
Method Detail
-
getCipherClassId
public int getCipherClassId()
Returns the ID of the selected cipher class.- Returns:
- The ID.
-
getKx
public IKeyExchange getKx()
Returns current key exchange object.- Returns:
- Current key exchange object.
-
createKx
public void createKx()
Creates a key exchange object.
-
destroyKx
public void destroyKx()
Destroys the key exchange object.
-
createSymCipherSuite
public void createSymCipherSuite(byte cipherid, byte[] symkey)Creates a symmetric cipher suite.- Parameters:
cipherid- ID of the key used by the cipher.symkey- The key.
-
getSymCipherSuite
public SymCipherSuite getSymCipherSuite(byte cipherid)
Gets a symmetric cipher suite.- Parameters:
cipherid- ID of the key used by the cipher.
-
getActiveSymCipherSuite
public SymCipherSuite getActiveSymCipherSuite()
Gets the currently active symmetric cipher suite.
-
getActiveSymCipherId
public byte getActiveSymCipherId()
Gets the currently active symmetric cipher ID.
-
setActiveSymCipherId
public void setActiveSymCipherId(byte cipherid)
Sets the currently active symmetric cipher ID.- Parameters:
cipherid- The ID.
-
destroySymCipherSuite
public void destroySymCipherSuite(byte cipherid)
Destroys a symmetric cipher.- Parameters:
cipherid- ID of the key used by the cipher.
-
getRemainingBytes
public long getRemainingBytes()
Returns bytes remaining before rekeying.- Returns:
- Bytes remaining before rekeying.
-
subtractRemainingBytes
public void subtractRemainingBytes(long bytes)
Subtracts a number of bytes from the remaining bytes.- Parameters:
bytes- Bytes to subtract.
-
refreshRemainingBytes
public void refreshRemainingBytes()
Refreshes the remaining bytes after rekeying.
-
-