Package org.activecomponents.udp
Class SymCipherManagement
- java.lang.Object
-
- org.activecomponents.udp.SymCipherManagement
-
public class SymCipherManagement extends java.lang.Object
Management for keying and maintaining the symmetric encryption.
-
-
Field Summary
Fields Modifier and Type Field Description protected byte
activesymcipher
Currently active symcipher.protected int
cipherclassid
ID of class used as cipher for symmetric encryption.protected java.lang.reflect.Constructor<?>
ciphercon
Constructor for creating new ISymCipher objects.protected static java.lang.String[]
CIPHERS
Available cipher suites, order is important, only append please.protected KeyExchangeGenerator
keyexgen
Generator for key exchanges.protected IKeyExchange
kx
The key exchange.protected java.util.concurrent.atomic.AtomicLong
messageidcounter
Counters for message IDs.protected java.util.concurrent.atomic.AtomicLong
packetidcounter
Counters for packet IDs, must be greater than Long.MIN_VALUE to allow replay identification to work.protected long
remainingbytes
Bytes 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 void
createKx()
Creates a key exchange object.void
createSymCipherSuite(byte cipherid, byte[] symkey)
Creates a symmetric cipher suite.void
destroyKx()
Destroys the key exchange object.void
destroySymCipherSuite(byte cipherid)
Destroys a symmetric cipher.byte
getActiveSymCipherId()
Gets the currently active symmetric cipher ID.SymCipherSuite
getActiveSymCipherSuite()
Gets the currently active symmetric cipher suite.int
getCipherClassId()
Returns the ID of the selected cipher class.IKeyExchange
getKx()
Returns current key exchange object.long
getRemainingBytes()
Returns bytes remaining before rekeying.SymCipherSuite
getSymCipherSuite(byte cipherid)
Gets a symmetric cipher suite.void
refreshRemainingBytes()
Refreshes the remaining bytes after rekeying.void
setActiveSymCipherId(byte cipherid)
Sets the currently active symmetric cipher ID.void
subtractRemainingBytes(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.
-
-