java.security.spec.DSAParameterSpec源码实例Demo

类java.security.spec.DSAParameterSpec源码实例Demo

下面列出了java.security.spec.DSAParameterSpec 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: dragonwell8_jdk   文件: DSAPublicKey.java
/**
 * Returns the DSA parameters associated with this key, or null if the
 * parameters could not be parsed.
 */
public DSAParams getParams() {
    try {
        if (algid instanceof DSAParams) {
            return (DSAParams)algid;
        } else {
            DSAParameterSpec paramSpec;
            AlgorithmParameters algParams = algid.getParameters();
            if (algParams == null) {
                return null;
            }
            paramSpec = algParams.getParameterSpec(DSAParameterSpec.class);
            return (DSAParams)paramSpec;
        }
    } catch (InvalidParameterSpecException e) {
        return null;
    }
}
 
源代码2 项目: jdk8u-dev-jdk   文件: DSAPrivateKey.java
/**
 * Returns the DSA parameters associated with this key, or null if the
 * parameters could not be parsed.
 */
public DSAParams getParams() {
    try {
        if (algid instanceof DSAParams) {
            return (DSAParams)algid;
        } else {
            DSAParameterSpec paramSpec;
            AlgorithmParameters algParams = algid.getParameters();
            if (algParams == null) {
                return null;
            }
            paramSpec = algParams.getParameterSpec(DSAParameterSpec.class);
            return (DSAParams)paramSpec;
        }
    } catch (InvalidParameterSpecException e) {
        return null;
    }
}
 
源代码3 项目: openjdk-8-source   文件: DSAKeyPairGenerator.java
/**
 * Generates a pair of keys usable by any JavaSecurity compliant
 * DSA implementation.
 */
public KeyPair generateKeyPair() {
    if (random == null) {
        random = JCAUtil.getSecureRandom();
    }
    DSAParameterSpec spec;
    try {
        if (forceNewParameters) {
            // generate new parameters each time
            spec = ParameterCache.getNewDSAParameterSpec(plen, qlen, random);
        } else {
            if (params == null) {
                params =
                    ParameterCache.getDSAParameterSpec(plen, qlen, random);
            }
            spec = params;
        }
    } catch (GeneralSecurityException e) {
        throw new ProviderException(e);
    }
    return generateKeyPair(spec.getP(), spec.getQ(), spec.getG(), random);
}
 
源代码4 项目: dragonwell8_jdk   文件: DSAPrivateKey.java
/**
 * Returns the DSA parameters associated with this key, or null if the
 * parameters could not be parsed.
 */
public DSAParams getParams() {
    try {
        if (algid instanceof DSAParams) {
            return (DSAParams)algid;
        } else {
            DSAParameterSpec paramSpec;
            AlgorithmParameters algParams = algid.getParameters();
            if (algParams == null) {
                return null;
            }
            paramSpec = algParams.getParameterSpec(DSAParameterSpec.class);
            return (DSAParams)paramSpec;
        }
    } catch (InvalidParameterSpecException e) {
        return null;
    }
}
 
源代码5 项目: openjdk-8   文件: DSAPublicKey.java
/**
 * Returns the DSA parameters associated with this key, or null if the
 * parameters could not be parsed.
 */
public DSAParams getParams() {
    try {
        if (algid instanceof DSAParams) {
            return (DSAParams)algid;
        } else {
            DSAParameterSpec paramSpec;
            AlgorithmParameters algParams = algid.getParameters();
            if (algParams == null) {
                return null;
            }
            paramSpec = algParams.getParameterSpec(DSAParameterSpec.class);
            return (DSAParams)paramSpec;
        }
    } catch (InvalidParameterSpecException e) {
        return null;
    }
}
 
源代码6 项目: hottub   文件: DSAPrivateKey.java
/**
 * Returns the DSA parameters associated with this key, or null if the
 * parameters could not be parsed.
 */
public DSAParams getParams() {
    try {
        if (algid instanceof DSAParams) {
            return (DSAParams)algid;
        } else {
            DSAParameterSpec paramSpec;
            AlgorithmParameters algParams = algid.getParameters();
            if (algParams == null) {
                return null;
            }
            paramSpec = algParams.getParameterSpec(DSAParameterSpec.class);
            return (DSAParams)paramSpec;
        }
    } catch (InvalidParameterSpecException e) {
        return null;
    }
}
 
