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

Java OwnerPIN类代码示例

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

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



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

示例1: CardEdge

import javacard.framework.OwnerPIN; //导入依赖的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


示例2: LedgerWalletApplet

import javacard.framework.OwnerPIN; //导入依赖的package包/类
public LedgerWalletApplet(byte[] parameters, short parametersOffset, byte parametersLength) {
    BCDUtils.init();
    TC.init();
    Crypto.init();
    Transaction.init();
    Bip32Cache.init();
    Keycard.init();
    limits = new byte[LIMIT_LAST];
    scratch256 = JCSystem.makeTransientByteArray((short)256, JCSystem.CLEAR_ON_DESELECT);
    transactionPin = new OwnerPIN(TRANSACTION_PIN_ATTEMPTS, TRANSACTION_PIN_SIZE);
    walletPin = new OwnerPIN(WALLET_PIN_ATTEMPTS, WALLET_PIN_SIZE);
    secondaryPin = new OwnerPIN(SECONDARY_PIN_ATTEMPTS, SECONDARY_PIN_SIZE);
    masterDerived = new byte[64];
    chipKey = (DESKey)KeyBuilder.buildKey(KeyBuilder.TYPE_DES, KeyBuilder.LENGTH_DES3_2KEY, false);
    trustedInputKey = (DESKey)KeyBuilder.buildKey(KeyBuilder.TYPE_DES, KeyBuilder.LENGTH_DES3_2KEY, false);
    developerKey = (DESKey)KeyBuilder.buildKey(KeyBuilder.TYPE_DES, KeyBuilder.LENGTH_DES3_2KEY, false);
    try {
        pairingKey = (AESKey)KeyBuilder.buildKey(KeyBuilder.TYPE_AES, KeyBuilder.LENGTH_AES_256, false);
    }
    catch(Exception e) {
    }
    reset();
    if (parametersLength != 0) {
        attestationPrivate = (ECPrivateKey)KeyBuilder.buildKey(KeyBuilder.TYPE_EC_FP_PRIVATE, KeyBuilder.LENGTH_EC_FP_256, false);
        attestationPublic = new byte[65];
        Secp256k1.setCommonCurveParameters(attestationPrivate);
        attestationPrivate.setS(parameters, parametersOffset, (short)32);
        parametersOffset += (short)32;
        attestationSignature = new byte[parameters[(short)(parametersOffset + 1)] + 2];
        Util.arrayCopy(parameters, parametersOffset, attestationSignature, (short)0, (short)attestationSignature.length);
    }
}
 
开发者ID:LedgerHQ,项目名称:ledger-javacard,代码行数:33,代码来源:LedgerWalletApplet.java


示例3: CryptonitApplet

import javacard.framework.OwnerPIN; //导入依赖的package包/类
protected CryptonitApplet(byte[] bArray, short bOffset, byte bLength) {
    mgmt_key = KeyBuilder.buildKey(KeyBuilder.TYPE_DES,
            KeyBuilder.LENGTH_DES3_3KEY, false);
    ((DESKey) mgmt_key).setKey(new byte[]{
        0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
        0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
        0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08
    }, (short) 0);
    mgmt_counter = new OwnerPIN(MGMT_MAX_TRIES, (byte) 4);
    mgmt_counter.update(new byte[]{0x00, 0x00, 0x00, 0x00}, (short) 0, (byte) 4);

    challenge = JCSystem.makeTransientByteArray((short) 8,
            JCSystem.CLEAR_ON_DESELECT);

    pin = new OwnerPIN(PIN_MAX_TRIES, PIN_MAX_LENGTH);
    pin.update(new byte[]{
        0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38
    }, (short) 0, (byte) 8);

    keys = new Key[(byte) 4];
    random = RandomData.getInstance(RandomData.ALG_SECURE_RANDOM);
    authenticated = JCSystem.makeTransientBooleanArray((short) 1, JCSystem.CLEAR_ON_DESELECT);
    rsa_cipher = Cipher.getInstance(Cipher.ALG_RSA_NOPAD, false);
    try {
        ec_signature = Signature.getInstance(Signature.ALG_ECDSA_SHA, false);
    } catch (Exception e) {
    }
    FileIndex index = new FileIndex();
    io = new IOBuffer(index);
    register();
}
 
