Java Code Examples for javacard.framework.JCSystem#makeTransientObjectArray()

The following examples show how to use javacard.framework.JCSystem#makeTransientObjectArray() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NdefApplet.java    From openjavacard-ndef with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Main constructor
 *
 * This will construct and initialize an instance
 * of this applet according to the provided app data.
 *
 * @param buf containing application data
 * @param off offset of app data in buf
 * @param len length of app data in buf
 */
protected NdefApplet(byte[] buf, short off, byte len) {
    // create transient variables
    vars = JCSystem.makeTransientShortArray(NUM_VARS, JCSystem.CLEAR_ON_DESELECT);
    refs = JCSystem.makeTransientObjectArray(NUM_REFS, JCSystem.CLEAR_ON_DESELECT);
    // create capabilities files
    capsFile = makeCaps((short)0);
    // process install data
    if(len < 6 || len > 17) {
        ISOException.throwIt(ISO7816.SW_WRONG_DATA);
    }
    // first byte is the service ID
    serviceID = buf[off++]; len--;
    // rest is the service AID
    serviceAID = new byte[len];
    Util.arrayCopyNonAtomic(buf, off, serviceAID, (short)0, len);
}
 
Example 2
Source File: ObjectLocker.java    From JCMathLib with MIT License 5 votes vote down vote up
private final void initialize(short numObjects, boolean bEraseOnLock, boolean bEraseOnUnlock) {
    lockedObjects = JCSystem.makeTransientObjectArray((short) (2 * numObjects), JCSystem.CLEAR_ON_RESET);
    lockedObjectsPersistent = new Object[(short) (2 * numObjects)];
    ERASE_ON_LOCK = bEraseOnLock;
    ERASE_ON_UNLOCK = bEraseOnUnlock;
    profileLockedObjects = new byte[(short) (numObjects * numObjects)]; 
    resetProfileLocks();
}
 
Example 3
Source File: GidsPINManager.java    From GidsApplet with GNU General Public License v3.0 5 votes vote down vote up
public GidsPINManager() {
    pin_pin = new GidsPIN(PIN_MAX_TRIES, PIN_MAX_LENGTH, PIN_MIN_LENGTH);
    ExternalChallenge = JCSystem.makeTransientByteArray((short)16, JCSystem.CLEAR_ON_DESELECT);
    CardChallenge = JCSystem.makeTransientByteArray((short)16, JCSystem.CLEAR_ON_DESELECT);
    KeyReference = JCSystem.makeTransientObjectArray((short)1, JCSystem.CLEAR_ON_DESELECT);
    buffer = JCSystem.makeTransientByteArray((short)40, JCSystem.CLEAR_ON_DESELECT);
    sharedKey = JCSystem.makeTransientByteArray((short)40, JCSystem.CLEAR_ON_DESELECT);
    status = JCSystem.makeTransientByteArray((short)1, JCSystem.CLEAR_ON_DESELECT);
}
 
Example 4
Source File: TransmitManager.java    From GidsApplet with GNU General Public License v3.0 4 votes vote down vote up
public TransmitManager() {
    ram_buf = JCSystem.makeTransientByteArray(RAM_BUF_SIZE, JCSystem.CLEAR_ON_DESELECT);
    chaining_cache = JCSystem.makeTransientShortArray(CHAINING_CACHE_SIZE, JCSystem.CLEAR_ON_DESELECT);
    chaining_object = JCSystem.makeTransientObjectArray((short) 2, JCSystem.CLEAR_ON_DESELECT);

}
 
Example 5
Source File: GidsApplet.java    From GidsApplet with GNU General Public License v3.0 4 votes vote down vote up
/**
 * \brief Only this class's install method should create the applet object.
 */
protected GidsApplet() {

    // by default the pin manager is in "initialization mode"
    pinManager = new GidsPINManager();

    transmitManager = new TransmitManager();

    currentAlgorithmRef = JCSystem.makeTransientByteArray((short)1, JCSystem.CLEAR_ON_DESELECT);
    currentKey = JCSystem.makeTransientObjectArray((short)1, JCSystem.CLEAR_ON_DESELECT);

    rsaPkcs1Cipher = Cipher.getInstance(Cipher.ALG_RSA_PKCS1, false);
    try {
        rsaOaepCipher = Cipher.getInstance(Cipher.ALG_RSA_PKCS1_OAEP, false);
    } catch (CryptoException e) {
        if(e.getReason() == CryptoException.NO_SUCH_ALGORITHM) {
            rsaOaepCipher = null;
        } else {
            throw e;
        }
    }
    rsaRawCipher = Cipher.getInstance(Cipher.ALG_RSA_NOPAD, false);

    byte mechanisms =  (byte) 0xC0;
    fs = new GidsFileSystem(pinManager, transmitManager, (short) 0x3F00,
                            // FCP
                            new byte[]	{
                                (byte)0x62, (byte)0x08,
                                (byte)0x82, (byte)0x01, (byte)0x38, // File descriptor byte.
                                (byte)0x8C, (byte)0x03, (byte)0x03, (byte)0x30, (byte)0x30,// security attribute
                            },
                            // FCI
                            new byte[]	{
                                0x61, 0X12,
                                0x4F, 0x0B, (byte) 0xA0, (byte) 0x00, (byte) 0x00, (byte) 0x03, (byte) 0x97, (byte) 0x42, (byte) 0x54, (byte) 0x46, (byte) 0x59, 0x02, 0x01, // AID
                                0x73, 0x03,
                                0x40, 0x01, mechanisms, // cryptographic mechanism
                            },
                            // FMD
                            new byte[]	{
                                (byte)0x64, (byte)0x09,
                                (byte)0x5F, (byte)0x2F, (byte) 0x01, (byte) 0x60, // pin usage policy
                                (byte)0x7F, (byte)0x65, 0x02, (byte) 0x80, 0x00
                            }
                           );

    // FCI / FMD / FCP are hard coded
    register();
}