java.security.interfaces.DSAPublicKey#getY ( )源码实例Demo

下面列出了java.security.interfaces.DSAPublicKey#getY ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: xipki   文件: CaClientExample.java
protected static MyKeypair generateDsaKeypair() throws Exception {
  // plen: 2048, qlen: 256
  DSAParameterSpec spec = new DSAParameterSpec(P2048_Q256_P, P2048_Q256_Q, P2048_Q256_G);
  KeyPairGenerator kpGen = KeyPairGenerator.getInstance("DSA");
  kpGen.initialize(spec);
  KeyPair kp = kpGen.generateKeyPair();

  DSAPublicKey dsaPubKey = (DSAPublicKey) kp.getPublic();
  ASN1EncodableVector vec = new ASN1EncodableVector();
  vec.add(new ASN1Integer(dsaPubKey.getParams().getP()));
  vec.add(new ASN1Integer(dsaPubKey.getParams().getQ()));
  vec.add(new ASN1Integer(dsaPubKey.getParams().getG()));
  ASN1Sequence dssParams = new DERSequence(vec);

  SubjectPublicKeyInfo subjectPublicKeyInfo = new SubjectPublicKeyInfo(
      new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, dssParams),
      new ASN1Integer(dsaPubKey.getY()));

  return new MyKeypair(kp.getPrivate(), subjectPublicKeyInfo);
}
 
源代码2 项目: dragonwell8_jdk   文件: DOMKeyValue.java
DSA(PublicKey key) throws KeyException {
    super(key);
    DSAPublicKey dkey = (DSAPublicKey) key;
    DSAParams params = dkey.getParams();
    p = new DOMCryptoBinary(params.getP());
    q = new DOMCryptoBinary(params.getQ());
    g = new DOMCryptoBinary(params.getG());
    y = new DOMCryptoBinary(dkey.getY());
}
 
源代码3 项目: TencentKona-8   文件: DOMKeyValue.java
DSA(PublicKey key) throws KeyException {
    super(key);
    DSAPublicKey dkey = (DSAPublicKey) key;
    DSAParams params = dkey.getParams();
    p = new DOMCryptoBinary(params.getP());
    q = new DOMCryptoBinary(params.getQ());
    g = new DOMCryptoBinary(params.getG());
    y = new DOMCryptoBinary(dkey.getY());
}
 
源代码4 项目: openjdk-jdk8u   文件: DOMKeyValue.java
DSA(PublicKey key) throws KeyException {
    super(key);
    DSAPublicKey dkey = (DSAPublicKey) key;
    DSAParams params = dkey.getParams();
    p = new DOMCryptoBinary(params.getP());
    q = new DOMCryptoBinary(params.getQ());
    g = new DOMCryptoBinary(params.getG());
    y = new DOMCryptoBinary(dkey.getY());
}
 
源代码5 项目: openjdk-jdk9   文件: DOMKeyValue.java
DSA(PublicKey key) throws KeyException {
    super(key);
    DSAPublicKey dkey = (DSAPublicKey) key;
    DSAParams params = dkey.getParams();
    p = new DOMCryptoBinary(params.getP());
    q = new DOMCryptoBinary(params.getQ());
    g = new DOMCryptoBinary(params.getG());
    y = new DOMCryptoBinary(dkey.getY());
}
 
源代码6 项目: jdk8u-jdk   文件: DOMKeyValue.java
DSA(PublicKey key) throws KeyException {
    super(key);
    DSAPublicKey dkey = (DSAPublicKey) key;
    DSAParams params = dkey.getParams();
    p = new DOMCryptoBinary(params.getP());
    q = new DOMCryptoBinary(params.getQ());
    g = new DOMCryptoBinary(params.getG());
    y = new DOMCryptoBinary(dkey.getY());
}
 
源代码7 项目: BiglyBT   文件: DSAUtil.java
static public AsymmetricKeyParameter generatePublicKeyParameter(
    PublicKey    key)
    throws InvalidKeyException
{
    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());
}
 
源代码8 项目: hottub   文件: DOMKeyValue.java
DSA(PublicKey key) throws KeyException {
    super(key);
    DSAPublicKey dkey = (DSAPublicKey) key;
    DSAParams params = dkey.getParams();
    p = new DOMCryptoBinary(params.getP());
    q = new DOMCryptoBinary(params.getQ());
    g = new DOMCryptoBinary(params.getG());
    y = new DOMCryptoBinary(dkey.getY());
}
 
源代码9 项目: openjdk-8-source   文件: DOMKeyValue.java
DSA(PublicKey key) throws KeyException {
    super(key);
    DSAPublicKey dkey = (DSAPublicKey) key;
    DSAParams params = dkey.getParams();
    p = new DOMCryptoBinary(params.getP());
    q = new DOMCryptoBinary(params.getQ());
    g = new DOMCryptoBinary(params.getG());
    y = new DOMCryptoBinary(dkey.getY());
}
 
