当前位置: 首页>>代码示例>>Java>>正文


Java DEROctetString类代码示例

本文整理汇总了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);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:32,代码来源:RespID.java

示例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);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:18,代码来源:McElieceCCA2PublicKey.java

示例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);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:22,代码来源:ECDHKEKGenerator.java

示例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);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:25,代码来源:ECPrivateKeyStructure.java

示例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);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:21,代码来源:AuthorityKeyIdentifier.java

示例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);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:19,代码来源:V2TBSCertListGenerator.java

示例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);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:17,代码来源:V2TBSCertListGenerator.java

示例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);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:10,代码来源:DigestInfo.java

示例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;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:22,代码来源:ECDSAPublicKey.java

示例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);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:18,代码来源:CVCertificateRequest.java

示例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);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:25,代码来源:CVCertificate.java

示例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);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:21,代码来源:DSTU4145Params.java

示例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()));
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:17,代码来源:DSTU4145ECBinary.java

示例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();
}
 
开发者ID:xipki,项目名称:xitk,代码行数:18,代码来源:ProxyP11Identity.java

示例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());
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:25,代码来源:SignatureSpi.java


注:本文中的org.bouncycastle.asn1.DEROctetString类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。