Package org.bouncycastle.crypto.params

Examples of org.bouncycastle.crypto.params.ECPrivateKeyParameters


                throw new InvalidKeyException(kaAlgorithm + " key agreement requires "
                    + getSimpleName(MQVPrivateKey.class) + " for initialisation");
            }

            MQVPrivateKey mqvPrivKey = (MQVPrivateKey)key;
            ECPrivateKeyParameters staticPrivKey = (ECPrivateKeyParameters)
                ECUtil.generatePrivateKeyParameter(mqvPrivKey.getStaticPrivateKey());
            ECPrivateKeyParameters ephemPrivKey = (ECPrivateKeyParameters)
                ECUtil.generatePrivateKeyParameter(mqvPrivKey.getEphemeralPrivateKey());

            ECPublicKeyParameters ephemPubKey = null;
            if (mqvPrivKey.getEphemeralPublicKey() != null)
            {
                ephemPubKey = (ECPublicKeyParameters)
                    ECUtil.generatePublicKeyParameter(mqvPrivKey.getEphemeralPublicKey());
            }

            MQVPrivateParameters localParams = new MQVPrivateParameters(staticPrivKey, ephemPrivKey, ephemPubKey);
            this.parameters = staticPrivKey.getParameters();

            // TODO Validate that all the keys are using the same parameters?

            agreement.init(localParams);
        }
        else
        {
            if (!(key instanceof ECPrivateKey))
            {
                throw new InvalidKeyException(kaAlgorithm + " key agreement requires "
                    + getSimpleName(ECPrivateKey.class) + " for initialisation");
            }

            ECPrivateKeyParameters privKey = (ECPrivateKeyParameters)ECUtil.generatePrivateKeyParameter((PrivateKey)key);
            this.parameters = privKey.getParameters();

            agreement.init(privKey);
        }
    }
View Full Code Here


                throw new IllegalStateException("EC Key Pair Generator not initialised");
            }

            AsymmetricCipherKeyPair     pair = engine.generateKeyPair();
            ECPublicKeyParameters       pub = (ECPublicKeyParameters)pair.getPublic();
            ECPrivateKeyParameters      priv = (ECPrivateKeyParameters)pair.getPrivate();

            if (ecParams instanceof ECParameterSpec)
            {
                ECParameterSpec p = (ECParameterSpec)ecParams;
View Full Code Here

        ECPoint Q = params.getG().multiply(d);

        return new AsymmetricCipherKeyPair(
            new ECPublicKeyParameters(Q, params),
            new ECPrivateKeyParameters(d, params));
    }
View Full Code Here

        if (key instanceof ECPrivateKey)
        {
            ECPrivateKey  k = (ECPrivateKey)key;
            ECParameterSpec s = k.getParameters();

            return new ECPrivateKeyParameters(
                            k.getD(),
                            new ECDomainParameters(s.getCurve(), s.getG(), s.getN()));
        }
                       
        throw new InvalidKeyException("can't identify EC private key.");
View Full Code Here

                throw new IllegalStateException("EC Key Pair Generator not initialised");
            }

            AsymmetricCipherKeyPair     pair = engine.generateKeyPair();
            ECPublicKeyParameters       pub = (ECPublicKeyParameters)pair.getPublic();
            ECPrivateKeyParameters      priv = (ECPrivateKeyParameters)pair.getPrivate();

            if (ecParams instanceof ECParameterSpec)
            {
                ECParameterSpec p = (ECParameterSpec)ecParams;
               
View Full Code Here

            if (s == null)
            {
                s = ProviderUtil.getEcImplicitlyCa();
            }

            return new ECPrivateKeyParameters(
                            k.getD(),
                            new ECDomainParameters(s.getCurve(), s.getG(), s.getN(), s.getH(), s.getSeed()));
        }
                       
        throw new InvalidKeyException("can't identify EC private key.");
View Full Code Here

            if (s == null)
            {
                s = BouncyCastleProvider.CONFIGURATION.getEcImplicitlyCa();
            }

            return new ECPrivateKeyParameters(
                            k.getD(),
                            new ECDomainParameters(s.getCurve(), s.getG(), s.getN(), s.getH(), s.getSeed()));
        }
        else if (key instanceof java.security.interfaces.ECPrivateKey)
        {
            java.security.interfaces.ECPrivateKey privKey = (java.security.interfaces.ECPrivateKey)key;
            ECParameterSpec s = EC5Util.convertSpec(privKey.getParams(), false);
            return new ECPrivateKeyParameters(
                            privKey.getS(),
                            new ECDomainParameters(s.getCurve(), s.getG(), s.getN(), s.getH(), s.getSeed()));
        }
        else
        {
View Full Code Here

      dos.write(passphrase.getBytes(Charset.forName("UTF-8")));
      dos.flush();
      byte[] digest = new byte[28];
      sha.doFinal(digest, 0);
      ECDSASigner signer = new ECDSASigner();
      signer.init(true, new ECPrivateKeyParameters(new BigInteger(1, digest), secp224k1));
      dos.writeLong(userID);
      dos.write(Base64.decode(serverNonce));
      dos.write(clientNonce);
      dos.flush();
      dos.close();
View Full Code Here

  {
    ECKeyPairGenerator generator = new ECKeyPairGenerator ();
    ECKeyGenerationParameters keygenParams = new ECKeyGenerationParameters (domain, secureRandom);
    generator.init (keygenParams);
    AsymmetricCipherKeyPair keypair = generator.generateKeyPair ();
    ECPrivateKeyParameters privParams = (ECPrivateKeyParameters) keypair.getPrivate ();
    ECPublicKeyParameters pubParams = (ECPublicKeyParameters) keypair.getPublic ();
    ECKeyPair k = new ECKeyPair ();
    k.priv = privParams.getD ();
    k.compressed = compressed;
    k.pub = pubParams.getQ ().getEncoded (compressed);
    return k;
  }
View Full Code Here

    if ( priv == null )
    {
      throw new ValidationException ("Need private key to sign");
    }
    ECDSASigner signer = new ECDSASigner (new HMacDSAKCalculator (new SHA256Digest ()));
    signer.init (true, new ECPrivateKeyParameters (priv, domain));
    BigInteger[] signature = signer.generateSignature (hash);
    ByteArrayOutputStream s = new ByteArrayOutputStream ();
    try
    {
      DERSequenceGenerator seq = new DERSequenceGenerator (s);
View Full Code Here

TOP

Related Classes of org.bouncycastle.crypto.params.ECPrivateKeyParameters

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.