• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ISOException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javacard.framework.ISOException的典型用法代码示例。如果您正苦于以下问题:Java ISOException类的具体用法?Java ISOException怎么用?Java ISOException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ISOException类属于javacard.framework包,在下文中一共展示了ISOException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: copy

import javacard.framework.ISOException; //导入依赖的package包/类
/**
* Copies {@code other} into this. No size requirements. If {@code other}
* has more digits then the superfluous leading digits of {@code other} are
* asserted to be zero. If this bignat has more digits than its leading
* digits are correctly initilized to zero. This function will not change size 
* attribute of this object.
* 
* @param other
*            Bignat to copy into this object.
*/
public void copy(Bignat other) {
    short this_start, other_start, len;
    if (this.size >= other.size) {
        this_start = (short) (this.size - other.size);
        other_start = 0;
        len = other.size;
    } else {
        this_start = 0;
        other_start = (short) (other.size - this.size);
        len = this.size;
        // Verify here that other have leading zeroes up to other_start
        for (short i = 0; i < other_start; i ++) {
            if (other.value[i] != 0) {
                ISOException.throwIt(ReturnCodes.SW_BIGNAT_INVALIDCOPYOTHER);
            }
        }
    }

    if (this_start > 0) {
        // if this bignat has more digits than its leading digits are initilized to zero
        Util.arrayFillNonAtomic(this.value, (short) 0, this_start, (byte) 0);
    }
    Util.arrayCopyNonAtomic(other.value, other_start, this.value, this_start, len);
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:35,代码来源:Bignat.java


示例2: clone

import javacard.framework.ISOException; //导入依赖的package包/类
/**
 * Copies content of {@code other} into this and set size of this to {@code other}. 
 * The size attribute (returned by length()) is updated. If {@code other}
 * is longer than maximum capacity of this, internal buffer is reallocated if enabled 
 * (ALLOW_RUNTIME_REALLOCATION), otherwise exception is thrown.
 * @param other 
 *            Bignat to clone into this object.
 */    
public void clone(Bignat other) { 
    // Reallocate array only if current array cannot store the other value and reallocation is enabled by ALLOW_RUNTIME_REALLOCATION
    if (this.max_size < other.length()) {
        // Reallocation necessary
        if (ALLOW_RUNTIME_REALLOCATION) {
            allocate_storage_array(other.length(), this.allocatorType);
        }
        else {
            ISOException.throwIt(ReturnCodes.SW_BIGNAT_REALLOCATIONNOTALLOWED);
        }
    }
    
    // copy value from other into proper place in this (this can be longer than other so rest of bytes wil be filled with 0)
    other.copy_to_buffer(this.value, (short) 0);
    if (this.max_size > other.length()) {
        Util.arrayFillNonAtomic(this.value, other.length(), (short) (this.max_size - other.length()), (byte) 0);
    }
    this.size = other.length();
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:28,代码来源:Bignat.java


示例3: n_mod_exp

import javacard.framework.ISOException; //导入依赖的package包/类
/**
 * Calculates {@code res := base ** exp mod mod} using RSA engine. 
 * Requirements:
 * 1. Modulo must be either 521, 1024, 2048 or other lengths supported by RSA (see appendzeros() and mod() method)
 * 2. Base must have the same size as modulo (see prependzeros())
 * @param baseLen   length of base rounded to size of RSA engine
 * @param base      value of base (if size is not equal to baseLen then zeroes are appended)
 * @param exponent  array with exponent
 * @param exponentLen length of exponent
 * @param modulo    value of modulo 
 * @param resultArray array for the computed result
 * @param resultOffset start offset of resultArray
 */
private short n_mod_exp(short baseLen, Bignat base, byte[] exponent, short exponentLen, Bignat modulo, byte[] resultArray, short resultOffset) {
    // Verify if pre-allocated engine match the required values
    if (bnh.fnc_NmodE_pubKey.getSize() < (short) (modulo.length() * 8)) {
        // attempt to perform modulu with higher or smaller than supported length - try change constant MODULO_ENGINE_MAX_LENGTH
        ISOException.throwIt(ReturnCodes.SW_BIGNAT_MODULOTOOLARGE);
    }
    if (bnh.fnc_NmodE_pubKey.getSize() < (short) (base.length() * 8)) {
        ISOException.throwIt(ReturnCodes.SW_BIGNAT_MODULOTOOLARGE);
    }
    // Potential problem: we are changing key value for publicKey already used before with occ.bnHelper.modCipher. 
    // Simulator and potentially some cards fail to initialize this new value properly (probably assuming that same key object will always have same value)
    // Fix (if problem occure): generate new key object: RSAPublicKey publicKey = (RSAPublicKey) KeyBuilder.buildKey(KeyBuilder.TYPE_RSA_PUBLIC, (short) (baseLen * 8), false);

    bnh.fnc_NmodE_pubKey.setExponent(exponent, (short) 0, exponentLen);
    bnh.lock(bnh.fnc_deep_resize_tmp);
    modulo.append_zeros(baseLen, bnh.fnc_deep_resize_tmp, (short) 0);
    bnh.fnc_NmodE_pubKey.setModulus(bnh.fnc_deep_resize_tmp, (short) 0, baseLen);
    bnh.fnc_NmodE_cipher.init(bnh.fnc_NmodE_pubKey, Cipher.MODE_DECRYPT);        
    base.prepend_zeros(baseLen, bnh.fnc_deep_resize_tmp, (short) 0);
    // BUGBUG: Check if input is not all zeroes (causes out-of-bound exception on some cards)
    short len = bnh.fnc_NmodE_cipher.doFinal(bnh.fnc_deep_resize_tmp, (short) 0, baseLen, resultArray, resultOffset); 
    bnh.unlock(bnh.fnc_deep_resize_tmp);
    return len;
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:38,代码来源:Bignat.java


示例4: registerLock

import javacard.framework.ISOException; //导入依赖的package包/类
/**
 * Register new object for lock guarding. 
 * @param objToLock object to be guarded
 * @return index to internal array where registered object is stored (if known, lock/unlock is faster)
 */
public short registerLock(Object objToLock) {
    short i;
    for (i = 0; i < (short) lockedObjects.length; i += 2) {
        if (lockedObjects[i] == null) {
            // Free slot found
            lockedObjects[i] = objToLock;
            lockedObjects[(short) (i + 1)] = null; // null means array is unlocked
            lockedObjectsPersistent[i] = objToLock; // Store same into persistent array as well
            lockedObjectsPersistent[(short) (i + 1)] = null; 
            return i; // Return index for potential speedup of locking
        }
    }
    ISOException.throwIt(ReturnCodes.SW_LOCK_NOFREESLOT);
    return -1;
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:21,代码来源:ObjectLocker.java


示例5: lock

import javacard.framework.ISOException; //导入依赖的package包/类
/**
 * Lock/reserve provided object for subsequent use. Used to protect corruption
 * of pre-allocated shared objects in different, potentially nested,
 * operations. Must be unlocked later on.
 *
 * @param objToLock array to be locked
 * @throws SW_ALREADYLOCKED if already locked (is already in use by
 * other operation)
 */
public void lock(Object objToLock) {
    if (!bLockingActive) {
        return;
    }
    // Find object to lock
    short i;
    for (i = 0; i < (short) lockedObjects.length; i += 2) {
        if (lockedObjects[i] != null && lockedObjects[i].equals(objToLock)) {
            lock(objToLock, i);
            break;
        }
    }
    // If reached here, required array was not found
    if (i == (short) lockedObjects.length) {
        ISOException.throwIt(ReturnCodes.SW_LOCK_OBJECT_NOT_FOUND);
    }
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:27,代码来源:ObjectLocker.java


示例6: unlock

import javacard.framework.ISOException; //导入依赖的package包/类
/**
 * Unlock/release object from use. Used to protect corruption of
 * pre-allocated objects used in different nested operations. Must
 * be locked before.
 *
 * @param objToUnlock object to unlock
 * @throws SW_NOTLOCKED_BIGNAT if was not locked before (inconsistence in
 * lock/unlock sequence)
 */

public void unlock(Object objToUnlock) {
    if (!bLockingActive) {
        return;
    }
    // Find object to unlock
    short i;
    for (i = 0; i < (short) lockedObjects.length; i += 2) {
        if (lockedObjects[i] != null && lockedObjects[i].equals(objToUnlock)) {
            unlock(objToUnlock, i);
            break;
        }
    }
    // If reached here, required array was not found
    if (i == (short) lockedObjects.length) {
        ISOException.throwIt(ReturnCodes.SW_LOCK_OBJECT_NOT_FOUND);
    }
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:28,代码来源:ObjectLocker.java


示例7: isLocked

import javacard.framework.ISOException; //导入依赖的package包/类
/**
 * Check if provided object is logically locked
 * @param objToUnlock object to be checked
 * @return true of array is logically locked, false otherwise 
 */

public boolean isLocked(Object objToUnlock) {
    if (!bLockingActive) {
        return false;
    }
    // Find object to unlock
    short i;
    for (i = 0; i < (short) lockedObjects.length; i += 2) {
        if (lockedObjects[i] != null && lockedObjects[i].equals(objToUnlock)) {
            return lockedObjects[(short) (i + 1)] != null;
        }
    }
    // If reached here, required object was not found
    if (i == (short) lockedObjects.length) {
        ISOException.throwIt(ReturnCodes.SW_LOCK_OBJECT_NOT_FOUND);
    }
    return false;
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:24,代码来源:ObjectLocker.java


示例8: process

import javacard.framework.ISOException; //导入依赖的package包/类
public void process(APDU apdu) {
	// Good practice: Return 9000 on SELECT
	if (selectingApplet()) {
		return;
	}

	byte[] buf = apdu.getBuffer();
	switch (buf[ISO7816.OFFSET_INS]) {
	case (byte) 0x00:
		handleGetPRand(apdu);
		break;
	case (byte) 0x01:
		handleGetCmac(apdu);
		break;
	default:
		// good practice: If you don't know the INStruction, say so:
		ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
	}
}
 
开发者ID:tsenger,项目名称:CCU2F,代码行数:20,代码来源:PRNGTest.java


示例9: createPoint

import javacard.framework.ISOException; //导入依赖的package包/类
static ECPointBase createPoint(short keyLen) {
    switch (ECPOINT_LIB) {
        case ECPOINT_INSTANCE_TYPE_SW: 
            return ECPoint_SW.createPoint(ecc);
        case ECPOINT_INSTANCE_TYPE_NXP: 
            ISOException.throwIt(Consts.SW_NOTSUPPORTEDYET);
            break;
        case ECPOINT_INSTANCE_TYPE_GEMALTO:
            ISOException.throwIt(Consts.SW_NOTSUPPORTEDYET);
            break;
        case ECPOINT_INSTANCE_TYPE_GD:
            ISOException.throwIt(Consts.SW_NOTSUPPORTEDYET);
            break;
        case ECPOINT_INSTANCE_TYPE_FEITIAN:
            ISOException.throwIt(Consts.SW_NOTSUPPORTEDYET);
            break;
        default: 
            ISOException.throwIt(Consts.SW_NOTSUPPORTEDYET);
    }
    return null;
}
 
开发者ID:OpenCryptoProject,项目名称:Myst,代码行数:22,代码来源:ECPointBuilder.java


示例10: allocate

import javacard.framework.ISOException; //导入依赖的package包/类
public static void allocate(ECCurve curve, ECConfig ecCfg) {
    theCurve = curve;
    ecc = ecCfg;
    
    switch (ECPOINT_LIB) {
        case ECPOINT_INSTANCE_TYPE_SW:
            ECPoint_SW.allocate(ecc, theCurve);
            break;
        case ECPOINT_INSTANCE_TYPE_NXP:
            ISOException.throwIt(Consts.SW_NOTSUPPORTEDYET);
            break;
        case ECPOINT_INSTANCE_TYPE_GEMALTO:
            ISOException.throwIt(Consts.SW_NOTSUPPORTEDYET);
            break;
        case ECPOINT_INSTANCE_TYPE_GD:
            ISOException.throwIt(Consts.SW_NOTSUPPORTEDYET);
            break;
        case ECPOINT_INSTANCE_TYPE_FEITIAN:
            ISOException.throwIt(Consts.SW_NOTSUPPORTEDYET);
            break;
        default:
            ISOException.throwIt(Consts.SW_NOTSUPPORTEDYET);
    }
}
 
开发者ID:OpenCryptoProject,项目名称:Myst,代码行数:25,代码来源:ECPointBuilder.java


示例11: copy

import javacard.framework.ISOException; //导入依赖的package包/类
/**
* Copies {@code other} into this. No size requirements. If {@code other}
* has more digits then the superfluous leading digits of {@code other} are
* asserted to be zero. If this bignat has more digits than its leading
* digits are correctly initilized to zero. This function will not change size 
* attribute of this object.
* 
* @param other
*            Bignat to copy into this object.
*/
public void copy(Bignat other) {
    short this_start, other_start, len;
    if (this.size >= other.size) {
        this_start = (short) (this.size - other.size);
        other_start = 0;
        len = other.size;
    } else {
        this_start = 0;
        other_start = (short) (other.size - this.size);
        len = this.size;
        // Verify here that other have leading zeroes up to other_start
        for (short i = 0; i < other_start; i ++) {
            if (other.value[i] != 0) {
                ISOException.throwIt(ReturnCodes.SW_BIGNAT_INVALIDCOPYOTHER);
            }
        }
    }
    
    if (this_start > 0) {
        // if this bignat has more digits than its leading digits are initilized to zero
        Util.arrayFillNonAtomic(this.value, (short) 0, this_start, (byte) 0);
    }
    Util.arrayCopyNonAtomic(other.value, other_start, this.value, this_start, len);
}
 
开发者ID:OpenCryptoProject,项目名称:Myst,代码行数:35,代码来源:jcmathlib.java


示例12: n_mod_exp

import javacard.framework.ISOException; //导入依赖的package包/类
/**
 * Calculates {@code res := base ** exp mod mod} using RSA engine. 
 * Requirements:
 * 1. Modulo must be either 521, 1024, 2048 or other lengths supported by RSA (see appendzeros() and mod() method)
 * 2. Base must have the same size as modulo (see prependzeros())
 * @param baseLen   length of base rounded to size of RSA engine
 * @param base      value of base (if size is not equal to baseLen then zeroes are appended)
 * @param exponent  array with exponent
 * @param exponentLen length of exponent
 * @param modulo    value of modulo 
 * @param resultArray array for the computed result
 * @param resultOffset start offset of resultArray
 */
private short n_mod_exp(short baseLen, Bignat base, byte[] exponent, short exponentLen, Bignat modulo, byte[] resultArray, short resultOffset) {
    // Verify if pre-allocated engine match the required values
    if (bnh.fnc_NmodE_pubKey.getSize() < (short) (modulo.length() * 8)) {
        // attempt to perform modulu with higher or smaller than supported length - try change constant MODULO_ENGINE_MAX_LENGTH
        ISOException.throwIt(ReturnCodes.SW_BIGNAT_MODULOTOOLARGE);
    }
    if (bnh.fnc_NmodE_pubKey.getSize() < (short) (base.length() * 8)) {
        ISOException.throwIt(ReturnCodes.SW_BIGNAT_MODULOTOOLARGE);
    }
    // Potential problem: we are changing key value for publicKey already used before with occ.bnHelper.modCipher. 
    // Simulator and potentially some cards fail to initialize this new value properly (probably assuming that same key object will always have same value)
    // Fix (if problem occure): generate new key object: RSAPublicKey publicKey = (RSAPublicKey) KeyBuilder.buildKey(KeyBuilder.TYPE_RSA_PUBLIC, (short) (baseLen * 8), false);
    
    bnh.fnc_NmodE_pubKey.setExponent(exponent, (short) 0, exponentLen);
    bnh.lock(bnh.fnc_deep_resize_tmp);
    modulo.append_zeros(baseLen, bnh.fnc_deep_resize_tmp, (short) 0);
    bnh.fnc_NmodE_pubKey.setModulus(bnh.fnc_deep_resize_tmp, (short) 0, baseLen);
    bnh.fnc_NmodE_cipher.init(bnh.fnc_NmodE_pubKey, Cipher.MODE_DECRYPT);        
    base.prepend_zeros(baseLen, bnh.fnc_deep_resize_tmp, (short) 0);
    // BUGBUG: Check if input is not all zeroes (causes out-of-bound exception on some cards)
    short len = bnh.fnc_NmodE_cipher.doFinal(bnh.fnc_deep_resize_tmp, (short) 0, baseLen, resultArray, resultOffset); 
    bnh.unlock(bnh.fnc_deep_resize_tmp);
    return len;
}
 
开发者ID:OpenCryptoProject,项目名称:Myst,代码行数:38,代码来源:jcmathlib.java


示例13: MPCApplet

import javacard.framework.ISOException; //导入依赖的package包/类
public MPCApplet() {
    m_ecc = new ECConfig((short) 256);
    m_ecc.bnh.bIsSimulator = bIsSimulator;
    m_curve = new ECCurve(false, SecP256r1.p, SecP256r1.a, SecP256r1.b, SecP256r1.G, SecP256r1.r);

    ECPointBuilder.allocate(m_curve, m_ecc);
    ECPointBase.allocate(m_curve);
    if (m_ecc.MULT_RSA_ENGINE_MAX_LENGTH_BITS < (short) 1024) {
        ISOException.throwIt(Consts.SW_INCORRECTJCMATHLIBSETTINGS);
    }
    
    m_cryptoOps = new MPCCryptoOps(m_ecc);
    
    m_quorums = new QuorumContext[Consts.MAX_QUORUMS];
    for (short i = 0; i < (short) m_quorums.length; i++) {
        m_quorums[i] = new QuorumContext(m_ecc, m_curve, m_cryptoOps);
    }
    
    // Generate random unique card ID
    cardIDLong = new byte[Consts.CARD_ID_LONG_LENGTH];
    m_cryptoOps.randomData.generateData(cardIDLong, (short) 0, (short) cardIDLong.length);
}
 
开发者ID:OpenCryptoProject,项目名称:Myst,代码行数:23,代码来源:MPCApplet.java


示例14: GenerateRandomData

import javacard.framework.ISOException; //导入依赖的package包/类
/**
 * The remote host submits a request for randomness to all actors
 * participating in the quorum. Subsequently, each actor independently
 * generates a random share bi , encrypts it with the public key of the
 * host, and signs the ciphertext with its private key. Once the host
 * receives all the shares, he combines them to retrieve the b and then uses
 * an one way function (e.g., SHA3-512) to convert it to a fixed length
 * string.
 */
void GenerateRandomData(APDU apdu) {
    ISOException.throwIt(Consts.SW_NOTSUPPORTEDYET);

    byte[] apdubuf = apdu.getBuffer();
    short paramsOffset = GetOperationParamsOffset(Consts.INS_GENERATE_RANDOM, apdu);
    // Parse incoming apdu to obtain target quorum context
    QuorumContext quorumCtx = GetTargetQuorumContext(apdubuf, paramsOffset);
    // Verify authorization
    quorumCtx.VerifyCallerAuthorization(apdu, StateModel.FNC_QuorumContext_GenerateRandomData);
    
    // TODO: Check state
    // TODO: Verify signature on request
    // TODO: Generate share
    // TODO: Encrypt share with host public key
    // TODO: Sign output share

    //apdu.setOutgoingAndSend((short) 0, len);
}
 
开发者ID:OpenCryptoProject,项目名称:Myst,代码行数:28,代码来源:MPCApplet.java


示例15: StoreCommitment

import javacard.framework.ISOException; //导入依赖的package包/类
public void StoreCommitment(short id, byte[] commitment, short commitmentOffset, short commitmentLength) {
    state.CheckAllowedFunction(StateModel.FNC_QuorumContext_StoreCommitment);

    if (id < 0 || id == CARD_INDEX_THIS || id >= NUM_PLAYERS) {
        ISOException.throwIt(Consts.SW_INVALIDPLAYERINDEX);
    }
    if (commitmentLength != players[id].YsCommitment.length) {
        ISOException.throwIt(Consts.SW_INVALIDCOMMITMENTLENGTH);
    }
    if (players[id].bYsCommitmentValid) {
        // commitment already stored
        ISOException.throwIt(Consts.SW_COMMITMENTALREADYSTORED);
    }
    else {
        Util.arrayCopyNonAtomic(commitment, commitmentOffset, players[id].YsCommitment, (short) 0, commitmentLength);
        players[id].bYsCommitmentValid = true;
        num_commitments_count++;

        if (num_commitments_count == NUM_PLAYERS) {
            // All commitments were collected, allow for export of this card share
            state.MakeStateTransition(StateModel.STATE_KEYGEN_COMMITMENTSCOLLECTED);  
        }
        
    }
}
 
开发者ID:OpenCryptoProject,项目名称:Myst,代码行数:26,代码来源:QuorumContext.java


示例16: GetYi

import javacard.framework.ISOException; //导入依赖的package包/类
/**
 * Returns this card public key share
 * @param commitmentBuffer output buffer where to store commitment
 * @param commitmentOffset start offset within target output buffer
 * @return 
 */
public short GetYi(byte[] commitmentBuffer, short commitmentOffset) {
    state.CheckAllowedFunction(StateModel.FNC_QuorumContext_GetYi);

    if (state.GetState() == StateModel.STATE_KEYGEN_COMMITMENTSCOLLECTED) {
        if (players[CARD_INDEX_THIS].bYsValid) {
            Util.arrayCopyNonAtomic(this_card_Ys, (short) 0, commitmentBuffer, commitmentOffset, (short) this_card_Ys.length);
            return (short) this_card_Ys.length;
        } else {
            ISOException.throwIt(Consts.SW_INVALIDYSHARE);
        }
    } else {
        ISOException.throwIt(Consts.SW_INCORRECTSTATE);
    }
    return 0;
}
 
开发者ID:OpenCryptoProject,项目名称:Myst,代码行数:22,代码来源:QuorumContext.java


示例17: decodeLength

import javacard.framework.ISOException; //导入依赖的package包/类
public static short decodeLength(byte[] buf, short offset) {
    short off = offset;
    byte b = buf[off];
    short s = buf[off];
    if ((b & (byte) 0x80) != 0) {
        off += 1;

        if (b == (byte) 0x81) {
            s = (short) (0x00FF & buf[off]);
        } else if (b == (byte) 0x82) {
            s = Util.getShort(buf, off);
        } else {
            ISOException.throwIt(ISO7816.SW_UNKNOWN);
        }
    }
    return s;
}
 
开发者ID:mbrossard,项目名称:cryptonit-applet,代码行数:18,代码来源:BERTLV.java


示例18: receiveBuffer

import javacard.framework.ISOException; //导入依赖的package包/类
public void receiveBuffer(byte[] buf, short offset, short length) {
    if (this.bools[isLOADED]) {
        if (this.bools[isFILE]) {
            ISOException.throwIt(ISO7816.SW_CONDITIONS_NOT_SATISFIED);
        }
        if ((short) (this.shorts[SIZE] + length) > this.buffer.length) {
            ISOException.throwIt(ISO7816.SW_FILE_FULL);
        }
        Util.arrayCopy(buf, offset, this.buffer, this.shorts[SIZE], length);
        this.shorts[SIZE] += length;
    } else {
        Util.arrayCopy(buf, offset, this.buffer, (short) 0, length);
        this.shorts[SIZE] = length;
        this.bools[isLOADED] = true;
        this.bools[isFILE] = false;
    }
}
 
开发者ID:mbrossard,项目名称:cryptonit-applet,代码行数:18,代码来源:IOBuffer.java


示例19: createObject

import javacard.framework.ISOException; //导入依赖的package包/类
/**
 * Creates an object with specified parameters. Throws a SW_NO_MEMORY_LEFT
 * exception if cannot allocate the memory. Does not check if object exists.
 * 
 * @param type
 *            Object Type
 * @param id
 *            Object ID (Type and ID form a generic 4 bytes identifier)
 * @param acl_buf
 *            Java byte array containing the ACL for the new object
 * @param acl_offset
 *            Offset at which the ACL starts in acl_buf[]
 * @return The memory base address for the object. It can be used in
 *         successive calls to xxxFromAddress() methods.
 */
public short createObject(short type, short id, short size, byte[] acl_buf, short acl_offset) {
	/* Allocate memory for new object */
	short base = mem.alloc((short) (size + OBJ_HEADER_SIZE));
	if (base == MemoryManager.NULL_OFFSET)
		ISOException.throwIt(SW_NO_MEMORY_LEFT);
	/* New obj will be inserted in the head of the list */
	mem.setShort(base, OBJ_H_NEXT, obj_list_head);
	mem.setShort(base, OBJ_H_CLASS, type);
	mem.setShort(base, OBJ_H_ID, id);
	mem.setShort(base, OBJ_H_SIZE, size);
	mem.setBytes(base, OBJ_H_ACL, acl_buf, acl_offset, OBJ_ACL_SIZE);
	obj_list_head = base;

	/* Add to the map */
	// map.addEntry(type, id, base);

	// Return base address
	return (short) (base + OBJ_HEADER_SIZE);
}
 
开发者ID:Toporin,项目名称:SatoChipApplet,代码行数:35,代码来源:ObjectManager.java


示例20: CardEdge

import javacard.framework.ISOException; //导入依赖的package包/类
/****************************************
 * Methods *
 ****************************************/

private CardEdge(byte[] bArray, short bOffset, byte bLength) {
	// FIXED: something should be done already here, not only with setup APDU
	
	/* If init pin code does not satisfy policies, internal error */
	if (!CheckPINPolicy(PIN_INIT_VALUE, (short) 0, (byte) PIN_INIT_VALUE.length))
	    ISOException.throwIt(SW_INTERNAL_ERROR);

    ublk_pins = new OwnerPIN[MAX_NUM_PINS];
	pins = new OwnerPIN[MAX_NUM_PINS];

	// DONE: pass in starting PIN setting with instantiation
	/* Setting initial PIN n.0 value */
	pins[0] = new OwnerPIN((byte) 3, (byte) PIN_INIT_VALUE.length);
	pins[0].update(PIN_INIT_VALUE, (short) 0, (byte) PIN_INIT_VALUE.length);
	
	// debug
	register();
}
 
开发者ID:Toporin,项目名称:SatoChipApplet,代码行数:23,代码来源:CardEdge.java



注:本文中的javacard.framework.ISOException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Configuration类代码示例发布时间:2022-05-21
下一篇:
Java Transform类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap