Package sun.security.util

Examples of sun.security.util.DerValue


     *
     * @param out the DER stream to encode the X400Address to.
     * @exception IOException on encoding errors.
     */
    public void encode(DerOutputStream out) throws IOException {
        DerValue derValue = new DerValue(nameValue);
        out.putDerValue(derValue);
    }
View Full Code Here


            throw new IOException("Invalid encoding of PolicyInformation");
        }
        policyIdentifier = new CertificatePolicyId(val.data.getDerValue());
        if (val.data.available() != 0) {
            policyQualifiers = new LinkedHashSet<PolicyQualifierInfo>();
            DerValue opt = val.data.getDerValue();
            if (opt.tag != DerValue.tag_Sequence)
                throw new IOException("Invalid encoding of PolicyInformation");
            if (opt.data.available() == 0)
                throw new IOException("No data available in policyQualifiers");
            while (opt.data.available() != 0)
View Full Code Here

        gns.add(new GeneralName(new DNSName("dns")));
        DerOutputStream out;

        // length should be 5 since only {T,F,T} should be encoded
        KeyUsageExtension x1 = new KeyUsageExtension(bb);
        check(new DerValue(x1.getExtensionValue()).getUnalignedBitString().length(), 3);

        NetscapeCertTypeExtension x2 = new NetscapeCertTypeExtension(bb);
        check(new DerValue(x2.getExtensionValue()).getUnalignedBitString().length(), 3);

        ReasonFlags r = new ReasonFlags(bb);
        out = new DerOutputStream();
        r.encode(out);
        check(new DerValue(out.toByteArray()).getUnalignedBitString().length(), 3);

        // Read sun.security.x509.DistributionPoint for ASN.1 definition
        DistributionPoint dp = new DistributionPoint(gns, bb, gns);
        out = new DerOutputStream();
        dp.encode(out);
        DerValue v = new DerValue(out.toByteArray());
        // skip distributionPoint
        v.data.getDerValue();
        // read reasons
        DerValue v2 = v.data.getDerValue();
        // reset to BitString since it's context-specfic[1] encoded
        v2.resetTag(DerValue.tag_BitString);
        // length should be 5 since only {T,F,T} should be encoded
        check(v2.getUnalignedBitString().length(), 3);

        BitArray ba;
        ba = new BitArray(new boolean[] {false, false, false});
        check(ba.length(), 3);
        ba = ba.truncate();
View Full Code Here

    {
        if (encoded == null) {
            throw new IllegalArgumentException("encoding must not be null");
        }

        DerValue val = new DerValue(encoded);

        DerValue[] seq = new DerValue[2];

        seq[0] = val.data.getDerValue();
        seq[1] = val.data.getDerValue();
View Full Code Here

    }

    public void parse(byte[] bytes) throws IOException {

        // Parse signingCertificate
        DerValue derValue = new DerValue(bytes);
        if (derValue.tag != DerValue.tag_Sequence) {
            throw new IOException("Bad encoding for signingCertificate");
        }

        // Parse certs
View Full Code Here

        // Parse certHash
        certHash = certId.data.getDerValue().toByteArray();

        // Parse issuerSerial, if present
        if (certId.data.available() > 0) {
            DerValue issuerSerial = certId.data.getDerValue();
            // Parse issuer
            issuer = new GeneralNames(issuerSerial.data.getDerValue());
            // Parse serialNumber
            serialNumber = new SerialNumber(issuerSerial.data.getDerValue());
        }
View Full Code Here

                if (extVal == null) {
                    return true;
                }
                DerInputStream in = new DerInputStream(extVal);
                byte[] encoded = in.getOctetString();
                encoded = new DerValue(encoded).getUnalignedBitString()
                                                                .toByteArray();
                ext = new NetscapeCertTypeExtension(encoded);
            }
            Boolean val = (Boolean)ext.get(type);
            return val.booleanValue();
View Full Code Here

            };
            fetchAttributes(attributes);
            try {
                params = P11ECKeyFactory.decodeParameters
                            (attributes[1].getByteArray());
                DerValue wECPoint = new DerValue(attributes[0].getByteArray());
                if (wECPoint.getTag() != DerValue.tag_OctetString)
                    throw new IOException("Unexpected tag: " +
                        wECPoint.getTag());
                params = P11ECKeyFactory.decodeParameters
                            (attributes[1].getByteArray());
                w = P11ECKeyFactory.decodePoint
                    (wECPoint.getDataBytes(), params.getCurve());


            } catch (Exception e) {
                throw new RuntimeException("Could not parse key values", e);
            }
View Full Code Here

    }

    private PublicKey generatePublic(ECPoint point, ECParameterSpec params) throws PKCS11Exception {
        byte[] encodedParams = ECParameters.encodeParameters(params);
        byte[] encodedPoint = null;
        DerValue pkECPoint = new DerValue(DerValue.tag_OctetString,
            ECParameters.encodePoint(point, params.getCurve()));

        try {
            encodedPoint = pkECPoint.toByteArray();
        } catch (IOException e) {
            throw new IllegalArgumentException("Could not DER encode point", e);
        }

        CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTE[] {
View Full Code Here

                        (PrivateKeyCallback.SubjectKeyIDRequest)req;
                byte[] subjectKeyID = skReq.getSubjectKeyID();
                if (subjectKeyID != null) {
                    boolean found = false;
                    // In DER, subjectKeyID will be an OCTET STRING of OCTET STRING
                    DerValue derValue1 = new DerValue(
                        DerValue.tag_OctetString, subjectKeyID);
                    DerValue derValue2 = new DerValue(
                        DerValue.tag_OctetString, derValue1.toByteArray());
                    byte[] derSubjectKeyID = derValue2.toByteArray();

                    for (int i = 0; i < kstores.length && !found; i++) {
                        Enumeration aliases = kstores[i].aliases();
                        while (aliases.hasMoreElements() && !found) {
                            String nextAlias = (String)aliases.nextElement();
View Full Code Here

TOP

Related Classes of sun.security.util.DerValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.