martinpaljak / GlobalPlatformPro

🌐 🔐 Manage applets and keys on JavaCard-s like a pro (via command line or from your Java project)
https://javacard.pro/globalplatform
GNU Lesser General Public License v3.0
673 stars 210 forks source link

GlobalPlatformPro support Put Key AES SCP03 ? #342

Closed yp25 closed 8 months ago

yp25 commented 8 months ago

Hello, I would like to know whether GlobalPlatformPro support Put Key AES SCP03 ?

                // Check for presence (thus replace)
                // WORKAROUND: some cards reject the command if actually trying to replace existing key.
                // List<GPKeyInfo> current = gp.getKeyInfoTemplate();
                // boolean replace = current.stream().filter(p -> p.getVersion() == keyVersion).count() == 1 || args.has(OPT_REPLACE_KEY);
                boolean replace = args.has(OPT_REPLACE_KEY);
                if (kv.getPublic().isPresent()) {
                    gp.putKey(kv.getPublic().get(), keyVersion, replace);
                } else if (kv.getSymmetric().isPresent()) {
                    byte[] k = kv.getSymmetric().get();
                    if (k.length != 16)
                        throw new IllegalArgumentException("Invalid key length: " + k.length);
                    // FIXME: implicit DES currently
                    gp.putKey(GPCrypto.des3key(k), keyVersion, replace);
                } else {
                    throw new IllegalArgumentException("Only public and symmetric keys are supported for put-key");
                }
            }`