Add support for KEY INFORMATION tag

This commit is contained in:
Arnaud Fontaine 2019-06-14 18:34:11 +02:00
parent eebca4b69e
commit 1e89a26e8e
3 changed files with 29 additions and 1 deletions

View File

@ -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_SIG = (short)0x00ce;
protected static final short TAG_GENERATION_DATE_DEC = (short)0x00cf; 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_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_RESETTING_CODE = (short)0x00d3;
protected static final short TAG_EXTENDED_LENGTH_INFORMATION = (short)0x7f66; protected static final short TAG_EXTENDED_LENGTH_INFORMATION = (short)0x7f66;
protected static final short TAG_PRIVATE_DO_0101 = (short)0x0101; protected static final short TAG_PRIVATE_DO_0101 = (short)0x0101;

View File

@ -37,6 +37,8 @@ public final class PGPKey {
protected final byte[] attributes; protected final byte[] attributes;
protected byte attributes_length; protected byte attributes_length;
private boolean has_been_generated;
private KeyPair keys; private KeyPair keys;
private final Cipher cipher_rsa_pkcs1; private final Cipher cipher_rsa_pkcs1;
@ -71,6 +73,8 @@ public final class PGPKey {
fingerprint.reset(isRegistering); fingerprint.reset(isRegistering);
has_been_generated = false;
Util.arrayFillNonAtomic(generation_date, (short)0, Constants.GENERATION_DATE_SIZE, (byte)0); 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(); 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) { protected final void setCertificate(final byte[] buf, final short off, final short len) {
if((len < 0) || if((len < 0) ||
(len > Constants.cardholderCertificateMaxLength())) { (len > Constants.cardholderCertificateMaxLength())) {
@ -203,7 +219,7 @@ public final class PGPKey {
} }
resetKeys(false); resetKeys(false);
has_been_generated = true;
keys = nkeys; keys = nkeys;
} }

View File

@ -428,6 +428,17 @@ public final class SmartPGPApplet extends Applet {
k.certificate_length); k.certificate_length);
break; 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: case Constants.TAG_KEY_DERIVATION_FUNCTION:
off = Util.arrayCopyNonAtomic(data.key_derivation_function, (short)0, off = Util.arrayCopyNonAtomic(data.key_derivation_function, (short)0,
buf, off, buf, off,