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


Java DerOutputStream类代码示例

本文整理汇总了Java中sun.security.util.DerOutputStream的典型用法代码示例。如果您正苦于以下问题:Java DerOutputStream类的具体用法?Java DerOutputStream怎么用?Java DerOutputStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DerOutputStream类属于sun.security.util包,在下文中一共展示了DerOutputStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: encode

import sun.security.util.DerOutputStream; //导入依赖的package包/类
/**
 * Encodes the distribution point name and writes it to the DerOutputStream.
 *
 * @param out the output stream.
 * @exception IOException on encoding error.
 */
public void encode(DerOutputStream out) throws IOException {

    DerOutputStream theChoice = new DerOutputStream();

    if (fullName != null) {
        fullName.encode(theChoice);
        out.writeImplicit(
            DerValue.createTag(DerValue.TAG_CONTEXT, true, TAG_FULL_NAME),
            theChoice);

    } else {
        relativeName.encode(theChoice);
        out.writeImplicit(
            DerValue.createTag(DerValue.TAG_CONTEXT, true,
                TAG_RELATIVE_NAME),
            theChoice);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:DistributionPointName.java

示例2: NamedCurve

import sun.security.util.DerOutputStream; //导入依赖的package包/类
NamedCurve(String name, String oid, EllipticCurve curve,
        ECPoint g, BigInteger n, int h) {
    super(curve, g, n, h);
    this.name = name;
    this.oid = oid;

    DerOutputStream out = new DerOutputStream();

    try {
        out.putOID(new ObjectIdentifier(oid));
    } catch (IOException e) {
        throw new RuntimeException("Internal error", e);
    }

    encoded = out.toByteArray();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:NamedCurve.java

示例3: getEncoded

import sun.security.util.DerOutputStream; //导入依赖的package包/类
/**
 * Returns the ASN.1 encoding of this class.
 */
public byte[] getEncoded()
    throws IOException
{
    if (this.encoded != null) return this.encoded.clone();

    DerOutputStream out = new DerOutputStream();
    DerOutputStream tmp = new DerOutputStream();

    // encode encryption algorithm
    algid.encode(tmp);

    // encode encrypted data
    tmp.putOctetString(encryptedData);

    // wrap everything into a SEQUENCE
    out.write(DerValue.tag_Sequence, tmp);
    this.encoded = out.toByteArray();

    return this.encoded.clone();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:EncryptedPrivateKeyInfo.java

示例4: setSkiAndSerialNumber

import sun.security.util.DerOutputStream; //导入依赖的package包/类
/**
 * Sets the subjectKeyIdentifier and serialNumber criteria from the
 * authority key identifier extension.
 *
 * The subjectKeyIdentifier criterion is set to the keyIdentifier field
 * of the extension, or null if it is empty. The serialNumber criterion
 * is set to the authorityCertSerialNumber field, or null if it is empty.
 *
 * Note that we do not set the subject criterion to the
 * authorityCertIssuer field of the extension. The caller MUST set
 * the subject criterion before calling match().
 *
 * @param ext the authorityKeyIdentifier extension
 * @throws IOException if there is an error parsing the extension
 */
void setSkiAndSerialNumber(AuthorityKeyIdentifierExtension ext)
    throws IOException {

    ski = null;
    serial = null;

    if (ext != null) {
        KeyIdentifier akid = (KeyIdentifier)ext.get(
            AuthorityKeyIdentifierExtension.KEY_ID);
        if (akid != null) {
            DerOutputStream derout = new DerOutputStream();
            derout.putOctetString(akid.getIdentifier());
            ski = derout.toByteArray();
        }
        SerialNumber asn = (SerialNumber)ext.get(
            AuthorityKeyIdentifierExtension.SERIAL_NUMBER);
        if (asn != null) {
            serial = asn.getNumber();
        }
        // the subject criterion should be set by the caller
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:38,代码来源:AdaptableX509CertSelector.java

示例5: engineSign

import sun.security.util.DerOutputStream; //导入依赖的package包/类
/**
 * Sign all the data thus far updated. The signature is formatted
 * according to the Canonical Encoding Rules, returned as a DER
 * sequence of Integer, r and s.
 *
 * @return a signature block formatted according to the Canonical
 * Encoding Rules.
 *
 * @exception SignatureException if the signature object was not
 * properly initialized, or if another exception occurs.
 *
 * @see sun.security.DSA#engineUpdate
 * @see sun.security.DSA#engineVerify
 */
protected byte[] engineSign() throws SignatureException {
    BigInteger k = generateK(presetQ);
    BigInteger r = generateR(presetP, presetQ, presetG, k);
    BigInteger s = generateS(presetX, presetQ, r, k);

    try {
        DerOutputStream outseq = new DerOutputStream(100);
        outseq.putInteger(r);
        outseq.putInteger(s);
        DerValue result = new DerValue(DerValue.tag_Sequence,
                                       outseq.toByteArray());

        return result.toByteArray();

    } catch (IOException e) {
        throw new SignatureException("error encoding signature");
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:DSA.java

示例6: getEncoded

import sun.security.util.DerOutputStream; //导入依赖的package包/类
/**
 * Returns the ASN.1 encoding of this object.
 * @return the ASN.1 encoding. Returns a new array
 * each time this method is called.
 * @exception IOException if error occurs when constructing its
 * ASN.1 encoding.
 */
public byte[] getEncoded() throws IOException {
    if (this.encoded == null) {
        DerOutputStream out = new DerOutputStream();
        DerOutputStream tmp = new DerOutputStream();

        // encode encryption algorithm
        algid.encode(tmp);

        // encode encrypted data
        tmp.putOctetString(encryptedData);

        // wrap everything into a SEQUENCE
        out.write(DerValue.tag_Sequence, tmp);
        this.encoded = out.toByteArray();
    }
    return this.encoded.clone();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:EncryptedPrivateKeyInfo.java

示例7: encodeTbsResponse

import sun.security.util.DerOutputStream; //导入依赖的package包/类
private byte[] encodeTbsResponse() throws IOException {
    DerOutputStream outerSeq = new DerOutputStream();
    DerOutputStream tbsStream = new DerOutputStream();

    // Note: We're not going explicitly assert the version
    tbsStream.write(respId.getEncoded());
    tbsStream.putGeneralizedTime(producedAtDate);

    // Sequence of responses
    encodeSingleResponses(tbsStream);

    // TODO: add response extension support
    encodeExtensions(tbsStream);

    outerSeq.write(DerValue.tag_Sequence, tbsStream);
    return outerSeq.toByteArray();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:SimpleOCSPServer.java

示例8: ECPrivateKeyImpl

import sun.security.util.DerOutputStream; //导入依赖的package包/类
/**
 * Construct a key from its components. Used by the
 * KeyFactory.
 */
ECPrivateKeyImpl(BigInteger s, ECParameterSpec params)
        throws InvalidKeyException {
    this.s = s;
    this.params = params;
    // generate the encoding
    algid = new AlgorithmId
        (AlgorithmId.EC_oid, ECParameters.getAlgorithmParameters(params));
    try {
        DerOutputStream out = new DerOutputStream();
        out.putInteger(1); // version 1
        byte[] privBytes = ECUtil.trimZeroes(s.toByteArray());
        out.putOctetString(privBytes);
        DerValue val =
            new DerValue(DerValue.tag_Sequence, out.toByteArray());
        key = val.toByteArray();
    } catch (IOException exc) {
        // should never occur
        throw new InvalidKeyException(exc);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:ECPrivateKeyImpl.java

示例9: send

import sun.security.util.DerOutputStream; //导入依赖的package包/类
/**
 * Send the encoded {@code OCSPStatusRequest} out through the provided
 *      {@code HandshakeOutputStream}
 *
 * @param s the {@code HandshakeOutputStream} on which to send the encoded
 *      data
 *
 * @throws IOException if any encoding errors occur
 */
@Override
public void send(HandshakeOutStream s) throws IOException {
    s.putInt16(ridListLen);
    for (ResponderId rid : responderIds) {
        s.putBytes16(rid.getEncoded());
    }

    DerOutputStream seqOut = new DerOutputStream();
    DerOutputStream extBytes = new DerOutputStream();

    if (extensions.size() > 0) {
        for (Extension ext : extensions) {
            ext.encode(extBytes);
        }
        seqOut.write(DerValue.tag_Sequence, extBytes);
    }
    s.putBytes16(seqOut.toByteArray());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:OCSPStatusRequest.java

示例10: derEncode

import sun.security.util.DerOutputStream; //导入依赖的package包/类
/**
 * DER encode this object onto an output stream.
 * Implements the {@code DerEncoder} interface.
 *
 * @param out
 * the output stream on which to write the DER encoding.
 *
 * @exception IOException on encoding error.
 */
public void derEncode(OutputStream out) throws IOException {
    DerOutputStream seq = new DerOutputStream();
    seq.putInteger(version);
    DerOutputStream issuerAndSerialNumber = new DerOutputStream();
    issuerName.encode(issuerAndSerialNumber);
    issuerAndSerialNumber.putInteger(certificateSerialNumber);
    seq.write(DerValue.tag_Sequence, issuerAndSerialNumber);

    digestAlgorithmId.encode(seq);

    // encode authenticated attributes if there are any
    if (authenticatedAttributes != null)
        authenticatedAttributes.encode((byte)0xA0, seq);

    digestEncryptionAlgorithmId.encode(seq);

    seq.putOctetString(encryptedDigest);

    // encode unauthenticated attributes if there are any
    if (unauthenticatedAttributes != null)
        unauthenticatedAttributes.encode((byte)0xA1, seq);

    DerOutputStream tmp = new DerOutputStream();
    tmp.write(DerValue.tag_Sequence, seq);

    out.write(tmp.toByteArray());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:SignerInfo.java

示例11: encode

import sun.security.util.DerOutputStream; //导入依赖的package包/类
/**
 * Write the PolicyInformation to the DerOutputStream.
 *
 * @param out the DerOutputStream to write the extension to.
 * @exception IOException on encoding errors.
 */
public void encode(DerOutputStream out) throws IOException {
    DerOutputStream tmp = new DerOutputStream();
    policyIdentifier.encode(tmp);
    if (!policyQualifiers.isEmpty()) {
        DerOutputStream tmp2 = new DerOutputStream();
        for (PolicyQualifierInfo pq : policyQualifiers) {
            tmp2.write(pq.getEncoded());
        }
        tmp.write(DerValue.tag_Sequence, tmp2);
    }
    out.write(DerValue.tag_Sequence, tmp);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:PolicyInformation.java

示例12: encodeThis

import sun.security.util.DerOutputStream; //导入依赖的package包/类
private void encodeThis() throws IOException {
    if (certPolicies == null || certPolicies.isEmpty()) {
        this.extensionValue = null;
    } else {
        DerOutputStream os = new DerOutputStream();
        DerOutputStream tmp = new DerOutputStream();

        for (PolicyInformation info : certPolicies) {
            info.encode(tmp);
        }

        os.write(DerValue.tag_Sequence, tmp);
        this.extensionValue = os.toByteArray();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:CertificatePoliciesExtension.java

示例13: calculateMac

import sun.security.util.DerOutputStream; //导入依赖的package包/类
private byte[] calculateMac(char[] passwd, byte[] data)
    throws IOException
{
    byte[] mData = null;
    String algName = "SHA1";

    try {
        // Generate a random salt.
        byte[] salt = getSalt();

        // generate MAC (MAC key is generated within JCE)
        Mac m = Mac.getInstance("HmacPBESHA1");
        PBEParameterSpec params =
                    new PBEParameterSpec(salt, iterationCount);
        SecretKey key = getPBEKey(passwd);
        m.init(key, params);
        m.update(data);
        byte[] macResult = m.doFinal();

        // encode as MacData
        MacData macData = new MacData(algName, macResult, salt,
                                            iterationCount);
        DerOutputStream bytes = new DerOutputStream();
        bytes.write(macData.getEncoded());
        mData = bytes.toByteArray();
    } catch (Exception e) {
        throw new IOException("calculateMac failed: " + e, e);
    }
    return mData;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:PKCS12KeyStore.java

示例14: encode

import sun.security.util.DerOutputStream; //导入依赖的package包/类
/**
 * Write the extension to the DerOutputStream.
 *
 * @param out the DerOutputStream to write the extension to.
 * @exception IOException on encoding errors.
 */
public void encode(OutputStream out) throws IOException {
    DerOutputStream tmp = new DerOutputStream();
    if (this.extensionValue == null) {
        this.extensionId = PKIXExtensions.SubjectInfoAccess_Id;
        this.critical = false;
        encodeThis();
    }
    super.encode(tmp);
    out.write(tmp.toByteArray());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:SubjectInfoAccessExtension.java

示例15: encodeThis

import sun.security.util.DerOutputStream; //导入依赖的package包/类
private void encodeThis() throws IOException {
    if (accessDescriptions.isEmpty()) {
        this.extensionValue = null;
    } else {
        DerOutputStream ads = new DerOutputStream();
        for (AccessDescription accessDescription : accessDescriptions) {
            accessDescription.encode(ads);
        }
        DerOutputStream seq = new DerOutputStream();
        seq.write(DerValue.tag_Sequence, ads);
        this.extensionValue = seq.toByteArray();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:SubjectInfoAccessExtension.java


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