java.security.interfaces.DSAParams#getP ( )源码实例Demo

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

源代码1 项目: dragonwell8_jdk   文件: BasicChecker.java
/**
 * Internal method to create a new key with inherited key parameters.
 *
 * @param keyValueKey key from which to obtain key value
 * @param keyParamsKey key from which to obtain key parameters
 * @return new public key having value and parameters
 * @throws CertPathValidatorException if keys are not appropriate types
 * for this operation
 */
static PublicKey makeInheritedParamsKey(PublicKey keyValueKey,
    PublicKey keyParamsKey) throws CertPathValidatorException
{
    if (!(keyValueKey instanceof DSAPublicKey) ||
        !(keyParamsKey instanceof DSAPublicKey))
        throw new CertPathValidatorException("Input key is not " +
                                             "appropriate type for " +
                                             "inheriting parameters");
    DSAParams params = ((DSAPublicKey)keyParamsKey).getParams();
    if (params == null)
        throw new CertPathValidatorException("Key parameters missing");
    try {
        BigInteger y = ((DSAPublicKey)keyValueKey).getY();
        KeyFactory kf = KeyFactory.getInstance("DSA");
        DSAPublicKeySpec ks = new DSAPublicKeySpec(y,
                                                   params.getP(),
                                                   params.getQ(),
                                                   params.getG());
        return kf.generatePublic(ks);
    } catch (GeneralSecurityException e) {
        throw new CertPathValidatorException("Unable to generate key with" +
                                             " inherited parameters: " +
                                             e.getMessage(), e);
    }
}
 
源代码2 项目: openjdk-jdk8u   文件: BasicChecker.java
/**
 * Internal method to create a new key with inherited key parameters.
 *
 * @param keyValueKey key from which to obtain key value
 * @param keyParamsKey key from which to obtain key parameters
 * @return new public key having value and parameters
 * @throws CertPathValidatorException if keys are not appropriate types
 * for this operation
 */
static PublicKey makeInheritedParamsKey(PublicKey keyValueKey,
    PublicKey keyParamsKey) throws CertPathValidatorException
{
    if (!(keyValueKey instanceof DSAPublicKey) ||
        !(keyParamsKey instanceof DSAPublicKey))
        throw new CertPathValidatorException("Input key is not " +
                                             "appropriate type for " +
                                             "inheriting parameters");
    DSAParams params = ((DSAPublicKey)keyParamsKey).getParams();
    if (params == null)
        throw new CertPathValidatorException("Key parameters missing");
    try {
        BigInteger y = ((DSAPublicKey)keyValueKey).getY();
        KeyFactory kf = KeyFactory.getInstance("DSA");
        DSAPublicKeySpec ks = new DSAPublicKeySpec(y,
                                                   params.getP(),
                                                   params.getQ(),
                                                   params.getG());
        return kf.generatePublic(ks);
    } catch (GeneralSecurityException e) {
        throw new CertPathValidatorException("Unable to generate key with" +
                                             " inherited parameters: " +
                                             e.getMessage(), e);
    }
}
 
源代码3 项目: jdk8u-jdk   文件: BasicChecker.java
/**
 * Internal method to create a new key with inherited key parameters.
 *
 * @param keyValueKey key from which to obtain key value
 * @param keyParamsKey key from which to obtain key parameters
 * @return new public key having value and parameters
 * @throws CertPathValidatorException if keys are not appropriate types
 * for this operation
 */
static PublicKey makeInheritedParamsKey(PublicKey keyValueKey,
    PublicKey keyParamsKey) throws CertPathValidatorException
{
    if (!(keyValueKey instanceof DSAPublicKey) ||
        !(keyParamsKey instanceof DSAPublicKey))
        throw new CertPathValidatorException("Input key is not " +
                                             "appropriate type for " +
                                             "inheriting parameters");
    DSAParams params = ((DSAPublicKey)keyParamsKey).getParams();
    if (params == null)
        throw new CertPathValidatorException("Key parameters missing");
    try {
        BigInteger y = ((DSAPublicKey)keyValueKey).getY();
        KeyFactory kf = KeyFactory.getInstance("DSA");
        DSAPublicKeySpec ks = new DSAPublicKeySpec(y,
                                                   params.getP(),
                                                   params.getQ(),
                                                   params.getG());
        return kf.generatePublic(ks);
    } catch (GeneralSecurityException e) {
        throw new CertPathValidatorException("Unable to generate key with" +
                                             " inherited parameters: " +
                                             e.getMessage(), e);
    }
}
 
