Package codec.pkcs1

Examples of codec.pkcs1.DigestInfo


        try
        {
            byte[] res = calculatePbeMac(id_SHA1, mSalt, itCount, password, false, data);

            AlgorithmIdentifier algId = new AlgorithmIdentifier(id_SHA1, DERNull.INSTANCE);
            DigestInfo dInfo = new DigestInfo(algId, res);

            mData = new MacData(dInfo, mSalt, itCount);
        }
        catch (Exception e)
        {
View Full Code Here


    private byte[] derEncode(
        byte[] hash)
        throws IOException
    {
        DigestInfo dInfo = new DigestInfo(algId, hash);

        return dInfo.getEncoded(ASN1Encoding.DER);
    }
View Full Code Here

    public OtherCertID(
        AlgorithmIdentifier  algId,
        byte[]               digest)
    {
        this.otherCertHash = new DigestInfo(algId, digest);
    }
View Full Code Here

    public OtherCertID(
        AlgorithmIdentifier  algId,
        byte[]               digest,
        IssuerSerial    issuerSerial)
    {
        this.otherCertHash = new DigestInfo(algId, digest);
        this.issuerSerial = issuerSerial;
    }
View Full Code Here

    }

    private byte[] derEncode(
        byte[] hash)
    {
        DigestInfo dInfo = new DigestInfo(algId, hash);

        return dInfo.getDEREncoded();
    }
View Full Code Here

        boolean         wrongPKCS12Zero = false;

        if (bag.getMacData() != null)           // check the mac code
        {
            MacData                     mData = bag.getMacData();
            DigestInfo                  dInfo = mData.getMac();
            AlgorithmIdentifier         algId = dInfo.getAlgorithmId();
            byte[]                      salt = mData.getSalt();
            int                         itCount = mData.getIterationCount().intValue();

            byte[]  data = ((ASN1OctetString)info.getContent()).getOctets();

            try
            {
                byte[] res = calculatePbeMac(algId.getObjectId(), salt, itCount, password, false, data);
                byte[] dig = dInfo.getDigest();

                if (!Arrays.areEqual(res, dig))
                {
                    if (password.length > 0)
                    {
View Full Code Here

        try
        {
            byte[] res = calculatePbeMac(id_SHA1, mSalt, itCount, password, false, data);

            AlgorithmIdentifier     algId = new AlgorithmIdentifier(id_SHA1, new DERNull());
            DigestInfo              dInfo = new DigestInfo(algId, res);

            mData = new MacData(dInfo, mSalt, itCount);
        }
        catch (Exception e)
        {
View Full Code Here

    private byte[] derEncode(
        byte[]  hash)
        throws IOException
    {
        DigestInfo              dInfo = new DigestInfo(algId, hash);

        return dInfo.getEncoded(ASN1Encodable.DER);
    }
View Full Code Here

            ASN1InputStream     aIn = new ASN1InputStream(new ByteArrayInputStream(pkcs12));
            ASN1Sequence        obj = (ASN1Sequence)aIn.readObject();
            Pfx                 bag = new Pfx(obj);
            ContentInfo         info = bag.getAuthSafe();
            MacData             mData = bag.getMacData();
            DigestInfo          dInfo = mData.getMac();
            AlgorithmIdentifier algId = dInfo.getAlgorithmId();
            byte[]              salt = mData.getSalt();
            int                 itCount = mData.getIterationCount().intValue();

            aIn = new ASN1InputStream(new ByteArrayInputStream(((ASN1OctetString)info.getContent()).getOctets()));

            AuthenticatedSafe   authSafe = new AuthenticatedSafe((ASN1Sequence)aIn.readObject());
            ContentInfo[]       c = authSafe.getContentInfo();

            //
            // private key section
            //
            if (!c[0].getContentType().equals(PKCSObjectIdentifiers.data))
            {
                return new SimpleTestResult(false, getName() + ": failed comparison data test");
            }
           
            aIn = new ASN1InputStream(new ByteArrayInputStream(((ASN1OctetString)c[0].getContent()).getOctets()));
            ASN1Sequence    seq = (ASN1Sequence)aIn.readObject();
           
            SafeBag b = new SafeBag((ASN1Sequence)seq.getObjectAt(0));
            if (!b.getBagId().equals(PKCSObjectIdentifiers.pkcs8ShroudedKeyBag))
            {
                return new SimpleTestResult(false, getName() + ": failed comparison shroudedKeyBag test");
            }
           
            EncryptedPrivateKeyInfo encInfo = EncryptedPrivateKeyInfo.getInstance((ASN1Sequence)b.getBagValue());
           
            encInfo = new EncryptedPrivateKeyInfo(encInfo.getEncryptionAlgorithm(), encInfo.getEncryptedData());
           
            b = new SafeBag(PKCSObjectIdentifiers.pkcs8ShroudedKeyBag, encInfo.toASN1Object(), b.getBagAttributes());
           
            ByteArrayOutputStream abOut = new ByteArrayOutputStream();
            ASN1OutputStream      berOut = new ASN1OutputStream(abOut);
           
            berOut.writeObject(new DERSequence(b));
           
            c[0] = new ContentInfo(PKCSObjectIdentifiers.data, new BERConstructedOctetString(abOut.toByteArray()));
           
            //
            // certificates
            //
            if (!c[1].getContentType().equals(PKCSObjectIdentifiers.encryptedData))
            {
                return new SimpleTestResult(false, getName() + ": failed comparison encryptedData test");
            }
           
            EncryptedData   eData = EncryptedData.getInstance(c[1].getContent());
           
            c[1] = new ContentInfo(PKCSObjectIdentifiers.encryptedData, eData);
           
            //
            // create an octet stream represent the BER encoding of authSafe
            //
            authSafe = new AuthenticatedSafe(c);
           
            abOut = new ByteArrayOutputStream();
            berOut = new ASN1OutputStream(abOut);

            berOut.writeObject(authSafe);
           
            info = new ContentInfo(PKCSObjectIdentifiers.data, new BERConstructedOctetString(abOut.toByteArray()));
           
            mData = new MacData(new DigestInfo(algId, dInfo.getDigest()), salt, itCount);
           
            bag = new Pfx(info, mData);

            //
            // comparison test
View Full Code Here

        boolean         wrongPKCS12Zero = false;

        if (bag.getMacData() != null)           // check the mac code
        {
            MacData                     mData = bag.getMacData();
            DigestInfo                  dInfo = mData.getMac();
            AlgorithmIdentifier         algId = dInfo.getAlgorithmId();
            byte[]                      salt = mData.getSalt();
            int                         itCount = mData.getIterationCount().intValue();

            byte[]  data = ((ASN1OctetString)info.getContent()).getOctets();

            try
            {
                byte[] res = calculatePbeMac(algId.getObjectId(), salt, itCount, password, false, data);
                byte[] dig = dInfo.getDigest();

                if (!Arrays.constantTimeAreEqual(res, dig))
                {
                    if (password.length > 0)
                    {
View Full Code Here

TOP

Related Classes of codec.pkcs1.DigestInfo

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.