本文整理汇总了Java中javacard.framework.JCSystem.commitTransaction方法的典型用法代码示例。如果您正苦于以下问题:Java JCSystem.commitTransaction方法的具体用法?Java JCSystem.commitTransaction怎么用?Java JCSystem.commitTransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javacard.framework.JCSystem
的用法示例。
在下文中一共展示了JCSystem.commitTransaction方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: storeVariableLength
import javacard.framework.JCSystem; //导入方法依赖的package包/类
/**
* Store the incoming APDU data in a fixed buffer, the first byte will contain the data length.
*
* @param pin_type indicates which PIN should be checked.
*/
void storeVariableLength(APDU apdu, byte[] destination, short pin_type) {
byte[] buffer = apdu.getBuffer();
// When writing DOs, PW1 really means PW1 submitted as PW2.
if (!pins[pin_type].isValidated() ||
((pin_type == PIN_INDEX_PW1) && !pinSubmitted[1])) {
ISOException.throwIt(ISO7816.SW_SECURITY_STATUS_NOT_SATISFIED);
}
short length = (short) (buffer[ISO7816.OFFSET_LC] & 0x00FF);
if ((short) (length + 1) > destination.length || length > (short) 255 ||
apdu.setIncomingAndReceive() != length) {
ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
}
JCSystem.beginTransaction();
destination[0] = (byte) length;
Util.arrayCopy(buffer, ISO7816.OFFSET_CDATA, destination, (short) 1, length);
JCSystem.commitTransaction();
}
开发者ID:JavaCardOS,项目名称:FluffyPGP-Applet,代码行数:23,代码来源:Gpg.java示例2: delete
import javacard.framework.JCSystem; //导入方法依赖的package包/类
static void delete(byte[] buf, short ofs, byte len) {
PasswordPinEntry pe = search(buf, ofs, len);
if (pe != null) {
JCSystem.beginTransaction();
pe.remove();
pe.recycle();
JCSystem.commitTransaction();
}
}
开发者ID:bertrandmartel,项目名称:javacard-tutorial,代码行数:10,代码来源:PasswordPinEntry.java示例3: delete
import javacard.framework.JCSystem; //导入方法依赖的package包/类
static void delete(byte[] buf, short ofs, byte len) {
PasswordEntry pe = search(buf, ofs, len);
if (pe != null) {
JCSystem.beginTransaction();
pe.remove();
pe.recycle();
JCSystem.commitTransaction();
}
}
开发者ID:bertrandmartel,项目名称:javacard-tutorial,代码行数:10,代码来源:PasswordEntry.java示例4: computeSignature
import javacard.framework.JCSystem; //导入方法依赖的package包/类
private void computeSignature(APDU apdu) {
byte[] buffer = apdu.getBuffer();
short length = (short) (buffer[ISO7816.OFFSET_LC] & 0x00FF);
// Make sure that DigestInfo is <= 40% of the RSA key length.
if ((short) (length * 4) > (short) (RSA_KEY_LENGTH_BYTES * 10) ||
apdu.setIncomingAndReceive() != length) {
ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
}
if (!pinSubmitted[PIN_INDEX_PW1] || !pins[PIN_INDEX_PW1].isValidated()) {
ISOException.throwIt(ISO7816.SW_CONDITIONS_NOT_SATISFIED);
}
if (!signatureKey.getPrivate().isInitialized()) {
ISOException.throwIt(ISO7816.SW_FILE_NOT_FOUND);
}
if (pinValidForMultipleSignatures == (byte) 0) {
pinSubmitted[PIN_INDEX_PW1] = false;
}
cipherRSA.init(signatureKey.getPrivate(), Cipher.MODE_ENCRYPT);
cipherRSA.doFinal(buffer, ISO7816.OFFSET_CDATA, length, buffer, (short) 0);
JCSystem.beginTransaction();
if (signatureCounter[2] != (byte) 0xFF) {
signatureCounter[2] = (byte) ((signatureCounter[2] & 0xFF) + 1);
} else {
signatureCounter[2] = 0;
if (signatureCounter[1] != (byte) 0xFF) {
signatureCounter[1] = (byte) ((signatureCounter[1] & 0xFF) + 1);
} else if (signatureCounter[0] != (byte) 0xFF) {
signatureCounter[1] = 0;
signatureCounter[0] = (byte) ((signatureCounter[0] & 0xFF) + 1);
} else {
JCSystem.abortTransaction();
ISOException.throwIt(ISO7816.SW_FILE_FULL);
}
}
JCSystem.commitTransaction();
apdu.setOutgoingAndSend((short) 0, RSA_KEY_LENGTH_BYTES);
}
开发者ID:JavaCardOS,项目名称:FluffyPGP-Applet,代码行数:39,代码来源:Gpg.java示例5: generateKeys
import javacard.framework.JCSystem; //导入方法依赖的package包/类
private void generateKeys(APDU apdu) {
if (keysGenerated) {
ISOException.throwIt(ISO7816.SW_CONDITIONS_NOT_SATISFIED);
}
try {
JCSystem.beginTransaction();
prng(keyBytes, OFFSET_ZERO, KEY_LENGTH);
keysGenerated = true;
} finally {
JCSystem.commitTransaction();
}
}
开发者ID:nelenkov,项目名称:sim-password-manager,代码行数:14,代码来源:PasswordManagerApplet.java示例6: clear
import javacard.framework.JCSystem; //导入方法依赖的package包/类
private void clear(APDU apdu) {
try {
JCSystem.beginTransaction();
for (short i = 0; i < KEY_LENGTH; i++) {
keyBytes[i] = 0;
}
keysGenerated = false;
prngCounter = 0;
} finally {
JCSystem.commitTransaction();
}
}
开发者ID:nelenkov,项目名称:sim-password-manager,代码行数:14,代码来源:PasswordManagerApplet.java示例7: generateAsymetricKey
import javacard.framework.JCSystem; //导入方法依赖的package包/类
/**
* GENERATE KEY APDU implementation.
*/
private void generateAsymetricKey(APDU apdu) {
byte[] buffer = apdu.getBuffer();
//lc=2
if (apdu.setIncomingAndReceive() != 1) {
ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
}
KeyPair key = getKey(buffer[ISO7816.OFFSET_CDATA]);
if (buffer[ISO7816.OFFSET_P1] == (byte) 0x81) {
if (!(key.getPublic()).isInitialized()) {
ISOException.throwIt(ISO7816.SW_FILE_NOT_FOUND);
}
} else {
if (!pins[PIN_INDEX_PW3].isValidated()) {
ISOException.throwIt(ISO7816.SW_CONDITIONS_NOT_SATISFIED);
}
JCSystem.beginTransaction();
key.genKeyPair();
if (buffer[ISO7816.OFFSET_CDATA] == (byte)0xB6) {
signatureCounter[0] = 0;
signatureCounter[1] = 0;
signatureCounter[2] = 0;
}
JCSystem.commitTransaction();
}
// Send the TLV data and public exponent using the APDU buffer.
buffer[ISO7816.OFFSET_CDATA] = 0x7F;
buffer[(short) (ISO7816.OFFSET_CDATA + 1)] = 0x49;
buffer[(short) (ISO7816.OFFSET_CDATA + 2)] = (byte) 0x82;
buffer[(short) (ISO7816.OFFSET_CDATA + 5)] = (byte) 0x82;
short length = ((RSAPublicKey) key.getPublic()).getExponent(
buffer, (short) (ISO7816.OFFSET_CDATA + 7));
buffer[(short) (ISO7816.OFFSET_CDATA + 6)] = (byte) length;
short pos = (short) (ISO7816.OFFSET_CDATA + 7 + length);
buffer[pos] = (byte) 0x81;
buffer[(short) (pos + 1)] = (byte) 0x82;
Util.setShort(buffer, (short) (pos + 2), RSA_KEY_LENGTH_BYTES);
Util.setShort(buffer, (short) (ISO7816.OFFSET_CDATA + 3),
(short) (pos + RSA_KEY_LENGTH_BYTES - ISO7816.OFFSET_CDATA - 1));
apdu.setOutgoingAndSend(ISO7816.OFFSET_CDATA, (short) (length + 11));
// And the modulus using get response.
Util.setShort(commandChainingBuffer, TEMP_GET_RESPONSE_LENGTH, RSA_KEY_LENGTH_BYTES);
((RSAPublicKey) key.getPublic()).getModulus(commandChainingBuffer, TEMP_GET_RESPONSE_DATA);
// Skip leading zero byte.
if (commandChainingBuffer[TEMP_GET_RESPONSE_DATA] == 0) {//��==0 ��GetModulusʧ��
Util.setShort(commandChainingBuffer, TEMP_GET_RESPONSE_OFFSET,
(short) (TEMP_GET_RESPONSE_DATA + 1));
} else {
Util.setShort(commandChainingBuffer, TEMP_GET_RESPONSE_OFFSET, TEMP_GET_RESPONSE_DATA);
}
commandChainingBuffer[TEMP_INS] = buffer[ISO7816.OFFSET_INS];
ISOException.throwIt(ISO7816.SW_BYTES_REMAINING_00);
}
开发者ID:JavaCardOS,项目名称:FluffyPGP-Applet,代码行数:57,代码来源:Gpg.java示例8: PayPass
import javacard.framework.JCSystem; //导入方法依赖的package包/类
public PayPass(byte[] bArray, short bOffset, byte bLength)
{
if(bLength!=27)
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
//transaction starts
JCSystem.beginTransaction();
//set up and initialize all the DES encryption/descrytion ciphers used in the app
DESKEY_KD_PERSO_L_EN = (DESKey) KeyBuilder.buildKey(KeyBuilder.TYPE_DES,KeyBuilder.LENGTH_DES,false);
DESKEY_KD_PERSO_R_DE = (DESKey) KeyBuilder.buildKey(KeyBuilder.TYPE_DES,KeyBuilder.LENGTH_DES,false);
DESKEY_KD_PERSO_L_DE = (DESKey) KeyBuilder.buildKey(KeyBuilder.TYPE_DES,KeyBuilder.LENGTH_DES,false);
DESKEY_KD_PERSO_R_EN = (DESKey) KeyBuilder.buildKey(KeyBuilder.TYPE_DES,KeyBuilder.LENGTH_DES,false);
CIPHER_KD_PERSO_L_EN = Cipher.getInstance(Cipher.ALG_DES_ECB_NOPAD,false);
CIPHER_KD_PERSO_R_DE = Cipher.getInstance(Cipher.ALG_DES_ECB_NOPAD,false);
CIPHER_KD_PERSO_L_DE = Cipher.getInstance(Cipher.ALG_DES_ECB_NOPAD,false);
CIPHER_KD_PERSO_R_EN = Cipher.getInstance(Cipher.ALG_DES_ECB_NOPAD,false);
//transaction ends
JCSystem.commitTransaction();
//define RAM buffers for faster operation
CVC3_DATA = JCSystem.makeTransientByteArray((short) 16, JCSystem.CLEAR_ON_DESELECT);
CMD_BUF = JCSystem.makeTransientByteArray((short) 261, JCSystem.CLEAR_ON_DESELECT);
MAC = JCSystem.makeTransientByteArray((short) 8, JCSystem.CLEAR_ON_DESELECT);
//on initialize the current state is not_alive
state = not_alive;
PROFILE = new Profile();
//testing area
//pre-personalization data
//issuer supply
PROFILE.VER_KMC = (byte)0x01; //MC version
PROFILE.VER_KMC = bArray[bOffset]; //MC version
PROFILE.KMC_ID[0] = (byte)0x54; //key id
PROFILE.KMC_ID[1] = (byte)0x13;
PROFILE.KMC_ID[2] = (byte)0x12;
PROFILE.KMC_ID[3] = (byte)0xFF;
PROFILE.KMC_ID[4] = (byte)0xFF;
PROFILE.KMC_ID[5] = (byte)0xFF;
Util.arrayCopyNonAtomic(bArray, (short)(bOffset+1), PROFILE.KMC_ID, (short)0, (short)6);
PROFILE.KD_PERSO[0] = (byte)0xA8; //personalization key
PROFILE.KD_PERSO[1] = (byte)0x6A;
PROFILE.KD_PERSO[2] = (byte)0x3D;
PROFILE.KD_PERSO[3] = (byte)0x06;
PROFILE.KD_PERSO[4] = (byte)0xCA;
PROFILE.KD_PERSO[5] = (byte)0xE7;
PROFILE.KD_PERSO[6] = (byte)0x04;
PROFILE.KD_PERSO[7] = (byte)0x6A;
PROFILE.KD_PERSO[8] = (byte)0x10;
PROFILE.KD_PERSO[9] = (byte)0x63;
PROFILE.KD_PERSO[10] = (byte)0x58;
PROFILE.KD_PERSO[11] = (byte)0xD5;
PROFILE.KD_PERSO[12] = (byte)0xB8;
PROFILE.KD_PERSO[13] = (byte)0x23;
PROFILE.KD_PERSO[14] = (byte)0x9C;
PROFILE.KD_PERSO[15] = (byte)0xBE;
Util.arrayCopyNonAtomic(bArray, (short)(bOffset+7), PROFILE.KD_PERSO, (short)0, (short)16);
PROFILE.CSN[0] = (byte)0x89;
PROFILE.CSN[1] = (byte)0xAA;
PROFILE.CSN[2] = (byte)0x7F;
PROFILE.CSN[3] = (byte)0x00;
Util.arrayCopyNonAtomic(bArray, (short)(bOffset+23), PROFILE.CSN, (short)0, (short)4);
//end issuer supply
//profile can now be considered in personalization state
PROFILE.STATE = PERSO;
}
开发者ID:jiankeliu5,项目名称:CardApplet-PayPass,代码行数:70,代码来源:PayPass.java示例9: generateAsymetricKey
import javacard.framework.JCSystem; //导入方法依赖的package包/类
/**
* GENERATE KEY APDU implementation.
*/
private void generateAsymetricKey(APDU apdu) {
byte[] buffer = apdu.getBuffer();
if (apdu.setIncomingAndReceive() != 2) {
ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
}
KeyPair key = getKey(buffer[ISO7816.OFFSET_CDATA]);
if (buffer[ISO7816.OFFSET_P1] == (byte) 0x81) {
if (!(key.getPublic()).isInitialized()) {
ISOException.throwIt(ISO7816.SW_FILE_NOT_FOUND);
}
} else {
if (!pins[PIN_INDEX_PW3].isValidated()) {
ISOException.throwIt(ISO7816.SW_CONDITIONS_NOT_SATISFIED);
}
JCSystem.beginTransaction();
key.genKeyPair();
if (buffer[ISO7816.OFFSET_CDATA] == (byte)0xB6) {
signatureCounter[0] = 0;
signatureCounter[1] = 0;
signatureCounter[2] = 0;
}
JCSystem.commitTransaction();
}
// Send the TLV data and public exponent using the APDU buffer.
buffer[ISO7816.OFFSET_CDATA] = 0x7F;
buffer[(short) (ISO7816.OFFSET_CDATA + 1)] = 0x49;
buffer[(short) (ISO7816.OFFSET_CDATA + 2)] = (byte) 0x82;
buffer[(short) (ISO7816.OFFSET_CDATA + 5)] = (byte) 0x82;
short length = ((RSAPublicKey) key.getPublic()).getExponent(
buffer, (short) (ISO7816.OFFSET_CDATA + 7));
buffer[(short) (ISO7816.OFFSET_CDATA + 6)] = (byte) length;
short pos = (short) (ISO7816.OFFSET_CDATA + 7 + length);
buffer[pos] = (byte) 0x81;
buffer[(short) (pos + 1)] = (byte) 0x82;
Util.setShort(buffer, (short) (pos + 2), RSA_KEY_LENGTH_BYTES);
Util.setShort(buffer, (short) (ISO7816.OFFSET_CDATA + 3),
(short) (pos + RSA_KEY_LENGTH_BYTES - ISO7816.OFFSET_CDATA - 1));
apdu.setOutgoingAndSend(ISO7816.OFFSET_CDATA, (short) (length + 11));
// And the modulus using get response.
Util.setShort(commandChainingBuffer, TEMP_GET_RESPONSE_LENGTH, RSA_KEY_LENGTH_BYTES);
((RSAPublicKey) key.getPublic()).getModulus(commandChainingBuffer, TEMP_GET_RESPONSE_DATA);
// Skip leading zero byte.
if (commandChainingBuffer[TEMP_GET_RESPONSE_DATA] == 0) {
Util.setShort(commandChainingBuffer, TEMP_GET_RESPONSE_OFFSET,
(short) (TEMP_GET_RESPONSE_DATA + 1));
} else {
Util.setShort(commandChainingBuffer, TEMP_GET_RESPONSE_OFFSET, TEMP_GET_RESPONSE_DATA);
}
commandChainingBuffer[TEMP_INS] = buffer[ISO7816.OFFSET_INS];
ISOException.throwIt(ISO7816.SW_BYTES_REMAINING_00);
}
开发者ID:FluffyKaon,项目名称:OpenPGP-Card,代码行数:56,代码来源:Gpg.java示例10: PayPass
import javacard.framework.JCSystem; //导入方法依赖的package包/类
public PayPass(byte[] bArray, short bOffset, byte bLength) {
if (bLength != 27)
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
// transaction starts
JCSystem.beginTransaction();
// set up and initialize all the DES encryption/descrytion ciphers used in the app
DESKEY_KD_PERSO_L_EN = (DESKey) KeyBuilder.buildKey(KeyBuilder.TYPE_DES, KeyBuilder.LENGTH_DES, false);
DESKEY_KD_PERSO_R_DE = (DESKey) KeyBuilder.buildKey(KeyBuilder.TYPE_DES, KeyBuilder.LENGTH_DES, false);
DESKEY_KD_PERSO_L_DE = (DESKey) KeyBuilder.buildKey(KeyBuilder.TYPE_DES, KeyBuilder.LENGTH_DES, false);
DESKEY_KD_PERSO_R_EN = (DESKey) KeyBuilder.buildKey(KeyBuilder.TYPE_DES, KeyBuilder.LENGTH_DES, false);
CIPHER_KD_PERSO_L_EN = Cipher.getInstance(Cipher.ALG_DES_ECB_NOPAD, false);
CIPHER_KD_PERSO_R_DE = Cipher.getInstance(Cipher.ALG_DES_ECB_NOPAD, false);
CIPHER_KD_PERSO_L_DE = Cipher.getInstance(Cipher.ALG_DES_ECB_NOPAD, false);
CIPHER_KD_PERSO_R_EN = Cipher.getInstance(Cipher.ALG_DES_ECB_NOPAD, false);
// transaction ends
JCSystem.commitTransaction();
// define RAM buffers for faster operation
CVC3_DATA = JCSystem.makeTransientByteArray((short) 16, JCSystem.CLEAR_ON_DESELECT);
CMD_BUF = JCSystem.makeTransientByteArray((short) 261, JCSystem.CLEAR_ON_DESELECT);
MAC = JCSystem.makeTransientByteArray((short) 8, JCSystem.CLEAR_ON_DESELECT);
// on initialize the current state is not_alive
state = not_alive;
PROFILE = new Profile();
// testing area
// pre-personalization data
// issuer supply
PROFILE.VER_KMC = (byte) 0x01; // MC version
PROFILE.VER_KMC = bArray[bOffset]; // MC version
PROFILE.KMC_ID[0] = (byte) 0x54; // key id
PROFILE.KMC_ID[1] = (byte) 0x13;
PROFILE.KMC_ID[2] = (byte) 0x12;
PROFILE.KMC_ID[3] = (byte) 0xFF;
PROFILE.KMC_ID[4] = (byte) 0xFF;
PROFILE.KMC_ID[5] = (byte) 0xFF;
Util.arrayCopyNonAtomic(bArray, (short) (bOffset + 1), PROFILE.KMC_ID, (short) 0, (short) 6);
PROFILE.KD_PERSO[0] = (byte) 0xA8; // personalization key
PROFILE.KD_PERSO[1] = (byte) 0x6A;
PROFILE.KD_PERSO[2] = (byte) 0x3D;
PROFILE.KD_PERSO[3] = (byte) 0x06;
PROFILE.KD_PERSO[4] = (byte) 0xCA;
PROFILE.KD_PERSO[5] = (byte) 0xE7;
PROFILE.KD_PERSO[6] = (byte) 0x04;
PROFILE.KD_PERSO[7] = (byte) 0x6A;
PROFILE.KD_PERSO[8] = (byte) 0x10;
PROFILE.KD_PERSO[9] = (byte) 0x63;
PROFILE.KD_PERSO[10] = (byte) 0x58;
PROFILE.KD_PERSO[11] = (byte) 0xD5;
PROFILE.KD_PERSO[12] = (byte) 0xB8;
PROFILE.KD_PERSO[13] = (byte) 0x23;
PROFILE.KD_PERSO[14] = (byte) 0x9C;
PROFILE.KD_PERSO[15] = (byte) 0xBE;
Util.arrayCopyNonAtomic(bArray, (short) (bOffset + 7), PROFILE.KD_PERSO, (short) 0, (short) 16);
PROFILE.CSN[0] = (byte) 0x89;
PROFILE.CSN[1] = (byte) 0xAA;
PROFILE.CSN[2] = (byte) 0x7F;
PROFILE.CSN[3] = (byte) 0x00;
Util.arrayCopyNonAtomic(bArray, (short) (bOffset + 23), PROFILE.CSN, (short) 0, (short) 4);
// end issuer supply
// profile can now be considered in personalization state
PROFILE.STATE = PERSO;
}
开发者ID:SimplyTapp,项目名称:CardExamples,代码行数:69,代码来源:PayPass.java示例11: updatePIN
import javacard.framework.JCSystem; //导入方法依赖的package包/类
/**
* Udpate the PIN and its length in a transaction.
* @param pinId which PIN will be updated.
* @param data contains the new PIN.
* @param dataOffset first byte of the new PIN in the data array.
* @param newLength the new PIN length.
*/
private void updatePIN(short pinId, byte[] data, short dataOffset, byte newLength) {
JCSystem.beginTransaction();
pins[pinId].update(data, dataOffset, newLength);
pinLength[pinId] = newLength;
JCSystem.commitTransaction();
}
开发者ID:JavaCardOS,项目名称:FluffyPGP-Applet,代码行数:14,代码来源:Gpg.java本文标签属性:
示例:示例英语
代码:代码零九
java:java自行车
JCSystem:进程system占用cpu过高原因
commitTransaction:commitTransaction