Package org.bouncycastle.crypto.params

Examples of org.bouncycastle.crypto.params.DSAParameters


  }    
  public void setPubKey(byte[] y, byte[] p, byte[] q, byte[] g) throws Exception{
    //System.out.println(this+".setPubKey()");
    DSAPublicKeyParameters pubKey=
      new DSAPublicKeyParameters(new BigInteger(y),
         new DSAParameters(new BigInteger(p),
               new BigInteger(q),
               new BigInteger(g)
               ));
    signature.init(false, pubKey);
  }
View Full Code Here


  }
  public void setPrvKey(byte[] x, byte[] p, byte[] q, byte[] g) throws Exception{
    //System.out.println(this+".setPrvKey()");
    DSAPrivateKeyParameters prvKey =
  new DSAPrivateKeyParameters(new BigInteger(x),
         new DSAParameters(new BigInteger(p),
               new BigInteger(q),
               new BigInteger(g)));
    signature.init(true, prvKey);
  }
View Full Code Here

    SecureRandom sr = new SecureRandom();

    DSAParametersGenerator dsapgen=new DSAParametersGenerator();
    dsapgen.init(key_size, 80, sr);
    DSAParameters dsap=dsapgen.generateParameters();
    DSAKeyGenerationParameters DSAKeyGenPara =
      new DSAKeyGenerationParameters(sr, dsap);
    DSAKeyPairGenerator kpgen=new DSAKeyPairGenerator();
    kpgen.init( DSAKeyGenPara );
    AsymmetricCipherKeyPair keyPair=kpgen.generateKeyPair();
    DSAPrivateKeyParameters prvKey=
      (DSAPrivateKeyParameters)keyPair.getPrivate();
    DSAPublicKeyParameters pubKey=
      (DSAPublicKeyParameters)keyPair.getPublic();

    x=prvKey.getX().toByteArray();
    y=pubKey.getY().toByteArray();

    p=dsap.getP().toByteArray();
    q=dsap.getQ().toByteArray();
    g=dsap.getG().toByteArray();
  }
View Full Code Here

            }

            break;
        }

        return new DSAParameters(p, q, g, new DSAValidationParameters(seed, counter));
    }
View Full Code Here

    }

    public AsymmetricCipherKeyPair generateKeyPair()
    {
        BigInteger      p, q, g, x, y;
        DSAParameters   dsaParams = param.getParameters();
        SecureRandom    random = param.getRandom();

        q = dsaParams.getQ();
        p = dsaParams.getP();
        g = dsaParams.getG();

        do
        {
            x = new BigInteger(160, random);
        }
View Full Code Here

        if (key instanceof DSAPublicKey)
        {
            DSAPublicKey    k = (DSAPublicKey)key;

            return new DSAPublicKeyParameters(k.getY(),
                new DSAParameters(k.getParams().getP(), k.getParams().getQ(), k.getParams().getG()));
        }

        throw new InvalidKeyException("can't identify DSA public key: " + key.getClass().getName());
    }
View Full Code Here

        if (key instanceof DSAPrivateKey)
        {
            DSAPrivateKey    k = (DSAPrivateKey)key;

            return new DSAPrivateKeyParameters(k.getX(),
                new DSAParameters(k.getParams().getP(), k.getParams().getQ(), k.getParams().getG()));
        }
                       
        throw new InvalidKeyException("can't identify DSA private key.");
    }
View Full Code Here

            else
            {
                pGen.init(strength, 20, new SecureRandom());
            }

            DSAParameters p = pGen.generateParameters();

            AlgorithmParameters params;

            try
            {
                params = AlgorithmParameters.getInstance("DSA", "BC");
                params.init(new DSAParameterSpec(p.getP(), p.getQ(), p.getG()));
            }
            catch (Exception e)
            {
                throw new RuntimeException(e.getMessage());
            }
View Full Code Here

            {
                throw new InvalidAlgorithmParameterException("parameter object not a DSAParameterSpec");
            }
            DSAParameterSpec     dsaParams = (DSAParameterSpec)params;

            param = new DSAKeyGenerationParameters(random, new DSAParameters(dsaParams.getP(), dsaParams.getQ(), dsaParams.getG()));

            engine.init(param);
            initialised = true;
        }
View Full Code Here

                return new RSAKeyParameters(false, rsaK.getModulus(), rsaK.getPublicExponent());
            case PublicKeyAlgorithmTags.DSA:
                DSAPublicBCPGKey dsaK = (DSAPublicBCPGKey)publicPk.getKey();

                return new DSAPublicKeyParameters(dsaK.getY(), new DSAParameters(dsaK.getP(), dsaK.getQ(), dsaK.getG()));
            case PublicKeyAlgorithmTags.ELGAMAL_ENCRYPT:
            case PublicKeyAlgorithmTags.ELGAMAL_GENERAL:
                ElGamalPublicBCPGKey elK = (ElGamalPublicBCPGKey)publicPk.getKey();

                return new ElGamalPublicKeyParameters(elK.getY(), new ElGamalParameters(elK.getP(), elK.getG()));
View Full Code Here

TOP

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

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.