本文整理匯總了Java中org.bouncycastle.asn1.DEROctetString類的典型用法代碼示例。如果您正苦於以下問題:Java DEROctetString類的具體用法?Java DEROctetString怎麽用?Java DEROctetString使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DEROctetString類屬於org.bouncycastle.asn1包,在下文中一共展示了DEROctetString類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: RespID
import org.bouncycastle.asn1.DEROctetString; //導入依賴的package包/類
/**
* Calculate a RespID based on the public key of the responder.
*
* @param subjectPublicKeyInfo the info structure for the responder public key.
* @param digCalc a SHA-1 digest calculator.
* @throws OCSPException on exception creating ID.
*/
public RespID(
SubjectPublicKeyInfo subjectPublicKeyInfo,
DigestCalculator digCalc)
throws OCSPException
{
try
{
if (!digCalc.getAlgorithmIdentifier().equals(HASH_SHA1))
{
throw new IllegalArgumentException("only SHA-1 can be used with RespID");
}
OutputStream digOut = digCalc.getOutputStream();
digOut.write(subjectPublicKeyInfo.getPublicKeyData().getBytes());
digOut.close();
this.id = new ResponderID(new DEROctetString(digCalc.getDigest()));
}
catch (Exception e)
{
throw new OCSPException("problem creating ID: " + e, e);
}
}
示例2: toASN1Primitive
import org.bouncycastle.asn1.DEROctetString; //導入依賴的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);
}
示例3: generateBytes
import org.bouncycastle.asn1.DEROctetString; //導入依賴的package包/類
public int generateBytes(byte[] out, int outOff, int len)
throws DataLengthException, IllegalArgumentException
{
// TODO Create an ASN.1 class for this (RFC3278)
// ECC-CMS-SharedInfo
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(new AlgorithmIdentifier(algorithm, DERNull.INSTANCE));
v.add(new DERTaggedObject(true, 2, new DEROctetString(Pack.intToBigEndian(keySize))));
try
{
kdf.init(new KDFParameters(z, new DERSequence(v).getEncoded(ASN1Encoding.DER)));
}
catch (IOException e)
{
throw new IllegalArgumentException("unable to initialise kdf: " + e.getMessage());
}
return kdf.generateBytes(out, outOff, len);
}
示例4: ECPrivateKeyStructure
import org.bouncycastle.asn1.DEROctetString; //導入依賴的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);
}
示例5: AuthorityKeyIdentifier
import org.bouncycastle.asn1.DEROctetString; //導入依賴的package包/類
/**
* create an AuthorityKeyIdentifier with the GeneralNames tag and
* the serial number provided as well.
*/
public AuthorityKeyIdentifier(
SubjectPublicKeyInfo spki,
GeneralNames name,
BigInteger serialNumber)
{
Digest digest = new SHA1Digest();
byte[] resBuf = new byte[digest.getDigestSize()];
byte[] bytes = spki.getPublicKeyData().getBytes();
digest.update(bytes, 0, bytes.length);
digest.doFinal(resBuf, 0);
this.keyidentifier = new DEROctetString(resBuf);
this.certissuer = GeneralNames.getInstance(name.toASN1Primitive());
this.certserno = new ASN1Integer(serialNumber);
}
示例6: createReasonExtension
import org.bouncycastle.asn1.DEROctetString; //導入依賴的package包/類
private static ASN1Sequence createReasonExtension(int reasonCode)
{
ASN1EncodableVector v = new ASN1EncodableVector();
CRLReason crlReason = CRLReason.lookup(reasonCode);
try
{
v.add(Extension.reasonCode);
v.add(new DEROctetString(crlReason.getEncoded()));
}
catch (IOException e)
{
throw new IllegalArgumentException("error encoding reason: " + e);
}
return new DERSequence(v);
}
示例7: createInvalidityDateExtension
import org.bouncycastle.asn1.DEROctetString; //導入依賴的package包/類
private static ASN1Sequence createInvalidityDateExtension(ASN1GeneralizedTime invalidityDate)
{
ASN1EncodableVector v = new ASN1EncodableVector();
try
{
v.add(Extension.invalidityDate);
v.add(new DEROctetString(invalidityDate.getEncoded()));
}
catch (IOException e)
{
throw new IllegalArgumentException("error encoding reason: " + e);
}
return new DERSequence(v);
}
示例8: toASN1Primitive
import org.bouncycastle.asn1.DEROctetString; //導入依賴的package包/類
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(algId);
v.add(new DEROctetString(digest));
return new DERSequence(v);
}
示例9: getASN1EncodableVector
import org.bouncycastle.asn1.DEROctetString; //導入依賴的package包/類
public ASN1EncodableVector getASN1EncodableVector(ASN1ObjectIdentifier oid, boolean publicPointOnly)
{
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(oid);
if (!publicPointOnly)
{
v.add(new UnsignedInteger(0x01, getPrimeModulusP()));
v.add(new UnsignedInteger(0x02, getFirstCoefA()));
v.add(new UnsignedInteger(0x03, getSecondCoefB()));
v.add(new DERTaggedObject(false, 0x04, new DEROctetString(getBasePointG())));
v.add(new UnsignedInteger(0x05, getOrderOfBasePointR()));
}
v.add(new DERTaggedObject(false, 0x06, new DEROctetString(getPublicPointY())));
if (!publicPointOnly)
{
v.add(new UnsignedInteger(0x07, getCofactorF()));
}
return v;
}
示例10: toASN1Primitive
import org.bouncycastle.asn1.DEROctetString; //導入依賴的package包/類
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(certificateBody);
try
{
v.add(new DERApplicationSpecific(false, EACTags.STATIC_INTERNAL_AUTHENTIFICATION_ONE_STEP, new DEROctetString(innerSignature)));
}
catch (IOException e)
{
throw new IllegalStateException("unable to convert signature!");
}
return new DERApplicationSpecific(EACTags.CARDHOLDER_CERTIFICATE, v);
}
示例11: toASN1Primitive
import org.bouncycastle.asn1.DEROctetString; //導入依賴的package包/類
/**
* @see org.bouncycastle.asn1.ASN1Object#toASN1Primitive()
*/
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
if (valid != (signValid | bodyValid))
{
return null;
}
v.add(certificateBody);
try
{
v.add(new DERApplicationSpecific(false, EACTags.STATIC_INTERNAL_AUTHENTIFICATION_ONE_STEP, new DEROctetString(signature)));
}
catch (IOException e)
{
throw new IllegalStateException("unable to convert signature!");
}
return new DERApplicationSpecific(EACTags.CARDHOLDER_CERTIFICATE, v);
}
示例12: toASN1Primitive
import org.bouncycastle.asn1.DEROctetString; //導入依賴的package包/類
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
if (namedCurve != null)
{
v.add(namedCurve);
}
else
{
v.add(ecbinary);
}
if (!org.bouncycastle.util.Arrays.areEqual(dke, DEFAULT_DKE))
{
v.add(new DEROctetString(dke));
}
return new DERSequence(v);
}
示例13: DSTU4145ECBinary
import org.bouncycastle.asn1.DEROctetString; //導入依賴的package包/類
public DSTU4145ECBinary(ECDomainParameters params)
{
if (!(params.getCurve() instanceof ECCurve.F2m))
{
throw new IllegalArgumentException("only binary domain is possible");
}
// We always use big-endian in parameter encoding
ECCurve.F2m curve = (ECCurve.F2m)params.getCurve();
f = new DSTU4145BinaryField(curve.getM(), curve.getK1(), curve.getK2(), curve.getK3());
a = new ASN1Integer(curve.getA().toBigInteger());
X9IntegerConverter converter = new X9IntegerConverter();
b = new DEROctetString(converter.integerToBytes(curve.getB().toBigInteger(), converter.getByteLength(curve)));
n = new ASN1Integer(params.getN());
bp = new DEROctetString(DSTU4145PointEncoder.encodePoint(params.getG()));
}
示例14: digestSecretKey0
import org.bouncycastle.asn1.DEROctetString; //導入依賴的package包/類
@Override
protected byte[] digestSecretKey0(long mechanism) throws P11TokenException {
Asn1P11EntityIdentifier asn1EntityId = new Asn1P11EntityIdentifier(identityId);
Asn1DigestSecretKeyTemplate template = new Asn1DigestSecretKeyTemplate(
asn1EntityId, mechanism);
byte[] result = ((ProxyP11Slot) slot).module().send(
P11ProxyConstants.ACTION_DIGEST_SECRETKEY, template);
ASN1OctetString octetString;
try {
octetString = DEROctetString.getInstance(result);
} catch (IllegalArgumentException ex) {
throw new P11TokenException("the returned result is not OCTET STRING");
}
return (octetString == null) ? null : octetString.getOctets();
}
示例15: engineSign
import org.bouncycastle.asn1.DEROctetString; //導入依賴的package包/類
protected byte[] engineSign()
throws SignatureException
{
byte[] hash = new byte[digest.getDigestSize()];
digest.doFinal(hash, 0);
try
{
BigInteger[] sig = signer.generateSignature(hash);
byte[] r = sig[0].toByteArray();
byte[] s = sig[1].toByteArray();
byte[] sigBytes = new byte[(r.length > s.length ? r.length * 2 : s.length * 2)];
System.arraycopy(s, 0, sigBytes, (sigBytes.length / 2) - s.length, s.length);
System.arraycopy(r, 0, sigBytes, sigBytes.length - r.length, r.length);
return new DEROctetString(sigBytes).getEncoded();
}
catch (Exception e)
{
throw new SignatureException(e.toString());
}
}