本文整理汇总了Java中org.spongycastle.util.Arrays.fill方法的典型用法代码示例。如果您正苦于以下问题:Java Arrays.fill方法的具体用法?Java Arrays.fill怎么用?Java Arrays.fill使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spongycastle.util.Arrays
的用法示例。
在下文中一共展示了Arrays.fill方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import org.spongycastle.util.Arrays; //导入方法依赖的package包/类
/**
* Update the message digest with a single byte.
*
* @param b the input byte to be entered.
*/
public void update(byte b) {
int remainingLength; // left bytes of buffer
// process the buffer if full else add to buffer:
remainingLength = BLOCK_LENGTH_BYTES - bufferPos;
if (remainingLength == 0) { // full buffer
t0 += BLOCK_LENGTH_BYTES;
if (t0 == 0) { // if message > 2^32
t1++;
}
compress(buffer, 0);
Arrays.fill(buffer, (byte)0);// clear buffer
buffer[0] = b;
bufferPos = 1;
} else {
buffer[bufferPos] = b;
bufferPos++;
}
}
示例2: doFinal
import org.spongycastle.util.Arrays; //导入方法依赖的package包/类
/**
* Close the digest, producing the final digest value. The doFinal() call
* leaves the digest reset. Key, salt and personal string remain.
*
* @param out the array the digest is to be copied into.
* @param outOffset the offset into the out array the digest is to start at.
*/
public int doFinal(byte[] out, int outOffset) {
f0 = 0xFFFFFFFF;
t0 += bufferPos;
// bufferPos may be < 64, so (t0 == 0) does not work
// for 2^32 < message length > 2^32 - 63
if ((t0 < 0) && (bufferPos > -t0)) {
t1++;
}
compress(buffer, 0);
Arrays.fill(buffer, (byte) 0);// Holds eventually the key if input is null
Arrays.fill(internalState, 0);
for (int i = 0; i < chainValue.length && (i * 4 < digestLength); i++) {
byte[] bytes = int2bytes(chainValue[i]);
if (i * 4 < digestLength - 4) {
System.arraycopy(bytes, 0, out, outOffset + i * 4, 4);
} else {
System.arraycopy(bytes, 0, out, outOffset + i * 4,
digestLength - (i * 4));
}
}
Arrays.fill(chainValue, 0);
reset();
return digestLength;
}
示例3: reset
import org.spongycastle.util.Arrays; //导入方法依赖的package包/类
/**
* Reset the digest back to its initial state. The key, the salt and the
* personal string will remain for further computations.
*/
public void reset() {
bufferPos = 0;
f0 = 0;
t0 = 0;
t1 = 0;
chainValue = null;
if (key != null) {
Arrays.fill(buffer, (byte) 0);
System.arraycopy(key, 0, buffer, 0, key.length);
bufferPos = BLOCK_LENGTH_BYTES; // zero padding
}
init();
}
示例4: clearKey
import org.spongycastle.util.Arrays; //导入方法依赖的package包/类
/**
* Overwrite the key if it is no longer used (zeroization).
*/
public void clearKey() {
if (key != null) {
Arrays.fill(key, (byte) 0);
Arrays.fill(buffer, (byte) 0);
}
}
示例5: assignDataRange
import org.spongycastle.util.Arrays; //导入方法依赖的package包/类
public void assignDataRange(byte[] data,int ofs,int len) {
if (data == null) {
this.data = ByteUtil.EMPTY_BYTE_ARRAY;
} else if (len <= 32) {
//if there is not enough data
// trailing zeros are assumed (this is required for PUSH opcode semantic
Arrays.fill(this.data, (byte) 0); // first clear
int dlen =Integer.min(len,data.length-ofs);
System.arraycopy(data, ofs, this.data, 32 - len ,dlen );
} else {
throw new RuntimeException("Data word can't exceed 32 bytes: " + data);
}
}
示例6: generateRecordMACKey
import org.spongycastle.util.Arrays; //导入方法依赖的package包/类
private static KeyParameter generateRecordMACKey(StreamCipher cipher) {
byte[] firstBlock = new byte[64];
cipher.processBytes(firstBlock, 0, firstBlock.length, firstBlock, 0);
KeyParameter macKey = new KeyParameter(firstBlock, 0, 32);
Arrays.fill(firstBlock, (byte) 0);
return macKey;
}
示例7: clearSalt
import org.spongycastle.util.Arrays; //导入方法依赖的package包/类
/**
* Overwrite the salt (pepper) if it is secret and no longer used
* (zeroization).
*/
public void clearSalt() {
if (salt != null) {
Arrays.fill(salt, (byte) 0);
}
}
示例8: zero
import org.spongycastle.util.Arrays; //导入方法依赖的package包/类
public DataWord zero() {
Arrays.fill(this.data, (byte) 0);
return this;
}