本文整理匯總了Java中org.bouncycastle.asn1.ASN1Primitive.getEncoded方法的典型用法代碼示例。如果您正苦於以下問題:Java ASN1Primitive.getEncoded方法的具體用法?Java ASN1Primitive.getEncoded怎麽用?Java ASN1Primitive.getEncoded使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bouncycastle.asn1.ASN1Primitive
的用法示例。
在下文中一共展示了ASN1Primitive.getEncoded方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseDG1
import org.bouncycastle.asn1.ASN1Primitive; //導入方法依賴的package包/類
private void parseDG1(byte[] DG1) {
try {
ASN1InputStream bIn = new ASN1InputStream(DG1);
org.bouncycastle.asn1.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]== 0x41) {
Log.d("type approval number", ByteUtils.bytesToHex(data));
this.set5F01(data);
} else if (data[0] == 0x42) {
byte[] input = Arrays.copyOfRange(data, 3, data.length);
parse5F02(input);
} else if (data[0] == 0x7F) {
parse7F63(data);
}
}
bIn.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例2: parseDG11
import org.bouncycastle.asn1.ASN1Primitive; //導入方法依賴的package包/類
private void parseDG11(byte[] DG11) {
try {
ASN1InputStream bIn = new ASN1InputStream(DG11);
org.bouncycastle.asn1.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));
}
}
bIn.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例3: parseCardMappedPublicKey
import org.bouncycastle.asn1.ASN1Primitive; //導入方法依賴的package包/類
private PublicKey parseCardMappedPublicKey(byte[] data) {
try (ASN1InputStream innerIn = new ASN1InputStream(Bytes.allButFirst(data, 2))) {
ASN1Primitive innerObj = innerIn.readObject();
byte[] innerTLV = innerObj.getEncoded();
// tag 82 = Mapping Data
if (innerTLV[0] == (byte) 0x82) {
// Get the card's Public key
return ECCUtils.encodeECCPublicKeyX509(Bytes.allButFirst(innerTLV, 2), curveRef);
}
} catch (IOException e) {
Log.e(getClass().getName(), "Failed to parse card public key", e);
}
return null;
}
示例4: parseCardAgreedPublicKey
import org.bouncycastle.asn1.ASN1Primitive; //導入方法依賴的package包/類
private PublicKey parseCardAgreedPublicKey(byte[] data) {
try (ASN1InputStream innerIn = new ASN1InputStream(Bytes.allButFirst(data, 2))) {
ASN1Primitive innerObj = innerIn.readObject();
byte[] innerTLV = innerObj.getEncoded();
// tag 82 = Mapping Data
if (innerTLV[0] == (byte) 0x84) {
// Get the card's Public key
return ECCUtils.encodeECCPublicKeyX509(Bytes.allButFirst(innerTLV, 2), curveRef);
}
} catch (IOException e) {
Log.e(getClass().getName(), "Failed to parse card public key", e);
}
return null;
}
示例5: parseAuthCommandResponse
import org.bouncycastle.asn1.ASN1Primitive; //導入方法依賴的package包/類
private byte[] parseAuthCommandResponse(byte[] data) {
try (ASN1InputStream innerIn = new ASN1InputStream(Bytes.allButFirst(data, 2))) {
ASN1Primitive innerObj = innerIn.readObject();
byte[] innerTLV = innerObj.getEncoded();
// tag 86 = Mapping Data
if (innerTLV[0] == (byte) 0x86) {
// Get the card's Public key
return Bytes.allButFirst(innerTLV, 2);
}
} catch (IOException e) {
Log.e(getClass().getName(), "Failed to parse card token", e);
}
return null;
}
示例6: parseDG1
import org.bouncycastle.asn1.ASN1Primitive; //導入方法依賴的package包/類
private void parseDG1(byte[] DG1) {
try (ASN1InputStream bIn = new ASN1InputStream(DG1)) {
org.bouncycastle.asn1.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]== 0x41) {
Log.d("type approval number", ByteUtils.bytesToHex(data));
this.set5F01(Bytes.allButFirst(data, 1));
} else if (data[0] == 0x42) {
byte[] input = Arrays.copyOfRange(data, 3, data.length);
parse5F02(input);
} else if (data[0] == 0x7F) {
parse7F63(data);
}
}
} catch (IOException e) {
Log.e(getClass().getName(), e.getMessage(), e);
}
}
示例7: parse7F63
import org.bouncycastle.asn1.ASN1Primitive; //導入方法依賴的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);
}
}
示例8: parseDG11
import org.bouncycastle.asn1.ASN1Primitive; //導入方法依賴的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);
}
}
示例9: parse7F63
import org.bouncycastle.asn1.ASN1Primitive; //導入方法依賴的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();
}
}
示例10: parseDG15
import org.bouncycastle.asn1.ASN1Primitive; //導入方法依賴的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();
}
}
示例11: parseDG16
import org.bouncycastle.asn1.ASN1Primitive; //導入方法依賴的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();
}
}
示例12: parseDG15
import org.bouncycastle.asn1.ASN1Primitive; //導入方法依賴的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);
}
}
示例13: parseDG16
import org.bouncycastle.asn1.ASN1Primitive; //導入方法依賴的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);
}
}
示例14: parse5F02
import org.bouncycastle.asn1.ASN1Primitive; //導入方法依賴的package包/類
private void parse5F02(byte[] input) {
Log.d("input", ByteUtils.bytesToHex(input));
try {
ASN1InputStream bIn = new ASN1InputStream(input);
ASN1Primitive obj;
while ((obj = bIn.readObject())!= null) {
byte[] data = obj.getEncoded();
Log.d("5F02data", ByteUtils.bytesToHex(data));
switch (data[0]) {
case 0x43:
this.set5F03(Arrays.copyOfRange(data, 2, data.length));
break;
case 0x44:
this.set5F04(Arrays.copyOfRange(data, 2, data.length));
break;
case 0x45:
this.set5F05(Arrays.copyOfRange(data, 2, data.length));
break;
case 0x46:
this.set5F06(Arrays.copyOfRange(data, 2, data.length));
break;
case 0x47:
this.set5F07(Arrays.copyOfRange(data, 2, data.length));
break;
case 0x48:
this.set5F08(Arrays.copyOfRange(data, 2, data.length));
break;
case 0x49:
this.set5F09(Arrays.copyOfRange(data, 2, data.length));
break;
case 0x4A:
this.set5F0A(Arrays.copyOfRange(data, 2, data.length));
break;
case 0x4B:
this.set5F0B(Arrays.copyOfRange(data, 2, data.length));
break;
case 0x4C:
this.set5F0C(Arrays.copyOfRange(data, 2, data.length));
break;
case 0x4E:
this.set5F0E(Arrays.copyOfRange(data, 2, data.length));
break;
case 0x4F:
this.set5F0F(Arrays.copyOfRange(data, 2, data.length));
break;
default:
Log.d("UNKNOWN_TAG", "unknown tag");
}
bIn.close();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例15: parse5F02
import org.bouncycastle.asn1.ASN1Primitive; //導入方法依賴的package包/類
private void parse5F02(byte[] input) {
Log.d("input", ByteUtils.bytesToHex(input));
try (ASN1InputStream bIn = new ASN1InputStream(input)) {
ASN1Primitive obj;
while ((obj = bIn.readObject())!= null) {
byte[] data = obj.getEncoded();
Log.d("5F02data", ByteUtils.bytesToHex(data));
switch (data[0]) {
case 0x43:
this.set5F03(Arrays.copyOfRange(data, 2, data.length));
break;
case 0x44:
this.set5F04(Arrays.copyOfRange(data, 2, data.length));
break;
case 0x45:
this.set5F05(Arrays.copyOfRange(data, 2, data.length));
break;
case 0x46:
this.set5F06(Arrays.copyOfRange(data, 2, data.length));
break;
case 0x47:
this.set5F07(Arrays.copyOfRange(data, 2, data.length));
break;
case 0x48:
this.set5F08(Arrays.copyOfRange(data, 2, data.length));
break;
case 0x49:
this.set5F09(Arrays.copyOfRange(data, 2, data.length));
break;
case 0x4A:
this.set5F0A(Arrays.copyOfRange(data, 2, data.length));
break;
case 0x4B:
this.set5F0B(Arrays.copyOfRange(data, 2, data.length));
break;
case 0x4C:
this.set5F0C(Arrays.copyOfRange(data, 2, data.length));
break;
case 0x4E:
this.set5F0E(Arrays.copyOfRange(data, 2, data.length));
break;
case 0x4F:
this.set5F0F(Arrays.copyOfRange(data, 2, data.length));
break;
default:
Log.d("UNKNOWN_TAG", "unknown tag");
}
}
} catch (IOException e) {
Log.e(getClass().getName(), e.getMessage(), e);
}
}