源代码7 项目: TencentKona-8   文件: DSAParameters.java
protected <T extends AlgorithmParameterSpec>
    T engineGetParameterSpec(Class<T> paramSpec)
    throws InvalidParameterSpecException
{
        try {
            Class<?> dsaParamSpec = Class.forName
                ("java.security.spec.DSAParameterSpec");
            if (dsaParamSpec.isAssignableFrom(paramSpec)) {
                return paramSpec.cast(
                        new DSAParameterSpec(this.p, this.q, this.g));
            } else {
                throw new InvalidParameterSpecException
                    ("Inappropriate parameter Specification");
            }
        } catch (ClassNotFoundException e) {
            throw new InvalidParameterSpecException
                ("Unsupported parameter specification: " + e.getMessage());
        }
}
 
源代码8 项目: TencentKona-8   文件: DSAKeyPairGenerator.java
/**
 * Initializes the DSA key pair generator. If <code>genParams</code>
 * is false, a set of pre-computed parameters is used.
 */
@Override
public void initialize(int modlen, boolean genParams,
    SecureRandom random) throws InvalidParameterException {
    if (genParams) {
        super.init(modlen, random, true);
    } else {
        DSAParameterSpec cachedParams =
            ParameterCache.getCachedDSAParameterSpec(modlen,
                getDefDSASubprimeSize(modlen));
        if (cachedParams == null) {
            throw new InvalidParameterException
                ("No precomputed parameters for requested modulus" +
                 " size available");
        }
        super.init(cachedParams, random, false);
    }
}
 
源代码9 项目: TencentKona-8   文件: TestAlgParameterGenerator.java
private static void checkParamStrength(AlgorithmParameters param,
        DSAGenParameterSpec genParam)
        throws Exception {
    String algo = param.getAlgorithm();
    if (!algo.equalsIgnoreCase("DSA")) {
        throw new RuntimeException("Unexpected type of parameters: " + algo);
    }
    DSAParameterSpec spec = param.getParameterSpec(DSAParameterSpec.class);
    int valueL = spec.getP().bitLength();
    int strength = genParam.getPrimePLength();
    if (strength != valueL) {
        System.out.println("P: Expected " + strength + " but actual " + valueL);
        throw new RuntimeException("Wrong P strength");
    }
    int valueN = spec.getQ().bitLength();
    strength = genParam.getSubprimeQLength();
    if (strength != valueN) {
        System.out.println("Q: Expected " + strength + " but actual " + valueN);
        throw new RuntimeException("Wrong Q strength");
    }
}
 
源代码10 项目: jdk8u60   文件: DSAPublicKey.java
/**
 * Returns the DSA parameters associated with this key, or null if the
 * parameters could not be parsed.
 */
public DSAParams getParams() {
    try {
        if (algid instanceof DSAParams) {
            return (DSAParams)algid;
        } else {
            DSAParameterSpec paramSpec;
            AlgorithmParameters algParams = algid.getParameters();
            if (algParams == null) {
                return null;
            }
            paramSpec = algParams.getParameterSpec(DSAParameterSpec.class);
            return (DSAParams)paramSpec;
        }
    } catch (InvalidParameterSpecException e) {
        return null;
    }
}
 
源代码11 项目: jdk8u60   文件: DSAParameters.java
protected <T extends AlgorithmParameterSpec>
    T engineGetParameterSpec(Class<T> paramSpec)
    throws InvalidParameterSpecException
{
        try {
            Class<?> dsaParamSpec = Class.forName
                ("java.security.spec.DSAParameterSpec");
            if (dsaParamSpec.isAssignableFrom(paramSpec)) {
                return paramSpec.cast(
                        new DSAParameterSpec(this.p, this.q, this.g));
            } else {
                throw new InvalidParameterSpecException
                    ("Inappropriate parameter Specification");
            }
        } catch (ClassNotFoundException e) {
            throw new InvalidParameterSpecException
                ("Unsupported parameter specification: " + e.getMessage());
        }
}
 
