本文整理汇总了Java中org.bouncycastle.asn1.DERObjectIdentifier类的典型用法代码示例。如果您正苦于以下问题:Java DERObjectIdentifier类的具体用法?Java DERObjectIdentifier怎么用?Java DERObjectIdentifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DERObjectIdentifier类属于org.bouncycastle.asn1包,在下文中一共展示了DERObjectIdentifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculatePbeMac
import org.bouncycastle.asn1.DERObjectIdentifier; //导入依赖的package包/类
private static byte[] calculatePbeMac(
DERObjectIdentifier oid,
byte[] salt,
int itCount,
char[] password,
byte[] data,
String provider)
throws Exception
{
SecretKeyFactory keyFact = SecretKeyFactory.getInstance(oid.getId(), provider);
PBEParameterSpec defParams = new PBEParameterSpec(salt, itCount);
PBEKeySpec pbeSpec = new PBEKeySpec(password);
SecretKey key = keyFact.generateSecret(pbeSpec);
Mac mac = Mac.getInstance(oid.getId(), provider);
mac.init(key, defParams);
mac.update(data);
return mac.doFinal();
}
示例2: GenOcspReq
import org.bouncycastle.asn1.DERObjectIdentifier; //导入依赖的package包/类
public static OCSPReq GenOcspReq(X509Certificate nextCert,
X509Certificate nextIssuer) throws OCSPException {
OCSPReqGenerator ocspRequestGenerator = new OCSPReqGenerator();
CertificateID certId = new CertificateID(CertificateID.HASH_SHA1,
nextIssuer, nextCert.getSerialNumber());
ocspRequestGenerator.addRequest(certId);
BigInteger nonce = BigInteger.valueOf(System.currentTimeMillis());
Vector<DERObjectIdentifier> oids = new Vector<DERObjectIdentifier>();
Vector<X509Extension> values = new Vector<X509Extension>();
oids.add(OCSPObjectIdentifiers.id_pkix_ocsp_nonce);
values.add(new X509Extension(false, new DEROctetString(nonce
.toByteArray())));
ocspRequestGenerator.setRequestExtensions(new X509Extensions(oids,
values));
return ocspRequestGenerator.generate();
}
示例3: JCEPBEKey
import org.bouncycastle.asn1.DERObjectIdentifier; //导入依赖的package包/类
/**
* @param param
*/
public JCEPBEKey(
String algorithm,
DERObjectIdentifier oid,
int type,
int digest,
int keySize,
int ivSize,
PBEKeySpec pbeKeySpec,
CipherParameters param)
{
this.algorithm = algorithm;
this.oid = oid;
this.type = type;
this.digest = digest;
this.keySize = keySize;
this.ivSize = ivSize;
this.pbeKeySpec = pbeKeySpec;
this.param = param;
}
示例4: writeObject
import org.bouncycastle.asn1.DERObjectIdentifier; //导入依赖的package包/类
public void writeObject(ObjectOutputStream out)
throws IOException
{
if (pkcs12Ordering.size() == 0)
{
out.writeObject(new Hashtable());
out.writeObject(new Vector());
}
else
{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
ASN1OutputStream aOut = new ASN1OutputStream(bOut);
Enumeration e = this.getBagAttributeKeys();
while (e.hasMoreElements())
{
DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
aOut.writeObject(oid);
aOut.writeObject(pkcs12Attributes.get(oid));
}
out.writeObject(bOut.toByteArray());
}
}
示例5: readObject
import org.bouncycastle.asn1.DERObjectIdentifier; //导入依赖的package包/类
public void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException
{
Object obj = in.readObject();
if (obj instanceof Hashtable)
{
this.pkcs12Attributes = (Hashtable)obj;
this.pkcs12Ordering = (Vector)in.readObject();
}
else
{
ASN1InputStream aIn = new ASN1InputStream((byte[])obj);
DERObjectIdentifier oid;
while ((oid = (DERObjectIdentifier)aIn.readObject()) != null)
{
this.setBagAttribute(oid, aIn.readObject());
}
}
}
示例6: getSigAlgID
import org.bouncycastle.asn1.DERObjectIdentifier; //导入依赖的package包/类
static AlgorithmIdentifier getSigAlgID(
DERObjectIdentifier sigOid,
String algorithmName)
{
if (noParams.contains(sigOid))
{
return new AlgorithmIdentifier(sigOid);
}
algorithmName = Strings.toUpperCase(algorithmName);
if (params.containsKey(algorithmName))
{
return new AlgorithmIdentifier(sigOid, (ASN1Encodable)params.get(algorithmName));
}
else
{
return new AlgorithmIdentifier(sigOid, DERNull.INSTANCE);
}
}
示例7: calculateSignature
import org.bouncycastle.asn1.DERObjectIdentifier; //导入依赖的package包/类
static byte[] calculateSignature(
DERObjectIdentifier sigOid,
String sigName,
PrivateKey key,
SecureRandom random,
ASN1Encodable object)
throws IOException, NoSuchAlgorithmException, InvalidKeyException, SignatureException
{
Signature sig;
if (sigOid == null)
{
throw new IllegalStateException("no signature algorithm specified");
}
sig = X509Util.getSignatureInstance(sigName);
if (random != null)
{
sig.initSign(key, random);
}
else
{
sig.initSign(key);
}
sig.update(object.toASN1Primitive().getEncoded(ASN1Encoding.DER));
return sig.sign();
}
示例8: readDERCertificate
import org.bouncycastle.asn1.DERObjectIdentifier; //导入依赖的package包/类
private X509AttributeCertificate readDERCertificate(
InputStream in)
throws IOException
{
ASN1InputStream dIn = new ASN1InputStream(in);
ASN1Sequence seq = (ASN1Sequence)dIn.readObject();
if (seq.size() > 1
&& seq.getObjectAt(0) instanceof DERObjectIdentifier)
{
if (seq.getObjectAt(0).equals(PKCSObjectIdentifiers.signedData))
{
sData = new SignedData(ASN1Sequence.getInstance(
(ASN1TaggedObject)seq.getObjectAt(1), true)).getCertificates();
return getCertificate();
}
}
return new X509V2AttributeCertificate(seq.getEncoded());
}
示例9: getSignatureName
import org.bouncycastle.asn1.DERObjectIdentifier; //导入依赖的package包/类
static String getSignatureName(
AlgorithmIdentifier sigAlgId)
{
ASN1Encodable params = sigAlgId.getParameters();
if (params != null && !derNull.equals(params))
{
if (sigAlgId.getObjectId().equals(PKCSObjectIdentifiers.id_RSASSA_PSS))
{
RSASSAPSSparams rsaParams = RSASSAPSSparams.getInstance(params);
return getDigestAlgName(rsaParams.getHashAlgorithm().getObjectId()) + "withRSAandMGF1";
}
if (sigAlgId.getObjectId().equals(X9ObjectIdentifiers.ecdsa_with_SHA2))
{
ASN1Sequence ecDsaParams = ASN1Sequence.getInstance(params);
return getDigestAlgName((DERObjectIdentifier)ecDsaParams.getObjectAt(0)) + "withECDSA";
}
}
return sigAlgId.getObjectId().getId();
}
示例10: readDERCertificate
import org.bouncycastle.asn1.DERObjectIdentifier; //导入依赖的package包/类
private Certificate readDERCertificate(
InputStream in)
throws IOException, CertificateParsingException
{
ASN1InputStream dIn = new ASN1InputStream(in);
ASN1Sequence seq = (ASN1Sequence)dIn.readObject();
if (seq.size() > 1
&& seq.getObjectAt(0) instanceof DERObjectIdentifier)
{
if (seq.getObjectAt(0).equals(PKCSObjectIdentifiers.signedData))
{
sData = new SignedData(ASN1Sequence.getInstance(
(ASN1TaggedObject)seq.getObjectAt(1), true)).getCertificates();
return getCertificate();
}
}
return new X509CertificateObject(
org.bouncycastle.asn1.x509.Certificate.getInstance(seq));
}
示例11: readDERCRL
import org.bouncycastle.asn1.DERObjectIdentifier; //导入依赖的package包/类
private CRL readDERCRL(
InputStream in)
throws IOException, CRLException
{
ASN1InputStream dIn = new ASN1InputStream(in);
ASN1Sequence seq = (ASN1Sequence)dIn.readObject();
if (seq.size() > 1
&& seq.getObjectAt(0) instanceof DERObjectIdentifier)
{
if (seq.getObjectAt(0).equals(PKCSObjectIdentifiers.signedData))
{
sData = new SignedData(ASN1Sequence.getInstance(
(ASN1TaggedObject)seq.getObjectAt(1), true)).getCRLs();
return getCRL();
}
}
return new X509CRLObject(CertificateList.getInstance(seq));
}
示例12: getSignatureName
import org.bouncycastle.asn1.DERObjectIdentifier; //导入依赖的package包/类
static String getSignatureName(
AlgorithmIdentifier sigAlgId)
{
ASN1Encodable params = sigAlgId.getParameters();
if (params != null && !derNull.equals(params))
{
if (sigAlgId.getAlgorithm().equals(PKCSObjectIdentifiers.id_RSASSA_PSS))
{
RSASSAPSSparams rsaParams = RSASSAPSSparams.getInstance(params);
return getDigestAlgName(rsaParams.getHashAlgorithm().getAlgorithm()) + "withRSAandMGF1";
}
if (sigAlgId.getAlgorithm().equals(X9ObjectIdentifiers.ecdsa_with_SHA2))
{
ASN1Sequence ecDsaParams = ASN1Sequence.getInstance(params);
return getDigestAlgName((DERObjectIdentifier)ecDsaParams.getObjectAt(0)) + "withECDSA";
}
}
return sigAlgId.getAlgorithm().getId();
}
示例13: writeObject
import org.bouncycastle.asn1.DERObjectIdentifier; //导入依赖的package包/类
public void writeObject(ObjectOutputStream out)
throws IOException
{
if (pkcs12Ordering.size() == 0)
{
out.writeObject(new Hashtable());
out.writeObject(new Vector());
}
else
{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
ASN1OutputStream aOut = new ASN1OutputStream(bOut);
Enumeration e = this.getBagAttributeKeys();
while (e.hasMoreElements())
{
DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
aOut.writeObject(oid);
aOut.writeObject((ASN1Encodable)pkcs12Attributes.get(oid));
}
out.writeObject(bOut.toByteArray());
}
}
示例14: getExtensionOIDs
import org.bouncycastle.asn1.DERObjectIdentifier; //导入依赖的package包/类
private Set getExtensionOIDs(boolean critical)
{
Set set = new HashSet();
X509Extensions extensions = this.getResponseExtensions();
if (extensions != null)
{
Enumeration e = extensions.oids();
while (e.hasMoreElements())
{
DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
X509Extension ext = extensions.getExtension(oid);
if (critical == ext.isCritical())
{
set.add(oid.getId());
}
}
}
return set;
}
示例15: getExtensionValue
import org.bouncycastle.asn1.DERObjectIdentifier; //导入依赖的package包/类
public byte[] getExtensionValue(String oid)
{
X509Extensions exts = this.getResponseExtensions();
if (exts != null)
{
X509Extension ext = exts.getExtension(new DERObjectIdentifier(oid));
if (ext != null)
{
try
{
return ext.getValue().getEncoded(ASN1Encoding.DER);
}
catch (Exception e)
{
throw new RuntimeException("error encoding " + e.toString());
}
}
}
return null;
}