源代码4 项目: openjdk-8   文件: BasicChecker.java
/**
 * Internal method to create a new key with inherited key parameters.
 *
 * @param keyValueKey key from which to obtain key value
 * @param keyParamsKey key from which to obtain key parameters
 * @return new public key having value and parameters
 * @throws CertPathValidatorException if keys are not appropriate types
 * for this operation
 */
static PublicKey makeInheritedParamsKey(PublicKey keyValueKey,
    PublicKey keyParamsKey) throws CertPathValidatorException
{
    if (!(keyValueKey instanceof DSAPublicKey) ||
        !(keyParamsKey instanceof DSAPublicKey))
        throw new CertPathValidatorException("Input key is not " +
                                             "appropriate type for " +
                                             "inheriting parameters");
    DSAParams params = ((DSAPublicKey)keyParamsKey).getParams();
    if (params == null)
        throw new CertPathValidatorException("Key parameters missing");
    try {
        BigInteger y = ((DSAPublicKey)keyValueKey).getY();
        KeyFactory kf = KeyFactory.getInstance("DSA");
        DSAPublicKeySpec ks = new DSAPublicKeySpec(y,
                                                   params.getP(),
                                                   params.getQ(),
                                                   params.getG());
        return kf.generatePublic(ks);
    } catch (GeneralSecurityException e) {
        throw new CertPathValidatorException("Unable to generate key with" +
                                             " inherited parameters: " +
                                             e.getMessage(), e);
    }
}
 
源代码5 项目: dragonwell8_jdk   文件: DSAKeyPairGenerator.java
/**
 * Initializes the DSA object using a DSA parameter object.
 *
 * @param params a fully initialized DSA parameter object.
 */
@Override
public void initialize(DSAParams params, SecureRandom random)
    throws InvalidParameterException {
    if (params == null) {
        throw new InvalidParameterException("Params must not be null");
     }
     DSAParameterSpec spec = new DSAParameterSpec
         (params.getP(), params.getQ(), params.getG());
     super.init(spec, random, false);
}
 
源代码6 项目: jdk8u_jdk   文件: DSAKeyPairGenerator.java
/**
 * Initializes the DSA object using a DSA parameter object.
 *
 * @param params a fully initialized DSA parameter object.
 */
@Override
public void initialize(DSAParams params, SecureRandom random)
    throws InvalidParameterException {
    if (params == null) {
        throw new InvalidParameterException("Params must not be null");
     }
     DSAParameterSpec spec = new DSAParameterSpec
         (params.getP(), params.getQ(), params.getG());
     super.init(spec, random, false);
}
 
源代码7 项目: openjdk-8   文件: DSAKeyPairGenerator.java
/**
 * Initializes the DSA object using a DSA parameter object.
 *
 * @param params a fully initialized DSA parameter object.
 */
public void initialize(DSAParams params, SecureRandom random) {
    if (params == null) {
        throw new InvalidParameterException("Params must not be null");
    }
    DSAParameterSpec spec = new DSAParameterSpec
                            (params.getP(), params.getQ(), params.getG());
    initialize0(spec, random);
}
 
源代码8 项目: 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());
}
 
源代码9 项目: 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());
}
 
源代码10 项目: hottub   文件: DSAKeyPairGenerator.java
/**
 * Initializes the DSA object using a DSA parameter object.
 *
 * @param params a fully initialized DSA parameter object.
 */
public void initialize(DSAParams params, SecureRandom random) {
    if (params == null) {
        throw new InvalidParameterException("Params must not be null");
    }
    DSAParameterSpec spec = new DSAParameterSpec
                            (params.getP(), params.getQ(), params.getG());
    initialize0(spec, random);
}
 
