04.01.2013 Views

DoD Implementation Guide for CAC PIV End-Point - Common ...

DoD Implementation Guide for CAC PIV End-Point - Common ...

DoD Implementation Guide for CAC PIV End-Point - Common ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>DoD</strong> <strong>Implementation</strong> <strong>Guide</strong> <strong>for</strong> <strong>CAC</strong> <strong>PIV</strong> <strong>End</strong>-<strong>Point</strong><br />

}<br />

/*<br />

* obtain the data of the currently selected app<br />

*/<br />

private static ResponseAPDU getData(CardChannel channel)<br />

throws CardException{<br />

// SP800-73-1 APDU GET_DATA APDU command.<br />

byte[] apdu={0x00, (byte)0xCB, 0x3F,<br />

(byte)0xFF, 0x05, 0x5C, 0x03,<br />

(byte)0x5F, byte)0xC1, 0x02}; // BERT-TLV CHUID tag<br />

int size, sw1, sw2, nr, count=0, offset;<br />

ResponseAPDU res;<br />

}<br />

//obtain the first 2 bytes to get buf size<br />

res = channel.transmit(new CommandAPDU(apdu));<br />

//display status<br />

System.out.println(" ------------------------------" );<br />

System.out.println("GetData " + res.toString());<br />

return res;<br />

/*<br />

* Select a card application/container<br />

*/<br />

private static void select(CardChannel channel, byte[] data)<br />

throws CardException{<br />

byte cla = 0x00,<br />

ins = (byte)(0xA4 & 0xFF),<br />

p1 = 0x04,<br />

p2 = 0x00,<br />

de = 0x00;<br />

int sw1 = 0, sw2 = 0, nr = 0;<br />

}<br />

ResponseAPDU res = channel.transmit(<br />

new CommandAPDU(cla, ins, p1, p2, data, de)<br />

);<br />

nr = res.getNr();<br />

//display status<br />

System.out.println(" ------------------------------" );<br />

System.out.println("Select " + res.toString());<br />

try{<br />

System.out.println(toString(res.getBytes(), nr+2));<br />

//+2 <strong>for</strong> status words (90 00)<br />

}catch(UnsupportedEncodingException e){<br />

System.out.println("Unsupported Encoding Error");<br />

}<br />

/*<br />

* convert a byte array to ASCII Hexadecimal<br />

*/<br />

private static String toString(byte[] buf, int length)<br />

36

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!