当前位置: 首页>>代码示例>>Java>>正文


Java ISO7816.OFFSET_P2属性代码示例

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


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

示例1: test_EC_SETCURVE_G

void test_EC_SETCURVE_G(APDU apdu, short dataLen) {
     byte[] apdubuf = apdu.getBuffer();
     
     Util.arrayCopyNonAtomic(apdubuf, ISO7816.OFFSET_CDATA, m_customG, (short) 0, dataLen);
     PM.check(PM.TRAP_EC_SETCURVE_1);

     if (apdubuf[ISO7816.OFFSET_P2] == 1) { // If required, complete new custom curve and point is allocated
         m_testCurveCustom = new ECCurve(false, SecP256r1.p, SecP256r1.a, SecP256r1.b, m_customG, SecP256r1.r);
         m_testPointCustom = new ECPoint(m_testCurveCustom, m_ecc.ech);
         PM.check(PM.TRAP_EC_SETCURVE_2);
         // Release unused previous objects
         if (!bIsSimulator) {
             JCSystem.requestObjectDeletion();
         }
     }
     else {
         // Otherwise, only G is set and relevant objects are updated
         m_testCurveCustom.setG(apdubuf, (short) ISO7816.OFFSET_CDATA, m_testCurveCustom.POINT_SIZE);
         m_testPointCustom.updatePointObjects(); // After changing curve parameters, internal objects needs to be actualized
     }
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:21,代码来源:OCUnitTests.java

示例2: test_BN_EXP

void test_BN_EXP(APDU apdu, short dataLen) {
    byte[] apdubuf = apdu.getBuffer();
    short p1 = (short) (apdubuf[ISO7816.OFFSET_P1] & 0x00FF);
    short p2 = (short) (apdubuf[ISO7816.OFFSET_P2] & 0x00FF);

    PM.check(PM.TRAP_BN_EXP_1);    
    Bignat base = m_testBN1;
    base.set_size(p1);
    PM.check(PM.TRAP_BN_EXP_2);
    Bignat exp = m_testBN2;
    exp.set_size((short) (dataLen - p1));
    PM.check(PM.TRAP_BN_EXP_3);
    Bignat res = m_testBN3;
    res.set_size((short) (m_ecc.MAX_BIGNAT_SIZE / 2));
    PM.check(PM.TRAP_BN_EXP_4);
    base.from_byte_array(p1, (short) 0, apdubuf, ISO7816.OFFSET_CDATA);
    exp.from_byte_array((short) (dataLen - p1), (short) 0, apdubuf, (short)(ISO7816.OFFSET_CDATA+p1));
    PM.check(PM.TRAP_BN_EXP_5);
    res.exponentiation(base, exp);
    PM.check(PM.TRAP_BN_EXP_6);
    short len = res.copy_to_buffer(apdubuf, (short) 0);
    apdu.setOutgoingAndSend((short) 0, len);
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:23,代码来源:OCUnitTests.java

示例3: test_BN_ADD_MOD

void test_BN_ADD_MOD(APDU apdu, short dataLen) {
    byte[] apdubuf = apdu.getBuffer();
    short p1 = (short) (apdubuf[ISO7816.OFFSET_P1] & 0x00FF);
    short p2 = (short) (apdubuf[ISO7816.OFFSET_P2] & 0x00FF);

    PM.check(PM.TRAP_BN_ADD_MOD_1);    
    Bignat num1 = m_testBN1;
    num1.set_size(p1);
    PM.check(PM.TRAP_BN_ADD_MOD_2);
    Bignat num2 = m_testBN2;
    num2.set_size(p2);
    PM.check(PM.TRAP_BN_ADD_MOD_3);
    Bignat mod = m_testBN3;
    mod.set_size((short) (dataLen - p1 - p2));
    PM.check(PM.TRAP_BN_ADD_MOD_4);
    num1.from_byte_array(p1, (short)0, apdubuf, ISO7816.OFFSET_CDATA);
    num2.from_byte_array(p2, (short)0, apdubuf, (short)(ISO7816.OFFSET_CDATA+p1));
    PM.check(PM.TRAP_BN_ADD_MOD_5);
    mod.from_byte_array((short)(dataLen-p1-p2), (short)0, apdubuf, (short)(ISO7816.OFFSET_CDATA+p1+p2));
    PM.check(PM.TRAP_BN_ADD_MOD_6);
    num1.mod_add(num2, mod);
    PM.check(PM.TRAP_BN_ADD_MOD_7);
    short len = num1.copy_to_buffer(apdubuf, (short) 0);
    apdu.setOutgoingAndSend((short) 0, len);
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:25,代码来源:OCUnitTests.java

示例4: test_BN_SUB_MOD

void test_BN_SUB_MOD(APDU apdu, short dataLen) {
    byte[] apdubuf = apdu.getBuffer();
    short p1 = (short) (apdubuf[ISO7816.OFFSET_P1] & 0x00FF);
    short p2 = (short) (apdubuf[ISO7816.OFFSET_P2] & 0x00FF);

    PM.check(PM.TRAP_BN_SUB_MOD_1);    
    Bignat num1 = m_testBN1;
    num1.set_size(p1);
    PM.check(PM.TRAP_BN_SUB_MOD_2);
    Bignat num2 = m_testBN2;
    num2.set_size(p2);
    PM.check(PM.TRAP_BN_SUB_MOD_3);
    Bignat mod = m_testBN3;
    mod.set_size((short) (dataLen - p1 - p2));
    PM.check(PM.TRAP_BN_SUB_MOD_4);
    num1.from_byte_array(p1, (short)0, apdubuf, ISO7816.OFFSET_CDATA);
    num2.from_byte_array(p2, (short)0, apdubuf, (short)(ISO7816.OFFSET_CDATA+p1));
    mod.from_byte_array((short)(dataLen-p1-p2), (short)0, apdubuf, (short)(ISO7816.OFFSET_CDATA+p1+p2));
    PM.check(PM.TRAP_BN_SUB_MOD_5);
    num1.mod_sub(num2, mod);
    PM.check(PM.TRAP_BN_SUB_MOD_6);
    short len = num1.copy_to_buffer(apdubuf, (short) 0);
    apdu.setOutgoingAndSend((short) 0, len);
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:24,代码来源:OCUnitTests.java

示例5: test_BN_MUL_MOD

void test_BN_MUL_MOD(APDU apdu, short dataLen) {
    byte[] apdubuf = apdu.getBuffer();
    short p1 = (short) (apdubuf[ISO7816.OFFSET_P1] & 0x00FF);
    short p2 = (short) (apdubuf[ISO7816.OFFSET_P2] & 0x00FF);

    PM.check(PM.TRAP_BN_MUL_MOD_1);    
    Bignat num1 = m_testBN1;
    num1.set_size(p1);
    PM.check(PM.TRAP_BN_MUL_MOD_2);
    Bignat num2 = m_testBN2;
    num2.set_size(p2);
    PM.check(PM.TRAP_BN_MUL_MOD_3);
    Bignat mod = m_testBN3;
    mod.set_size((short) (dataLen - p1 - p2));
    PM.check(PM.TRAP_BN_MUL_MOD_4);
    num1.from_byte_array(p1, (short)0, apdubuf, ISO7816.OFFSET_CDATA);
    num2.from_byte_array(p2, (short)0, apdubuf, (short)(ISO7816.OFFSET_CDATA+p1));
    mod.from_byte_array((short)(dataLen-p1-p2), (short)0, apdubuf, (short)(ISO7816.OFFSET_CDATA+p1+p2));
    PM.check(PM.TRAP_BN_MUL_MOD_5);
    num1.mod_mult(num1, num2, mod);
    PM.check(PM.TRAP_BN_MUL_MOD_6);
    short len = num1.copy_to_buffer(apdubuf, (short) 0);
    apdu.setOutgoingAndSend((short) 0, len);
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:24,代码来源:OCUnitTests.java

示例6: test_BN_EXP_MOD

void test_BN_EXP_MOD(APDU apdu, short dataLen) {
    byte[] apdubuf = apdu.getBuffer();
    short p1 = (short) (apdubuf[ISO7816.OFFSET_P1] & 0x00FF);
    short p2 = (short) (apdubuf[ISO7816.OFFSET_P2] & 0x00FF);

    PM.check(PM.TRAP_BN_EXP_MOD_1);    
    Bignat num1 = m_testBN1;
    num1.set_size(p1);
    PM.check(PM.TRAP_BN_EXP_MOD_2);
    Bignat num2 = m_testBN2;
    num2.set_size(p2);
    PM.check(PM.TRAP_BN_EXP_MOD_3);
    Bignat mod = m_testBN3;
    mod.set_size((short) (dataLen - p1 - p2));
    PM.check(PM.TRAP_BN_EXP_MOD_4);
    num1.from_byte_array(p1, (short)0, apdubuf, ISO7816.OFFSET_CDATA);
    num2.from_byte_array(p2, (short)0, apdubuf, (short)(ISO7816.OFFSET_CDATA+p1));
    mod.from_byte_array((short)(dataLen-p1-p2), (short)0, apdubuf, (short)(ISO7816.OFFSET_CDATA+p1+p2));
    PM.check(PM.TRAP_BN_EXP_MOD_5);
    num1.mod_exp(num2, mod);
    PM.check(PM.TRAP_BN_EXP_MOD_6);
    short len = num1.copy_to_buffer(apdubuf, (short) 0);
    apdu.setOutgoingAndSend((short) 0, len);
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:24,代码来源:OCUnitTests.java

示例7: test_BN_POW2_MOD

void test_BN_POW2_MOD(APDU apdu, short dataLen) {
    byte[] apdubuf = apdu.getBuffer();
    short p1 = (short) (apdubuf[ISO7816.OFFSET_P1] & 0x00FF);
    short p2 = (short) (apdubuf[ISO7816.OFFSET_P2] & 0x00FF);

    PM.check(PM.TRAP_BN_POW2_MOD_1);
    Bignat num1 = m_testBN1;
    num1.set_size(p1);
    Bignat mod = m_testBN3;
    mod.set_size((short) (dataLen - p1));
    num1.from_byte_array(p1, (short) 0, apdubuf, ISO7816.OFFSET_CDATA);
    mod.from_byte_array((short) (dataLen - p1), (short) 0, apdubuf, (short) (ISO7816.OFFSET_CDATA + p1));
    PM.check(PM.TRAP_BN_POW2_MOD_2);
    //num1.pow2Mod_RSATrick(mod);
    num1.mod_exp2(mod);
    PM.check(PM.TRAP_BN_POW2_MOD_3);
    short len = num1.copy_to_buffer(apdubuf, (short) 0);
    apdu.setOutgoingAndSend((short) 0, len);
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:19,代码来源:OCUnitTests.java

示例8: test_EC_SETCURVE_G

void test_EC_SETCURVE_G(APDU apdu, short dataLen) {
     byte[] apdubuf = apdu.getBuffer();
     
     Util.arrayCopyNonAtomic(apdubuf, ISO7816.OFFSET_CDATA, m_customG, (short) 0, dataLen);
     PM.check(PM.TRAP_EC_SETCURVE_1);

     if (apdubuf[ISO7816.OFFSET_P2] == 1) { // If required, complete new custom curve and point is allocated
         m_testCurveCustom = new ECCurve(false, SecP256r1.p, SecP256r1.a, SecP256r1.b, m_customG, SecP256r1.r, m_ecc);
         m_testPointCustom = new ECPoint(m_testCurveCustom, m_ecc);
         PM.check(PM.TRAP_EC_SETCURVE_2);
         // Release unused previous objects
         if (!bIsSimulator) {
             JCSystem.requestObjectDeletion();
         }
     }
     else {
         // Otherwise, only G is set and relevant objects are updated
         m_testCurveCustom.setG(apdubuf, (short) ISO7816.OFFSET_CDATA, m_testCurveCustom.POINT_SIZE);
         m_testPointCustom.updatePointObjects(); // After changing curve parameters, internal objects needs to be actualized
     }
}
 
开发者ID:OpenCryptoProject,项目名称:JCProfiler,代码行数:21,代码来源:OCUnitTests.java

示例9: DeleteObject

/**
 * This function deletes the object identified by the provided object ID. The object�s
 * space and name will be removed from the heap and made available for other objects.
 * The zero flag denotes whether the object�s memory should be zeroed after
 * deletion. This kind of deletion is recommended if object was storing sensitive data.
 *   
 * ins: 0x52
 * p1: 0x00
 * p2: 0x00 or 0x01 for secure erasure 
 * data: [object_id(4b)] 
 * return: none
 */
private void DeleteObject(APDU apdu, byte[] buffer) {
	if (buffer[ISO7816.OFFSET_P1] != (byte) 0x00)
		ISOException.throwIt(SW_INCORRECT_P1);
	if ((buffer[ISO7816.OFFSET_P2] != (byte) 0x00) && (buffer[ISO7816.OFFSET_P2] != (byte) 0x01))
		ISOException.throwIt(SW_INCORRECT_P2);
	short bytesLeft = Util.makeShort((byte) 0x00, buffer[ISO7816.OFFSET_LC]);
	if (bytesLeft != apdu.setIncomingAndReceive())
		ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
	if (bytesLeft != (short) 0x04)
		ISOException.throwIt(SW_INVALID_PARAMETER);
	short obj_class = Util.getShort(buffer, ISO7816.OFFSET_CDATA);
	short obj_id = Util.getShort(buffer, (short) (ISO7816.OFFSET_CDATA + (short) 2));
	// TODO: Here there are 2 object lookups. Optimize, please !
	// (single destroy function with logged_ids param)
	short base = om.getBaseAddress(obj_class, obj_id);
	// Verify that object exists
	if (base == MemoryManager.NULL_OFFSET)
		ISOException.throwIt(SW_OBJECT_NOT_FOUND);
	// Enforce Access Control
	if (!om.authorizeDeleteFromAddress(base, logged_ids))
		ISOException.throwIt(SW_UNAUTHORIZED);
	// Actually delete the object
	om.destroyObject(obj_class, obj_id, buffer[ISO7816.OFFSET_P2] == 0x01);
}
 
开发者ID:Toporin,项目名称:SatoChipApplet,代码行数:36,代码来源:CardEdge.java

示例10: GetObjectSize

/**
 * This function returns the size of an object that has been previously created with 
 * MSCCreateObject.  
 *   
	 * ins: 0x57
 * p1: 0x00
 * p2: 0x00 
 * data: [object_id(4b)] 
 * return: [object_size(2b)]
 */
private void GetObjectSize(APDU apdu, byte[] buffer) {
	// Checking P1 & P2
	if (buffer[ISO7816.OFFSET_P1] != (byte) 0x00)
		ISOException.throwIt(SW_INCORRECT_P1);
	if (buffer[ISO7816.OFFSET_P2] != (byte) 0x00)
		ISOException.throwIt(SW_INCORRECT_P2);
	short bytesLeft = Util.makeShort((byte) 0x00, buffer[ISO7816.OFFSET_LC]);
	if (bytesLeft != apdu.setIncomingAndReceive())
		ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
	if (bytesLeft != (short) 4)
		ISOException.throwIt(SW_INVALID_PARAMETER);
	short obj_class = Util.getShort(buffer, ISO7816.OFFSET_CDATA);
	short obj_id = Util.getShort(buffer, (short) (ISO7816.OFFSET_CDATA + (short) 2));
	short base = om.getBaseAddress(obj_class, obj_id);
	// Verify that object exists
	if (base == MemoryManager.NULL_OFFSET)
		ISOException.throwIt(SW_INVALID_PARAMETER);
	// get object size
	short obj_size= om.getSizeFromAddress(base);
	// Fill the buffer
	Util.setShort(buffer, (short) 0, obj_size);
	// Send response
	apdu.setOutgoingAndSend((short) 0, (short) 2);
}
 
开发者ID:Toporin,项目名称:SatoChipApplet,代码行数:34,代码来源:CardEdge.java

示例11: ListPINs

/**
 * This function returns a 2 byte bit mask of the available PINs that are currently in
 * use. Each set bit corresponds to an active PIN.
 * 
 *  ins: 0x48
 *  p1: 0x00
 *  p2: 0x00
 *  data: none
 *  return: [RFU(1b) | PIN_mask(1b)]
 */
private void ListPINs(APDU apdu, byte[] buffer) {
	// Checking P1 & P2
	if (buffer[ISO7816.OFFSET_P1] != (byte) 0x00)
		ISOException.throwIt(SW_INCORRECT_P1);
	if (buffer[ISO7816.OFFSET_P2] != (byte) 0x00)
		ISOException.throwIt(SW_INCORRECT_P2);
	byte expectedBytes = (byte) (buffer[ISO7816.OFFSET_LC]);
	if (expectedBytes != (short) 2)
		ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
	// Build the PIN bit mask
	short mask = (short) 0x00;
	short b;
	for (b = (short) 0; b < MAX_NUM_PINS; b++)
		if (pins[b] != null)
			mask |= (short) (((short) 0x01) << b);
	// Fill the buffer
	Util.setShort(buffer, (short) 0, mask);
	// Send response
	apdu.setOutgoingAndSend((short) 0, (short) 2);
}
 
开发者ID:Toporin,项目名称:SatoChipApplet,代码行数:30,代码来源:CardEdge.java

示例12: ListObjects

/**
 * This function returns a list of current objects and their properties including id,
 * size, and access control. This function must be initially called with the reset
 * option. The function only returns one object information at a time and must be
 * called in repetition until SW_SUCCESS is returned with no further data.
 * Applications cannot rely on any special ordering of the sequence of returned objects. 
 * 
 *  ins: 0x58
 *  p1: 0x00 (reset and get first entry) or 0x01 (next entry)
 *  p2: 0x00 
 *  data: none
 *  return: [object_id(4b) | object_size(4b) | object_ACL(6b)]
 */
private void ListObjects(APDU apdu, byte[] buffer) {
	// Checking P1 & P2
	if (buffer[ISO7816.OFFSET_P2] != (byte) 0x00)
		ISOException.throwIt(SW_INCORRECT_P2);
	byte expectedBytes = (byte) (buffer[ISO7816.OFFSET_LC]);
	if (expectedBytes < ObjectManager.RECORD_SIZE)
		ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
	boolean found = false; // Suppress compiler warning
	if (buffer[ISO7816.OFFSET_P1] == LIST_OPT_RESET)
		found = om.getFirstRecord(buffer, (short) 0);
	else if (buffer[ISO7816.OFFSET_P1] != LIST_OPT_NEXT)
		ISOException.throwIt(SW_INCORRECT_P1);
	else
		found = om.getNextRecord(buffer, (short) 0);
	if (found)
		apdu.setOutgoingAndSend((short) 0, (short) ObjectManager.RECORD_SIZE);
	else
		ISOException.throwIt(SW_SEQUENCE_END);
}
 
开发者ID:Toporin,项目名称:SatoChipApplet,代码行数:32,代码来源:CardEdge.java

示例13: ListKeys

/**
 * This function returns a list of current keys and their properties including id, type,
 * size, partner, and access control. This function is initially called with the reset
 * sequence set for sequence type. The function only returns one object id at a time
 * and must be called in repetition until SW_SUCCESS is returned. 
 * 
 *  ins: 0x3A
 *  p1: 0x00 (reset and get first entry) or 0x01 (next entry)
 *  p2: 0x00 
 *  data: none
 *  return: [key_num(1b) | key_type(1b) | key_partner(1b) | key_size(2b) | key_ACL(6b)]
 */
private void ListKeys(APDU apdu, byte[] buffer) {
	// Checking P2
	if (buffer[ISO7816.OFFSET_P2] != (byte) 0x00)
		ISOException.throwIt(SW_INCORRECT_P2);
	short expectedBytes = Util.makeShort((byte) 0x00, buffer[ISO7816.OFFSET_LC]);
	if (expectedBytes != (short) 0x0B)
		ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
	if (buffer[ISO7816.OFFSET_P1] == LIST_OPT_RESET)
		key_it = (byte) 0;
	else if (buffer[ISO7816.OFFSET_P1] != LIST_OPT_NEXT)
		ISOException.throwIt(SW_INCORRECT_P1);
	while ((key_it < MAX_NUM_KEYS) && ((keys[key_it] == null) || !keys[key_it].isInitialized()))
		key_it++;
	if (key_it < MAX_NUM_KEYS) {
		Key key = keys[key_it];
		buffer[(short) 0] = key_it;
		buffer[(short) 1] = key.getType();// getKeyType(key);
		buffer[(short) 2] = (byte) 0xFF; // No partner information available
		Util.setShort(buffer, (short) 3, key.getSize());
		Util.arrayCopyNonAtomic(keyACLs, (short) (key_it * KEY_ACL_SIZE), buffer, (short) 5, KEY_ACL_SIZE);
		// Advance iterator
		key_it++;
		apdu.setOutgoingAndSend((short) 0, (short) (5 + KEY_ACL_SIZE));
	}
}
 
开发者ID:Toporin,项目名称:SatoChipApplet,代码行数:37,代码来源:CardEdge.java

示例14: computeHmac

private void computeHmac(APDU apdu, byte[] buffer) {
	if (buffer[ISO7816.OFFSET_P1] != (byte)20 && buffer[ISO7816.OFFSET_P1] != (byte)64)
		ISOException.throwIt(SW_INCORRECT_P1);
	if (buffer[ISO7816.OFFSET_P2] != (byte) 0x00)
		ISOException.throwIt(SW_INCORRECT_P2);
	short avail = Util.makeShort((byte) 0x00, buffer[ISO7816.OFFSET_LC]);
	if (apdu.setIncomingAndReceive() != avail)
		ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
	
	short pos= ISO7816.OFFSET_CDATA;//apdu.getOffsetCdata(); //(short) ISO7816.OFFSET_CDATA;
	short key_size=Util.getShort(buffer, pos);
	pos+=2;
	pos+=key_size;
	short msg_size=Util.getShort(buffer, pos);
	pos+=2;
	short hashSize=0;
	if (buffer[ISO7816.OFFSET_P1]==(byte)20)
		hashSize= HmacSha160.computeHmacSha160(buffer, (short)(ISO7816.OFFSET_CDATA+2), key_size, buffer, pos, msg_size, buffer, (short)0);
	else if (buffer[ISO7816.OFFSET_P1]==(byte)64)
		hashSize= HmacSha512.computeHmacSha512(buffer, (short)(ISO7816.OFFSET_CDATA+2), key_size, buffer, pos, msg_size, buffer, (short)0);
	apdu.setOutgoingAndSend((short) 0, hashSize);
	return;
}
 
开发者ID:Toporin,项目名称:SatoChipApplet,代码行数:23,代码来源:CardEdge.java

示例15: processPerformSecurityOperation

/**
 * \brief Process the PERFORM SECURITY OPERATION apdu (INS=2A).
 *
 * This operation is used for cryptographic operations
 * (Computation of digital signatures, decrypting.).
 *
 * \param apdu The PERFORM SECURITY OPERATION apdu.
 *
 * \throw ISOException SW_SECURITY_STATUS_NOT_SATISFIED, SW_INCORRECT_P1P2 and
 * 			the ones from computeDigitalSignature() and decipher().
 */
private void processPerformSecurityOperation(APDU apdu) throws ISOException {
    byte[] buf = apdu.getBuffer();
    byte p1 = buf[ISO7816.OFFSET_P1];
    byte p2 = buf[ISO7816.OFFSET_P2];

    if( ! pin.isValidated() ) {
        ISOException.throwIt(ISO7816.SW_SECURITY_STATUS_NOT_SATISFIED);
    }

    if(p1 == (byte) 0x9E && p2 == (byte) 0x9A) {
        computeDigitalSignature(apdu);
    } else if(p1 == (byte) 0x80 && p2 == (byte) 0x86) {
        decipher(apdu);
    } else {
        ISOException.throwIt(ISO7816.SW_INCORRECT_P1P2);
    }

}
 
开发者ID:philipWendland,项目名称:IsoApplet,代码行数:29,代码来源:IsoApplet.java


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