开发者ID:mbrossard,项目名称:cryptonit-applet,代码行数:32,代码来源:CryptonitApplet.java


示例4: CreatePIN

import javacard.framework.OwnerPIN; //导入依赖的package包/类
/** 
 * This function creates a PIN with parameters specified by the P1, P2 and DATA
 * values. P2 specifies the maximum number of consecutive unsuccessful
 * verifications before the PIN blocks. PIN can be created only if one of the logged identities
 * allows it. 
 * 
 * ins: 0x40
 * p1: PIN number (0x00-0x07)
 * p2: max attempt number
 * data: [PIN_size(1b) | PIN | UBLK_size(1b) | UBLK] 
 * return: none
 */
private void CreatePIN(APDU apdu, byte[] buffer) {
	byte pin_nb = buffer[ISO7816.OFFSET_P1];
	byte num_tries = buffer[ISO7816.OFFSET_P2];
	/* Check that Identity n.0 is logged */
	if ((create_pin_ACL == (byte) 0xFF)
			|| (((logged_ids & create_pin_ACL) == (short) 0x0000) && (create_pin_ACL != (byte) 0x00)))
		ISOException.throwIt(SW_UNAUTHORIZED);
	if ((pin_nb < 0) || (pin_nb >= MAX_NUM_PINS) || (pins[pin_nb] != null))
		ISOException.throwIt(SW_INCORRECT_P1);
	/* Allow pin lengths > 127 (useful at all ?) */
	short avail = Util.makeShort((byte) 0x00, buffer[ISO7816.OFFSET_LC]);
	if (apdu.setIncomingAndReceive() != avail)
		ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
	// At least 1 character for PIN and 1 for unblock code (+ lengths)
	if (avail < 4)
		ISOException.throwIt(SW_INVALID_PARAMETER);
	byte pin_size = buffer[ISO7816.OFFSET_CDATA];
	if (avail < (short) (1 + pin_size + 1))
		ISOException.throwIt(SW_INVALID_PARAMETER);
	if (!CheckPINPolicy(buffer, (short) (ISO7816.OFFSET_CDATA + 1), pin_size))
		ISOException.throwIt(SW_INVALID_PARAMETER);
	byte ucode_size = buffer[(short) (ISO7816.OFFSET_CDATA + 1 + pin_size)];
	if (avail != (short) (1 + pin_size + 1 + ucode_size))
		ISOException.throwIt(SW_INVALID_PARAMETER);
	if (!CheckPINPolicy(buffer, (short) (ISO7816.OFFSET_CDATA + 1 + pin_size + 1), ucode_size))
		ISOException.throwIt(SW_INVALID_PARAMETER);
	pins[pin_nb] = new OwnerPIN(num_tries, PIN_MAX_SIZE);
	pins[pin_nb].update(buffer, (short) (ISO7816.OFFSET_CDATA + 1), pin_size);
	ublk_pins[pin_nb] = new OwnerPIN((byte) 3, PIN_MAX_SIZE);
	// Recycle variable pin_size
	pin_size = (byte) (ISO7816.OFFSET_CDATA + 1 + pin_size + 1);
	ublk_pins[pin_nb].update(buffer, pin_size, ucode_size);
}
 
开发者ID:Toporin,项目名称:SatoChipApplet,代码行数:46,代码来源:CardEdge.java


示例5: VerifyPIN

import javacard.framework.OwnerPIN; //导入依赖的package包/类
/** 
 * This function verifies a PIN number sent by the DATA portion. The length of
 * this PIN is specified by the value contained in P3.
 * Multiple consecutive unsuccessful PIN verifications will block the PIN. If a PIN
 * blocks, then an UnblockPIN command can be issued.
 * 
 * ins: 0x42
 * p1: PIN number (0x00-0x07)
 * p2: 0x00
 * data: [PIN] 
 * return: none (throws an exception in case of wrong PIN)
 */
