Skip to content

Commit 480c78b

Browse files
committed
GPSecureChannel: eliminate use of wrappers
We do not want the SCP to use the wrappers so that it is simpler and more reusable.
1 parent 3576b6c commit 480c78b

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

globalplatform/src/main/java/org/openjavacard/gp/client/GPCard.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ public void connect() throws CardException {
381381
mCardKeyInfo.checkKeysetForUsage(mKeys);
382382

383383
// create a secure channel object
384-
mSecureChannel = new GPSecureChannel(mContext, mBasicWrapper, mKeys, mDiversification, mProtocolPolicy, mSecurityPolicy);
384+
mSecureChannel = new GPSecureChannel(mContext, mBasicChannel, mKeys, mDiversification, mProtocolPolicy, mSecurityPolicy);
385385

386386
// set protocol expectation of secure channel
387387
if (mCardData != null) {

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.openjavacard.gp.keys.GPKeyUsage;
2929
import org.openjavacard.gp.protocol.GP;
3030
import org.openjavacard.gp.structure.GPInitUpdateResponse;
31-
import org.openjavacard.gp.wrapper.GPBasicWrapper;
3231
import org.openjavacard.iso.ISO7816;
3332
import org.openjavacard.iso.SW;
3433
import org.openjavacard.iso.SWException;
@@ -58,8 +57,6 @@ public class GPSecureChannel extends CardChannel {
5857
private final SecureRandom mRandom;
5958
/** Context for checks */
6059
private final GPContext mContext;
61-
/** Underlying channel wrapper for communication */
62-
private final GPBasicWrapper mBasicWrapper;
6360
/** Underlying card channel */
6461
private final CardChannel mChannel;
6562
/** Initial static keys */
@@ -90,18 +87,17 @@ public class GPSecureChannel extends CardChannel {
9087
* Objects are not intended to be reconfigured.
9188
* <p/>
9289
* @param context for this secure channel
93-
* @param basicWrapper to communicate through
90+
* @param channel to communicate through
9491
* @param keys to use
9592
* @param protocolPolicy to conform to
9693
* @param securityPolicy to conform to
9794
*/
98-
public GPSecureChannel(GPContext context, GPBasicWrapper basicWrapper,
95+
public GPSecureChannel(GPContext context, CardChannel channel,
9996
GPKeySet keys, GPKeyDiversification diversification,
10097
SCPProtocolPolicy protocolPolicy, SCPSecurityPolicy securityPolicy) {
10198
mRandom = new SecureRandom();
10299
mContext = context;
103-
mBasicWrapper = basicWrapper;
104-
mChannel = mBasicWrapper.getChannel();
100+
mChannel = channel;
105101
mStaticKeys = keys;
106102
mDiversification = diversification;
107103
mProtocolPolicy = protocolPolicy;
@@ -242,7 +238,7 @@ private ResponseAPDU transmitInternal(CommandAPDU command) throws CardException
242238
// wrap the command (sign, encrypt)
243239
CommandAPDU wrappedCommand = mWrapper.wrap(command);
244240
// send the wrapped command
245-
ResponseAPDU wrappedResponse = mBasicWrapper.transmitRaw(wrappedCommand);
241+
ResponseAPDU wrappedResponse = mChannel.transmit(wrappedCommand);
246242
// unwrap the response, but not if it is an error
247243
int sw = wrappedResponse.getSW();
248244
ResponseAPDU response = wrappedResponse;
@@ -547,7 +543,7 @@ private GPInitUpdateResponse performInitializeUpdate(byte keyVersion, byte keyId
547543
hostChallenge
548544
);
549545
// and transmit it on the underlying channel
550-
ResponseAPDU initResponse = mBasicWrapper.transmitRaw(initCommand);
546+
ResponseAPDU initResponse = mChannel.transmit(initCommand);
551547
// check the response
552548
checkResponse(initResponse);
553549
// parse the response

0 commit comments

Comments
 (0)