本文整理汇总了Java中javacard.security.MessageDigest类的典型用法代码示例。如果您正苦于以下问题:Java MessageDigest类的具体用法?Java MessageDigest怎么用?Java MessageDigest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MessageDigest类属于javacard.security包,在下文中一共展示了MessageDigest类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: FIDOCCImplementation
import javacard.security.MessageDigest; //导入依赖的package包/类
public FIDOCCImplementation() {
random = RandomData.getInstance(RandomData.ALG_SECURE_RANDOM);
scratch = JCSystem.makeTransientByteArray((short)128, JCSystem.CLEAR_ON_DESELECT);
//seed = new byte[64];
keyPair = new KeyPair(
(ECPublicKey)KeyBuilder.buildKey(KeyBuilder.TYPE_EC_FP_PUBLIC, KeyBuilder.LENGTH_EC_FP_256, false),
(ECPrivateKey)KeyBuilder.buildKey(KeyBuilder.TYPE_EC_FP_PRIVATE, KeyBuilder.LENGTH_EC_FP_256, false));
Secp256r1.setCommonCurveParameters((ECKey)keyPair.getPrivate());
Secp256r1.setCommonCurveParameters((ECKey)keyPair.getPublic());
// Initialize the unique seed for DRNG function
//random.generateData(seed, (short)0, (short)64);
// Initialize the unique seed for DRNG function
drngSeed1 = (AESKey)KeyBuilderX.buildKey(KeyBuilderX.TYPE_AES_STATIC, KeyBuilder.LENGTH_AES_256, false);
drngSeed2 = (AESKey)KeyBuilderX.buildKey(KeyBuilderX.TYPE_AES_STATIC, KeyBuilder.LENGTH_AES_256, false);
random.generateData(scratch, (short)0, (short)32);
drngSeed1.setKey(scratch, (short)0);
random.generateData(scratch, (short)0, (short)32);
drngSeed2.setKey(scratch, (short)0);
sha256 = MessageDigest.getInstance(MessageDigest.ALG_SHA_256, false);
// Initialize the unique keys for MAC function
macKey1 = (AESKey)KeyBuilderX.buildKey(KeyBuilderX.TYPE_AES_STATIC, KeyBuilder.LENGTH_AES_128, false);
macKey2 = (AESKey)KeyBuilderX.buildKey(KeyBuilderX.TYPE_AES_STATIC, KeyBuilder.LENGTH_AES_128, false);
random.generateData(scratch, (short)0, (short)16);
macKey1.setKey(scratch, (short)0);
random.generateData(scratch, (short)0, (short)16);
macKey2.setKey(scratch, (short)0);
// Initialize ecMultiplier
ecMultiplyHelper = KeyAgreementX.getInstance(KeyAgreementX.ALG_EC_SVDP_DH_PLAIN_XY, false);
}
开发者ID:tsenger,项目名称:CCU2F,代码行数:38,代码来源:FIDOCCImplementation.java
示例2: HMACgenerator
import javacard.security.MessageDigest; //导入依赖的package包/类
/**
*
* @param key Shared secret to use when generating HMAC
* @param keyLen Length of shared secret in bytes
* @param digits Numbers of digits to generate
*/
public HMACgenerator(byte key[], short keyLen, short digits){
//Set counter to 0
counter = new byte[counterSize];
Util.arrayFillNonAtomic(counter, (short) 0, counterSize, (byte) 0);
k_opad = new byte[64];
k_ipad = new byte[64];
shaBuffer = new byte[84];
outBuffer = new byte[20];
this.digits = digits;
asciiBuffer = new byte[10];
outputCodeDigits = new byte[digits];
for (short i = (short) 0; i < (short) 64; i++){
if(i < keyLen){
k_opad[i] = (byte) (key[i] ^ 0x5c);
k_ipad[i] = (byte) (key[i] ^ 0x36);
} else {
k_opad[i] = (byte) (0x5c);
k_ipad[i] = (byte) (0x36);
}
}
digest = MessageDigest.getInstance(MessageDigest.ALG_SHA, true);
}
开发者ID:petrs,项目名称:hotp_via_ndef,代码行数:32,代码来源:HMACgenerator.java
示例3: UsmileKeyAgreement
import javacard.security.MessageDigest; //导入依赖的package包/类
/**
* Constructors
*
* <p>
* Performs necessary initialization and memory allocations
*
* @param initBuffer
* initialization byte array buffer, contains identity':'password
* @param length Length of ID and password
*
*/
public UsmileKeyAgreement(byte[] initBuffer, short length) {
tempBuffer = initBuffer;
/**
* init messageDigest
*/
mUsedMsgDigest = MessageDigest.getInstance(MessageDigest.ALG_SHA_256,
false);
// Initialize all key objects
initializeKeys();
// Compute all values which will not change during key agreement and verification phase
staticComputations(tempBuffer, (short)0, length);
}
开发者ID:mobilesec,项目名称:secure-channel-ec-srp-applet,代码行数:28,代码来源:UsmileKeyAgreement.java
示例4: initialize
import javacard.security.MessageDigest; //导入依赖的package包/类
public void initialize(short MAX_POINT_SIZE, short MAX_COORD_SIZE, short MAX_BIGNAT_SIZE, short MULT_RSA_ENGINE_MAX_LENGTH_BITS, Bignat_Helper bnh) {
// Allocate long-term helper values
locker = new ObjectLocker((short) (NUM_HELPER_ARRAYS + NUM_SHARED_HELPER_OBJECTS));
//locker.setLockingActive(false); // if required, locking can be disabled
memAlloc = new ObjectAllocator();
memAlloc.setAllAllocatorsRAM();
//if required, memory for helper objects and arrays can be in persistent memory to save RAM (or some tradeoff)
//ObjectAllocator.setAllAllocatorsEEPROM(); //ObjectAllocator.setAllocatorsTradeoff();
// Multiplication speedup engines and arrays used by Bignat.mult_RSATrick()
helper_BN_array1 = memAlloc.allocateByteArray((short) (MULT_RSA_ENGINE_MAX_LENGTH_BITS / 8), memAlloc.getAllocatorType(ObjectAllocator.BNH_helper_BN_array1));
locker.registerLock(helper_BN_array1);
helper_BN_array2 = memAlloc.allocateByteArray((short) (MULT_RSA_ENGINE_MAX_LENGTH_BITS / 8), memAlloc.getAllocatorType(ObjectAllocator.BNH_helper_BN_array2));
locker.registerLock(helper_BN_array2);
helper_uncompressed_point_arr1 = memAlloc.allocateByteArray((short) (MAX_POINT_SIZE + 1), memAlloc.getAllocatorType(ObjectAllocator.ECPH_uncompressed_point_arr1));
locker.registerLock(helper_uncompressed_point_arr1);
hashEngine = MessageDigest.getInstance(MessageDigest.ALG_SHA_256, false);
helper_hashArray = memAlloc.allocateByteArray(hashEngine.getLength(), memAlloc.getAllocatorType(ObjectAllocator.ECPH_hashArray));
locker.registerLock(helper_hashArray);
//locker.registerLock(hashEngine); // register hash engine to slightly speedup search for locked objects (hash engine used less frequently)
helper_BN_A = new Bignat(MAX_BIGNAT_SIZE, memAlloc.getAllocatorType(ObjectAllocator.BNH_helper_BN_A), bnh);
helper_BN_B = new Bignat(MAX_BIGNAT_SIZE, memAlloc.getAllocatorType(ObjectAllocator.BNH_helper_BN_B), bnh);
helper_BN_C = new Bignat(MAX_BIGNAT_SIZE, memAlloc.getAllocatorType(ObjectAllocator.BNH_helper_BN_C), bnh);
helper_BN_D = new Bignat(MAX_BIGNAT_SIZE, memAlloc.getAllocatorType(ObjectAllocator.BNH_helper_BN_D), bnh);
helper_BN_E = new Bignat(MAX_BIGNAT_SIZE, memAlloc.getAllocatorType(ObjectAllocator.BNH_helper_BN_E), bnh);
helper_BN_F = new Bignat((short) (MAX_BIGNAT_SIZE + 2), memAlloc.getAllocatorType(ObjectAllocator.BNH_helper_BN_F), bnh); // +2 is to correct for infrequent RSA result with two or more leading zeroes
helperEC_BN_A = new Bignat(MAX_POINT_SIZE, memAlloc.getAllocatorType(ObjectAllocator.ECPH_helperEC_BN_A), bnh);
helperEC_BN_B = new Bignat(MAX_COORD_SIZE, memAlloc.getAllocatorType(ObjectAllocator.ECPH_helperEC_BN_B), bnh);
helperEC_BN_C = new Bignat(MAX_COORD_SIZE, memAlloc.getAllocatorType(ObjectAllocator.ECPH_helperEC_BN_C), bnh);
helperEC_BN_D = new Bignat(MAX_COORD_SIZE, memAlloc.getAllocatorType(ObjectAllocator.ECPH_helperEC_BN_D), bnh);
helperEC_BN_E = new Bignat(MAX_COORD_SIZE, memAlloc.getAllocatorType(ObjectAllocator.ECPH_helperEC_BN_E), bnh);
helperEC_BN_F = new Bignat(MAX_COORD_SIZE, memAlloc.getAllocatorType(ObjectAllocator.ECPH_helperEC_BN_F), bnh);
}
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:40,代码来源:ResourceManager.java
示例5: initialize
import javacard.security.MessageDigest; //导入依赖的package包/类
public void initialize(short MAX_POINT_SIZE, short MAX_COORD_SIZE, short MAX_BIGNAT_SIZE, short MULT_RSA_ENGINE_MAX_LENGTH_BITS, Bignat_Helper bnh) {
// Allocate long-term helper values
locker = new ObjectLocker((short) (NUM_HELPER_ARRAYS + NUM_SHARED_HELPER_OBJECTS));
//locker.setLockingActive(false); // if required, locking can be disabled
memAlloc = new ObjectAllocator();
memAlloc.setAllAllocatorsRAM();
//if required, memory for helper objects and arrays can be in persistent memory to save RAM (or some tradeoff)
//ObjectAllocator.setAllAllocatorsEEPROM(); //ObjectAllocator.setAllocatorsTradeoff();
// Multiplication speedup engines and arrays used by Bignat.mult_RSATrick()
helper_BN_array1 = memAlloc.allocateByteArray((short) (MULT_RSA_ENGINE_MAX_LENGTH_BITS / 8), memAlloc.getAllocatorType(ObjectAllocator.BNH_helper_BN_array1));
locker.registerLock(helper_BN_array1);
helper_BN_array2 = memAlloc.allocateByteArray((short) (MULT_RSA_ENGINE_MAX_LENGTH_BITS / 8), memAlloc.getAllocatorType(ObjectAllocator.BNH_helper_BN_array2));
locker.registerLock(helper_BN_array2);
helper_uncompressed_point_arr1 = memAlloc.allocateByteArray((short) (MAX_POINT_SIZE + 1), memAlloc.getAllocatorType(ObjectAllocator.ECPH_uncompressed_point_arr1));
locker.registerLock(helper_uncompressed_point_arr1);
hashEngine = MessageDigest.getInstance(MessageDigest.ALG_SHA_256, false);
helper_hashArray = memAlloc.allocateByteArray(hashEngine.getLength(), memAlloc.getAllocatorType(ObjectAllocator.ECPH_hashArray));
locker.registerLock(helper_hashArray);
//locker.registerLock(hashEngine); // register hash engine to slightly speedup search for locked objects (hash engine used less frequently)
helper_BN_A = new Bignat(MAX_BIGNAT_SIZE, memAlloc.getAllocatorType(ObjectAllocator.BNH_helper_BN_A), bnh);
helper_BN_B = new Bignat(MAX_BIGNAT_SIZE, memAlloc.getAllocatorType(ObjectAllocator.BNH_helper_BN_B), bnh);
helper_BN_C = new Bignat(MAX_BIGNAT_SIZE, memAlloc.getAllocatorType(ObjectAllocator.BNH_helper_BN_C), bnh);
helper_BN_D = new Bignat(MAX_BIGNAT_SIZE, memAlloc.getAllocatorType(ObjectAllocator.BNH_helper_BN_D), bnh);
helper_BN_E = new Bignat(MAX_BIGNAT_SIZE, memAlloc.getAllocatorType(ObjectAllocator.BNH_helper_BN_E), bnh);
helper_BN_F = new Bignat((short) (MAX_BIGNAT_SIZE + 2), memAlloc.getAllocatorType(ObjectAllocator.BNH_helper_BN_F), bnh); // +2 is to correct for infrequent RSA result with two or more leading zeroes
helperEC_BN_A = new Bignat(MAX_POINT_SIZE, memAlloc.getAllocatorType(ObjectAllocator.ECPH_helperEC_BN_A), bnh);
helperEC_BN_B = new Bignat(MAX_COORD_SIZE, memAlloc.getAllocatorType(ObjectAllocator.ECPH_helperEC_BN_B), bnh);
helperEC_BN_C = new Bignat(MAX_COORD_SIZE, memAlloc.getAllocatorType(ObjectAllocator.ECPH_helperEC_BN_C), bnh);
helperEC_BN_D = new Bignat(MAX_COORD_SIZE, memAlloc.getAllocatorType(ObjectAllocator.ECPH_helperEC_BN_D), bnh);
helperEC_BN_E = new Bignat(MAX_COORD_SIZE, memAlloc.getAllocatorType(ObjectAllocator.ECPH_helperEC_BN_E), bnh);
helperEC_BN_F = new Bignat(MAX_COORD_SIZE, memAlloc.getAllocatorType(ObjectAllocator.ECPH_helperEC_BN_F), bnh);
}
开发者ID:OpenCryptoProject,项目名称:Myst,代码行数:40,代码来源:jcmathlib.java
示例6: setKey
import javacard.security.MessageDigest; //导入依赖的package包/类
public void setKey(byte[] buf, short offs, byte type, short len) {
if((type & HMAC_MASK) != HMAC_SHA1 && (type & HMAC_MASK) != HMAC_SHA256) {
ISOException.throwIt(ISO7816.SW_DATA_INVALID);
}
if((type & OATH_MASK) != HOTP_TYPE && (type & OATH_MASK) != TOTP_TYPE) {
ISOException.throwIt(ISO7816.SW_DATA_INVALID);
}
if(len > hmac_buf_size) {
ISOException.throwIt(ISO7816.SW_WRONG_DATA);
}
if((type & HMAC_MASK) == HMAC_SHA1) {
if(sha == null) {
sha = MessageDigest.getInstance(MessageDigest.ALG_SHA, false);
}
digest = sha;
} else if((type & HMAC_MASK) == HMAC_SHA256) {
if(sha256 == null) {
sha256 = MessageDigest.getInstance(MessageDigest.ALG_SHA_256, false);
}
digest = sha256;
}
this.type = type;
this.counter = 0;
Util.arrayFillNonAtomic(inner, _0, hmac_buf_size, (byte) 0x36);
Util.arrayFillNonAtomic(outer, _0, hmac_buf_size, (byte) 0x5c);
for (short i = 0; i < len; i++, offs++) {
inner[i] = (byte) (buf[offs] ^ 0x36);
outer[i] = (byte) (buf[offs] ^ 0x5c);
}
}
开发者ID:JavaCardOS,项目名称:Oath-Applet,代码行数:32,代码来源:OathObj.java
示例7: SecureMessaging
import javacard.security.MessageDigest; //导入依赖的package包/类
/**
* Constructor
*
* @param _tempBuffer a reference for Transient byte array buffer that is used for intermediate operations
*/
public SecureMessaging(byte[] _tempBuffer) {
tempBuffer = _tempBuffer;
mEncryptionKey = (AESKey) KeyBuilder.buildKey(
KeyBuilder.TYPE_AES_TRANSIENT_DESELECT,
KeyBuilder.LENGTH_AES_256, false);
mMackey_1 = (AESKey) KeyBuilder.buildKey(
KeyBuilder.TYPE_AES_TRANSIENT_DESELECT,
KeyBuilder.LENGTH_AES_128, false);
mMackey_2 = (AESKey) KeyBuilder.buildKey(
KeyBuilder.TYPE_AES_TRANSIENT_DESELECT,
KeyBuilder.LENGTH_AES_128, false);
// iv = new byte[(short)0x10];
mAESCipher = Cipher.getInstance(Cipher.ALG_AES_BLOCK_128_CBC_NOPAD,
false);
msgDigest_SHA256 = MessageDigest.getInstance(MessageDigest.ALG_SHA_256,
false);
mSignature = Signature.getInstance(Signature.ALG_AES_MAC_128_NOPAD,
false);
}
开发者ID:mobilesec,项目名称:secure-channel-ec-srp-applet,代码行数:33,代码来源:SecureMessaging.java
示例8: init
import javacard.security.MessageDigest; //导入依赖的package包/类
public static void init() {
h = JCSystem.makeTransientShortArray((short)2, JCSystem.CLEAR_ON_DESELECT);
ctx = JCSystem.makeTransientByteArray(TX_CONTEXT_SIZE, JCSystem.CLEAR_ON_DESELECT);
digestFull = MessageDigest.getInstance(MessageDigest.ALG_SHA_256, false);
}
开发者ID:Toporin,项目名称:SatoChipApplet,代码行数:6,代码来源:Transaction.java
示例9: SignTransaction
import javacard.security.MessageDigest; //导入依赖的package包/类
/**
* This function signs the current hash transaction with a std or the last extended key
* The hash provided in the APDU is compared to the version stored inside the chip.
* Depending of the total amount in the transaction and the predefined limit,
* a HMAC must be provided as an additional security layer.
*
* ins: 0x6F
* p1: key number or 0xFF for the last derived Bip32 extended key
* p2: 0x00
* data: [hash(32b) | option:hmac(20b)]
*
* return: [sig ]
*
*/
private void SignTransaction(APDU apdu, byte[] buffer){
byte key_nb = buffer[ISO7816.OFFSET_P1];
if ( (key_nb!=(byte)0xFF) && ((key_nb < 0) || (key_nb >= MAX_NUM_KEYS)) )
ISOException.throwIt(SW_INCORRECT_P1);
short bytesLeft = Util.makeShort((byte) 0x00, buffer[ISO7816.OFFSET_LC]);
if (bytesLeft != apdu.setIncomingAndReceive())
ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
if (bytesLeft<MessageDigest.LENGTH_SHA_256)
ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
if (key_nb==(byte)0xFF && !authorizeKeyOp(bip32_extendedACL, ACL_USE))
ISOException.throwIt(SW_UNAUTHORIZED);
if (key_nb!=(byte)0xFF && !authorizeKeyOp(key_nb, ACL_USE))
ISOException.throwIt(SW_UNAUTHORIZED);
// check whether the seed is initialized
if (key_nb==(byte)0xFF && !bip32_seeded)
ISOException.throwIt(SW_BIP32_UNINITIALIZED_SEED);
// check doublehash value in buffer with cached singlehash value
sha256.reset();
sha256.doFinal(transactionData, OFFSET_TRANSACTION_HASH, MessageDigest.LENGTH_SHA_256, recvBuffer, (short)0);
if ((byte)0 != Util.arrayCompare(buffer, ISO7816.OFFSET_CDATA, recvBuffer, (short)0, MessageDigest.LENGTH_SHA_256))
ISOException.throwIt(SW_INCORRECT_TXHASH);
// check challenge-response answer if necessary
if( (option_flags & HMAC_CHALRESP_2FA)==HMAC_CHALRESP_2FA){
if( Biginteger.lessThan(transactionData, OFFSET_TRANSACTION_LIMIT, transactionData, OFFSET_TRANSACTION_AMOUNT, (short)8)){
if (bytesLeft<MessageDigest.LENGTH_SHA_256+MessageDigest.LENGTH_SHA+(short)2)
ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
// check flag for 2fa_hmac_chalresp
short hmac_flags= Util.getShort(buffer, (short)(ISO7816.OFFSET_CDATA+32+2));
if (hmac_flags!=HMAC_CHALRESP_2FA)
ISOException.throwIt(SW_INCORRECT_ALG);
// hmac of 64-bytes msg: (doublesha256(raw_tx) | 32bytes padding)
Util.arrayFillNonAtomic(recvBuffer, (short)32, (short)32, (byte)0x00);
HmacSha160.computeHmacSha160(transactionData, OFFSET_TRANSACTION_HMACKEY, (short)20, recvBuffer, (short)0, (short)64, recvBuffer, (short)64);
if (Util.arrayCompare(buffer, (short)(ISO7816.OFFSET_CDATA+32+2), recvBuffer, (short)64, (short)20)!=0)
ISOException.throwIt(SW_SIGNATURE_INVALID);
// reset total amount
Util.arrayFillNonAtomic(transactionData, OFFSET_TRANSACTION_TOTAL, (short)8, (byte)0x00);
}
else{
//update total amount
Util.arrayCopyNonAtomic(transactionData, OFFSET_TRANSACTION_AMOUNT, transactionData, OFFSET_TRANSACTION_TOTAL, (short)8);
}
}
// hash+sign singlehash
if (key_nb==(byte)0xFF)
sigECDSA.init(bip32_extendedkey, Signature.MODE_SIGN);
else{
Key key= keys[key_nb];
if (key.getType()!=KeyBuilder.TYPE_EC_FP_PRIVATE)
ISOException.throwIt(SW_INCORRECT_ALG);
sigECDSA.init(key, Signature.MODE_SIGN);
}
short sign_size= sigECDSA.sign(transactionData, OFFSET_TRANSACTION_HASH, (short)32, buffer, (short)0);
apdu.setOutgoingAndSend((short) 0, sign_size);
}
开发者ID:Toporin,项目名称:SatoChipApplet,代码行数:78,代码来源:CardEdge.java
示例10: init
import javacard.security.MessageDigest; //导入依赖的package包/类
public static void init(byte[] tmp){
sha160= MessageDigest.getInstance(MessageDigest.ALG_SHA, false);
data= tmp;
}
开发者ID:Toporin,项目名称:SatoChipApplet,代码行数:5,代码来源:HmacSha160.java
示例11: init
import javacard.security.MessageDigest; //导入依赖的package包/类
public static void init(MessageDigest sha512_native, SHA512 sha512) {
SHA512Wrapper.sha512_native = sha512_native;
SHA512Wrapper.sha512 = sha512;
}
开发者ID:LedgerHQ,项目名称:ledger-javacard-eligibility,代码行数:5,代码来源:SHA512Wrapper.java
示例12: STPayP
import javacard.security.MessageDigest; //导入依赖的package包/类
/**
* Creates Java Card applet object.
*
* @param array
* the byte array containing the AID bytes
* @param offset
* the start of AID bytes in array
* @param length
* the length of the AID bytes in array
*/
private STPayP(byte[] array, short offset, byte length) {
/*** Start allocate memory when applet is instantiated. ***/
this.records = new Records(Constants.MAX_SFI_RECORDS);
this.persistentByteBuffer = new byte[Constants.SIZE_PBB];
this.personalizedPersistentByteBuffer = new byte[Constants.SIZE_PPBB];
this.transientByteBuffer = JCSystem.makeTransientByteArray(Constants.SIZE_TBB, JCSystem.CLEAR_ON_DESELECT);
// NOTE: 'keyEncryption' parameter not used.
this.mkAC = (DESKey) KeyBuilder.buildKey(KeyBuilder.TYPE_DES, KeyBuilder.LENGTH_DES3_2KEY, false);
this.mkIDN = (DESKey) KeyBuilder.buildKey(KeyBuilder.TYPE_DES, KeyBuilder.LENGTH_DES3_2KEY, false);
/*** End allocate memory when applet is instantiated. ***/
/*** Allocate memory when personalized. ***/
this.selectResponse = null;
this.cardLayoutDescriptionPart1 = null;
this.cardLayoutDescriptionPart2 = null;
this.cardLayoutDescriptionPart3 = null;
this.gpState = GPSystem.APPLICATION_SELECTABLE;
/*** Start initialize variables specific to MPP Remote-SE Lite. ***/
this.cardProfile = new CardProfile();
// Build Card Profile.
// NOTE: This is a kludge to retrieve AID. This would not work with real Java Card.
byte aidLength = JCSystem.getAID().getBytes(this.transientByteBuffer, (short) 0);
this.cardProfile.setAid(this.transientByteBuffer, (short) 0, aidLength);
this.cardProfileHash = new byte[32];
// Initialize and seed random.
this.random = RandomData.getInstance(RandomData.ALG_PSEUDO_RANDOM);
byte[] seed = DataUtil.stringToCompressedByteArray(String.valueOf(Calendar.getInstance().getTimeInMillis()));
this.random.setSeed(seed, (short) 0, (short) seed.length);
// Initialize Mobile Key.
this.dataEncryption = new DataEncryption();
if (!this.dataEncryption.initMobileKey()) {
System.out.println("Error: M_Key not initialized.");
}
this.sha256 = MessageDigest.getInstance(MessageDigest.ALG_SHA_256, false);
/*** End initialize variables specific to MPP Remote-SE Lite. ***/
// Register instance AID.
register(array, (short) (offset + (byte) 1), array[offset]);
}
开发者ID:SimplyTapp,项目名称:CardExamples,代码行数:60,代码来源:STPayP.java
示例13: MPCCryptoOps
import javacard.security.MessageDigest; //导入依赖的package包/类
public MPCCryptoOps(ECConfig eccfg) {
temp_sign_counter = new Bignat((short) 2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET, eccfg.bnh);
tmp_arr = JCSystem.makeTransientByteArray(Consts.SHARE_DOUBLE_SIZE_CARRY, JCSystem.MEMORY_TYPE_TRANSIENT_RESET);
placeholder = ECPointBuilder.createPoint(SecP256r1.KEY_LENGTH);
placeholder.initializeECPoint_SecP256r1();
c2_EC = ECPointBuilder.createPoint(SecP256r1.KEY_LENGTH);
c2_EC.initializeECPoint_SecP256r1();
GenPoint = ECPointBuilder.createPoint(SecP256r1.KEY_LENGTH);
GenPoint.setW(SecP256r1.G, (short) 0, (short) SecP256r1.G.length);
plaintext_EC = ECPointBuilder.createPoint(SecP256r1.KEY_LENGTH);
plaintext_EC.initializeECPoint_SecP256r1();
tmp_EC = ECPointBuilder.createPoint(SecP256r1.KEY_LENGTH);
tmp_EC.initializeECPoint_SecP256r1();
randomData = RandomData.getInstance(RandomData.ALG_SECURE_RANDOM);
y_Bn = JCSystem.makeTransientByteArray(Consts.SHARE_BASIC_SIZE, JCSystem.MEMORY_TYPE_TRANSIENT_RESET);
encResult = JCSystem.makeTransientByteArray(Consts.SHARE_DOUBLE_SIZE_CARRY, JCSystem.MEMORY_TYPE_TRANSIENT_RESET);
e_arr = JCSystem.makeTransientByteArray(Consts.SHARE_BASIC_SIZE, JCSystem.MEMORY_TYPE_TRANSIENT_RESET);
md = MessageDigest.getInstance(MessageDigest.ALG_SHA_256, false);
tmp_k_n = JCSystem.makeTransientByteArray(Consts.SHARE_BASIC_SIZE, JCSystem.MEMORY_TYPE_TRANSIENT_RESET);
prf_result = JCSystem.makeTransientByteArray(Consts.SHARE_BASIC_SIZE, JCSystem.MEMORY_TYPE_TRANSIENT_RESET);
modulo_Bn = new Bignat(Consts.SHARE_BASIC_SIZE, JCSystem.MEMORY_TYPE_TRANSIENT_RESET, eccfg.bnh);
modulo_Bn.from_byte_array((short) SecP256r1.r.length, (short) 0, SecP256r1.r, (short) 0);
aBn = new Bignat(Consts.SHARE_DOUBLE_SIZE, JCSystem.MEMORY_TYPE_TRANSIENT_RESET, eccfg.bnh);
aBn.set_from_byte_array((short) (aBn.length() - (short) r_for_BigInteger.length), r_for_BigInteger, (short) 0, (short) r_for_BigInteger.length);
e_Bn = new Bignat(Consts.SHARE_BASIC_SIZE, JCSystem.MEMORY_TYPE_TRANSIENT_RESET, eccfg.bnh);
s_Bn = new Bignat(Consts.SHARE_BASIC_SIZE, JCSystem.MEMORY_TYPE_TRANSIENT_RESET, eccfg.bnh);
xi_Bn = new Bignat(Consts.SHARE_BASIC_SIZE, JCSystem.MEMORY_TYPE_TRANSIENT_RESET, eccfg.bnh);
xe_Bn = new Bignat(Consts.SHARE_DOUBLE_SIZE, JCSystem.MEMORY_TYPE_TRANSIENT_RESET, eccfg.bnh);
resBn1 = new Bignat((short) ((short) (eccfg.bnh.MULT_RSA_ENGINE_MAX_LENGTH_BITS / 8) + 1), JCSystem.MEMORY_TYPE_TRANSIENT_RESET, eccfg.bnh);
resBn2 = new Bignat(Consts.SHARE_BASIC_SIZE, JCSystem.MEMORY_TYPE_TRANSIENT_RESET, eccfg.bnh);
resBn3 = new Bignat(Consts.SHARE_DOUBLE_SIZE, JCSystem.MEMORY_TYPE_TRANSIENT_RESET, eccfg.bnh);
// AddPoint objects
four_Bn = new Bignat((short) 32, JCSystem.MEMORY_TYPE_TRANSIENT_RESET, eccfg.bnh);
five_Bn = new Bignat((short) 32, JCSystem.MEMORY_TYPE_TRANSIENT_RESET, eccfg.bnh);
p_Bn = new Bignat((short) 32, JCSystem.MEMORY_TYPE_TRANSIENT_RESET, eccfg.bnh);
md = MessageDigest.getInstance(MessageDigest.ALG_SHA_256, false);
m_shortByteArray = JCSystem.makeTransientByteArray((short) 2, JCSystem.MEMORY_TYPE_TRANSIENT_DESELECT);
}
开发者ID:OpenCryptoProject,项目名称:Myst,代码行数:58,代码来源:MPCCryptoOps.java
注:本文中的javacard.security.MessageDigest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论