private void VerifyPIN(APDU apdu, byte[] buffer) {
	byte pin_nb = buffer[ISO7816.OFFSET_P1];
	if ((pin_nb < 0) || (pin_nb >= MAX_NUM_PINS))
		ISOException.throwIt(SW_INCORRECT_P1);
	OwnerPIN pin = pins[pin_nb];
	if (pin == null)
		ISOException.throwIt(SW_INCORRECT_P1);
	if (buffer[ISO7816.OFFSET_P2] != 0x00)
		ISOException.throwIt(SW_INCORRECT_P2);
	short numBytes = Util.makeShort((byte) 0x00, buffer[ISO7816.OFFSET_LC]);
	/*
	 * Here I suppose the PIN code is small enough to enter in the buffer
	 * TODO: Verify the assumption and eventually adjust code to support
	 * reading PIN in multiple read()s
	 */
	if (numBytes != apdu.setIncomingAndReceive())
		ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
	if (!CheckPINPolicy(buffer, ISO7816.OFFSET_CDATA, (byte) numBytes))
		ISOException.throwIt(SW_INVALID_PARAMETER);
	if (pin.getTriesRemaining() == (byte) 0x00)
		ISOException.throwIt(SW_IDENTITY_BLOCKED);
	if (!pin.check(buffer, (short) ISO7816.OFFSET_CDATA, (byte) numBytes)) {
		LogoutIdentity(pin_nb);
		ISOException.throwIt(SW_AUTH_FAILED);
	}
	// Actually register that PIN has been successfully verified.
	logged_ids |= (short) (0x0001 << pin_nb);
}
 
开发者ID:Toporin,项目名称:SatoChipApplet,代码行数:41,代码来源:CardEdge.java


示例6: UnblockPIN

import javacard.framework.OwnerPIN; //导入依赖的package包/类
/**
 * This function unblocks a PIN number using the unblock code specified in the
 * DATA portion. The P3 byte specifies the unblock code length. 
 * 
 * ins: 0x46
 * p1: PIN number (0x00-0x07)
 * p2: 0x00
 * data: [PUK] 
 * return: none (throws an exception in case of wrong PUK)
 */
private void UnblockPIN(APDU apdu, byte[] buffer) {
	byte pin_nb = buffer[ISO7816.OFFSET_P1];
	if ((pin_nb < 0) || (pin_nb >= MAX_NUM_PINS))
		ISOException.throwIt(SW_INCORRECT_P1);
	OwnerPIN pin = pins[pin_nb];
	OwnerPIN ublk_pin = ublk_pins[pin_nb];
	if (pin == null)
		ISOException.throwIt(SW_INCORRECT_P1);
	if (ublk_pin == null)
		ISOException.throwIt(SW_INTERNAL_ERROR);
	// If the PIN is not blocked, the call is inconsistent
	if (pin.getTriesRemaining() != 0)
		ISOException.throwIt(SW_OPERATION_NOT_ALLOWED);
	if (buffer[ISO7816.OFFSET_P2] != 0x00)
		ISOException.throwIt(SW_INCORRECT_P2);
	short numBytes = Util.makeShort((byte) 0x00, buffer[ISO7816.OFFSET_LC]);
	/*
	 * Here I suppose the PIN code is small enough to fit into the buffer
	 * TODO: Verify the assumption and eventually adjust code to support
	 * reading PIN in multiple read()s
	 */
	if (numBytes != apdu.setIncomingAndReceive())
		ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
	if (!CheckPINPolicy(buffer, ISO7816.OFFSET_CDATA, (byte) numBytes))
		ISOException.throwIt(SW_INVALID_PARAMETER);
	if (!ublk_pin.check(buffer, ISO7816.OFFSET_CDATA, (byte) numBytes))
		ISOException.throwIt(SW_AUTH_FAILED);
	pin.resetAndUnblock();
}
 
开发者ID:Toporin,项目名称:SatoChipApplet,代码行数:40,代码来源:CardEdge.java


示例7: ChangePIN

import javacard.framework.OwnerPIN; //导入依赖的package包/类
/** 
 * This function changes a PIN code. The DATA portion contains both the old and
 * the new PIN codes. 
 * 
 * ins: 0x44
 * p1: PIN number (0x00-0x07)
 * p2: 0x00
 * data: [PIN_size(1b) | old_PIN | PIN_size(1b) | new_PIN ] 
 * return: none (throws an exception in case of wrong PIN)
 */
