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


Java DERApplicationSpecific.getObject方法代码示例

本文整理汇总了Java中org.bouncycastle.asn1.DERApplicationSpecific.getObject方法的典型用法代码示例。如果您正苦于以下问题:Java DERApplicationSpecific.getObject方法的具体用法?Java DERApplicationSpecific.getObject怎么用?Java DERApplicationSpecific.getObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bouncycastle.asn1.DERApplicationSpecific的用法示例。


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

示例1: parseNonce

import org.bouncycastle.asn1.DERApplicationSpecific; //导入方法依赖的package包/类
private byte[] parseNonce(byte[] data) {
    try (ASN1InputStream bIn = new ASN1InputStream(data)) {
        DERApplicationSpecific app = (DERApplicationSpecific) bIn.readObject();

        ASN1Sequence seq = (ASN1Sequence) app.getObject(BERTags.SEQUENCE);

        byte[] tag80 = ((ASN1Primitive) seq.getObjects().nextElement()).getEncoded();

        if (tag80[0] == (byte) 0x80) {

            MessageDigest md = MessageDigest.getInstance("SHA-256");
            byte[] kpi =  md.digest(Bytes.concatenate(CAN.getBytes(), Bytes.bytes("00 00 00 03")));

            return AESUtils.decryptAESCBC(Bytes.allButFirst(tag80, 2), kpi);
        }
    } catch (IOException | NoSuchAlgorithmException e) {
        Log.e(getClass().getName(), "Failed to parse nonce from response data", e);
    }

    return null;
}
 
开发者ID:mDL-ILP,项目名称:mDL-ILP,代码行数:22,代码来源:PACEAPDUInterface.java

示例2: parse7F63

import org.bouncycastle.asn1.DERApplicationSpecific; //导入方法依赖的package包/类
private void parse7F63(byte[] input) {
    Log.d("input", ByteUtils.bytesToHex(input));
    try (ASN1InputStream bIn = new ASN1InputStream(input)) {
        ASN1Primitive obj = bIn.readObject();
        DERApplicationSpecific app = (DERApplicationSpecific) obj;
        ASN1Sequence seq = (ASN1Sequence) app.getObject(BERTags.SEQUENCE);
        Enumeration secEnum = seq.getObjects();
        List<byte[]> categories = new ArrayList<>();
        while (secEnum.hasMoreElements()) {
            ASN1Primitive seqObj = (ASN1Primitive) secEnum.nextElement();
            byte[] data = seqObj.getEncoded();
            Log.d("5F02data", ByteUtils.bytesToHex(data));
            switch (data[0]) {
                case 0x02:
                    Log.d("#CATEGORY","number of categories:" + data[data.length-1]);
                    break;
                case (byte) 0x87:
                    categories.add(Arrays.copyOfRange(data, 2, data.length));
                    break;
            }
        }
        this.set7F63(categories);
    } catch (IOException e) {
        Log.e(getClass().getName(), e.getMessage(), e);
    }
}
 
开发者ID:mDL-ILP,项目名称:mDL-ILP,代码行数:27,代码来源:DrivingLicence.java

示例3: parseDG11

import org.bouncycastle.asn1.DERApplicationSpecific; //导入方法依赖的package包/类
private void parseDG11(byte[] DG11) {
    try (ASN1InputStream bIn = new ASN1InputStream(DG11)) {
        DERApplicationSpecific app = (DERApplicationSpecific) bIn.readObject();

        ASN1Sequence seq = (ASN1Sequence) app.getObject(BERTags.SEQUENCE);
        Enumeration secEnum = seq.getObjects();
        while (secEnum.hasMoreElements()) {
            ASN1Primitive seqObj = (ASN1Primitive) secEnum.nextElement();
            byte[] data = seqObj.getEncoded();
            if (data[0]== 0x7F) {
                parseDG11(data);
            } else if (data[0] == (byte) 0x80) {
                this.setBSN(Arrays.copyOfRange(data, 2, data.length));
            }
        }
    } catch (IOException e) {
        Log.e(getClass().getName(), e.getMessage(), e);
    }
}
 
开发者ID:mDL-ILP,项目名称:mDL-ILP,代码行数:20,代码来源:DrivingLicence.java

示例4: asApplicationSpecific

import org.bouncycastle.asn1.DERApplicationSpecific; //导入方法依赖的package包/类
static ASN1Primitive asApplicationSpecific(int tag, ASN1Encodable encodable) {
    try {
        DERApplicationSpecific specific = as(DERApplicationSpecific.class, encodable);

        if (specific.getApplicationTag() == tag) {
            return specific.getObject();

        } else {
            throw new IllegalArgumentException(
                    "tag mismatch, expected " + tag + " got " + specific.getApplicationTag());
        }

    } catch (IOException ex) {
        throw new IllegalArgumentException(ex);
    }
}
 