源代码10 项目: openjdk-8   文件: DOMKeyValue.java
DSA(PublicKey key) throws KeyException {
    super(key);
    DSAPublicKey dkey = (DSAPublicKey) key;
    DSAParams params = dkey.getParams();
    p = new DOMCryptoBinary(params.getP());
    q = new DOMCryptoBinary(params.getQ());
    g = new DOMCryptoBinary(params.getG());
    y = new DOMCryptoBinary(dkey.getY());
}
 
源代码11 项目: jdk8u_jdk   文件: DOMKeyValue.java
DSA(PublicKey key) throws KeyException {
    super(key);
    DSAPublicKey dkey = (DSAPublicKey) key;
    DSAParams params = dkey.getParams();
    p = new DOMCryptoBinary(params.getP());
    q = new DOMCryptoBinary(params.getQ());
    g = new DOMCryptoBinary(params.getG());
    y = new DOMCryptoBinary(dkey.getY());
}
 
源代码12 项目: ripple-lib-java   文件: DSAUtil.java
static public AsymmetricKeyParameter generatePublicKeyParameter(
    PublicKey    key)
    throws InvalidKeyException
{
    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());
}
 
源代码13 项目: RipplePower   文件: DSAUtil.java
static public AsymmetricKeyParameter generatePublicKeyParameter(
    PublicKey    key)
    throws InvalidKeyException
{
    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());
}
 
源代码14 项目: jdk8u-jdk   文件: DOMKeyValue.java
DSA(PublicKey key) throws KeyException {
    super(key);
    DSAPublicKey dkey = (DSAPublicKey) key;
    DSAParams params = dkey.getParams();
    p = new DOMCryptoBinary(params.getP());
    q = new DOMCryptoBinary(params.getQ());
    g = new DOMCryptoBinary(params.getG());
    y = new DOMCryptoBinary(dkey.getY());
}
 
源代码15 项目: jdk8u-dev-jdk   文件: DOMKeyValue.java
DSA(PublicKey key) throws KeyException {
    super(key);
    DSAPublicKey dkey = (DSAPublicKey) key;
    DSAParams params = dkey.getParams();
    p = new DOMCryptoBinary(params.getP());
    q = new DOMCryptoBinary(params.getQ());
    g = new DOMCryptoBinary(params.getG());
    y = new DOMCryptoBinary(dkey.getY());
}
 
源代码16 项目: RipplePower   文件: BCDSAPublicKey.java
BCDSAPublicKey(
    DSAPublicKey key)
{
    this.y = key.getY();
    this.dsaSpec = key.getParams();
}
 
源代码17 项目: ripple-lib-java   文件: BCDSAPublicKey.java
BCDSAPublicKey(
    DSAPublicKey key)
{
    this.y = key.getY();
    this.dsaSpec = key.getParams();
}
 
源代码18 项目: RipplePower   文件: CertPathValidatorUtilities.java
/**
 * Return the next working key inheriting DSA parameters if necessary.
 * <p>
 * This methods inherits DSA parameters from the indexed certificate or
 * previous certificates in the certificate chain to the returned
 * <code>PublicKey</code>. The list is searched upwards, meaning the end
 * certificate is at position 0 and previous certificates are following.
 * </p>
 * <p>
 * If the indexed certificate does not contain a DSA key this method simply
 * returns the public key. If the DSA key already contains DSA parameters
 * the key is also only returned.
 * </p>
 *
 * @param certs The certification path.
 * @param index The index of the certificate which contains the public key
 *              which should be extended with DSA parameters.
 * @return The public key of the certificate in list position
 *         <code>index</code> extended with DSA parameters if applicable.
 * @throws AnnotatedException if DSA parameters cannot be inherited.
 */
protected static PublicKey getNextWorkingKey(List certs, int index)
    throws CertPathValidatorException
{
    Certificate cert = (Certificate)certs.get(index);
    PublicKey pubKey = cert.getPublicKey();
    if (!(pubKey instanceof DSAPublicKey))
    {
        return pubKey;
    }
    DSAPublicKey dsaPubKey = (DSAPublicKey)pubKey;
    if (dsaPubKey.getParams() != null)
    {
        return dsaPubKey;
    }
    for (int i = index + 1; i < certs.size(); i++)
    {
        X509Certificate parentCert = (X509Certificate)certs.get(i);
        pubKey = parentCert.getPublicKey();
        if (!(pubKey instanceof DSAPublicKey))
        {
            throw new CertPathValidatorException(
                "DSA parameters cannot be inherited from previous certificate.");
        }
        DSAPublicKey prevDSAPubKey = (DSAPublicKey)pubKey;
        if (prevDSAPubKey.getParams() == null)
        {
            continue;
        }
        DSAParams dsaParams = prevDSAPubKey.getParams();
        DSAPublicKeySpec dsaPubKeySpec = new DSAPublicKeySpec(
            dsaPubKey.getY(), dsaParams.getP(), dsaParams.getQ(), dsaParams.getG());
        try
        {
            KeyFactory keyFactory = KeyFactory.getInstance("DSA", BouncyCastleProvider.PROVIDER_NAME);
            return keyFactory.generatePublic(dsaPubKeySpec);
        }
        catch (Exception exception)
        {
            throw new RuntimeException(exception.getMessage());
        }
    }
    throw new CertPathValidatorException("DSA parameters cannot be inherited from previous certificate.");
}
 
