Package com.biglybt.core.security.impl
Class CryptoHandlerECC
java.lang.Object
com.biglybt.core.security.impl.CryptoHandlerECC
- All Implemented Interfaces:
CryptoHandler
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
private static final String
private static final Long
(package private) final int
private long
(package private) final CryptoManagerImpl
private static final int
private PrivateKey
private PublicKey
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
CryptoHandlerECC
(CryptoManagerImpl _manager, int _instance_id) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
checkKeysOK
(String reason) protected Key[]
createAndStoreKeys
(CryptoManagerImpl.passwordDetails password_details) protected Key[]
createAndStoreKeys
(String reason) byte[]
byte[]
protected int
int
byte[]
getEncryptedPrivateKey
(String reason) int
protected PrivateKey
getMyPrivateKey
(String reason) protected PublicKey
getMyPublicKey
(String reason, boolean create_if_needed) byte[]
getPublicKey
(String reason) getSTSEngine
(String reason) getSTSEngine
(PublicKey public_key, PrivateKey private_key) int
getType()
int
boolean
importKeys
(String str) boolean
void
lock()
Puts the handler back into a state where password will be required to access private stuffbyte[]
void
recoverKeys
(byte[] public_key, byte[] encrypted_private_key_and_type) void
void
setDefaultPasswordHandlerType
(int new_type) void
setUnlockTimeoutSeconds
(int secs) byte[]
void
unlock()
Explicit unlock requestboolean
verify
(byte[] public_key, byte[] data, byte[] signature) boolean
verifyPublicKey
(byte[] encoded)
-
Field Details
-
DEFAULT_PASSWORD
- See Also:
-
DEFAULT_TIMEOUT
-
TIMEOUT_DEFAULT_SECS
private static final int TIMEOUT_DEFAULT_SECS- See Also:
-
manager
-
instance_id
final int instance_id -
CONFIG_PREFIX
-
use_method_private_key
-
use_method_public_key
-
last_unlock_time
private long last_unlock_time
-
-
Constructor Details
-
CryptoHandlerECC
-
-
Method Details
-
getType
public int getType()- Specified by:
getType
in interfaceCryptoHandler
-
getInstance
public int getInstance()- Specified by:
getInstance
in interfaceCryptoHandler
-
unlock
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
- 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, String reason) throws CryptoManagerException - Specified by:
encrypt
in interfaceCryptoHandler
- Throws:
CryptoManagerException
-
decrypt
public byte[] decrypt(byte[] other_public_key, byte[] data, String reason) throws CryptoManagerException - Specified by:
decrypt
in interfaceCryptoHandler
- Throws:
CryptoManagerException
-
getSTSEngine
- Specified by:
getSTSEngine
in interfaceCryptoHandler
- Throws:
CryptoManagerException
-
getSTSEngine
public CryptoSTSEngine getSTSEngine(PublicKey public_key, PrivateKey private_key) throws CryptoManagerException - Specified by:
getSTSEngine
in interfaceCryptoHandler
- Throws:
CryptoManagerException
-
peekPublicKey
public byte[] peekPublicKey()- Specified by:
peekPublicKey
in interfaceCryptoHandler
-
getPublicKey
- Specified by:
getPublicKey
in interfaceCryptoHandler
- Throws:
CryptoManagerException
-
getEncryptedPrivateKey
- 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
- Specified by:
resetKeys
in interfaceCryptoHandler
- Throws:
CryptoManagerException
-
getMyPrivateKey
- Throws:
CryptoManagerException
-
checkKeysOK
- Throws:
CryptoManagerException
-
getMyPublicKey
protected PublicKey getMyPublicKey(String reason, boolean create_if_needed) throws CryptoManagerException - Throws:
CryptoManagerException
-
getDefaultPasswordHandlerType
public int getDefaultPasswordHandlerType()- Specified by:
getDefaultPasswordHandlerType
in interfaceCryptoHandler
-
setDefaultPasswordHandlerType
- Specified by:
setDefaultPasswordHandlerType
in interfaceCryptoHandler
- Throws:
CryptoManagerException
-
createAndStoreKeys
- Throws:
CryptoManagerException
-
createAndStoreKeys
protected Key[] createAndStoreKeys(CryptoManagerImpl.passwordDetails password_details) throws CryptoManagerException - Throws:
CryptoManagerException
-
verifyPublicKey
public boolean verifyPublicKey(byte[] encoded) - Specified by:
verifyPublicKey
in interfaceCryptoHandler
-
exportKeys
- Specified by:
exportKeys
in interfaceCryptoHandler
- Throws:
CryptoManagerException
-
importKeys
- Specified by:
importKeys
in interfaceCryptoHandler
- Returns:
- true if a client restart is required
- Throws:
CryptoManagerException
-
getCurrentPasswordType
protected int getCurrentPasswordType()
-