本文整理汇总了Java中javacard.framework.Util.arrayFillNonAtomic方法的典型用法代码示例。如果您正苦于以下问题:Java Util.arrayFillNonAtomic方法的具体用法?Java Util.arrayFillNonAtomic怎么用?Java Util.arrayFillNonAtomic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javacard.framework.Util
的用法示例。
在下文中一共展示了Util.arrayFillNonAtomic方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: copy
import javacard.framework.Util; //导入方法依赖的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);
}
示例2: clone
import javacard.framework.Util; //导入方法依赖的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();
}
示例3: erase
import javacard.framework.Util; //导入方法依赖的package包/类
/**
* Erase all values stored in helper objects
*/
void erase() {
helper_BN_A.erase();
helper_BN_B.erase();
helper_BN_C.erase();
helper_BN_D.erase();
helper_BN_E.erase();
helper_BN_F.erase();
helperEC_BN_A.erase();
helperEC_BN_B.erase();
helperEC_BN_C.erase();
helperEC_BN_D.erase();
helperEC_BN_E.erase();
helperEC_BN_F.erase();
Util.arrayFillNonAtomic(helper_BN_array1, (short) 0, (short) helper_BN_array1.length, (byte) 0);
Util.arrayFillNonAtomic(helper_BN_array2, (short) 0, (short) helper_BN_array2.length, (byte) 0);
Util.arrayFillNonAtomic(helper_uncompressed_point_arr1, (short) 0, (short) helper_uncompressed_point_arr1.length, (byte) 0);
}
示例4: toBCD
import javacard.framework.Util; //导入方法依赖的package包/类
/**
* Converts up to 8 byte value to BCD array.
* Lenght of array + outOffset should be always >= 10.
* Number is considered to be big-endian.
* Output array can be same as input array.
*
* @param input Byte array containing number ot convert
* @param inOffset Start index of number in input array
* @param inLenght Length of number in bytes
* @param out Byte array that will be filled with BCD values.
* @param outOffset Start index of output array.
* @return Number of digits. Curretly always 10.
*/
public static short toBCD(byte[] input, short inOffset, short inLenght, byte[] out, short outOffset){
Util.arrayFillNonAtomic(buffer, (short) 0, (short) buffer.length, (byte) 0x00);
for(short index = inOffset; index < (short)(inOffset + inLenght); index++){
short bytePosition = (short)(index - inOffset);
short bytePositionFromLeft = (short)(inLenght - bytePosition - 1);
for(short bitPosition = 0; bitPosition < 8; bitPosition++){
if(((input[index] >> (7 - bitPosition)) & 1) > 0){
add(buffer, bcdValues, (short)((bytePositionFromLeft * 8 + (7 - bitPosition)) * 10));
}
}
}
Util.arrayCopyNonAtomic(buffer, (short) 0, out, outOffset, (short) 10);
Util.arrayFillNonAtomic(buffer, (short) 0, (short) buffer.length, (byte) 0); // Cleaning buffer, as static variables are not protected by firewall
return 10; //TODO
}
示例5: prepend_zeros
import javacard.framework.Util; //导入方法依赖的package包/类
/**
* Prepends zeros before the value of this Bignat up to target length.
*
* @param targetLength required length including prepended zeroes
* @param outBuffer output buffer for value with prepended zeroes
* @param outOffset start offset inside outBuffer for write
*/
public void prepend_zeros(short targetLength, byte[] outBuffer, short outOffset) {
short other_start = (short) (targetLength - this.size);
if (other_start > 0) {
Util.arrayFillNonAtomic(outBuffer, outOffset, other_start, (byte) 0); //fill prefix with zeros
}
Util.arrayCopyNonAtomic(value, (short) 0, outBuffer, (short) (outOffset + other_start), this.size); //copy the value
}
示例6: shift_bytes_right
import javacard.framework.Util; //导入方法依赖的package包/类
/**
* Shifts stored value to right by specified number of bytes. This operation equals to multiplication by value numBytes * 256.
* @param numBytes number of bytes to shift
*/
public void shift_bytes_right(short numBytes) {
// Move whole content by numBytes offset
bnh.lock(bnh.fnc_shift_bytes_right_tmp);
Util.arrayCopyNonAtomic(this.value, (short) 0, bnh.fnc_shift_bytes_right_tmp, (short) 0, (short) (this.value.length));
Util.arrayCopyNonAtomic(bnh.fnc_shift_bytes_right_tmp, (short) 0, this.value, numBytes, (short) ((short) (this.value.length) - numBytes));
Util.arrayFillNonAtomic(this.value, (short) 0, numBytes, (byte) 0);
bnh.unlock(bnh.fnc_shift_bytes_right_tmp);
}
示例7: unlock
import javacard.framework.Util; //导入方法依赖的package包/类
public void unlock(byte[] objToUnlock) {
if (!bLockingActive) {
return;
}
unlock((Object) objToUnlock);
if (ERASE_ON_UNLOCK) {
Util.arrayFillNonAtomic(objToUnlock, (short) 0, (short) objToUnlock.length, (byte) 0);
}
}
示例8: SetupNew
import javacard.framework.Util; //导入方法依赖的package包/类
public void SetupNew(short numPlayers, short thisPlayerIndex) {
state.CheckAllowedFunction(StateModel.FNC_QuorumContext_SetupNew);
// Reset previous state
Reset();
if (numPlayers > Consts.MAX_NUM_PLAYERS || numPlayers < 1) {
ISOException.throwIt(Consts.SW_TOOMANYPLAYERS);
}
if (thisPlayerIndex >= Consts.MAX_NUM_PLAYERS || thisPlayerIndex < 0) {
ISOException.throwIt(Consts.SW_INVALIDPLAYERINDEX);
}
// Setup new state
this.NUM_PLAYERS = numPlayers;
this.CARD_INDEX_THIS = thisPlayerIndex;
cryptoOps.randomData.generateData(signature_secret_seed, (short) 0, Consts.SHARE_BASIC_SIZE); // Utilized later during signature protocol in Sign() and Gen_R_i()
if (Consts.IS_BACKDOORED_EXAMPLE) {
Util.arrayFillNonAtomic(signature_secret_seed, (short) 0, Consts.SHARE_BASIC_SIZE, (byte) 0x33);
}
// TODO: store and setup user authorization keys (if provided)
// Set state
state.MakeStateTransition(StateModel.STATE_QUORUM_INITIALIZED);
state.MakeStateTransition(StateModel.STATE_KEYGEN_CLEARED);
}
示例9: lock
import javacard.framework.Util; //导入方法依赖的package包/类
public void lock(byte[] objToLock) {
if (!bLockingActive) {
return;
}
lock((Object) objToLock);
if (ERASE_ON_LOCK) {
Util.arrayFillNonAtomic(objToLock, (short) 0, (short) objToLock.length, (byte) 0);
}
}
示例10: deep_resize
import javacard.framework.Util; //导入方法依赖的package包/类
/**
* Create Bignat with different number of bytes used. Will cause longer number
* to shrink (loss of the more significant bytes) and shorter to be prepended with zeroes
*
* @param new_size new size in bytes
*/
void deep_resize(short new_size) {
if (new_size > this.max_size) {
if (ALLOW_RUNTIME_REALLOCATION) {
allocate_storage_array(new_size, this.allocatorType);
} else {
ISOException.throwIt(ReturnCodes.SW_BIGNAT_REALLOCATIONNOTALLOWED); // Reallocation to longer size not permitted
}
}
if (new_size == this.size) {
// No need to resize enything, same length
}
else {
short this_start, other_start, len;
bnh.lock(bnh.fnc_deep_resize_tmp);
if (this.size >= new_size) {
this_start = (short) (this.size - new_size);
other_start = 0;
len = new_size;
// Shrinking/cropping
Util.arrayCopyNonAtomic(value, this_start, bnh.fnc_deep_resize_tmp, (short) 0, len);
Util.arrayCopyNonAtomic(bnh.fnc_deep_resize_tmp, (short) 0, value, (short) 0, len); // Move bytes in item array towards beggining
// Erase rest of allocated array with zeroes (just as sanitization)
short toErase = (short) (this.max_size - new_size);
if (toErase > 0) {
Util.arrayFillNonAtomic(value, new_size, toErase, (byte) 0);
}
} else {
this_start = 0;
other_start = (short) (new_size - this.size);
len = this.size;
// Enlarging => Insert zeroes at begging, move bytes in item array towards the end
Util.arrayCopyNonAtomic(value, this_start, bnh.fnc_deep_resize_tmp, (short) 0, len);
// Move bytes in item array towards end
Util.arrayCopyNonAtomic(bnh.fnc_deep_resize_tmp, (short) 0, value, other_start, len);
// Fill begin of array with zeroes (just as sanitization)
if (other_start > 0) {
Util.arrayFillNonAtomic(value, (short) 0, other_start, (byte) 0);
}
}
bnh.unlock(bnh.fnc_deep_resize_tmp);
set_size(new_size);
}
}
示例11: setAllAllocatorsRAM
import javacard.framework.Util; //导入方法依赖的package包/类
/**
* All type of allocator for all object as RAM
*/
public void setAllAllocatorsRAM() {
Util.arrayFillNonAtomic(ALLOCATOR_TYPE_ARRAY, (short) 0, (short) ALLOCATOR_TYPE_ARRAY.length, JCSystem.MEMORY_TYPE_TRANSIENT_RESET);
}
示例12: erase
import javacard.framework.Util; //导入方法依赖的package包/类
/**
* Erase all values stored in helper objects
*/
void erase() {
rm.erase();
Util.arrayFillNonAtomic(tmp_array_short, (short) 0, (short) tmp_array_short.length, (byte) 0);
}
示例13: resetProfileLocks
import javacard.framework.Util; //导入方法依赖的package包/类
/**
* Reset profile array with profile locks statistics.
*/
public void resetProfileLocks() {
Util.arrayFillNonAtomic(profileLockedObjects, (short) 0, (short) profileLockedObjects.length, (byte) 0);
}
示例14: zero
import javacard.framework.Util; //导入方法依赖的package包/类
/**
* Stores zero in this object for currently used subpart given by internal size.
*/
public void zero() {
Util.arrayFillNonAtomic(value, (short) 0, this.size, (byte) 0);
}
示例15: append_zeros
import javacard.framework.Util; //导入方法依赖的package包/类
/**
* Appends zeros in the suffix to reach the defined byte length
* Essentially multiplies the number with 16 (HEX)
* @param targetLength required length including appended zeroes
* @param outBuffer output buffer for value with appended zeroes
* @param outOffset start offset inside outBuffer for write
*/
public void append_zeros(short targetLength, byte[] outBuffer, short outOffset) {
Util.arrayCopyNonAtomic(value, (short) 0, outBuffer, outOffset, this.size); //copy the value
Util.arrayFillNonAtomic(outBuffer, (short) (outOffset + this.size), (short) (targetLength - this.size), (byte) 0); //append zeros
}