diff --git a/src/fr/anssi/smartpgp/Constants.java b/src/fr/anssi/smartpgp/Constants.java index 2152fb4..8281433 100644 --- a/src/fr/anssi/smartpgp/Constants.java +++ b/src/fr/anssi/smartpgp/Constants.java @@ -98,6 +98,7 @@ public final class Constants { protected static final short TAG_GENERATION_DATE_SIG = (short)0x00ce; protected static final short TAG_GENERATION_DATE_DEC = (short)0x00cf; protected static final short TAG_GENERATION_DATE_AUT = (short)0x00d0; + protected static final short TAG_KEY_INFORMATION = (short)0x00de; protected static final short TAG_RESETTING_CODE = (short)0x00d3; protected static final short TAG_EXTENDED_LENGTH_INFORMATION = (short)0x7f66; protected static final short TAG_PRIVATE_DO_0101 = (short)0x0101; diff --git a/src/fr/anssi/smartpgp/PGPKey.java b/src/fr/anssi/smartpgp/PGPKey.java index dc1e285..8fba9c8 100644 --- a/src/fr/anssi/smartpgp/PGPKey.java +++ b/src/fr/anssi/smartpgp/PGPKey.java @@ -37,6 +37,8 @@ public final class PGPKey { protected final byte[] attributes; protected byte attributes_length; + private boolean has_been_generated; + private KeyPair keys; private final Cipher cipher_rsa_pkcs1; @@ -71,6 +73,8 @@ public final class PGPKey { fingerprint.reset(isRegistering); + has_been_generated = false; + Util.arrayFillNonAtomic(generation_date, (short)0, Constants.GENERATION_DATE_SIZE, (byte)0); } @@ -94,6 +98,18 @@ public final class PGPKey { return (keys != null) && keys.getPrivate().isInitialized() && keys.getPublic().isInitialized(); } + protected final byte keyInformation() { + byte res = (byte)0x0; + if(isInitialized()) { + if(has_been_generated) { + res = (byte)0x01; + } else { + res = (byte)0x02; + } + } + return res; + } + protected final void setCertificate(final byte[] buf, final short off, final short len) { if((len < 0) || (len > Constants.cardholderCertificateMaxLength())) { @@ -203,7 +219,7 @@ public final class PGPKey { } resetKeys(false); - + has_been_generated = true; keys = nkeys; } diff --git a/src/fr/anssi/smartpgp/SmartPGPApplet.java b/src/fr/anssi/smartpgp/SmartPGPApplet.java index c47870f..1977fac 100644 --- a/src/fr/anssi/smartpgp/SmartPGPApplet.java +++ b/src/fr/anssi/smartpgp/SmartPGPApplet.java @@ -428,6 +428,17 @@ public final class SmartPGPApplet extends Applet { k.certificate_length); break; + case Constants.TAG_KEY_INFORMATION: + buf[off++] = (byte)0xde; + buf[off++] = (byte)0x06; /* len */ + buf[off++] = (byte)0x01; + buf[off++] = data.pgp_keys[Persistent.PGP_KEYS_OFFSET_SIG].keyInformation(); + buf[off++] = (byte)0x02; + buf[off++] = data.pgp_keys[Persistent.PGP_KEYS_OFFSET_DEC].keyInformation(); + buf[off++] = (byte)0x03; + buf[off++] = data.pgp_keys[Persistent.PGP_KEYS_OFFSET_AUT].keyInformation(); + break; + case Constants.TAG_KEY_DERIVATION_FUNCTION: off = Util.arrayCopyNonAtomic(data.key_derivation_function, (short)0, buf, off,