本文整理汇总了Java中org.bouncycastle.asn1.x509.DSAParameter类的典型用法代码示例。如果您正苦于以下问题:Java DSAParameter类的具体用法?Java DSAParameter怎么用?Java DSAParameter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DSAParameter类属于org.bouncycastle.asn1.x509包,在下文中一共展示了DSAParameter类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEncoded
import org.bouncycastle.asn1.x509.DSAParameter; //导入依赖的package包/类
public byte[] getEncoded()
{
try
{
if (dsaSpec == null)
{
return new SubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa), new DERInteger(y)).getEncoded(ASN1Encoding.DER);
}
return new SubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG())), new DERInteger(y)).getEncoded(ASN1Encoding.DER);
}
catch (IOException e)
{
return null;
}
}
示例2: JDKDSAPublicKey
import org.bouncycastle.asn1.x509.DSAParameter; //导入依赖的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());
}
}
示例3: getEncoded
import org.bouncycastle.asn1.x509.DSAParameter; //导入依赖的package包/类
public byte[] getEncoded()
{
try
{
if (dsaSpec == null)
{
return new SubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa), new ASN1Integer(y)).getEncoded(ASN1Encoding.DER);
}
return new SubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG())), new ASN1Integer(y)).getEncoded(ASN1Encoding.DER);
}
catch (IOException e)
{
return null;
}
}
示例4: BCDSAPublicKey
import org.bouncycastle.asn1.x509.DSAParameter; //导入依赖的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());
}
}
示例5: JDKDSAPrivateKey
import org.bouncycastle.asn1.x509.DSAParameter; //导入依赖的package包/类
JDKDSAPrivateKey(
PrivateKeyInfo info)
throws IOException
{
DSAParameter params = DSAParameter.getInstance(info.getPrivateKeyAlgorithm().getParameters());
DERInteger derX = ASN1Integer.getInstance(info.parsePrivateKey());
this.x = derX.getValue();
this.dsaSpec = new DSAParameterSpec(params.getP(), params.getQ(), params.getG());
}
示例6: getEncoded
import org.bouncycastle.asn1.x509.DSAParameter; //导入依赖的package包/类
/**
* Return a PKCS8 representation of the key. The sequence returned
* represents a full PrivateKeyInfo object.
*
* @return a PKCS8 representation of the key.
*/
public byte[] getEncoded()
{
try
{
PrivateKeyInfo info = new PrivateKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG())), new DERInteger(getX()));
return info.getEncoded(ASN1Encoding.DER);
}
catch (IOException e)
{
return null;
}
}
示例7: getEncoded
import org.bouncycastle.asn1.x509.DSAParameter; //导入依赖的package包/类
public byte[] getEncoded()
{
if (dsaSpec == null)
{
return KeyUtil.getEncodedSubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa), new ASN1Integer(y));
}
return KeyUtil.getEncodedSubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG()).toASN1Primitive()), new ASN1Integer(y));
}
示例8: engineGetEncoded
import org.bouncycastle.asn1.x509.DSAParameter; //导入依赖的package包/类
/**
* Return the X.509 ASN.1 structure DSAParameter.
* <p/>
* <pre>
* DSAParameter ::= SEQUENCE {
* prime INTEGER, -- p
* subprime INTEGER, -- q
* base INTEGER, -- g}
* </pre>
*/
protected byte[] engineGetEncoded()
{
DSAParameter dsaP = new DSAParameter(currentSpec.getP(), currentSpec.getQ(), currentSpec.getG());
try
{
return dsaP.getEncoded(ASN1Encoding.DER);
}
catch (IOException e)
{
throw new RuntimeException("Error encoding DSAParameters");
}
}
示例9: BCDSAPrivateKey
import org.bouncycastle.asn1.x509.DSAParameter; //导入依赖的package包/类
public BCDSAPrivateKey(
PrivateKeyInfo info)
throws IOException
{
DSAParameter params = DSAParameter.getInstance(info.getPrivateKeyAlgorithm().getParameters());
ASN1Integer derX = (ASN1Integer)info.parsePrivateKey();
this.x = derX.getValue();
this.dsaSpec = new DSAParameterSpec(params.getP(), params.getQ(), params.getG());
}
示例10: JDKDSAPrivateKey
import org.bouncycastle.asn1.x509.DSAParameter; //导入依赖的package包/类
JDKDSAPrivateKey(
PrivateKeyInfo info)
throws IOException
{
DSAParameter params = DSAParameter.getInstance(info.getPrivateKeyAlgorithm().getParameters());
ASN1Integer derX = ASN1Integer.getInstance(info.parsePrivateKey());
this.x = derX.getValue();
this.dsaSpec = new DSAParameterSpec(params.getP(), params.getQ(), params.getG());
}
示例11: getEncoded
import org.bouncycastle.asn1.x509.DSAParameter; //导入依赖的package包/类
/**
* Return a PKCS8 representation of the key. The sequence returned
* represents a full PrivateKeyInfo object.
*
* @return a PKCS8 representation of the key.
*/
public byte[] getEncoded()
{
try
{
PrivateKeyInfo info = new PrivateKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG())), new ASN1Integer(getX()));
return info.getEncoded(ASN1Encoding.DER);
}
catch (IOException e)
{
return null;
}
}
示例12: engineGetEncoded
import org.bouncycastle.asn1.x509.DSAParameter; //导入依赖的package包/类
/**
* Return the X.509 ASN.1 structure DSAParameter.
* <pre>
* DSAParameter ::= SEQUENCE {
* prime INTEGER, -- p
* subprime INTEGER, -- q
* base INTEGER, -- g}
* </pre>
*/
protected byte[] engineGetEncoded()
{
DSAParameter dsaP = new DSAParameter(currentSpec.getP(), currentSpec.getQ(), currentSpec.getG());
try
{
return dsaP.getEncoded(ASN1Encoding.DER);
}
catch (IOException e)
{
throw new RuntimeException("Error encoding DSAParameters");
}
}
示例13: loadKeyPair
import org.bouncycastle.asn1.x509.DSAParameter; //导入依赖的package包/类
private static KeyPair loadKeyPair(PEMKeyPair privatekey)
throws CertificateException {
try {
PEMKeyPair pair = (PEMKeyPair) privatekey;
byte[] encodedPublicKey = pair.getPublicKeyInfo().getEncoded();
byte[] encodedPrivateKey = pair.getPrivateKeyInfo().getEncoded();
// Generate KeyPair.
KeyFactory keyFactory = KeyFactory
.getInstance(pair.getPublicKeyInfo().getAlgorithm()
.getParameters() instanceof DSAParameter ? "DSA"
: "RSA");
X509EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(
encodedPublicKey);
PublicKey publicKey = keyFactory.generatePublic(publicKeySpec);
PKCS8EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(
encodedPrivateKey);
PrivateKey privateKey = keyFactory.generatePrivate(privateKeySpec);
return new KeyPair(publicKey, privateKey);
} catch (Exception e) {
throw new CertificateException(
"Failed to convert PEMKeyPair into JCE KeyPair", e);
}
}
示例14: getEncoded
import org.bouncycastle.asn1.x509.DSAParameter; //导入依赖的package包/类
/**
* Return a PKCS8 representation of the key. The sequence returned
* represents a full PrivateKeyInfo object.
*
* @return a PKCS8 representation of the key.
*/
public byte[] getEncoded()
{
return KeyUtil.getEncodedPrivateKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG()).toASN1Primitive()), new ASN1Integer(getX()));
}