开发者ID:horrorho,项目名称:InflatableDonkey,代码行数:17,代码来源:DER.java

示例5: parse7F63

import org.bouncycastle.asn1.DERApplicationSpecific; //导入方法依赖的package包/类
private void parse7F63(byte[] input) {
    Log.d("input", ByteUtils.bytesToHex(input));
    try {
        ASN1InputStream bIn = new ASN1InputStream(input);
        ASN1Primitive obj = bIn.readObject();
        DERApplicationSpecific app = (DERApplicationSpecific) obj;
        ASN1Sequence seq = (ASN1Sequence) app.getObject(BERTags.SEQUENCE);
        Enumeration secEnum = seq.getObjects();
        List<byte[]> categories = new ArrayList<>();
        while (secEnum.hasMoreElements()) {
            ASN1Primitive seqObj = (ASN1Primitive) secEnum.nextElement();
            byte[] data = seqObj.getEncoded();
            Log.d("5F02data", ByteUtils.bytesToHex(data));
            switch (data[0]) {
                case 0x02:
                    Log.d("#CATEGORY","number of categories:" + data[data.length-1]);
                    break;
                case (byte) 0x87:
                    categories.add(Arrays.copyOfRange(data, 2, data.length));
                    break;
            }
        }
        bIn.close();
        this.set7F63(categories);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
 
开发者ID:mDL-ILP,项目名称:mDL-ILP,代码行数:30,代码来源:DrivingLicence.java

示例6: parseDG15

import org.bouncycastle.asn1.DERApplicationSpecific; //导入方法依赖的package包/类
private void parseDG15(byte[] DG15) {

        try (ASN1InputStream bIn = new ASN1InputStream(DG15)) {
            DERApplicationSpecific app = (DERApplicationSpecific) bIn.readObject();

            ASN1Sequence seq = (ASN1Sequence) app.getObject(BERTags.SEQUENCE);
            byte[] data = ((ASN1Primitive)seq.getObjects().nextElement()).getEncoded();

            Log.d(getClass().getName(), "Data = "+ Bytes.hexString(data));

            try (ASN1InputStream in = new ASN1InputStream(data)) {
                Enumeration seq1 = ((DLSequence) in.readObject()).getObjects();

                while (seq1.hasMoreElements()) {
                    ASN1Primitive obj = (ASN1Primitive)seq1.nextElement();
                    byte[] data1 = obj.getEncoded();
                    Log.d(getClass().getName(), "data1 = "+ Bytes.hexString(data1));

                    if (data1[0] == (byte) 0x01) {
                        this.set18(data1[2] == 0x01);
                    } else if (data1[0] == (byte) 0x02) {
                        this.setAge(Bytes.toInt(data1[2]));
                    }
                }
            }
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
 
开发者ID:mDL-ILP,项目名称:mDL-ILP,代码行数:31,代码来源:DrivingLicence.java

示例7: parseDG16

import org.bouncycastle.asn1.DERApplicationSpecific; //导入方法依赖的package包/类
private void parseDG16(byte[] DG16) {

        try (ASN1InputStream bIn = new ASN1InputStream(DG16)) {
            DERApplicationSpecific app = (DERApplicationSpecific) bIn.readObject();

            ASN1Sequence seq = (ASN1Sequence) app.getObject(BERTags.SEQUENCE);
            byte[] data = ((ASN1Primitive)seq.getObjects().nextElement()).getEncoded();

            Log.d(getClass().getName(), "Data = "+ Bytes.hexString(data));

            try (ASN1InputStream in = new ASN1InputStream(data)) {
                Enumeration seq1 = ((DLSequence) in.readObject()).getObjects();

                while (seq1.hasMoreElements()) {
                    ASN1Primitive obj = (ASN1Primitive)seq1.nextElement();
                    byte[] data1 = obj.getEncoded();
                    Log.d(getClass().getName(), "data1 = "+ Bytes.hexString(data1));

                    if (data1[0] == (byte) 0x01) {
                        this.set21(data1[2] == 0x01);
                    } else if (data1[0] == (byte) 0x02) {
                        this.setAge(Bytes.toInt(data1[2]));
                    }
                }
            }
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
 
开发者ID:mDL-ILP,项目名称:mDL-ILP,代码行数:31,代码来源:DrivingLicence.java

示例8: parseDG15

import org.bouncycastle.asn1.DERApplicationSpecific; //导入方法依赖的package包/类
private void parseDG15(byte[] DG15) {

        try (ASN1InputStream bIn = new ASN1InputStream(DG15)) {
            DERApplicationSpecific app = (DERApplicationSpecific) bIn.readObject();

            ASN1Sequence seq = (ASN1Sequence) app.getObject(BERTags.SEQUENCE);
            byte[] data = ((ASN1Primitive)seq.getObjects().nextElement()).getEncoded();

            try (ASN1InputStream in = new ASN1InputStream(data)) {
                Enumeration seq1 = ((DLSequence) in.readObject()).getObjects();

                while (seq1.hasMoreElements()) {
                    ASN1Primitive obj = (ASN1Primitive)seq1.nextElement();
                    byte[] data1 = obj.getEncoded();
                    if (data1[0] == (byte) 0x01) {
                        this.set18(data1[2] == 0x01);
                    } else if (data1[0] == (byte) 0x02) {
                        // Value of the age check
                    }  else if (data1[0] == (byte) 0x04) {
                        // Random
                    }
                }
            }
        } catch (IOException e) {
            Log.e(getClass().getName(), e.getMessage(), e);
        }
    }
 
开发者ID:mDL-ILP,项目名称:mDL-ILP,代码行数:28,代码来源:DrivingLicence.java

示例9: parseDG16

import org.bouncycastle.asn1.DERApplicationSpecific; //导入方法依赖的package包/类
private void parseDG16(byte[] DG16) {

        try (ASN1InputStream bIn = new ASN1InputStream(DG16)) {
            DERApplicationSpecific app = (DERApplicationSpecific) bIn.readObject();

            ASN1Sequence seq = (ASN1Sequence) app.getObject(BERTags.SEQUENCE);
            byte[] data = ((ASN1Primitive)seq.getObjects().nextElement()).getEncoded();

            try (ASN1InputStream in = new ASN1InputStream(data)) {
                Enumeration seq1 = ((DLSequence) in.readObject()).getObjects();

                while (seq1.hasMoreElements()) {
                    ASN1Primitive obj = (ASN1Primitive)seq1.nextElement();
                    byte[] data1 = obj.getEncoded();
                    if (data1[0] == (byte) 0x01) {
                        this.set21(data1[2] == 0x01);
                    } else if (data1[0] == (byte) 0x02) {
                        // Value of the age check
                    }  else if (data1[0] == (byte) 0x04) {
                        // Random
                    }
                }
            }
        } catch (IOException e) {
            Log.e(getClass().getName(), e.getMessage(), e);
        }
    }
 
开发者ID:mDL-ILP,项目名称:mDL-ILP,代码行数:28,代码来源:DrivingLicence.java

示例10: performTest

import org.bouncycastle.asn1.DERApplicationSpecific; //导入方法依赖的package包/类
public void performTest()
    throws Exception
{
    DERInteger value = new DERInteger(9);

    DERApplicationSpecific tagged = new DERApplicationSpecific(false, 3, value);

    if (!areEqual(impData, tagged.getEncoded()))
    {
        fail("implicit encoding failed");
    }

    DERInteger recVal = (DERInteger)tagged.getObject(BERTags.INTEGER);

    if (!value.equals(recVal))
    {
        fail("implicit read back failed");
    }

    DERApplicationSpecific certObj = (DERApplicationSpecific)
    ASN1Primitive.fromByteArray(certData);

    if (!certObj.isConstructed() || certObj.getApplicationTag() != 33)
    {
        fail("parsing of certificate data failed");
    }

    byte[] encoded = certObj.getEncoded(ASN1Encoding.DER);

    if (!Arrays.areEqual(certData, encoded))
    {
        fail("re-encoding of certificate data failed");
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:35,代码来源:DERApplicationSpecificTest.java

示例11: performTest

import org.bouncycastle.asn1.DERApplicationSpecific; //导入方法依赖的package包/类
public void performTest()
    throws Exception
{
    testTaggedObject();

    DERApplicationSpecific appSpec = (DERApplicationSpecific)ASN1Primitive.fromByteArray(sampleData);

    if (1 != appSpec.getApplicationTag())
    {
        fail("wrong tag detected");
    }

    ASN1Integer value = new ASN1Integer(9);

    DERApplicationSpecific tagged = new DERApplicationSpecific(false, 3, value);

    if (!areEqual(impData, tagged.getEncoded()))
    {
        fail("implicit encoding failed");
    }

    ASN1Integer recVal = (ASN1Integer)tagged.getObject(BERTags.INTEGER);

    if (!value.equals(recVal))
    {
        fail("implicit read back failed");
    }

    DERApplicationSpecific certObj = (DERApplicationSpecific)
    ASN1Primitive.fromByteArray(certData);

    if (!certObj.isConstructed() || certObj.getApplicationTag() != 33)
    {
        fail("parsing of certificate data failed");
    }

    byte[] encoded = certObj.getEncoded(ASN1Encoding.DER);

    if (!Arrays.areEqual(certData, encoded))
    {
        fail("re-encoding of certificate data failed");
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:44,代码来源:DERApplicationSpecificTest.java

示例12: runCompleteProcedure

import org.bouncycastle.asn1.DERApplicationSpecific; //导入方法依赖的package包/类
private void runCompleteProcedure() throws Exception {

		SecurityInfos cardAccess = getEFCardAccess();
		PublicKey ephPacePublicKey = performPACE(cardAccess);

		KeyPair ephPCDKeyPair = performTerminalAuthentication(cardAccess, ephPacePublicKey);

		// read EF.CardSecurity
		byte[] efcsBytes = facs.getFile(FID_EFCardSec, true);
		logger.info("EF.CardSecurity read");

		// extract SecurityInfos
		SecurityInfos efcs = decodeEFCardSecurity(efcsBytes);
		
		logger.debug("EF.CardSecurity \n: " + efcs);
		logger.info("EF.CardSecurity decoded");

		// create a Chip Authentication Operator and hand over the CardHandler
		CAOperator cop = new CAOperator(ch);

		// Initialize and perform CA 
		cop.initialize(efcs.getChipAuthenticationInfoList().get(0), efcs.getChipAuthenticationPublicKeyInfoList().get(0), ephPCDKeyPair);
		SecureMessaging sm2 = cop.performCA();

		// If CA was successful a new SecureMessaging object will be returned which 
		// will we used for SecureMessaging from now on 
		if (sm2 != null) {
			logger.info("id_CA established!");
			ch.setSecureMessaging(sm2);
		} else {
			logger.warn("Couldn't establish id_CA");
		}

		// select the eID application
		ch.transceive(CardCommands.selectApp(EID_APP_ID));

		// read a datagroup (e.g. DG4 contains the first name)
		byte dgno = 4;
		byte[] dgdata = facs.getFile(dgno);
		DERApplicationSpecific derapp = (DERApplicationSpecific) DERApplicationSpecific.fromByteArray(dgdata);
		DERUTF8String name = (DERUTF8String) derapp.getObject();
		logger.info("Content of DG0" + dgno + ": " + name);

	}
 
开发者ID:tsenger,项目名称:animamea,代码行数:45,代码来源:Operator.java

示例13: CVCertificate

import org.bouncycastle.asn1.DERApplicationSpecific; //导入方法依赖的package包/类
public CVCertificate(byte[] in) throws IllegalArgumentException, IOException {
	ASN1StreamParser asn1Parser = new ASN1StreamParser(in);
	
	DERApplicationSpecific cvcert = (DERApplicationSpecific) asn1Parser.readObject();
	if (cvcert.getApplicationTag()!=0x21) throw new IllegalArgumentException("Can't find a CV Certificate");
	
	ASN1Sequence derCert= (ASN1Sequence)cvcert.getObject(BERTags.SEQUENCE); // Das CV Cerificate ist eine Sequence
	
	DERApplicationSpecific body = (DERApplicationSpecific) derCert.getObjectAt(0); //Das erste Objekt des Certificates ist der Cert-Body
	if (body.getApplicationTag()!=0x4E) throw new IllegalArgumentException("Can't find a Body in the CV Certificate");
	
	certBody = new CVCertBody(body);
	
	DERApplicationSpecific signature = (DERApplicationSpecific) derCert.getObjectAt(1); //Das zweite Objekt des Certificates ist die Signatur
	if (signature.getApplicationTag()!=0x37) throw new IllegalArgumentException("Can't find a Signature in the CV Certificate");

	certSignature = new CVCertSignature(signature.getContents());
	
}
 
开发者ID:tsenger,项目名称:animamea,代码行数:20,代码来源:CVCertificate.java

示例14: fromApplicationSpecific

import org.bouncycastle.asn1.DERApplicationSpecific; //导入方法依赖的package包/类
public static Counter64 fromApplicationSpecific(DERApplicationSpecific app) throws IOException
{
    DERInteger i = (DERInteger) app.getObject(DERTags.INTEGER);
    return new Counter64(i.getValue());
}
 
开发者ID:intrbiz,项目名称:SNMP-IB,代码行数:6,代码来源:Counter64.java

示例15: fromApplicationSpecific

import org.bouncycastle.asn1.DERApplicationSpecific; //导入方法依赖的package包/类
public static IPAddress fromApplicationSpecific(DERApplicationSpecific app) throws IOException
{
    DEROctetString addr = (DEROctetString) app.getObject(DERTags.OCTET_STRING);
    return new IPAddress(InetAddress.getByAddress(addr.getOctets()));
}
 
开发者ID:intrbiz,项目名称:SNMP-IB,代码行数:6,代码来源:IPAddress.java


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