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

com.ibm.opencard.signature
Interface MFCSignatureImpl

All Known Implementing Classes:
MFC40SignatureImpl

public abstract interface MFCSignatureImpl

The interface to a signature card service implementation. The implementation of such a service is responsible for creating command APDUs and evaluating the smartcard's response APDUs.

Version:
$Id: MFCSignatureImpl.java,v 1.1 1999/12/02 16:06:10 damke Exp $

Method Summary
 void assertSignDataAlgorithm(java.lang.String alg)
          Assert that a specific signature service implementation supports a signature algorithm.
 void assertSignHashAlgorithm(java.lang.String alg)
          Assert that a specific signature service implementation supports a signature algorithm.
 void assertSignPadAlgorithm(java.lang.String alg)
          Assert that a specific signature service implementation supports a padding algorithm.
 void calculateHash(MFCCardChannel channel, MFCKeyInfo ki, byte[] bytes)
          send calculate hash commmand.
 MFCKeyInfo readKeyInfo(MFCCardChannel channel, int keyNr, MFCKeyInfoRParser parser, boolean privateKey)
          execute coammnd read key info and return an object describing the key
 byte[] sign(MFCCardChannel channel, MFCKeyInfo ki, byte[] bytes)
          send generate signature command
 boolean verify(MFCCardChannel channel, MFCKeyInfo ki, byte[] signature, byte[] data)
          send verify signature command
 

Method Detail

assertSignDataAlgorithm

public void assertSignDataAlgorithm(java.lang.String alg)
                             throws CardServiceInabilityException
Assert that a specific signature service implementation supports a signature algorithm. The algorithm specified must be a combination of hash/pka algorithm, for example "SHA-1/RSA".
Parameters:
alg - The standard algorithm name.
Throws:
CardServiceInabilityException - Thrown if the algorithm is not supported.

assertSignHashAlgorithm

public void assertSignHashAlgorithm(java.lang.String alg)
                             throws CardServiceInabilityException
Assert that a specific signature service implementation supports a signature algorithm. The algorithm specified must be a pka algorithm only, for example "RSA".
Parameters:
alg - The standard algorithm name.
Throws:
CardServiceInabilityException - Thrown if the algorithm is not supported.

assertSignPadAlgorithm

public void assertSignPadAlgorithm(java.lang.String alg)
                            throws CardServiceInabilityException
Assert that a specific signature service implementation supports a padding algorithm. The algorithm specified must be one of
Parameters:
alg - The padding algorithm name. for example one of ISO9796 PKCS#1 ZEROPADDING
Throws:
CardServiceInabilityException - Thrown if the algorithm is not supported.

calculateHash

public void calculateHash(MFCCardChannel channel,
                          MFCKeyInfo ki,
                          byte[] bytes)
                   throws CardServiceException,
                          CardTerminalException
send calculate hash commmand. The hash is not returned from the card but used in the next step to generate a signature on the hash.
Parameters:
channel - com.ibm.opencard.service.MFCCardChannel
ki - com.ibm.opencard.signature.MFCKeyInfo
bytes - the data for which the hash is to be calculated
Throws:
CardServiceException - any subclass of CardServiceException
CardTerminalException - any subclass of CardTerminalException

readKeyInfo

public MFCKeyInfo readKeyInfo(MFCCardChannel channel,
                              int keyNr,
                              MFCKeyInfoRParser parser,
                              boolean privateKey)
                       throws CardServiceException,
                              CardTerminalException
execute coammnd read key info and return an object describing the key
Parameters:
channel - MFCCardChannel
keyNr - the key number
parser - the key info response parser
privateKey - info is requested for private key?
Returns:
MFCKeyInfo
Throws:
CardServiceException - any subclass of CardServiceException
CardTerminalException - any subclass of CardTerminalException

sign

public byte[] sign(MFCCardChannel channel,
                   MFCKeyInfo ki,
                   byte[] bytes)
            throws CardServiceException,
                   CardTerminalException
send generate signature command
Parameters:
channel - com.ibm.opencard.service.MFCCardChannel
ki - the key used for the algorithm
bytes - byte[] the hash/message digest to be signed. If this parameter is null, the previous method must have been calculateHash()
Returns:
The signature.
Throws:
CardServiceException - any subclass of CardServiceException
CardTerminalException - any subclass of CardTerminalException

verify

public boolean verify(MFCCardChannel channel,
                      MFCKeyInfo ki,
                      byte[] signature,
                      byte[] data)
               throws CardServiceException,
                      CardTerminalException
send verify signature command
Parameters:
channel - com.ibm.opencard.service.MFCCardChannel
ki - the key used for the algorithm
signature - the signature to be verified
bytes - byte[] the hash/message digest to be signed. If this parameter is null, the previous method must have been calculateHash()
Returns:
true if the verification succeeded
Throws:
CardServiceException - any subclass of CardServiceException
CardTerminalException - any subclass of CardTerminalException