Package com.biglybt.core.security.impl
Class CryptoHandlerECC
- java.lang.Object
-
- com.biglybt.core.security.impl.CryptoHandlerECC
-
- All Implemented Interfaces:
CryptoHandler
public class CryptoHandlerECC extends java.lang.Object implements CryptoHandler
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
CryptoHandlerECC.InternalECIES
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
CONFIG_PREFIX
private static java.lang.String
DEFAULT_PASSWORD
private static java.lang.Long
DEFAULT_TIMEOUT
(package private) int
instance_id
private long
last_unlock_time
(package private) CryptoManagerImpl
manager
private static int
TIMEOUT_DEFAULT_SECS
private java.security.PrivateKey
use_method_private_key
private java.security.PublicKey
use_method_public_key
-
Constructor Summary
Constructors Modifier Constructor Description protected
CryptoHandlerECC(CryptoManagerImpl _manager, int _instance_id)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
checkKeysOK(java.lang.String reason)
protected java.security.Key[]
createAndStoreKeys(CryptoManagerImpl.passwordDetails password_details)
protected java.security.Key[]
createAndStoreKeys(java.lang.String reason)
byte[]
decrypt(byte[] other_public_key, byte[] data, java.lang.String reason)
byte[]
encrypt(byte[] other_public_key, byte[] data, java.lang.String reason)
java.lang.String
exportKeys()
protected int
getCurrentPasswordType()
int
getDefaultPasswordHandlerType()
byte[]
getEncryptedPrivateKey(java.lang.String reason)
int
getInstance()
protected java.security.PrivateKey
getMyPrivateKey(java.lang.String reason)
protected java.security.PublicKey
getMyPublicKey(java.lang.String reason, boolean create_if_needed)
byte[]
getPublicKey(java.lang.String reason)
CryptoSTSEngine
getSTSEngine(java.lang.String reason)
CryptoSTSEngine
getSTSEngine(java.security.PublicKey public_key, java.security.PrivateKey private_key)
int
getType()
int
getUnlockTimeoutSeconds()
boolean
importKeys(java.lang.String str)
boolean
isUnlocked()
void
lock()
Puts the handler back into a state where password will be required to access private stuffbyte[]
peekPublicKey()
void
recoverKeys(byte[] public_key, byte[] encrypted_private_key_and_type)
void
resetKeys(java.lang.String reason)
void
setDefaultPasswordHandlerType(int new_type)
void
setUnlockTimeoutSeconds(int secs)
byte[]
sign(byte[] data, java.lang.String reason)
void
unlock()
Explicit unlock requestboolean
verify(byte[] public_key, byte[] data, byte[] signature)
boolean
verifyPublicKey(byte[] encoded)
-
-
-
Field Detail
-
DEFAULT_PASSWORD
private static final java.lang.String DEFAULT_PASSWORD
- See Also:
- Constant Field Values
-
DEFAULT_TIMEOUT
private static final java.lang.Long DEFAULT_TIMEOUT
-
TIMEOUT_DEFAULT_SECS
private static final int TIMEOUT_DEFAULT_SECS
- See Also:
- Constant Field Values
-
manager
final CryptoManagerImpl manager
-
instance_id
final int instance_id
-
CONFIG_PREFIX
private java.lang.String CONFIG_PREFIX
-
use_method_private_key
private java.security.PrivateKey use_method_private_key
-
use_method_public_key
private java.security.PublicKey use_method_public_key
-
last_unlock_time
private long last_unlock_time
-
-
Constructor Detail
-
CryptoHandlerECC
protected CryptoHandlerECC(CryptoManagerImpl _manager, int _instance_id)
-
-
Method Detail
-
getType
public int getType()
- Specified by:
getType
in interfaceCryptoHandler
-
getInstance
public int getInstance()
- Specified by:
getInstance
in interfaceCryptoHandler
-
unlock
public void unlock() throws CryptoManagerException
Description copied from interface:CryptoHandler
Explicit unlock request- Specified by:
unlock
in interfaceCryptoHandler
- Throws:
CryptoManagerException
-
isUnlocked
public boolean isUnlocked()
- Specified by:
isUnlocked
in interfaceCryptoHandler
-
lock
public void lock()
Description copied from interface:CryptoHandler
Puts the handler back into a state where password will be required to access private stuff- Specified by:
lock
in interfaceCryptoHandler
-
getUnlockTimeoutSeconds
public int getUnlockTimeoutSeconds()
- Specified by:
getUnlockTimeoutSeconds
in interfaceCryptoHandler
-
setUnlockTimeoutSeconds
public void setUnlockTimeoutSeconds(int secs)
- Specified by:
setUnlockTimeoutSeconds
in interfaceCryptoHandler
- Parameters:
secs
- 0-> infinite
-
sign
public byte[] sign(byte[] data, java.lang.String reason) throws CryptoManagerException
- Specified by:
sign
in interfaceCryptoHandler
- Throws:
CryptoManagerException
-
verify
public boolean verify(byte[] public_key, byte[] data, byte[] signature) throws CryptoManagerException
- Specified by:
verify
in interfaceCryptoHandler
- Throws:
CryptoManagerException
-
encrypt
public byte[] encrypt(byte[] other_public_key, byte[] data, java.lang.String reason) throws CryptoManagerException
- Specified by:
encrypt
in interfaceCryptoHandler
- Throws:
CryptoManagerException
-
decrypt
public byte[] decrypt(byte[] other_public_key, byte[] data, java.lang.String reason) throws CryptoManagerException
- Specified by:
decrypt
in interfaceCryptoHandler
- Throws:
CryptoManagerException
-
getSTSEngine
public CryptoSTSEngine getSTSEngine(java.lang.String reason) throws CryptoManagerException
- Specified by:
getSTSEngine
in interfaceCryptoHandler
- Throws:
CryptoManagerException
-
getSTSEngine
public CryptoSTSEngine getSTSEngine(java.security.PublicKey public_key, java.security.PrivateKey private_key) throws CryptoManagerException
- Specified by:
getSTSEngine
in interfaceCryptoHandler
- Throws:
CryptoManagerException
-
peekPublicKey
public byte[] peekPublicKey()
- Specified by:
peekPublicKey
in interfaceCryptoHandler
-
getPublicKey
public byte[] getPublicKey(java.lang.String reason) throws CryptoManagerException
- Specified by:
getPublicKey
in interfaceCryptoHandler
- Throws:
CryptoManagerException
-
getEncryptedPrivateKey
public byte[] getEncryptedPrivateKey(java.lang.String reason) throws CryptoManagerException
- Specified by:
getEncryptedPrivateKey
in interfaceCryptoHandler
- Throws:
CryptoManagerException
-
recoverKeys
public void recoverKeys(byte[] public_key, byte[] encrypted_private_key_and_type) throws CryptoManagerException
- Specified by:
recoverKeys
in interfaceCryptoHandler
- Throws:
CryptoManagerException
-
resetKeys
public void resetKeys(java.lang.String reason) throws CryptoManagerException
- Specified by:
resetKeys
in interfaceCryptoHandler
- Throws:
CryptoManagerException
-
getMyPrivateKey
protected java.security.PrivateKey getMyPrivateKey(java.lang.String reason) throws CryptoManagerException
- Throws:
CryptoManagerException
-
checkKeysOK
protected boolean checkKeysOK(java.lang.String reason) throws CryptoManagerException
- Throws:
CryptoManagerException
-
getMyPublicKey
protected java.security.PublicKey getMyPublicKey(java.lang.String reason, boolean create_if_needed) throws CryptoManagerException
- Throws:
CryptoManagerException
-
getDefaultPasswordHandlerType
public int getDefaultPasswordHandlerType()
- Specified by:
getDefaultPasswordHandlerType
in interfaceCryptoHandler
-
setDefaultPasswordHandlerType
public void setDefaultPasswordHandlerType(int new_type) throws CryptoManagerException
- Specified by:
setDefaultPasswordHandlerType
in interfaceCryptoHandler
- Throws:
CryptoManagerException
-
createAndStoreKeys
protected java.security.Key[] createAndStoreKeys(java.lang.String reason) throws CryptoManagerException
- Throws:
CryptoManagerException
-
createAndStoreKeys
protected java.security.Key[] createAndStoreKeys(CryptoManagerImpl.passwordDetails password_details) throws CryptoManagerException
- Throws:
CryptoManagerException
-
verifyPublicKey
public boolean verifyPublicKey(byte[] encoded)
- Specified by:
verifyPublicKey
in interfaceCryptoHandler
-
exportKeys
public java.lang.String exportKeys() throws CryptoManagerException
- Specified by:
exportKeys
in interfaceCryptoHandler
- Throws:
CryptoManagerException
-
importKeys
public boolean importKeys(java.lang.String str) throws CryptoManagerException
- Specified by:
importKeys
in interfaceCryptoHandler
- Returns:
- true if a client restart is required
- Throws:
CryptoManagerException
-
getCurrentPasswordType
protected int getCurrentPasswordType()
-
-