当前位置: 首页>>代码示例>>Java>>正文


Java DSAParameterSpec类代码示例

本文整理汇总了Java中java.security.spec.DSAParameterSpec的典型用法代码示例。如果您正苦于以下问题:Java DSAParameterSpec类的具体用法?Java DSAParameterSpec怎么用?Java DSAParameterSpec使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DSAParameterSpec类属于java.security.spec包,在下文中一共展示了DSAParameterSpec类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initialize

import java.security.spec.DSAParameterSpec; //导入依赖的package包/类
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;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:17,代码来源:KeyPairGeneratorSpi.java

示例2: generateDSAKeypair

import java.security.spec.DSAParameterSpec; //导入依赖的package包/类
@Override
public P11ObjectIdentifier generateDSAKeypair(int plength, int qlength, String label,
        P11NewKeyControl control) throws P11TokenException {
    ParamUtil.requireMin("plength", plength, 1024);
    if (plength % 1024 != 0) {
        throw new IllegalArgumentException("key size is not multiple of 1024: " + plength);
    }
    assertWritable("generateDSAKeypair");
    assertMechanismSupported(PKCS11Constants.CKM_DSA_KEY_PAIR_GEN);
    if (getObjectIdForLabel(label) != null) {
        throw new P11DuplicateEntityException("identity with label " + label +
                " already exists");
    }

    DSAParameterSpec dsaParams = DSAParameterCache.getDSAParameterSpec(plength, qlength,
            random);
    P11Identity identity = generateDSAKeypair0(dsaParams.getP(), dsaParams.getQ(),
            dsaParams.getG(), label, control);
    addIdentity(identity);
    P11ObjectIdentifier objId = identity.identityId().objectId();
    LOG.info("generated DSA keypair {}", objId);
    return objId;
}
 
开发者ID:xipki,项目名称:xitk,代码行数:24,代码来源:AbstractP11Slot.java

示例3: getParams

import java.security.spec.DSAParameterSpec; //导入依赖的package包/类
/**
 * 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;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:DSAPublicKey.java

示例4: engineGetParameterSpec

import java.security.spec.DSAParameterSpec; //导入依赖的package包/类
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());
        }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:DSAParameters.java

示例5: generateKeyPair

import java.security.spec.DSAParameterSpec; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:DSAKeyPairGenerator.java

示例6: checkParamStrength

import java.security.spec.DSAParameterSpec; //导入依赖的package包/类
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");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:TestAlgParameterGenerator.java

示例7: initialize

import java.security.spec.DSAParameterSpec; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:22,代码来源:DSAKeyPairGenerator.java

示例8: JDKDSAPublicKey

import java.security.spec.DSAParameterSpec; //导入依赖的package包/类
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());
    }
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:25,代码来源:JDKDSAPublicKey.java

示例9: BCDSAPublicKey

import java.security.spec.DSAParameterSpec; //导入依赖的package包/类
public BCDSAPublicKey(
    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());
    }
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:25,代码来源:BCDSAPublicKey.java

示例10: initialize

import java.security.spec.DSAParameterSpec; //导入依赖的package包/类
public void initialize(AlgorithmParameterSpec params, SecureRandom random)
    throws InvalidAlgorithmParameterException
{
  HashMap attributes = new HashMap();
  if (params != null)
    {
      if (! (params instanceof DSAParameterSpec))
        throw new InvalidAlgorithmParameterException(
            "Parameters argument is not a non-null instance, or "
            + "sub-instance, of java.security.spec.DSAParameterSpec");
      attributes.put(DSSKeyPairGenerator.DSS_PARAMETERS, params);
    }
  if (random != null)
    attributes.put(DSSKeyPairGenerator.SOURCE_OF_RANDOMNESS, random);

  attributes.put(DSSKeyPairGenerator.PREFERRED_ENCODING_FORMAT,
                 Integer.valueOf(Registry.ASN1_ENCODING_ID));
  try
    {
      adaptee.setup(attributes);
    }
  catch (IllegalArgumentException x)
    {
      throw new InvalidAlgorithmParameterException(x.getMessage(), x);
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:27,代码来源:DSSKeyPairGeneratorSpi.java


注:本文中的java.security.spec.DSAParameterSpec类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。