Java Code Examples for java.security.interfaces.DSAParams#getP()

The following examples show how to use java.security.interfaces.DSAParams#getP() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BasicChecker.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 2
Source File: BasicChecker.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 3
Source File: BasicChecker.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 4
Source File: BasicChecker.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 5
Source File: DOMKeyValue.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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());
}
 
Example 6
Source File: DSAKeyPairGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 7
Source File: DSAKeyPairGenerator.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 8
Source File: DOMKeyValue.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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());
}
 
Example 9
Source File: DSAKeyPairGenerator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 10
Source File: DOMKeyValue.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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());
}
 
Example 11
Source File: DSAKeyPairGenerator.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 12
Source File: DOMKeyValue.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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());
}
 
Example 13
Source File: DSAKeyPairGenerator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 14
Source File: DSAKeyPairGenerator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 15
Source File: DOMKeyValue.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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());
}
 
Example 16
Source File: DOMKeyValue.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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());
}
 
Example 17
Source File: DSAKeyPairGenerator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 18
Source File: DSAKeyPairGenerator.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 19
Source File: DSAKeyPairGenerator.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 20
Source File: KeyInfoHelper.java    From lams with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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");
}