Package org.bouncycastle.jce.interfaces

Examples of org.bouncycastle.jce.interfaces.ElGamalPrivateKey


        PrivateKey    key)
        throws InvalidKeyException
    {
        if (key instanceof ElGamalPrivateKey)
        {
            ElGamalPrivateKey    k = (ElGamalPrivateKey)key;

            return new ElGamalPrivateKeyParameters(k.getX(),
                new ElGamalParameters(k.getParams().getP(), k.getParams().getG()));
        }
                       
        throw new InvalidKeyException("can't identify ElGamal private key.");
    }
View Full Code Here


        PrivateKey    key)
        throws InvalidKeyException
    {
        if (key instanceof ElGamalPrivateKey)
        {
            ElGamalPrivateKey    k = (ElGamalPrivateKey)key;

            return new ElGamalPrivateKeyParameters(k.getX(),
                new ElGamalParameters(k.getParameters().getP(), k.getParameters().getG()));
        }
        else if (key instanceof DHPrivateKey)
        {
            DHPrivateKey    k = (DHPrivateKey)key;

            return new ElGamalPrivateKeyParameters(k.getX(),
                new ElGamalParameters(k.getParams().getP(), k.getParams().getG()));
        }
                       
        throw new InvalidKeyException("can't identify private key for El Gamal.");
    }
View Full Code Here

        if (!elGamalP.equals(pub.getParameters().getP()))
        {
            fail("public key p mismatch");
        }
       
        ElGamalPrivateKey priv = (ElGamalPrivateKey)readObject(elGamalPriv);

        if (!elGamalX.equals(priv.getX()))
        {
            fail("private key x mismatch");
        }
        if (!elGamalG.equals(priv.getParameters().getG()))
        {
            fail("private key g mismatch");
        }
        if (!elGamalP.equals(priv.getParameters().getP()))
        {
            fail("private key p mismatch");
        }
    }
View Full Code Here

           
            secKey = new DSASecretBCPGKey(dsK.getX());
            break;
        case PGPPublicKey.ELGAMAL_ENCRYPT:
        case PGPPublicKey.ELGAMAL_GENERAL:
            ElGamalPrivateKey   esK = (ElGamalPrivateKey)privKey.getKey();
           
            secKey = new ElGamalSecretBCPGKey(esK.getX());
            break;
        default:
            throw new PGPException("unknown key class");
        }
View Full Code Here

        PrivateKey    key)
        throws InvalidKeyException
    {
        if (key instanceof ElGamalPrivateKey)
        {
            ElGamalPrivateKey    k = (ElGamalPrivateKey)key;

            return new ElGamalPrivateKeyParameters(k.getX(),
                new ElGamalParameters(k.getParameters().getP(), k.getParameters().getG()));
        }
        else if (key instanceof DHPrivateKey)
        {
            DHPrivateKey    k = (DHPrivateKey)key;

            return new ElGamalPrivateKeyParameters(k.getX(),
                new ElGamalParameters(k.getParams().getP(), k.getParams().getG()));
        }
                       
        throw new InvalidKeyException("can't identify private key for El Gamal.");
    }
View Full Code Here

            privPk = new DSASecretBCPGKey(dsK.getX());
            break;
        case PGPPublicKey.ELGAMAL_ENCRYPT:
        case PGPPublicKey.ELGAMAL_GENERAL:
            ElGamalPrivateKey esK = (ElGamalPrivateKey)privKey;

            privPk = new ElGamalSecretBCPGKey(esK.getX());
            break;
        default:
            throw new PGPException("unknown key class");
        }
        this.priv = new PGPPrivateKey(pub.getKeyID(), pub.getPublicKeyPacket(), privPk);
View Full Code Here

            privateKeyDataPacket = new DSASecretBCPGKey(dsK.getX());
        }
        else if (privateKey instanceof  ElGamalPrivateKey)
        {
            ElGamalPrivateKey esK = (ElGamalPrivateKey)privateKey;

            privateKeyDataPacket = new ElGamalSecretBCPGKey(esK.getX());
        }
        else
        {
            throw new IllegalArgumentException("unknown key class");
        }
View Full Code Here

           
            secKey = new DSASecretBCPGKey(dsK.getX());
            break;
        case PGPPublicKey.ELGAMAL_ENCRYPT:
        case PGPPublicKey.ELGAMAL_GENERAL:
            ElGamalPrivateKey   esK = (ElGamalPrivateKey)keyPair.getPrivateKey().getKey();
           
            secKey = new ElGamalSecretBCPGKey(esK.getX());
            break;
        default:
            throw new PGPException("unknown key class");
        }
View Full Code Here

      hashedAnswer = answer.getBytes();
    }

    // Verifying if correct answer is entered by user or not.
    try {
      ElGamalPrivateKey privateKey = Util.decryptPrivateKey(
          messageDetails.getPrvKey(), hashedAnswer);
      return Util.decrypt(messageDetails.getMessageKey(), privateKey);
    } catch (Exception e1) {
      e1.printStackTrace();
    }
View Full Code Here

   * java.lang.String, java.lang.String, java.lang.String)
   */
  public String send(String messageKey, String fromMail, String toMail, String question, String ans, Timestamp timeToLive, Float version) {
    String messageId = null;
    ElGamalPublicKey puk = getUserDao().getPublicKey(fromMail);
    ElGamalPrivateKey pvk = getUserDao().getPrivateKey(fromMail);
    byte[] hashedAnswer = null;
    if (version == 0.0F) {
      String answer = Normalizer.normalize(ans, Normalizer.Form.NFD);
      hashedAnswer = Util.hash(answer);
    } else {
View Full Code Here

TOP

Related Classes of org.bouncycastle.jce.interfaces.ElGamalPrivateKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.