本文整理汇总了Java中org.bouncycastle.util.Arrays.concatenate方法的典型用法代码示例。如果您正苦于以下问题:Java Arrays.concatenate方法的具体用法?Java Arrays.concatenate怎么用?Java Arrays.concatenate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.util.Arrays
的用法示例。
在下文中一共展示了Arrays.concatenate方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CTR_DRBG_Instantiate_algorithm
import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
private void CTR_DRBG_Instantiate_algorithm(byte[] entropy, byte[] nonce,
byte[] personalisationString)
{
byte[] seedMaterial = Arrays.concatenate(entropy, nonce, personalisationString);
byte[] seed = Block_Cipher_df(seedMaterial, _seedLength);
int outlen = _engine.getBlockSize();
_Key = new byte[(_keySizeInBits + 7) / 8];
_V = new byte[outlen];
// _Key & _V are modified by this call
CTR_DRBG_Update(seed, _Key, _V);
_reseedCounter = 1;
}
示例2: createLoopMessage
import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
public Pair<SphinxHeader, byte[]> createLoopMessage(List<LoopixNode> path)
throws SphinxException, IOException, CryptoException {
byte[] message = Arrays.concatenate(
"HT".getBytes(Charset.forName("UTF-8")),
Core.generateRandomBytes(noiseLength)
);
return packer.makePacket(this, path, message);
}
示例3: padBody
import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
public static byte[] padBody(int msgtotalsize, byte[] body)
throws SphinxException {
body = Arrays.append(body, (byte) 0x7F);
if (msgtotalsize - body.length < 0)
throw new SphinxException("Insufficient space for body");
byte[] padding = new byte[msgtotalsize - body.length];
for (int i = 0; i < padding.length; i++) {
padding[i] = (byte) 0xFF;
}
return Arrays.concatenate(body, padding);
}
示例4: reseed
import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
/**
* Reseed the DRBG.
*
* @param additionalInput additional input to be added to the DRBG in this step.
*/
public void reseed(byte[] additionalInput)
{
if (Utils.isTooLarge(additionalInput, MAX_ADDITIONAL_INPUT / 8))
{
throw new IllegalArgumentException("Additional input string too large");
}
byte[] entropy = _entropySource.getEntropy();
byte[] seedMaterial = Arrays.concatenate(pad8(_s, _seedlen), entropy, additionalInput);
_s = Utils.hash_df(_digest, seedMaterial, _seedlen);
_reseedCounter = 0;
}
示例5: HashSP800DRBG
import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
/**
* Construct a SP800-90A Hash DRBG.
* <p>
* Minimum entropy requirement is the security strength requested.
* </p>
* @param digest source digest to use for DRB stream.
* @param securityStrength security strength required (in bits)
* @param entropySource source of entropy to use for seeding/reseeding.
* @param personalizationString personalization string to distinguish this DRBG (may be null).
* @param nonce nonce to further distinguish this DRBG (may be null).
*/
public HashSP800DRBG(Digest digest, int securityStrength, EntropySource entropySource, byte[] personalizationString, byte[] nonce)
{
if (securityStrength > Utils.getMaxSecurityStrength(digest))
{
throw new IllegalArgumentException("Requested security strength is not supported by the derivation function");
}
if (entropySource.entropySize() < securityStrength)
{
throw new IllegalArgumentException("Not enough entropy for security strength required");
}
_digest = digest;
_entropySource = entropySource;
_securityStrength = securityStrength;
_seedLength = ((Integer)seedlens.get(digest.getAlgorithmName())).intValue();
// 1. seed_material = entropy_input || nonce || personalization_string.
// 2. seed = Hash_df (seed_material, seedlen).
// 3. V = seed.
// 4. C = Hash_df ((0x00 || V), seedlen). Comment: Preceed V with a byte
// of zeros.
// 5. reseed_counter = 1.
// 6. Return V, C, and reseed_counter as the initial_working_state
byte[] entropy = entropySource.getEntropy();
byte[] seedMaterial = Arrays.concatenate(entropy, nonce, personalizationString);
byte[] seed = Utils.hash_df(_digest, seedMaterial, _seedLength);
_V = seed;
byte[] subV = new byte[_V.length + 1];
System.arraycopy(_V, 0, subV, 1, _V.length);
_C = Utils.hash_df(_digest, subV, _seedLength);
_reseedCounter = 1;
}
示例6: reseed
import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
/**
* Reseed the DRBG.
*
* @param additionalInput additional input to be added to the DRBG in this step.
*/
public void reseed(byte[] additionalInput)
{
// 1. seed_material = 0x01 || V || entropy_input || additional_input.
//
// 2. seed = Hash_df (seed_material, seedlen).
//
// 3. V = seed.
//
// 4. C = Hash_df ((0x00 || V), seedlen).
//
// 5. reseed_counter = 1.
//
// 6. Return V, C, and reseed_counter for the new_working_state.
//
// Comment: Precede with a byte of all zeros.
byte[] entropy = _entropySource.getEntropy();
byte[] seedMaterial = Arrays.concatenate(ONE, _V, entropy, additionalInput);
byte[] seed = Utils.hash_df(_digest, seedMaterial, _seedLength);
_V = seed;
byte[] subV = new byte[_V.length + 1];
subV[0] = 0x00;
System.arraycopy(_V, 0, subV, 1, _V.length);
_C = Utils.hash_df(_digest, subV, _seedLength);
_reseedCounter = 1;
}
示例7: HMacSP800DRBG
import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
/**
* Construct a SP800-90A Hash DRBG.
* <p>
* Minimum entropy requirement is the security strength requested.
* </p>
* @param hMac Hash MAC to base the DRBG on.
* @param securityStrength security strength required (in bits)
* @param entropySource source of entropy to use for seeding/reseeding.
* @param personalizationString personalization string to distinguish this DRBG (may be null).
* @param nonce nonce to further distinguish this DRBG (may be null).
*/
public HMacSP800DRBG(Mac hMac, int securityStrength, EntropySource entropySource, byte[] personalizationString, byte[] nonce)
{
if (securityStrength > Utils.getMaxSecurityStrength(hMac))
{
throw new IllegalArgumentException("Requested security strength is not supported by the derivation function");
}
if (entropySource.entropySize() < securityStrength)
{
throw new IllegalArgumentException("Not enough entropy for security strength required");
}
_entropySource = entropySource;
_hMac = hMac;
byte[] entropy = entropySource.getEntropy();
byte[] seedMaterial = Arrays.concatenate(entropy, nonce, personalizationString);
_K = new byte[hMac.getMacSize()];
_V = new byte[_K.length];
Arrays.fill(_V, (byte)1);
hmac_DRBG_Update(seedMaterial);
_reseedCounter = 1;
}
示例8: reseed
import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
/**
* Reseed the DRBG.
*
* @param additionalInput additional input to be added to the DRBG in this step.
*/
public void reseed(byte[] additionalInput)
{
byte[] entropy = _entropySource.getEntropy();
byte[] seedMaterial = Arrays.concatenate(entropy, additionalInput);
hmac_DRBG_Update(seedMaterial);
_reseedCounter = 1;
}
示例9: MakeItem
import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
private static byte[] MakeItem(byte[] payload)
{
ByteBuffer byteBuffer = ByteBuffer.allocate(Integer.SIZE / Byte.SIZE).order(ByteOrder.BIG_ENDIAN);
byteBuffer.putInt(payload.length);
byte[] sizeBits = byteBuffer.array();
return Arrays.concatenate(sizeBits, payload);
}
示例10: MakeChunk
import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
private static ParserHelper.Chunk MakeChunk(String id, byte[][] items)
{
byte[] chained = items[0];
for (int i = 1; i < items.length; i++) {
chained = Arrays.concatenate(chained, items[i]);
}
return new ParserHelper.Chunk(id, chained);
}
示例11: getCipherSuites
import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
protected int[] getCipherSuites() {
return Arrays.concatenate(super.getCipherSuites(),
new int[]
{
CipherSuite.DRAFT_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256
});
}
示例12: wrapInResponse
import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
private byte[] wrapInResponse(final byte[] bytes) {
String header = HttpFaker.getRandomResponseHeader(Http.RESPONSE_200, true);
header = header.replaceAll(Matcher.quoteReplacement("$"), String.valueOf(bytes.length));
return Arrays.concatenate(header.getBytes(), bytes);
}
示例13: DualECSP800DRBG
import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
/**
* Construct a SP800-90A Dual EC DRBG.
* <p>
* Minimum entropy requirement is the security strength requested.
* </p>
* @param digest source digest to use with the DRB stream.
* @param securityStrength security strength required (in bits)
* @param entropySource source of entropy to use for seeding/reseeding.
* @param personalizationString personalization string to distinguish this DRBG (may be null).
* @param nonce nonce to further distinguish this DRBG (may be null).
*/
public DualECSP800DRBG(Digest digest, int securityStrength, EntropySource entropySource, byte[] personalizationString, byte[] nonce)
{
_digest = digest;
_entropySource = entropySource;
_securityStrength = securityStrength;
if (Utils.isTooLarge(personalizationString, MAX_PERSONALIZATION_STRING / 8))
{
throw new IllegalArgumentException("Personalization string too large");
}
if (entropySource.entropySize() < securityStrength || entropySource.entropySize() > MAX_ENTROPY_LENGTH)
{
throw new IllegalArgumentException("EntropySource must provide between " + securityStrength + " and " + MAX_ENTROPY_LENGTH + " bits");
}
byte[] entropy = entropySource.getEntropy();
byte[] seedMaterial = Arrays.concatenate(entropy, nonce, personalizationString);
if (securityStrength <= 128)
{
if (Utils.getMaxSecurityStrength(digest) < 128)
{
throw new IllegalArgumentException("Requested security strength is not supported by digest");
}
_seedlen = 256;
_outlen = 240 / 8;
_curve = (ECCurve.Fp)NISTNamedCurves.getByName("P-256").getCurve();
_P = new ECPoint.Fp(_curve, new ECFieldElement.Fp(_curve.getQ(), p256_Px), new ECFieldElement.Fp(_curve.getQ(), p256_Py));
_Q = new ECPoint.Fp(_curve, new ECFieldElement.Fp(_curve.getQ(), p256_Qx), new ECFieldElement.Fp(_curve.getQ(), p256_Qy));
}
else if (securityStrength <= 192)
{
if (Utils.getMaxSecurityStrength(digest) < 192)
{
throw new IllegalArgumentException("Requested security strength is not supported by digest");
}
_seedlen = 384;
_outlen = 368 / 8;
_curve = (ECCurve.Fp)NISTNamedCurves.getByName("P-384").getCurve();
_P = new ECPoint.Fp(_curve, new ECFieldElement.Fp(_curve.getQ(), p384_Px), new ECFieldElement.Fp(_curve.getQ(), p384_Py));
_Q = new ECPoint.Fp(_curve, new ECFieldElement.Fp(_curve.getQ(), p384_Qx), new ECFieldElement.Fp(_curve.getQ(), p384_Qy));
}
else if (securityStrength <= 256)
{
if (Utils.getMaxSecurityStrength(digest) < 256)
{
throw new IllegalArgumentException("Requested security strength is not supported by digest");
}
_seedlen = 521;
_outlen = 504 / 8;
_curve = (ECCurve.Fp)NISTNamedCurves.getByName("P-521").getCurve();
_P = new ECPoint.Fp(_curve, new ECFieldElement.Fp(_curve.getQ(), p521_Px), new ECFieldElement.Fp(_curve.getQ(), p521_Py));
_Q = new ECPoint.Fp(_curve, new ECFieldElement.Fp(_curve.getQ(), p521_Qx), new ECFieldElement.Fp(_curve.getQ(), p521_Qy));
}
else
{
throw new IllegalArgumentException("security strength cannot be greater than 256 bits");
}
_s = Utils.hash_df(_digest, seedMaterial, _seedlen);
_sLength = _s.length;
_reseedCounter = 0;
}
示例14: CTR_DRBG_Reseed_algorithm
import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
private void CTR_DRBG_Reseed_algorithm(EntropySource entropy, byte[] additionalInput)
{
byte[] seedMaterial = Arrays.concatenate(entropy.getEntropy(), additionalInput);
seedMaterial = Block_Cipher_df(seedMaterial, _seedLength);
CTR_DRBG_Update(seedMaterial, _Key, _V);
_reseedCounter = 1;
}