本文整理汇总了Java中org.bouncycastle.asn1.DERSequence类的典型用法代码示例。如果您正苦于以下问题:Java DERSequence类的具体用法?Java DERSequence怎么用?Java DERSequence使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DERSequence类属于org.bouncycastle.asn1包,在下文中一共展示了DERSequence类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toASN1Primitive
import org.bouncycastle.asn1.DERSequence; //导入依赖的package包/类
/**
* <pre>
* CertifiedKeyPair ::= SEQUENCE {
* certOrEncCert CertOrEncCert,
* privateKey [0] EncryptedValue OPTIONAL,
* -- see [CRMF] for comment on encoding
* publicationInfo [1] PKIPublicationInfo OPTIONAL
* }
* </pre>
* @return a basic ASN.1 object representation.
*/
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(certOrEncCert);
if (privateKey != null)
{
v.add(new DERTaggedObject(true, 0, privateKey));
}
if (publicationInfo != null)
{
v.add(new DERTaggedObject(true, 1, publicationInfo));
}
return new DERSequence(v);
}
示例2: dsaSigPlainToX962
import org.bouncycastle.asn1.DERSequence; //导入依赖的package包/类
public static byte[] dsaSigPlainToX962(byte[] signature) throws XiSecurityException {
ParamUtil.requireNonNull("signature", signature);
if (signature.length % 2 != 0) {
throw new XiSecurityException("signature.lenth must be even, but is odd");
}
byte[] ba = new byte[signature.length / 2];
ASN1EncodableVector sigder = new ASN1EncodableVector();
System.arraycopy(signature, 0, ba, 0, ba.length);
sigder.add(new ASN1Integer(new BigInteger(1, ba)));
System.arraycopy(signature, ba.length, ba, 0, ba.length);
sigder.add(new ASN1Integer(new BigInteger(1, ba)));
DERSequence seq = new DERSequence(sigder);
try {
return seq.getEncoded();
} catch (IOException ex) {
throw new XiSecurityException("IOException, message: " + ex.getMessage(), ex);
}
}
示例3: toASN1Primitive
import org.bouncycastle.asn1.DERSequence; //导入依赖的package包/类
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
if (null != this.crlVals)
{
v.add(new DERTaggedObject(true, 0, this.crlVals));
}
if (null != this.ocspVals)
{
v.add(new DERTaggedObject(true, 1, this.ocspVals));
}
if (null != this.otherRevVals)
{
v.add(new DERTaggedObject(true, 2, this.otherRevVals.toASN1Primitive()));
}
return new DERSequence(v);
}
示例4: NetscapeCertRequest
import org.bouncycastle.asn1.DERSequence; //导入依赖的package包/类
public NetscapeCertRequest(
String challenge,
AlgorithmIdentifier signing_alg,
PublicKey pub_key) throws NoSuchAlgorithmException,
InvalidKeySpecException, NoSuchProviderException
{
this.challenge = challenge;
sigAlg = signing_alg;
pubkey = pub_key;
ASN1EncodableVector content_der = new ASN1EncodableVector();
content_der.add(getKeySpec());
//content_der.add(new SubjectPublicKeyInfo(sigAlg, new RSAPublicKeyStructure(pubkey.getModulus(), pubkey.getPublicExponent()).getDERObject()));
content_der.add(new DERIA5String(challenge));
try
{
content = new DERBitString(new DERSequence(content_der));
}
catch (IOException e)
{
throw new InvalidKeySpecException("exception encoding key: " + e.toString());
}
}
示例5: toASN1Primitive
import org.bouncycastle.asn1.DERSequence; //导入依赖的package包/类
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector seqOfPSh = new ASN1EncodableVector();
ASN1EncodableVector seqOfPSw = new ASN1EncodableVector();
ASN1EncodableVector seqOfPSK = new ASN1EncodableVector();
for (int i = 0; i < h.length; i++)
{
seqOfPSh.add(new ASN1Integer(h[i]));
seqOfPSw.add(new ASN1Integer(w[i]));
seqOfPSK.add(new ASN1Integer(k[i]));
}
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(new ASN1Integer(t));
v.add(new DERSequence(seqOfPSh));
v.add(new DERSequence(seqOfPSw));
v.add(new DERSequence(seqOfPSK));
return new DERSequence(v);
}
示例6: toASN1Primitive
import org.bouncycastle.asn1.DERSequence; //导入依赖的package包/类
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
// encode <oidString>
v.add(oid);
// encode <n>
v.add(new ASN1Integer(n));
// encode <t>
v.add(new ASN1Integer(t));
// encode <matrixG>
v.add(new DEROctetString(matrixG));
return new DERSequence(v);
}
示例7: toASN1Primitive
import org.bouncycastle.asn1.DERSequence; //导入依赖的package包/类
/**
* Produce an object suitable for an ASN1OutputStream.
* <pre>
* KEKIdentifier ::= SEQUENCE {
* keyIdentifier OCTET STRING,
* date GeneralizedTime OPTIONAL,
* other OtherKeyAttribute OPTIONAL
* }
* </pre>
*/
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(keyIdentifier);
if (date != null)
{
v.add(date);
}
if (other != null)
{
v.add(other);
}
return new DERSequence(v);
}
示例8: toASN1Primitive
import org.bouncycastle.asn1.DERSequence; //导入依赖的package包/类
/**
* <pre>
* POPOSigningKeyInput ::= SEQUENCE {
* authInfo CHOICE {
* sender [0] GeneralName,
* -- used only if an authenticated identity has been
* -- established for the sender (e.g., a DN from a
* -- previously-issued and currently-valid certificate
* publicKeyMAC PKMACValue },
* -- used if no authenticated GeneralName currently exists for
* -- the sender; publicKeyMAC contains a password-based MAC
* -- on the DER-encoded value of publicKey
* publicKey SubjectPublicKeyInfo } -- from CertTemplate
* </pre>
* @return a basic ASN.1 object representation.
*/
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
if (sender != null)
{
v.add(new DERTaggedObject(false, 0, sender));
}
else
{
v.add(publicKeyMAC);
}
v.add(publicKey);
return new DERSequence(v);
}
示例9: generateServerCertificate
import org.bouncycastle.asn1.DERSequence; //导入依赖的package包/类
public static X500PrivateCredential generateServerCertificate(KeyPair caKeyPair) throws NoSuchAlgorithmException, CertificateException, OperatorCreationException, CertIOException {
X500Name issuerName = new X500Name("CN=bouncrca");
X500Name subjectName = new X500Name("CN=bouncr");
BigInteger serial = BigInteger.valueOf(2);
long t1 = System.currentTimeMillis();
KeyPairGenerator rsa = KeyPairGenerator.getInstance("RSA");
rsa.initialize(2048, SecureRandom.getInstance("NativePRNGNonBlocking"));
KeyPair kp = rsa.generateKeyPair();
System.out.println(System.currentTimeMillis() - t1);
X509v3CertificateBuilder builder = new JcaX509v3CertificateBuilder(issuerName, serial, NOT_BEFORE, NOT_AFTER, subjectName, kp.getPublic());
DERSequence subjectAlternativeNames = new DERSequence(new ASN1Encodable[] {
new GeneralName(GeneralName.dNSName, "localhost"),
new GeneralName(GeneralName.dNSName, "127.0.0.1")
});
builder.addExtension(Extension.subjectAlternativeName, false, subjectAlternativeNames);
X509Certificate cert = signCertificate(builder, caKeyPair.getPrivate());
return new X500PrivateCredential(cert, kp.getPrivate());
}
示例10: toASN1Primitive
import org.bouncycastle.asn1.DERSequence; //导入依赖的package包/类
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(this.p);
v.add(this.g);
v.add(this.q);
if (this.j != null)
{
v.add(this.j);
}
if (this.validationParms != null)
{
v.add(this.validationParms);
}
return new DERSequence(v);
}
示例11: CertReqMsg
import org.bouncycastle.asn1.DERSequence; //导入依赖的package包/类
/**
* Creates a new CertReqMsg.
* @param certReq CertRequest
* @param pop may be null
* @param regInfo may be null
*/
public CertReqMsg(
CertRequest certReq,
ProofOfPossession pop,
AttributeTypeAndValue[] regInfo)
{
if (certReq == null)
{
throw new IllegalArgumentException("'certReq' cannot be null");
}
this.certReq = certReq;
this.pop = pop;
if (regInfo != null)
{
this.regInfo = new DERSequence(regInfo);
}
}
示例12: toASN1Primitive
import org.bouncycastle.asn1.DERSequence; //导入依赖的package包/类
/**
* Produce an object suitable for an ASN1OutputStream.
* <pre>
* SignerInfo ::= SEQUENCE {
* version Version,
* issuerAndSerialNumber IssuerAndSerialNumber,
* digestAlgorithm DigestAlgorithmIdentifier,
* authenticatedAttributes [0] IMPLICIT Attributes OPTIONAL,
* digestEncryptionAlgorithm DigestEncryptionAlgorithmIdentifier,
* encryptedDigest EncryptedDigest,
* unauthenticatedAttributes [1] IMPLICIT Attributes OPTIONAL
* }
*
* EncryptedDigest ::= OCTET STRING
*
* DigestAlgorithmIdentifier ::= AlgorithmIdentifier
*
* DigestEncryptionAlgorithmIdentifier ::= AlgorithmIdentifier
* </pre>
*/
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(version);
v.add(issuerAndSerialNumber);
v.add(digAlgorithm);
if (authenticatedAttributes != null)
{
v.add(new DERTaggedObject(false, 0, authenticatedAttributes));
}
v.add(digEncryptionAlgorithm);
v.add(encryptedDigest);
if (unauthenticatedAttributes != null)
{
v.add(new DERTaggedObject(false, 1, unauthenticatedAttributes));
}
return new DERSequence(v);
}
示例13: build
import org.bouncycastle.asn1.DERSequence; //导入依赖的package包/类
/**
* <pre>
* CertTemplate ::= SEQUENCE {
* version [0] Version OPTIONAL,
* serialNumber [1] INTEGER OPTIONAL,
* signingAlg [2] AlgorithmIdentifier OPTIONAL,
* issuer [3] Name OPTIONAL,
* validity [4] OptionalValidity OPTIONAL,
* subject [5] Name OPTIONAL,
* publicKey [6] SubjectPublicKeyInfo OPTIONAL,
* issuerUID [7] UniqueIdentifier OPTIONAL,
* subjectUID [8] UniqueIdentifier OPTIONAL,
* extensions [9] Extensions OPTIONAL }
* </pre>
* @return a basic ASN.1 object representation.
*/
public CertTemplate build()
{
ASN1EncodableVector v = new ASN1EncodableVector();
addOptional(v, 0, false, version);
addOptional(v, 1, false, serialNumber);
addOptional(v, 2, false, signingAlg);
addOptional(v, 3, true, issuer); // CHOICE
addOptional(v, 4, false, validity);
addOptional(v, 5, true, subject); // CHOICE
addOptional(v, 6, false, publicKey);
addOptional(v, 7, false, issuerUID);
addOptional(v, 8, false, subjectUID);
addOptional(v, 9, false, extensions);
return CertTemplate.getInstance(new DERSequence(v));
}
示例14: toASN1Primitive
import org.bouncycastle.asn1.DERSequence; //导入依赖的package包/类
/**
* Produce an object suitable for an ASN1OutputStream.
*/
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
if (keyidentifier != null)
{
v.add(new DERTaggedObject(false, 0, keyidentifier));
}
if (certissuer != null)
{
v.add(new DERTaggedObject(false, 1, certissuer));
}
if (certserno != null)
{
v.add(new DERTaggedObject(false, 2, certserno));
}
return new DERSequence(v);
}
示例15: toASN1Primitive
import org.bouncycastle.asn1.DERSequence; //导入依赖的package包/类
/**
* <pre>
* ESSCertIDv2 ::= SEQUENCE {
* hashAlgorithm AlgorithmIdentifier
* DEFAULT {algorithm id-sha256},
* certHash Hash,
* issuerSerial IssuerSerial OPTIONAL
* }
*
* Hash ::= OCTET STRING
*
* IssuerSerial ::= SEQUENCE {
* issuer GeneralNames,
* serialNumber CertificateSerialNumber
* }
* </pre>
*/
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
if (!hashAlgorithm.equals(DEFAULT_ALG_ID))
{
v.add(hashAlgorithm);
}
v.add(new DEROctetString(certHash).toASN1Primitive());
if (issuerSerial != null)
{
v.add(issuerSerial);
}
return new DERSequence(v);
}