Code example for InvalidKeyException

0
        // else 
        // END android-removed 
        { 
            if (!(key instanceof ECPublicKey))
            { 
                throw new InvalidKeyException(kaAlgorithm + " key agreement requires "
                    + getSimpleName(ECPublicKey.class) + " for doPhase");
            } 
 
            pubKey = ECUtil.generatePublicKeyParameter((PublicKey)key);
 
            // TODO Validate that all the keys are using the same parameters? 
        } 
 
        result = agreement.calculateAgreement(pubKey);
 
        return null; 
    } 
 
    protected byte[] engineGenerateSecret() 
        throws IllegalStateException