mirror of
https://github.com/i2p/i2p.i2p.git
synced 2026-10-15 06:49:58 +00:00
Crypto: Add SKMType enum (WIP)
for more efficient classification of SKMs
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package net.i2p.crypto;
|
||||
|
||||
/**
|
||||
* Enums for the various SessionKeyManagers, returned by getSKMType(),
|
||||
* to avoid instanceof()
|
||||
*
|
||||
* @since 0.9.71
|
||||
*/
|
||||
public enum SKMType {
|
||||
|
||||
/**
|
||||
* SessionKeyManager, app context
|
||||
*/
|
||||
DUMMY,
|
||||
/**
|
||||
* TransientSessionKeyManager
|
||||
*/
|
||||
ELGAMAL,
|
||||
/**
|
||||
* Single type, RATCHET or PQ-RATCHET
|
||||
*/
|
||||
RATCHET,
|
||||
/**
|
||||
* ELGAMAL and RATCHET
|
||||
*/
|
||||
MUXED,
|
||||
/**
|
||||
* RATCHET and PQ-RATCHET
|
||||
*/
|
||||
MUXEDPQ
|
||||
}
|
||||
@@ -27,13 +27,17 @@ import net.i2p.data.SessionTag;
|
||||
*/
|
||||
public class SessionKeyManager {
|
||||
|
||||
private final SKMType _type;
|
||||
|
||||
/**
|
||||
* A dummy SessionKeyManager for testing or for passing to
|
||||
* ElGamalAESEngine.decrypt()
|
||||
*
|
||||
* @since 0.9.14
|
||||
*/
|
||||
public SessionKeyManager() {}
|
||||
public SessionKeyManager() {
|
||||
this(SKMType.DUMMY);
|
||||
}
|
||||
|
||||
/**
|
||||
* A dummy SessionKeyManager for testing or for passing to
|
||||
@@ -42,8 +46,36 @@ public class SessionKeyManager {
|
||||
* @param context unused
|
||||
* @since public since 0.9.14; protected before that
|
||||
*/
|
||||
public SessionKeyManager(I2PAppContext context) {}
|
||||
|
||||
public SessionKeyManager(I2PAppContext context) {
|
||||
this(context, SKMType.DUMMY);
|
||||
}
|
||||
|
||||
/**
|
||||
* For subclasses
|
||||
*
|
||||
* @since 0.9.71
|
||||
*/
|
||||
protected SessionKeyManager(SKMType type) {
|
||||
_type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* For subclasses
|
||||
*
|
||||
* @param context unused
|
||||
* @since 0.9.71
|
||||
*/
|
||||
protected SessionKeyManager(I2PAppContext context, SKMType type) {
|
||||
_type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 0.9.71
|
||||
*/
|
||||
public SKMType getSKMType() {
|
||||
return _type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the session key currently associated with encryption to the target,
|
||||
* or null if a new session key should be generated.
|
||||
|
||||
Reference in New Issue
Block a user