Examples of CMSMessageSignatureServiceException


Examples of javax.microedition.securityservice.CMSMessageSignatureServiceException

                     .JSR177_STRING_TO_SIGN) +
         string, true) != 1) {
                    return null;
                }
            } catch (InterruptedException e) {
                throw new CMSMessageSignatureServiceException(
                        CMSMessageSignatureServiceException.SE_FAILURE);
            }

            data = Utils.stringToBytes(string);
        }
View Full Code Here

Examples of javax.microedition.securityservice.CMSMessageSignatureServiceException

            throw new SecurityException("PIN blocked");
        }

        if (pinStatus != PIN_DISABLED) {
            // IMPL_NOTE: need warning message?
            throw new CMSMessageSignatureServiceException(
                 CMSMessageSignatureServiceException.SE_CRYPTO_FAILURE);
        }

        // PIN is verified, create the CSR

        TLV CRInfo = TLV.createSequence();

        CRInfo.setChild(TLV.createInteger(0)).
            setNext(name).
            setNext(keyValue).
            setNext(new TLV(TLV.SET_TYPE).setTag(0xa0)).
            setChild(TLV.createSequence()).
            setChild(TLV.createOID("1.2.840.113549.1.9.14")).
            setNext(new TLV(TLV.SET_TYPE)).
            setChild(TLV.createSequence()).
            setChild(TLV.createSequence()).
            setChild(TLV.createOID("2.5.29.15")).
            setNext(new TLV(TLV.BOOLEAN_TYPE, new byte[] {(byte) 255})).
            setNext(new TLV(TLV.OCTETSTR_TYPE,
                keyUsage == UserCredentialManager.KEY_USAGE_AUTHENTICATION ?
                new byte[] {3, 2, 7, (byte) 0x80} :
                new byte[] {3, 2, 6, 0x40}));

        byte[] sign;

        try {
            sign = signData(key, CRInfo.getDERData());
        } catch (IOException e) {
            throw new CMSMessageSignatureServiceException(
                 CMSMessageSignatureServiceException.SE_CRYPTO_FAILURE);
        }

        TLV alg = CRInfo.child.next.next.child.copy();
View Full Code Here

Examples of javax.microedition.securityservice.CMSMessageSignatureServiceException

        // load existing certificates
        try {
            loadPrivateKeys();
            loadCertificates(true, true);
        } catch (IOException e) {
            throw new CMSMessageSignatureServiceException(
                    CMSMessageSignatureServiceException.SE_FAILURE);
        }

        // find certificate chains
        Vector chains = getChains(nonRepudiation, caNames);
        if (chains.size() == 0) {
            throw new CMSMessageSignatureServiceException(
             CMSMessageSignatureServiceException.CRYPTO_NO_CERTIFICATE);
        }

        // select certificate
        Vector chain = selectChain(chains);
        if (chain == null) {
            return null;
        }

        Certificate cert = (Certificate) chain.elementAt(0);
        PrivateKey key = getPrivateKey(cert.id);
        PINAttributes pin = getPIN(key.authId);

        int pinStatus = checkPIN(pin);

        if (pinStatus == PIN_BLOCKED) {
            throw new SecurityException();
        }

        if (pinStatus == PIN_CANCELLED) {
            return null;
        }

        TLV signedAttrs = new TLV(TLV.SET_TYPE);
        TLV t = signedAttrs.setChild(TLV.createSequence());
        t.setChild(TLV.createOID("1.2.840.113549.1.9.3")). // ContentType
          setNext(new TLV(TLV.SET_TYPE)).
          setChild(TLV.createOID("1.2.840.113549.1.7.1"))// data

        t.next = TLV.createSequence();
        t = t.next;

        Calendar calendar = Calendar.getInstance();
        calendar.setTimeZone(TimeZone.getTimeZone("GMT"));

        t.setChild(TLV.createOID("1.2.840.113549.1.9.5")). // signingTime
          setNext(new TLV(TLV.SET_TYPE)).
          setChild(TLV.createUTCTime(calendar));

        t.next = TLV.createSequence();
        t = t.next;

        t.setChild(TLV.createOID("1.2.840.113549.1.9.4")). // messageDigest
          setNext(new TLV(TLV.SET_TYPE)).
          setChild(TLV.createOctetString(Utils.getHash(data, 0, data.length)));

        // generate signature
        byte[] signature;
        try {
            signature = signData(key, signedAttrs.getDERData());
        } catch (IOException e) {
            throw new CMSMessageSignatureServiceException(
             CMSMessageSignatureServiceException.CRYPTO_FAILURE);
        }

        // format the signature
        /*
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.