源代码12 项目: jdk8u60   文件: DSAPrivateKey.java
/**
 * Returns the DSA parameters associated with this key, or null if the
 * parameters could not be parsed.
 */
public DSAParams getParams() {
    try {
        if (algid instanceof DSAParams) {
            return (DSAParams)algid;
        } else {
            DSAParameterSpec paramSpec;
            AlgorithmParameters algParams = algid.getParameters();
            if (algParams == null) {
                return null;
            }
            paramSpec = algParams.getParameterSpec(DSAParameterSpec.class);
            return (DSAParams)paramSpec;
        }
    } catch (InvalidParameterSpecException e) {
        return null;
    }
}
 
源代码13 项目: openjdk-jdk8u   文件: DSAPublicKey.java
/**
 * Returns the DSA parameters associated with this key, or null if the
 * parameters could not be parsed.
 */
public DSAParams getParams() {
    try {
        if (algid instanceof DSAParams) {
            return (DSAParams)algid;
        } else {
            DSAParameterSpec paramSpec;
            AlgorithmParameters algParams = algid.getParameters();
            if (algParams == null) {
                return null;
            }
            paramSpec = algParams.getParameterSpec(DSAParameterSpec.class);
            return (DSAParams)paramSpec;
        }
    } catch (InvalidParameterSpecException e) {
        return null;
    }
}
 
源代码14 项目: RipplePower   文件: JDKDSAPublicKey.java
JDKDSAPublicKey(
    SubjectPublicKeyInfo    info)
{

    ASN1Integer              derY;

    try
    {
        derY = (ASN1Integer)info.parsePublicKey();
    }
    catch (IOException e)
    {
        throw new IllegalArgumentException("invalid info structure in DSA public key");
    }

    this.y = derY.getValue();

    if (isNotNull(info.getAlgorithm().getParameters()))
    {
        DSAParameter params = DSAParameter.getInstance(info.getAlgorithm().getParameters());
        
        this.dsaSpec = new DSAParameterSpec(params.getP(), params.getQ(), params.getG());
    }
}
 
源代码15 项目: openjdk-8-source   文件: DSAPrivateKey.java
/**
 * Returns the DSA parameters associated with this key, or null if the
 * parameters could not be parsed.
 */
public DSAParams getParams() {
    try {
        if (algid instanceof DSAParams) {
            return (DSAParams)algid;
        } else {
            DSAParameterSpec paramSpec;
            AlgorithmParameters algParams = algid.getParameters();
            if (algParams == null) {
                return null;
            }
            paramSpec = algParams.getParameterSpec(DSAParameterSpec.class);
            return (DSAParams)paramSpec;
        }
    } catch (InvalidParameterSpecException e) {
        return null;
    }
}
 
