Class GBAUCipher.OneShot

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

public static final class GBAUCipher.OneShot extends GBAUCipher
The OneShot class is a specialization of the GBAUCipher 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 GBAUCipher-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.

The following code shows a typical usage pattern for the OneShot class.
 ...
 GBAUCipher.OneShot enc = null;
  try {
      enc = GBAUCipher.OneShot.open(Cipher.CIPHER_AES_CBC, Cipher.PAD_PKCS5);
      enc.init( Cipher.MODE_ENCRYPT, adfAID, adfAIDOff, adfAIDLen, nafID, nafIDOff, nafIDLen );
      enc.doFinal(someInData, (short) 0, (short) someInData.length, encData, (short) 0);
  } catch (CryptoException ce) {
      // Handle exception
  } finally {
      if (enc != null) {
          enc.close();
          enc = null;
      }
  }
 ...
 
  • Nested Class Summary

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

    GBAUCipher.OneShot
  • 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.
    short
    doFinal(byte[] inBuff, short inOffset, short inLength, byte[] outBuff, short outOffset)
    Generates encrypted/decrypted output from all/last input data using Ks_int_NAF linked to NAF ID given in init().
    byte
    Gets the cipher algorithm.
    byte
    Gets the raw cipher algorithm.
    byte
    Gets the padding algorithm.
    void
    init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen)
    Initializes the GBAUCipher 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 GBAUCipher 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 GBAUCipher 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 GBAUCipher object with the appropriate NAF ID (then Ks_int_NAF key).
    open(byte cipherAlgorithm, byte paddingAlgorithm)
    Opens/acquires a JCRE owned temporary Entry Point Object instance of OneShot with the selected cipher algorithm and padding algorithm.
    short
    update(byte[] inBuff, short inOffset, short inLength, byte[] outBuff, short outOffset)
    Always throws a CryptoException.

    Methods inherited from class uicc.usim.gba_u.GBAUCipher

    getInstance, getInstance

    Methods inherited from class java.lang.Object

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