开发者

Smart Cards Development

开发者 https://www.devze.com 2022-12-22 14:37 出处:网络
I need a \'开发者_如何学Pythonjava\' source code on how to extract a cap file from the computer and divide it into blocks in order to send it using APDUs to the smart card to install or load or delete

I need a '开发者_如何学Pythonjava' source code on how to extract a cap file from the computer and divide it into blocks in order to send it using APDUs to the smart card to install or load or delete an application. Thanks in advance.


You're talking about GlobalPlatform and there's a right open source tool out there for this, called GPJ


I think you should start at http://java.sun.com/javacard/


Get the source code from http://gpj.svn.sourceforge.net/viewvc/gpj/

You may get some idea about dealing with CAP file in the method getEntries(ZipInputStream in) of CapFile.java

private Map<String, byte[]> getEntries(ZipInputStream in)
            throws IOException {
        Map<String, byte[]> result = new HashMap<String, byte[]>();
        while (true) {
            ZipEntry entry = in.getNextEntry();
            if (entry == null) {
                break;
            }
            if (entry.getName().indexOf("MANIFEST.MF") != -1) {
                continue;
            }
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            byte[] buf = new byte[1024];
            int c;
            while ((c = in.read(buf)) > 0)
                bos.write(buf, 0, c);
            result.put(entry.getName(), bos.toByteArray());
        }
        return result;
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号