Skip to content

Commit 8e8f9b6

Browse files
committed
SCPWrapper: minor cleanup
1 parent c84874e commit 8e8f9b6

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

globalplatform/src/main/java/org/openjavacard/gp/scp/GPSecureChannel.java

+3
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,9 @@ public void open() throws CardException {
336336
// create CardAPDU wrapper
337337
mWrapper = buildWrapper();
338338

339+
// this is where we start using MAC
340+
mWrapper.startMAC();
341+
339342
// perform EXTERNAL AUTHENTICATE to authenticate to card
340343
LOG.debug("performing authentication");
341344
performExternalAuthenticate(hostCryptogram);

globalplatform/src/main/java/org/openjavacard/gp/scp/SCPWrapper.java

+12-3
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ public abstract class SCPWrapper {
3636
/** Session keys in use */
3737
protected final GPKeySet mKeys;
3838

39-
/** Command encryption currently enabled? */
40-
protected boolean mENC;
4139
/** Command authentication currently enabled? */
4240
protected boolean mMAC;
41+
/** Command encryption currently enabled? */
42+
protected boolean mENC;
4343
/** Response authentication currently enabled? */
4444
protected boolean mRMAC;
4545
/** Response encryption currently enabled? */
@@ -51,14 +51,23 @@ public abstract class SCPWrapper {
5151
*/
5252
SCPWrapper(GPKeySet keys) {
5353
mKeys = keys;
54-
// SCP0102 and SCP03 all start with MAC enabled
54+
// most protocols start with MAC enabled
5555
mMAC = true;
5656
// other options must be enabled by client
5757
mENC = false;
5858
mRMAC = false;
5959
mRENC = false;
6060
}
6161

62+
/**
63+
* Used to start command authentication when it is expected
64+
*
65+
* Subclasses may want to set up state.
66+
*/
67+
protected void startMAC() {
68+
mMAC = true;
69+
}
70+
6271
/**
6372
* Used to start command encryption when it is expected
6473
*

0 commit comments

Comments
 (0)