源代码16 项目: ripple-lib-java   文件: KeyPairGeneratorSpi.java
public void initialize(
    AlgorithmParameterSpec params,
    SecureRandom random)
    throws InvalidAlgorithmParameterException
{
    if (!(params instanceof DSAParameterSpec))
    {
        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;
}
 
源代码17 项目: openjdk-jdk8u   文件: DSAKeyPairGenerator.java
/**
 * Initializes the DSA key pair generator. If <code>genParams</code>
 * is false, a set of pre-computed parameters is used.
 */
@Override
public void initialize(int modlen, boolean genParams,
    SecureRandom random) throws InvalidParameterException {
    if (genParams) {
        super.init(modlen, random, true);
    } else {
        DSAParameterSpec cachedParams =
            ParameterCache.getCachedDSAParameterSpec(modlen,
                getDefDSASubprimeSize(modlen));
        if (cachedParams == null) {
            throw new InvalidParameterException
                ("No precomputed parameters for requested modulus" +
                 " size available");
        }
        super.init(cachedParams, random, false);
    }
}
 
源代码18 项目: openjdk-jdk8u   文件: DSAPrivateKey.java
/**
 * Returns the DSA parameters associated with this key, or null if the
 * parameters could not be parsed.
 */
public DSAParams getParams() {
    try {
        if (algid instanceof DSAParams) {
            return (DSAParams)algid;
        } else {
            DSAParameterSpec paramSpec;
            AlgorithmParameters algParams = algid.getParameters();
            if (algParams == null) {
                return null;
            }
            paramSpec = algParams.getParameterSpec(DSAParameterSpec.class);
            return (DSAParams)paramSpec;
        }
    } catch (InvalidParameterSpecException e) {
        return null;
    }
}
 
源代码19 项目: openjdk-8-source   文件: DSAPublicKey.java
/**
 * Returns the DSA parameters associated with this key, or null if the
 * parameters could not be parsed.
 */
public DSAParams getParams() {
    try {
        if (algid instanceof DSAParams) {
            return (DSAParams)algid;
        } else {
            DSAParameterSpec paramSpec;
            AlgorithmParameters algParams = algid.getParameters();
            if (algParams == null) {
                return null;
            }
            paramSpec = algParams.getParameterSpec(DSAParameterSpec.class);
            return (DSAParams)paramSpec;
        }
    } catch (InvalidParameterSpecException e) {
        return null;
    }
}
 
源代码20 项目: openjdk-8-source   文件: DSAParameters.java
protected <T extends AlgorithmParameterSpec>
    T engineGetParameterSpec(Class<T> paramSpec)
    throws InvalidParameterSpecException
{
        try {
            Class<?> dsaParamSpec = Class.forName
                ("java.security.spec.DSAParameterSpec");
            if (dsaParamSpec.isAssignableFrom(paramSpec)) {
                return paramSpec.cast(
                        new DSAParameterSpec(this.p, this.q, this.g));
            } else {
                throw new InvalidParameterSpecException
                    ("Inappropriate parameter Specification");
            }
        } catch (ClassNotFoundException e) {
            throw new InvalidParameterSpecException
                ("Unsupported parameter specification: " + e.getMessage());
        }
}
 
源代码21 项目: jdk8u_jdk   文件: DSAPublicKey.java
/**
 * Returns the DSA parameters associated with this key, or null if the
 * parameters could not be parsed.
 */
public DSAParams getParams() {
    try {
        if (algid instanceof DSAParams) {
            return (DSAParams)algid;
        } else {
            DSAParameterSpec paramSpec;
            AlgorithmParameters algParams = algid.getParameters();
            if (algParams == null) {
                return null;
            }
            paramSpec = algParams.getParameterSpec(DSAParameterSpec.class);
            return (DSAParams)paramSpec;
        }
    } catch (InvalidParameterSpecException e) {
        return null;
    }
}
 
源代码22 项目: openjdk-jdk8u-backup   文件: DSAKeyPairGenerator.java
/**
 * Initializes the DSA key pair generator. If <code>genParams</code>
 * is false, a set of pre-computed parameters is used.
 */
@Override
public void initialize(int modlen, boolean genParams,
    SecureRandom random) throws InvalidParameterException {
    if (genParams) {
        super.init(modlen, random, true);
    } else {
        DSAParameterSpec cachedParams =
            ParameterCache.getCachedDSAParameterSpec(modlen,
                getDefDSASubprimeSize(modlen));
        if (cachedParams == null) {
            throw new InvalidParameterException
                ("No precomputed parameters for requested modulus" +
                 " size available");
        }
        super.init(cachedParams, random, false);
    }
}
 
源代码23 项目: openjdk-jdk8u-backup   文件: DSAPrivateKey.java
/**
 * Returns the DSA parameters associated with this key, or null if the
 * parameters could not be parsed.
 */
public DSAParams getParams() {
    try {
        if (algid instanceof DSAParams) {
            return (DSAParams)algid;
        } else {
            DSAParameterSpec paramSpec;
            AlgorithmParameters algParams = algid.getParameters();
            if (algParams == null) {
                return null;
            }
            paramSpec = algParams.getParameterSpec(DSAParameterSpec.class);
            return (DSAParams)paramSpec;
        }
    } catch (InvalidParameterSpecException e) {
        return null;
    }
}
 
源代码24 项目: Bytecoder   文件: DSAPublicKey.java
/**
 * Returns the DSA parameters associated with this key, or null if the
 * parameters could not be parsed.
 */
public DSAParams getParams() {
    try {
        if (algid instanceof DSAParams) {
            return (DSAParams)algid;
        } else {
            DSAParameterSpec paramSpec;
            AlgorithmParameters algParams = algid.getParameters();
            if (algParams == null) {
                return null;
            }
            paramSpec = algParams.getParameterSpec(DSAParameterSpec.class);
            return (DSAParams)paramSpec;
        }
    } catch (InvalidParameterSpecException e) {
        return null;
    }
}
 
源代码25 项目: Bytecoder   文件: DSAParameters.java
protected <T extends AlgorithmParameterSpec>
    T engineGetParameterSpec(Class<T> paramSpec)
    throws InvalidParameterSpecException
{
        try {
            Class<?> dsaParamSpec = Class.forName
                ("java.security.spec.DSAParameterSpec");
            if (dsaParamSpec.isAssignableFrom(paramSpec)) {
                return paramSpec.cast(
                        new DSAParameterSpec(this.p, this.q, this.g));
            } else {
                throw new InvalidParameterSpecException
                    ("Inappropriate parameter Specification");
            }
        } catch (ClassNotFoundException e) {
            throw new InvalidParameterSpecException
                ("Unsupported parameter specification: " + e.getMessage());
        }
}
 
源代码26 项目: jdk8u-dev-jdk   文件: DSAParameters.java
protected <T extends AlgorithmParameterSpec>
    T engineGetParameterSpec(Class<T> paramSpec)
    throws InvalidParameterSpecException
{
        try {
            Class<?> dsaParamSpec = Class.forName
                ("java.security.spec.DSAParameterSpec");
            if (dsaParamSpec.isAssignableFrom(paramSpec)) {
                return paramSpec.cast(
                        new DSAParameterSpec(this.p, this.q, this.g));
            } else {
                throw new InvalidParameterSpecException
                    ("Inappropriate parameter Specification");
            }
        } catch (ClassNotFoundException e) {
            throw new InvalidParameterSpecException
                ("Unsupported parameter specification: " + e.getMessage());
        }
}
 
源代码27 项目: Bytecoder   文件: DSAKeyPairGenerator.java
/**
 * Initializes the DSA key pair generator. If <code>genParams</code>
 * is false, a set of pre-computed parameters is used.
 */
@Override
public void initialize(int modlen, boolean genParams,
    SecureRandom random) throws InvalidParameterException {
    if (genParams) {
        super.init(modlen, random, true);
    } else {
        DSAParameterSpec cachedParams =
            ParameterCache.getCachedDSAParameterSpec(modlen,
                getDefDSASubprimeSize(modlen));
        if (cachedParams == null) {
            throw new InvalidParameterException
                ("No precomputed parameters for requested modulus" +
                 " size available");
        }
        super.init(cachedParams, random, false);
    }
}
 
源代码28 项目: RipplePower   文件: KeyPairGeneratorSpi.java
public void initialize(
    AlgorithmParameterSpec params,
    SecureRandom random)
    throws InvalidAlgorithmParameterException
{
    if (!(params instanceof DSAParameterSpec))
    {
        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;
}
 
源代码29 项目: jdk8u-jdk   文件: DSAPublicKey.java
/**
 * Returns the DSA parameters associated with this key, or null if the
 * parameters could not be parsed.
 */
public DSAParams getParams() {
    try {
        if (algid instanceof DSAParams) {
            return (DSAParams)algid;
        } else {
            DSAParameterSpec paramSpec;
            AlgorithmParameters algParams = algid.getParameters();
            if (algParams == null) {
                return null;
            }
            paramSpec = algParams.getParameterSpec(DSAParameterSpec.class);
            return (DSAParams)paramSpec;
        }
    } catch (InvalidParameterSpecException e) {
        return null;
    }
}
 
源代码30 项目: ripple-lib-java   文件: JDKDSAPublicKey.java
JDKDSAPublicKey(
    SubjectPublicKeyInfo    info)
{

    ASN1Integer              derY;

    try
    {
        derY = (ASN1Integer)info.parsePublicKey();
    }
    catch (IOException e)
    {
        throw new IllegalArgumentException("invalid info structure in DSA public key");
    }

    this.y = derY.getValue();

    if (isNotNull(info.getAlgorithm().getParameters()))
    {
        DSAParameter params = DSAParameter.getInstance(info.getAlgorithm().getParameters());
        
        this.dsaSpec = new DSAParameterSpec(params.getP(), params.getQ(), params.getG());
    }
}