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 Object
implements CryptoHandler


Constructor Summary
protected CryptoHandlerECC(CryptoManagerImpl _manager, int _instance_id)
           
 
Method Summary
protected  boolean checkKeysOK(String reason)
           
protected  Key[] createAndStoreKeys(CryptoManagerImpl.passwordDetails password_details)
           
protected  Key[] createAndStoreKeys(String reason)
           
 byte[] decrypt(byte[] other_public_key, byte[] data, String reason)
           
 byte[] encrypt(byte[] other_public_key, byte[] data, String reason)
           
 String exportKeys()
           
protected  int getCurrentPasswordType()
           
 int getDefaultPasswordHandlerType()
           
 byte[] getEncryptedPrivateKey(String reason)
           
protected  PrivateKey getMyPrivateKey(String reason)
           
protected  PublicKey getMyPublicKey(String reason, boolean create_if_needed)
           
 byte[] getPublicKey(String reason)
           
 CryptoSTSEngine getSTSEngine(PublicKey public_key, PrivateKey private_key)
           
 CryptoSTSEngine getSTSEngine(String reason)
           
 int getType()
           
 int getUnlockTimeoutSeconds()
           
 boolean importKeys(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(String reason)
           
 void setDefaultPasswordHandlerType(int new_type)
           
 void setUnlockTimeoutSeconds(int secs)
           
 byte[] sign(byte[] data, 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,
                   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,
                      String reason)
               throws CryptoManagerException
Specified by:
encrypt in interface CryptoHandler
Throws:
CryptoManagerException

decrypt

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

getSTSEngine

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

getSTSEngine

public CryptoSTSEngine getSTSEngine(PublicKey public_key,
                                    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(String reason)
                    throws CryptoManagerException
Specified by:
getPublicKey in interface CryptoHandler
Throws:
CryptoManagerException

getEncryptedPrivateKey

public byte[] getEncryptedPrivateKey(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(String reason)
               throws CryptoManagerException
Specified by:
resetKeys in interface CryptoHandler
Throws:
CryptoManagerException

getMyPrivateKey

protected PrivateKey getMyPrivateKey(String reason)
                              throws CryptoManagerException
Throws:
CryptoManagerException

checkKeysOK

protected boolean checkKeysOK(String reason)
                       throws CryptoManagerException
Throws:
CryptoManagerException

getMyPublicKey

protected PublicKey getMyPublicKey(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 Key[] createAndStoreKeys(String reason)
                            throws CryptoManagerException
Throws:
CryptoManagerException

createAndStoreKeys

protected Key[] createAndStoreKeys(CryptoManagerImpl.passwordDetails password_details)
                            throws CryptoManagerException
Throws:
CryptoManagerException

verifyPublicKey

public boolean verifyPublicKey(byte[] encoded)
Specified by:
verifyPublicKey in interface CryptoHandler

exportKeys

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

importKeys

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

getCurrentPasswordType

protected int getCurrentPasswordType()