com.aelitis.azureus.core.security.impl
Class CryptoHandlerECC

java.lang.Object
  extended by com.aelitis.azureus.core.security.impl.CryptoHandlerECC
All Implemented Interfaces:
CryptoHandler

public class CryptoHandlerECC
extends java.lang.Object
implements CryptoHandler


Constructor Summary
protected CryptoHandlerECC(CryptoManagerImpl _manager, int _instance_id)
           
 
Method Summary
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)
           
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.security.PublicKey public_key, java.security.PrivateKey private_key)
           
 CryptoSTSEngine getSTSEngine(java.lang.String reason)
           
 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 stuff
 byte[] 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 request
 boolean verify(byte[] public_key, byte[] data, byte[] signature)
           
 boolean verifyPublicKey(byte[] encoded)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CryptoHandlerECC

protected CryptoHandlerECC(CryptoManagerImpl _manager,
                           int _instance_id)
Method Detail

getType

public int getType()
Specified by:
getType in interface CryptoHandler

unlock

public void unlock()
            throws CryptoManagerException
Description copied from interface: CryptoHandler
Explicit unlock request

Specified by:
unlock in interface CryptoHandler
Throws:
CryptoManagerException

isUnlocked

public boolean isUnlocked()
Specified by:
isUnlocked in interface CryptoHandler

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 interface CryptoHandler

getUnlockTimeoutSeconds

public int getUnlockTimeoutSeconds()
Specified by:
getUnlockTimeoutSeconds in interface CryptoHandler

setUnlockTimeoutSeconds

public void setUnlockTimeoutSeconds(int secs)
Specified by:
setUnlockTimeoutSeconds in interface CryptoHandler
Parameters:
secs - 0-> infinite

sign

public byte[] sign(byte[] data,
                   java.lang.String reason)
            throws CryptoManagerException
Specified by:
sign in interface CryptoHandler
Throws:
CryptoManagerException

verify

public boolean verify(byte[] public_key,
                      byte[] data,
                      byte[] signature)
               throws CryptoManagerException
Specified by:
verify in interface CryptoHandler
Throws:
CryptoManagerException

encrypt

public byte[] encrypt(byte[] other_public_key,
                      byte[] data,
                      java.lang.String reason)
               throws CryptoManagerException
Specified by:
encrypt in interface CryptoHandler
Throws:
CryptoManagerException

decrypt

public byte[] decrypt(byte[] other_public_key,
                      byte[] data,
                      java.lang.String reason)
               throws CryptoManagerException
Specified by:
decrypt in interface CryptoHandler
Throws:
CryptoManagerException

getSTSEngine

public CryptoSTSEngine getSTSEngine(java.lang.String reason)
                             throws CryptoManagerException
Specified by:
getSTSEngine in interface CryptoHandler
Throws:
CryptoManagerException

getSTSEngine

public CryptoSTSEngine getSTSEngine(java.security.PublicKey public_key,
                                    java.security.PrivateKey private_key)
                             throws CryptoManagerException
Specified by:
getSTSEngine in interface CryptoHandler
Throws:
CryptoManagerException

peekPublicKey

public byte[] peekPublicKey()
Specified by:
peekPublicKey in interface CryptoHandler

getPublicKey

public byte[] getPublicKey(java.lang.String reason)
                    throws CryptoManagerException
Specified by:
getPublicKey in interface CryptoHandler
Throws:
CryptoManagerException

getEncryptedPrivateKey

public byte[] getEncryptedPrivateKey(java.lang.String reason)
                              throws CryptoManagerException
Specified by:
getEncryptedPrivateKey in interface CryptoHandler
Throws:
CryptoManagerException

recoverKeys

public void recoverKeys(byte[] public_key,
                        byte[] encrypted_private_key_and_type)
                 throws CryptoManagerException
Specified by:
recoverKeys in interface CryptoHandler
Throws:
CryptoManagerException

resetKeys

public void resetKeys(java.lang.String reason)
               throws CryptoManagerException
Specified by:
resetKeys in interface CryptoHandler
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 interface CryptoHandler

setDefaultPasswordHandlerType

public void setDefaultPasswordHandlerType(int new_type)
                                   throws CryptoManagerException
Specified by:
setDefaultPasswordHandlerType in interface CryptoHandler
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 interface CryptoHandler

exportKeys

public java.lang.String exportKeys()
                            throws CryptoManagerException
Specified by:
exportKeys in interface CryptoHandler
Throws:
CryptoManagerException

importKeys

public boolean importKeys(java.lang.String str)
                   throws CryptoManagerException
Specified by:
importKeys in interface CryptoHandler
Returns:
true if an Azureus restart is required
Throws:
CryptoManagerException

getCurrentPasswordType

protected int getCurrentPasswordType()