OpenPGP card v3.3 : support KDF-DO

This commit is contained in:
Arnaud Fontaine
2017-05-22 16:18:56 +02:00
parent b92c7f3dec
commit d37a471067
3 changed files with 49 additions and 2 deletions

View File

@@ -447,6 +447,12 @@ public final class SmartPGPApplet extends Applet {
k.certificate_length);
break;
case Constants.TAG_KEY_DERIVATION_FUNCTION:
off = Util.arrayCopyNonAtomic(data.key_derivation_function, (short)0,
buf, off,
data.key_derivation_function_length);
break;
default:
ISOException.throwIt(Constants.SW_REFERENCE_DATA_NOT_FOUND);
return 0;
@@ -1031,6 +1037,22 @@ public final class SmartPGPApplet extends Applet {
JCSystem.commitTransaction();
break;
case Constants.TAG_KEY_DERIVATION_FUNCTION:
assertAdmin();
if((lc < Constants.KEY_DERIVATION_FUNCTION_MIN_LENGTH) ||
(lc > Constants.KEY_DERIVATION_FUNCTION_MAX_LENGTH)) {
ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
return;
}
JCSystem.beginTransaction();
if(data.key_derivation_function_length > 0) {
Util.arrayFillNonAtomic(data.key_derivation_function, (short)0, data.key_derivation_function_length, (byte)0);
}
Util.arrayCopyNonAtomic(buf, (short)0, data.key_derivation_function, (short)0, lc);
data.key_derivation_function_length = (byte)lc;
JCSystem.commitTransaction();
break;
default:
ISOException.throwIt(Constants.SW_REFERENCE_DATA_NOT_FOUND);
return;