private void ChangePIN(APDU apdu, byte[] buffer) {
	/*
	 * Here I suppose the PIN code is small enough that 2 of them enter in
	 * the buffer TODO: Verify the assumption and eventually adjust code to
	 * support reading PINs in multiple read()s
	 */
	byte pin_nb = buffer[ISO7816.OFFSET_P1];
	if ((pin_nb < 0) || (pin_nb >= MAX_NUM_PINS))
		ISOException.throwIt(SW_INCORRECT_P1);
	OwnerPIN pin = pins[pin_nb];
	if (pin == null)
		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);
	// At least 1 charachter for each PIN code
	if (avail < 4)
		ISOException.throwIt(SW_INVALID_PARAMETER);
	byte pin_size = buffer[ISO7816.OFFSET_CDATA];
	if (avail < (short) (1 + pin_size + 1))
		ISOException.throwIt(SW_INVALID_PARAMETER);
	if (!CheckPINPolicy(buffer, (short) (ISO7816.OFFSET_CDATA + 1), pin_size))
		ISOException.throwIt(SW_INVALID_PARAMETER);
	byte new_pin_size = buffer[(short) (ISO7816.OFFSET_CDATA + 1 + pin_size)];
	if (avail < (short) (1 + pin_size + 1 + new_pin_size))
		ISOException.throwIt(SW_INVALID_PARAMETER);
	if (!CheckPINPolicy(buffer, (short) (ISO7816.OFFSET_CDATA + 1 + pin_size + 1), new_pin_size))
		ISOException.throwIt(SW_INVALID_PARAMETER);
	if (pin.getTriesRemaining() == (byte) 0x00)
		ISOException.throwIt(SW_IDENTITY_BLOCKED);
	if (!pin.check(buffer, (short) (ISO7816.OFFSET_CDATA + 1), pin_size)) {
		LogoutIdentity(pin_nb);
		ISOException.throwIt(SW_AUTH_FAILED);
	}
	pin.update(buffer, (short) (ISO7816.OFFSET_CDATA + 1 + pin_size + 1), new_pin_size);
	// JC specifies this resets the validated flag. So we do.
	logged_ids &= (short) ((short) 0xFFFF ^ (0x01 << pin_nb));
}
 
开发者ID:Toporin,项目名称:SatoChipApplet,代码行数:51,代码来源:CardEdge.java


示例8: Gpg

import javacard.framework.OwnerPIN; //导入依赖的package包/类
/**
  * Only this class's install method should create the applet object.
  */
 protected Gpg(byte[] parameters, short offset, byte length) {
   pinLength = new byte[3];
   pins = new OwnerPIN[3];
   pins[PIN_INDEX_PW1] = new OwnerPIN(MAX_TRIES_PIN1, MAX_PIN_LENGTH);
   pins[PIN_INDEX_PW1].update(defaultPIN, (short) 0, MIN_PIN1_LENGTH);
   pinLength[PIN_INDEX_PW1] = MIN_PIN1_LENGTH;
   pins[PIN_INDEX_PW3] = new OwnerPIN(MAX_TRIES_PIN3, MAX_PIN_LENGTH);
   pins[PIN_INDEX_PW3].update(defaultPIN, (short) 0, MIN_PIN3_LENGTH);
   pinLength[PIN_INDEX_PW3] = MIN_PIN3_LENGTH;
   // The resetting code is disabled by default.
   pins[PIN_INDEX_RC] = new OwnerPIN(MAX_TRIES_RC, MAX_PIN_LENGTH);
   pinLength[PIN_INDEX_RC] = 0;
   pinSubmitted = JCSystem.makeTransientBooleanArray((short) 2, JCSystem.CLEAR_ON_DESELECT);

//263bytes
   commandChainingBuffer =
       JCSystem.makeTransientByteArray((short) (TEMP_PUT_KEY_ACCUMULATOR + RSA_KEY_LENGTH_BYTES),
                                       JCSystem.CLEAR_ON_DESELECT);

   privateDO1 = new byte[255];
   privateDO2 = new byte[255];
   privateDO3 = new byte[255];
   privateDO4 = new byte[255];

   loginData = new byte[(short) 255];
   url = new byte[(short) 255];
   name = new byte[(short) 40];
   language = new byte[(short) 9];
   sex = new byte[(short) 1];
   fingerprints = new byte[(short) 60];
   caFingerprints = new byte[(short) 60];
   generationDates = new byte[(short) 12];
   signatureCounter = new byte[(short) 3];
   pinValidForMultipleSignatures = (byte) 0;
   signatureKey = new KeyPair(KeyPair.ALG_RSA_CRT, (short) 2048);

   confidentialityKey = new KeyPair(KeyPair.ALG_RSA_CRT, (short) 2048);
   authenticationKey = new KeyPair(KeyPair.ALG_RSA_CRT, (short) 2048);
   cipherRSA = Cipher.getInstance(Cipher.ALG_RSA_PKCS1, false);
   randomData = RandomData.getInstance(RandomData.ALG_SECURE_RANDOM);

   register();
 }
 