/**
 * Return the next working key inheriting DSA parameters if necessary.
 * <p>
 * This methods inherits DSA parameters from the indexed certificate or
 * previous certificates in the certificate chain to the returned
 * <code>PublicKey</code>. The list is searched upwards, meaning the end
 * certificate is at position 0 and previous certificates are following.
 * </p>
 * <p>
 * If the indexed certificate does not contain a DSA key this method simply
 * returns the public key. If the DSA key already contains DSA parameters
 * the key is also only returned.
 * </p>
 *
 * @param certs The certification path.
 * @param index The index of the certificate which contains the public key
 *              which should be extended with DSA parameters.
 * @return The public key of the certificate in list position
 *         <code>index</code> extended with DSA parameters if applicable.
 * @throws AnnotatedException if DSA parameters cannot be inherited.
 */
protected static PublicKey getNextWorkingKey(List certs, int index)
    throws CertPathValidatorException
{
    Certificate cert = (Certificate)certs.get(index);
    PublicKey pubKey = cert.getPublicKey();
    if (!(pubKey instanceof DSAPublicKey))
    {
        return pubKey;
    }
    DSAPublicKey dsaPubKey = (DSAPublicKey)pubKey;
    if (dsaPubKey.getParams() != null)
    {
        return dsaPubKey;
    }
    for (int i = index + 1; i < certs.size(); i++)
    {
        X509Certificate parentCert = (X509Certificate)certs.get(i);
        pubKey = parentCert.getPublicKey();
        if (!(pubKey instanceof DSAPublicKey))
        {
            throw new CertPathValidatorException(
                "DSA parameters cannot be inherited from previous certificate.");
        }
        DSAPublicKey prevDSAPubKey = (DSAPublicKey)pubKey;
        if (prevDSAPubKey.getParams() == null)
        {
            continue;
        }
        DSAParams dsaParams = prevDSAPubKey.getParams();
        DSAPublicKeySpec dsaPubKeySpec = new DSAPublicKeySpec(
            dsaPubKey.getY(), dsaParams.getP(), dsaParams.getQ(), dsaParams.getG());
        try
        {
            KeyFactory keyFactory = KeyFactory.getInstance("DSA", BouncyCastleProvider.PROVIDER_NAME);
            return keyFactory.generatePublic(dsaPubKeySpec);
        }
        catch (Exception exception)
        {
            throw new RuntimeException(exception.getMessage());
        }
    }
    throw new CertPathValidatorException("DSA parameters cannot be inherited from previous certificate.");
}
 
/**
 * Return the next working key inheriting DSA parameters if necessary.
 * <p>
 * This methods inherits DSA parameters from the indexed certificate or
 * previous certificates in the certificate chain to the returned
 * <code>PublicKey</code>. The list is searched upwards, meaning the end
 * certificate is at position 0 and previous certificates are following.
 * </p>
 * <p>
 * If the indexed certificate does not contain a DSA key this method simply
 * returns the public key. If the DSA key already contains DSA parameters
 * the key is also only returned.
 * </p>
 *
 * @param certs The certification path.
 * @param index The index of the certificate which contains the public key
 *              which should be extended with DSA parameters.
 * @return The public key of the certificate in list position
 *         <code>index</code> extended with DSA parameters if applicable.
 * @throws AnnotatedException if DSA parameters cannot be inherited.
 */
protected static PublicKey getNextWorkingKey(List certs, int index, JcaJceHelper helper)
    throws CertPathValidatorException
{
    Certificate cert = (Certificate)certs.get(index);
    PublicKey pubKey = cert.getPublicKey();
    if (!(pubKey instanceof DSAPublicKey))
    {
        return pubKey;
    }
    DSAPublicKey dsaPubKey = (DSAPublicKey)pubKey;
    if (dsaPubKey.getParams() != null)
    {
        return dsaPubKey;
    }
    for (int i = index + 1; i < certs.size(); i++)
    {
        X509Certificate parentCert = (X509Certificate)certs.get(i);
        pubKey = parentCert.getPublicKey();
        if (!(pubKey instanceof DSAPublicKey))
        {
            throw new CertPathValidatorException(
                "DSA parameters cannot be inherited from previous certificate.");
        }
        DSAPublicKey prevDSAPubKey = (DSAPublicKey)pubKey;
        if (prevDSAPubKey.getParams() == null)
        {
            continue;
        }
        DSAParams dsaParams = prevDSAPubKey.getParams();
        DSAPublicKeySpec dsaPubKeySpec = new DSAPublicKeySpec(
            dsaPubKey.getY(), dsaParams.getP(), dsaParams.getQ(), dsaParams.getG());
        try
        {
            KeyFactory keyFactory = helper.createKeyFactory("DSA");
            return keyFactory.generatePublic(dsaPubKeySpec);
        }
        catch (Exception exception)
        {
            throw new RuntimeException(exception.getMessage());
        }
    }
    throw new CertPathValidatorException("DSA parameters cannot be inherited from previous certificate.");
}