Class GBAUSignature.OneShot

java.lang.Object
uicc.usim.gba_u.GBAUSignature
uicc.usim.gba_u.GBAUSignature.OneShot
Enclosing class:
GBAUSignature

public static final class GBAUSignature.OneShot extends GBAUSignature
The OneShot class is a specialization of the GBAUSignature class intended to support efficient one-shot ciphering and deciphering operations that may avoid persistent memory writes entirely. The OneShot class uses a delegation model where calls are delegated to an instance of a GBAUSignature-implementing class configured for one-shot use.

Note:
  • Instances of OneShot are JCRE owned temporary Entry Point Object instances and references to these temporary objects cannot be stored in class variables or instance variables or array components. See Runtime Environment Specification, Java Card Platform, Classic Edition for details.
  • The platform must support at least one instance of OneShot. Support for several OneShot instances is platform dependent. To guarantee application code portability, acquiring/opening and then releasing/closing OneShot instances should be performed within tight try-catch-finally blocks (as illustrated in the code sample below) in order to avoid unnecessarily keeping hold of instances and to prevent interleaving invocations - hence enforcing the One-Shot usage pattern. Additionally, any local variable holding a reference to a OneShot instance should be set to null once the instance is closed in order to prevent further use attempts.
  • Upon return from any Applet entry point method, back to the JCRE, and on tear or card reset events any OneShot instances in use are released back to the JCRE.
  • The internal state associated with an instance of OneShot must be bound to the initial calling context (owner context) as to preclude use/calls on that instance from other contexts.
  • Unless otherwise specified, after an instance of OneShot is released back to the JCRE, calls to any of the instance methods of the OneShot class results in an CryptoException being thrown with reason code CryptoException.ILLEGAL_USE.
  • OneShot cannot be used to get instances of type SignatureMessageRecovery.

The following code shows a typical usage pattern for the OneShot class.
 
 ...
 Signature.OneShot sig = null;
 try {
        sig = Signature.OneShot.open(MessageDigest.ALG_SHA, Signature.SIG_CIPHER_AES_CMAC128, Cipher.PAD_PKCS5);
        sig.init(Signature.MODE_SIGN, adfAID, adfAIDOff, adfAIDLen, nafID, nafOff, nafLen));
        sig.sign(someInData, (short) 0, (short) someInData.length, sigData, (short) 0);
 } catch (CryptoException ce) {
        // Handle exception
 } finally {
        if (sig != null) {
                sig.close();
                sig = null;
        }
 }
 ...

 
  • Nested Class Summary

    Nested classes/interfaces inherited from class uicc.usim.gba_u.GBAUSignature

    GBAUSignature.OneShot
  • Field Summary

    Fields inherited from class uicc.usim.gba_u.GBAUSignature

    ALG_HMAC_SM3
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Protected constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes and releases this JCRE owned temporary instance of the OneShot object for reuse.
    byte
    Gets the Signature algorithm.
    byte
    Gets the cipher algorithm.
    short
    Returns the short length of the signature data.
    byte
    Gets the message digest algorithm.
    byte
    Gets the padding algorithm.
    void
    init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen)
    Initializes the GBAUSignature object with the appropriate NAF ID (then Ks_int_NAF Key).
    void
    init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, byte[] bArray, short bOff, short bLen)
    Initializes the GBAUSignature object with the appropriate NAF ID (then Ks_int_NAF Key) and algorithm specific parameters.
    void
    init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, byte[] bArray, short bOff, short bLen, short keyLength)
    Initializes the GBAUSignature object with the appropriate NAF ID (then Ks_int_NAF Key) and algorithm specific parameters.
    void
    init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, short keyLength)
    Initializes the GBAUSignature object with the appropriate NAF ID (then Ks_int_NAF Key).
    open(byte messageDigestAlgorithm, byte cipherAlgorithm, byte paddingAlgorithm)
    Opens/acquires a JCRE owned temporary Entry Point Object instance of OneShot with the selected cipher algorithm and padding algorithm.
    void
    setInitialDigest(byte[] initialDigestBuf, short initialDigestOffset, short initialDigestLength, byte[] digestedMsgLenBuf, short digestedMsgLenOffset, short digestedMsgLenLength)
    This method initializes the starting hash value in place of the default value used by the GBAUSignature class.
    short
    sign(byte[] inBuff, short inOffset, short inLength, byte[] sigBuff, short sigOffset)
    Generates the signature of all/last input data using Ks_int_NAF linked to NAF ID used in init().
    short
    signPreComputedHash(byte[] hashBuff, short hashOffset, short hashLength, byte[] sigBuff, short sigOffset)
    Generates the signature of the precomputed hash data.
    void
    update(byte[] inBuff, short inOffset, short inLength)
    Always throws a CryptoException.
    boolean
    verify(byte[] inBuff, short inOffset, short inLength, byte[] sigBuff, short sigOffset, short sigLength)
    Verifies the signature of all/last input data against the passed in signature using Ks_int_NAF linked to NAF ID used in init().
    boolean
    verifyPreComputedHash(byte[] hashBuff, short hashOffset, short hashLength, byte[] sigBuff, short sigOffset, short sigLength)
    Verifies the signature of precomputed hash data.

    Methods inherited from class uicc.usim.gba_u.GBAUSignature

    getInstance, getInstance

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait