OpenCard  
 
OCF, the OpenCard Framework is a standard Java framework for working with Smart Cards.  
 

com.ibm.opencard.signature
Class MFC40KeyImpImpl

java.lang.Object
  |
  +--com.ibm.opencard.signature.MFC40KeyImpImpl

public class MFC40KeyImpImpl
extends java.lang.Object
implements MFCKeyImportImpl

Helper class for implementation of a key import card service for MFC 4.0 and compatible. Send APDUs to the card. The methods that send APDUs are synchronized simply to reuse the APDU buffers.

Version:
$Id: MFC40KeyImpImpl.java,v 1.1 1999/12/02 16:06:08 damke Exp $
See Also:
KeyImportCardService, MFCKeyImportService

Field Summary
protected  MFCSigCodes mfcCodes
          The CLAss and INStruction bytes for commands.
 
Constructor Summary
MFC40KeyImpImpl(MFCSigCodes codes)
          Instantiates a new key import service implementation.
 
Method Summary
protected  MFCCommandAPDU getImpKeyAPDU(int keyNr, byte[] data, boolean isPrivate, int offset, int length, boolean finish)
          Create APDU for prepare or finish stage of import key command.
protected  MFCCommandAPDU getValKeyAPDU(int keyNr, int verKey, byte[] signature, boolean isPrivate)
          Create APDU for validate key command
 void importKey(MFCCardChannel channel, MFCKeyInfo ki, byte[] data, boolean isPrivate)
          Send the command APDU for import key.
 boolean validateKey(MFCCardChannel channel, int keyNr, MFCKeyInfo ki, byte[] signature, boolean isPrivate)
          Send the command APDU for validate key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mfcCodes

protected MFCSigCodes mfcCodes
The CLAss and INStruction bytes for commands.
Constructor Detail

MFC40KeyImpImpl

public MFC40KeyImpImpl(MFCSigCodes codes)
Instantiates a new key import service implementation.
Parameters:
codes - the command codes for the MFC card to support
Method Detail

getImpKeyAPDU

protected MFCCommandAPDU getImpKeyAPDU(int keyNr,
                                       byte[] data,
                                       boolean isPrivate,
                                       int offset,
                                       int length,
                                       boolean finish)
Create APDU for prepare or finish stage of import key command. Note: the block length must be less then the maximum effective data length of the card
Parameters:
keyNr - key number
data - the key data to be imported
isPrivate - is it a private or a public key
offset - offset into data for the current block
length - length of current block
finish - if set to false, return a prepare command APDU, if set to true, return a finish command APDU.
Returns:
com.ibm.opencard.service.MFCCommandAPDU

getValKeyAPDU

protected MFCCommandAPDU getValKeyAPDU(int keyNr,
                                       int verKey,
                                       byte[] signature,
                                       boolean isPrivate)
Create APDU for validate key command
Parameters:
keyNr - key number of key to be validated
verKey - ken number of key to be used for signature verification
signature - the signature over key keyNr that is to be verified
isPrivate - key to be verified is a private or a public key
Returns:
com.ibm.opencard.service.MFCCommandAPDU

importKey

public void importKey(MFCCardChannel channel,
                      MFCKeyInfo ki,
                      byte[] data,
                      boolean isPrivate)
               throws CardServiceException,
                      CardTerminalException
Send the command APDU for import key.
Specified by:
importKey in interface MFCKeyImportImpl
Parameters:
channel - com.ibm.opencard.service.MFCCardChannel
ki - old key info
data - byte[] the key file data
isPrivate - true if a private key should be imported
Throws:
CardServiceException - any subclass of CardServiceException
CardTerminalException - any subclass of CardTerminalException

validateKey

public boolean validateKey(MFCCardChannel channel,
                           int keyNr,
                           MFCKeyInfo ki,
                           byte[] signature,
                           boolean isPrivate)
                    throws CardServiceException,
                           CardTerminalException
Send the command APDU for validate key.
Specified by:
validateKey in interface MFCKeyImportImpl
Parameters:
channel - com.ibm.opencard.service.MFCCardChannel
keyNr - number of key to be verified
ki - key info of key to be used for verification of signature
signature - the signature to be verified
isPrivate - true if a private key should be validated
Throws:
CardServiceException - any subclass of CardServiceException
CardTerminalException - any subclass of CardTerminalException