本文整理汇总了Java中org.bouncycastle.asn1.DERBitString类的典型用法代码示例。如果您正苦于以下问题:Java DERBitString类的具体用法?Java DERBitString怎么用?Java DERBitString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DERBitString类属于org.bouncycastle.asn1包,在下文中一共展示了DERBitString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPublicKey
import org.bouncycastle.asn1.DERBitString; //导入依赖的package包/类
public PublicKey getPublicKey(String provider)
throws NoSuchAlgorithmException, NoSuchProviderException,
InvalidKeyException
{
SubjectPublicKeyInfo subjectPKInfo = pkac.getSubjectPublicKeyInfo();
try
{
DERBitString bStr = new DERBitString(subjectPKInfo);
X509EncodedKeySpec xspec = new X509EncodedKeySpec(bStr.getBytes());
AlgorithmIdentifier keyAlg = subjectPKInfo.getAlgorithm();
KeyFactory factory =
KeyFactory.getInstance(keyAlg.getAlgorithm().getId(),provider);
return factory.generatePublic(xspec);
}
catch (Exception e)
{
throw new InvalidKeyException("error encoding public key");
}
}
示例2: getIssuerUniqueID
import org.bouncycastle.asn1.DERBitString; //导入依赖的package包/类
public boolean[] getIssuerUniqueID()
{
DERBitString id = cert.getAcinfo().getIssuerUniqueID();
if (id != null)
{
byte[] bytes = id.getBytes();
boolean[] boolId = new boolean[bytes.length * 8 - id.getPadBits()];
for (int i = 0; i != boolId.length; i++)
{
boolId[i] = (bytes[i / 8] & (0x80 >>> (i % 8))) != 0;
}
return boolId;
}
return null;
}
示例3: generateJcaObject
import org.bouncycastle.asn1.DERBitString; //导入依赖的package包/类
private X509Certificate generateJcaObject(TBSCertificate tbsCert, byte[] signature)
throws CertificateEncodingException
{
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(tbsCert);
v.add(sigAlgId);
v.add(new DERBitString(signature));
try
{
return new X509CertificateObject(Certificate.getInstance(new DERSequence(v)));
}
catch (CertificateParsingException e)
{
throw new ExtCertificateEncodingException("exception producing certificate object", e);
}
}
示例4: booleanToBitString
import org.bouncycastle.asn1.DERBitString; //导入依赖的package包/类
private DERBitString booleanToBitString(boolean[] id)
{
byte[] bytes = new byte[(id.length + 7) / 8];
for (int i = 0; i != id.length; i++)
{
bytes[i / 8] |= (id[i]) ? (1 << ((7 - (i % 8)))) : 0;
}
int pad = id.length % 8;
if (pad == 0)
{
return new DERBitString(bytes);
}
else
{
return new DERBitString(bytes, 8 - pad);
}
}
示例5: booleanToBitString
import org.bouncycastle.asn1.DERBitString; //导入依赖的package包/类
static DERBitString booleanToBitString(boolean[] id)
{
byte[] bytes = new byte[(id.length + 7) / 8];
for (int i = 0; i != id.length; i++)
{
bytes[i / 8] |= (id[i]) ? (1 << ((7 - (i % 8)))) : 0;
}
int pad = id.length % 8;
if (pad == 0)
{
return new DERBitString(bytes);
}
else
{
return new DERBitString(bytes, 8 - pad);
}
}
示例6: bitStringToBoolean
import org.bouncycastle.asn1.DERBitString; //导入依赖的package包/类
static boolean[] bitStringToBoolean(DERBitString bitString)
{
if (bitString != null)
{
byte[] bytes = bitString.getBytes();
boolean[] boolId = new boolean[bytes.length * 8 - bitString.getPadBits()];
for (int i = 0; i != boolId.length; i++)
{
boolId[i] = (bytes[i / 8] & (0x80 >>> (i % 8))) != 0;
}
return boolId;
}
return null;
}
示例7: generate
import org.bouncycastle.asn1.DERBitString; //导入依赖的package包/类
public PKMACValue generate(char[] password, SubjectPublicKeyInfo keyInfo)
throws CRMFException
{
MacCalculator calculator = builder.build(password);
OutputStream macOut = calculator.getOutputStream();
try
{
macOut.write(keyInfo.getEncoded(ASN1Encoding.DER));
macOut.close();
}
catch (IOException e)
{
throw new CRMFException("exception encoding mac input: " + e.getMessage(), e);
}
return new PKMACValue(calculator.getAlgorithmIdentifier(), new DERBitString(calculator.getMac()));
}
示例8: build
import org.bouncycastle.asn1.DERBitString; //导入依赖的package包/类
/**
* Build a protected PKI message which has MAC based integrity protection.
*
* @param macCalculator MAC calculator.
* @return the resulting protected PKI message.
* @throws CMPException if the protection MAC cannot be calculated.
*/
public ProtectedPKIMessage build(MacCalculator macCalculator)
throws CMPException
{
finaliseHeader(macCalculator.getAlgorithmIdentifier());
PKIHeader header = hdrBuilder.build();
try
{
DERBitString protection = new DERBitString(calculateMac(macCalculator, header, body));
return finaliseMessage(header, protection);
}
catch (IOException e)
{
throw new CMPException("unable to encode MAC input: " + e.getMessage(), e);
}
}
示例9: finaliseMessage
import org.bouncycastle.asn1.DERBitString; //导入依赖的package包/类
private ProtectedPKIMessage finaliseMessage(PKIHeader header, DERBitString protection)
{
if (!extraCerts.isEmpty())
{
CMPCertificate[] cmpCerts = new CMPCertificate[extraCerts.size()];
for (int i = 0; i != cmpCerts.length; i++)
{
cmpCerts[i] = new CMPCertificate(((X509CertificateHolder)extraCerts.get(i)).toASN1Structure());
}
return new ProtectedPKIMessage(new PKIMessage(header, body, protection, cmpCerts));
}
else
{
return new ProtectedPKIMessage(new PKIMessage(header, body, protection));
}
}
示例10: NetscapeCertRequest
import org.bouncycastle.asn1.DERBitString; //导入依赖的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());
}
}
示例11: toASN1Primitive
import org.bouncycastle.asn1.DERBitString; //导入依赖的package包/类
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector spkac = new ASN1EncodableVector();
ASN1EncodableVector pkac = new ASN1EncodableVector();
try
{
pkac.add(getKeySpec());
}
catch (Exception e)
{
//ignore
}
pkac.add(new DERIA5String(challenge));
spkac.add(new DERSequence(pkac));
spkac.add(sigAlg);
spkac.add(new DERBitString(sigBits));
return new DERSequence(spkac);
}
示例12: getIssuerUniqueID
import org.bouncycastle.asn1.DERBitString; //导入依赖的package包/类
public boolean[] getIssuerUniqueID()
{
DERBitString id = c.getTBSCertificate().getIssuerUniqueId();
if (id != null)
{
byte[] bytes = id.getBytes();
boolean[] boolId = new boolean[bytes.length * 8 - id.getPadBits()];
for (int i = 0; i != boolId.length; i++)
{
boolId[i] = (bytes[i / 8] & (0x80 >>> (i % 8))) != 0;
}
return boolId;
}
return null;
}
示例13: getSubjectUniqueID
import org.bouncycastle.asn1.DERBitString; //导入依赖的package包/类
public boolean[] getSubjectUniqueID()
{
DERBitString id = c.getTBSCertificate().getSubjectUniqueId();
if (id != null)
{
byte[] bytes = id.getBytes();
boolean[] boolId = new boolean[bytes.length * 8 - id.getPadBits()];
for (int i = 0; i != boolId.length; i++)
{
boolId[i] = (bytes[i / 8] & (0x80 >>> (i % 8))) != 0;
}
return boolId;
}
return null;
}
示例14: ECPrivateKeyStructure
import org.bouncycastle.asn1.DERBitString; //导入依赖的package包/类
public ECPrivateKeyStructure(
BigInteger key,
DERBitString publicKey,
ASN1Encodable parameters)
{
byte[] bytes = BigIntegers.asUnsignedByteArray(key);
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(new ASN1Integer(1));
v.add(new DEROctetString(bytes));
if (parameters != null)
{
v.add(new DERTaggedObject(true, 0, parameters));
}
if (publicKey != null)
{
v.add(new DERTaggedObject(true, 1, publicKey));
}
seq = new DERSequence(v);
}
示例15: ObjectDigestInfo
import org.bouncycastle.asn1.DERBitString; //导入依赖的package包/类
/**
* Constructor from given details.
* <p>
* If <code>digestedObjectType</code> is not {@link #publicKeyCert} or
* {@link #publicKey} <code>otherObjectTypeID</code> must be given,
* otherwise it is ignored.
*
* @param digestedObjectType The digest object type.
* @param otherObjectTypeID The object type ID for
* <code>otherObjectDigest</code>.
* @param digestAlgorithm The algorithm identifier for the hash.
* @param objectDigest The hash value.
*/
public ObjectDigestInfo(
int digestedObjectType,
ASN1ObjectIdentifier otherObjectTypeID,
AlgorithmIdentifier digestAlgorithm,
byte[] objectDigest)
{
this.digestedObjectType = new ASN1Enumerated(digestedObjectType);
if (digestedObjectType == otherObjectDigest)
{
this.otherObjectTypeID = otherObjectTypeID;
}
this.digestAlgorithm = digestAlgorithm;
this.objectDigest = new DERBitString(objectDigest);
}