开发者ID:JavaCardOS,项目名称:FluffyPGP-Applet,代码行数:47,代码来源:Gpg.java


示例9: Gpg

import javacard.framework.OwnerPIN; //导入依赖的package包/类
/**
 * Only this class's install method should create the applet object.
 */
protected Gpg(byte[] parameters, short offset, byte length) {
  pinLength = new byte[3];
  pins = new OwnerPIN[3];
  pins[PIN_INDEX_PW1] = new OwnerPIN(MAX_TRIES_PIN1, MAX_PIN_LENGTH);
  pins[PIN_INDEX_PW1].update(defaultPIN, (short) 0, MIN_PIN1_LENGTH);
  pinLength[PIN_INDEX_PW1] = MIN_PIN1_LENGTH;
  pins[PIN_INDEX_PW3] = new OwnerPIN(MAX_TRIES_PIN3, MAX_PIN_LENGTH);
  pins[PIN_INDEX_PW3].update(defaultPIN, (short) 0, MIN_PIN3_LENGTH);
  pinLength[PIN_INDEX_PW3] = MIN_PIN3_LENGTH;
  // The resetting code is disabled by default.
  pins[PIN_INDEX_RC] = new OwnerPIN(MAX_TRIES_RC, MAX_PIN_LENGTH);
  pinLength[PIN_INDEX_RC] = 0;
  pinSubmitted = JCSystem.makeTransientBooleanArray((short) 2, JCSystem.CLEAR_ON_DESELECT);

  commandChainingBuffer =
      JCSystem.makeTransientByteArray((short) (TEMP_PUT_KEY_ACCUMULATOR + RSA_KEY_LENGTH_BYTES),
                                      JCSystem.CLEAR_ON_DESELECT);

  privateDO1 = new byte[255];
  privateDO2 = new byte[255];
  privateDO3 = new byte[255];
  privateDO4 = new byte[255];

  loginData = new byte[(short) 255];
  url = new byte[(short) 255];
  name = new byte[(short) 40];
  language = new byte[(short) 9];
  sex = new byte[(short) 1];
  fingerprints = new byte[(short) 60];
  caFingerprints = new byte[(short) 60];
  generationDates = new byte[(short) 12];
  signatureCounter = new byte[(short) 3];
  pinValidForMultipleSignatures = (byte) 0;

  signatureKey = new KeyPair(KeyPair.ALG_RSA_CRT, (short) 2048);
  confidentialityKey = new KeyPair(KeyPair.ALG_RSA_CRT, (short) 2048);
  authenticationKey = new KeyPair(KeyPair.ALG_RSA_CRT, (short) 2048);
  cipherRSA = Cipher.getInstance(Cipher.ALG_RSA_PKCS1, false);
  randomData = RandomData.getInstance(RandomData.ALG_SECURE_RANDOM);

  register();
}
 
开发者ID:FluffyKaon,项目名称:OpenPGP-Card,代码行数:46,代码来源:Gpg.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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