源代码11 项目: jdk8u60   文件: DSAKeyPairGenerator.java
/**
 * Initializes the DSA object using a DSA parameter object.
 *
 * @param params a fully initialized DSA parameter object.
 */
public void initialize(DSAParams params, SecureRandom random) {
    if (params == null) {
        throw new InvalidParameterException("Params must not be null");
    }
    DSAParameterSpec spec = new DSAParameterSpec
                            (params.getP(), params.getQ(), params.getG());
    initialize0(spec, random);
}
 
源代码12 项目: jdk8u60   文件: 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());
}
 
源代码13 项目: 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());
}
 
源代码14 项目: openjdk-8-source   文件: DSAKeyPairGenerator.java
/**
 * Initializes the DSA object using a DSA parameter object.
 *
 * @param params a fully initialized DSA parameter object.
 */
public void initialize(DSAParams params, SecureRandom random) {
    if (params == null) {
        throw new InvalidParameterException("Params must not be null");
    }
    DSAParameterSpec spec = new DSAParameterSpec
                            (params.getP(), params.getQ(), params.getG());
    initialize0(spec, random);
}
 
源代码15 项目: 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());
}
 
源代码16 项目: openjdk-jdk8u-backup   文件: DSAKeyPairGenerator.java
/**
 * Initializes the DSA object using a DSA parameter object.
 *
 * @param params a fully initialized DSA parameter object.
 */
@Override
public void initialize(DSAParams params, SecureRandom random)
    throws InvalidParameterException {
    if (params == null) {
        throw new InvalidParameterException("Params must not be null");
     }
     DSAParameterSpec spec = new DSAParameterSpec
         (params.getP(), params.getQ(), params.getG());
     super.init(spec, random, false);
}
 
源代码17 项目: openjdk-jdk8u-backup   文件: 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());
}
 
源代码18 项目: Bytecoder   文件: DSAKeyPairGenerator.java
/**
 * Initializes the DSA object using a DSA parameter object.
 *
 * @param params a fully initialized DSA parameter object.
 */
@Override
public void initialize(DSAParams params, SecureRandom random)
    throws InvalidParameterException {
    if (params == null) {
        throw new InvalidParameterException("Params must not be null");
     }
     DSAParameterSpec spec = new DSAParameterSpec
         (params.getP(), params.getQ(), params.getG());
     super.init(spec, random, false);
}
 
源代码19 项目: openjdk-jdk9   文件: DSAKeyPairGenerator.java
/**
 * Initializes the DSA object using a DSA parameter object.
 *
 * @param params a fully initialized DSA parameter object.
 */
@Override
public void initialize(DSAParams params, SecureRandom random)
        throws InvalidParameterException {

    if (params == null) {
        throw new InvalidParameterException("Params must not be null");
    }
    DSAParameterSpec spec = new DSAParameterSpec
                            (params.getP(), params.getQ(), params.getG());
    initialize0(spec, random);
}
 
源代码20 项目: lams   文件: KeyInfoHelper.java
/**
 * Builds a DSA key from an {@link DSAKeyValue} element and the supplied Java {@link DSAParams},
 * which supplies key material from a shared key family.
 * 
 * @param keyDescriptor the {@link DSAKeyValue} key descriptor
 * @param dsaParams the {@link DSAParams} DSA key family parameters
 * 
 * @return a new {@link DSAPublicKey} instance of {@link PublicKey}
 * 
 * @throws KeyException thrown if the key algorithm is not supported by the JCE or the key spec does not
 *             contain valid information
 */
public static PublicKey getDSAKey(DSAKeyValue keyDescriptor, DSAParams dsaParams) throws KeyException {
    BigInteger yComponent = keyDescriptor.getY().getValueBigInt();

    DSAPublicKeySpec keySpec = 
        new DSAPublicKeySpec(yComponent, dsaParams.getP(), dsaParams.getQ(), dsaParams.getG());
    return buildKey(keySpec, "DSA");
}