本文整理了Java中org.spongycastle.util.Arrays.concatenate()
方法的一些代码示例,展示了Arrays.concatenate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Arrays.concatenate()
方法的具体详情如下:
包路径:org.spongycastle.util.Arrays
类名称:Arrays
方法名:concatenate
暂无
代码示例来源:origin: ethereum/ethereumj
/**
* Pack nibbles to binary
*
* @param nibbles sequence. may have a terminator
* @return hex-encoded byte array
*/
public static byte[] packNibbles(byte[] nibbles) {
int terminator = 0;
if (nibbles[nibbles.length - 1] == TERMINATOR) {
terminator = 1;
nibbles = copyOf(nibbles, nibbles.length - 1);
}
int oddlen = nibbles.length % 2;
int flag = 2 * terminator + oddlen;
if (oddlen != 0) {
byte[] flags = new byte[]{(byte) flag};
nibbles = concatenate(flags, nibbles);
} else {
byte[] flags = new byte[]{(byte) flag, 0};
nibbles = concatenate(flags, nibbles);
}
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
for (int i = 0; i < nibbles.length; i += 2) {
buffer.write(16 * nibbles[i] + nibbles[i + 1]);
}
return buffer.toByteArray();
}
代码示例来源:origin: ethereum/ethereumj
/**
* Integer limitation goes up to 2^31-1 so length can never be bigger than MAX_ITEM_LENGTH
*/
public static byte[] encodeLength(int length, int offset) {
if (length < SIZE_THRESHOLD) {
byte firstByte = (byte) (length + offset);
return new byte[]{firstByte};
} else if (length < MAX_ITEM_LENGTH) {
byte[] binaryLength;
if (length > 0xFF)
binaryLength = intToBytesNoLeadZeroes(length);
else
binaryLength = new byte[]{(byte) length};
byte firstByte = (byte) (binaryLength.length + offset + SIZE_THRESHOLD - 1);
return concatenate(new byte[]{firstByte}, binaryLength);
} else {
throw new RuntimeException("Input too long");
}
}
代码示例来源:origin: ethereum/ethereumj
public byte[] calcPowValue() {
// nonce bytes are expected in Little Endian order, reverting
byte[] nonceReverted = Arrays.reverse(nonce);
byte[] hashWithoutNonce = HashUtil.sha3(getEncodedWithoutNonce());
byte[] seed = Arrays.concatenate(hashWithoutNonce, nonceReverted);
byte[] seedHash = HashUtil.sha512(seed);
byte[] concat = Arrays.concatenate(seedHash, mixHash);
return HashUtil.sha3(concat);
}
代码示例来源:origin: ethereum/ethereumj
/**
* Turn Object into its RLP encoded equivalent of a byte-array
* Support for String, Integer, BigInteger and Lists of any of these types.
*
* @param input as object or List of objects
* @return byte[] RLP encoded
*/
public static byte[] encode(Object input) {
Value val = new Value(input);
if (val.isList()) {
List<Object> inputArray = val.asList();
if (inputArray.isEmpty()) {
return encodeLength(inputArray.size(), OFFSET_SHORT_LIST);
}
byte[] output = ByteUtil.EMPTY_BYTE_ARRAY;
for (Object object : inputArray) {
output = concatenate(output, encode(object));
}
byte[] prefix = encodeLength(output.length, OFFSET_SHORT_LIST);
return concatenate(prefix, output);
} else {
byte[] inputAsBytes = toBytes(input);
if (inputAsBytes.length == 1 && (inputAsBytes[0] & 0xff) <= 0x80) {
return inputAsBytes;
} else {
byte[] firstByte = encodeLength(inputAsBytes.length, OFFSET_SHORT_ITEM);
return concatenate(firstByte, inputAsBytes);
}
}
}
代码示例来源:origin: ethereum/ethereumj
concat = Arrays.concatenate(hash, testNonce);
byte[] result = sha3(concat);
if (FastByteComparisons.compareTo(result, 0, 32, target, 0, 32) < 0) {
代码示例来源:origin: com.madgag.spongycastle/core
private byte[] concatenate(byte[] header, byte[] id1, byte[] id2, byte[] ed1, byte[] ed2, byte[] text)
{
return Arrays.concatenate(Arrays.concatenate(header, id1, id2), Arrays.concatenate(ed1, ed2, text));
}
}
代码示例来源:origin: com.madgag.spongycastle/bcpg-jdk15on
public SignatureTarget(
boolean critical,
int publicKeyAlgorithm,
int hashAlgorithm,
byte[] hashData)
{
super(SignatureSubpacketTags.SIGNATURE_TARGET, critical, false, Arrays.concatenate(new byte[] { (byte)publicKeyAlgorithm, (byte)hashAlgorithm }, hashData));
}
代码示例来源:origin: com.madgag.spongycastle/prov
static String generateKeyFingerprint(BigInteger modulus, BigInteger publicExponent)
{
return new Fingerprint(Arrays.concatenate(modulus.toByteArray(), publicExponent.toByteArray())).toString();
}
}
代码示例来源:origin: com.madgag.spongycastle/bctls-jdk15on
static void sendSignatureInput(TlsContext context, DigestInputBuffer buf, OutputStream output)
throws IOException
{
SecurityParameters securityParameters = context.getSecurityParameters();
// NOTE: The implicit copy here is intended (and important)
output.write(Arrays.concatenate(securityParameters.clientRandom, securityParameters.serverRandom));
buf.copyTo(output);
output.close();
}
代码示例来源:origin: com.madgag.spongycastle/prov
private static byte[] generateDefaultPersonalizationString(byte[] seed)
{
return Arrays.concatenate(Strings.toByteArray("Default"), seed,
Pack.longToBigEndian(Thread.currentThread().getId()), Pack.longToBigEndian(System.currentTimeMillis()));
}
代码示例来源:origin: com.madgag.spongycastle/prov
private static byte[] generateNonceIVPersonalizationString(byte[] seed)
{
return Arrays.concatenate(Strings.toByteArray("Nonce"), seed,
Pack.longToLittleEndian(Thread.currentThread().getId()), Pack.longToLittleEndian(System.currentTimeMillis()));
}
代码示例来源:origin: com.madgag.spongycastle/core
/**
* Reseed the DRBG.
*
* @param additionalInput additional input to be added to the DRBG in this step.
*/
public void reseed(byte[] additionalInput)
{
byte[] entropy = getEntropy();
byte[] seedMaterial = Arrays.concatenate(entropy, additionalInput);
hmac_DRBG_Update(seedMaterial);
_reseedCounter = 1;
}
代码示例来源:origin: com.madgag.spongycastle/prov
static String generateKeyFingerprint(BigInteger y, DSAParams params)
{
return new Fingerprint(Arrays.concatenate(y.toByteArray(), params.getP().toByteArray(), params.getQ().toByteArray(), params.getG().toByteArray())).toString();
}
}
代码示例来源:origin: com.madgag.spongycastle/core
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;
}
代码示例来源:origin: com.madgag.spongycastle/core
private void CTR_DRBG_Reseed_algorithm(byte[] additionalInput)
{
byte[] seedMaterial = Arrays.concatenate(getEntropy(), additionalInput);
seedMaterial = Block_Cipher_df(seedMaterial, _seedLength);
CTR_DRBG_Update(seedMaterial, _Key, _V);
_reseedCounter = 1;
}
代码示例来源:origin: com.madgag.spongycastle/bcpkix-jdk15on
public byte[] getEncoded()
throws IOException
{
return Arrays.concatenate(certificateHolder.getEncoded(), trustBlock.toASN1Sequence().getEncoded());
}
代码示例来源:origin: com.madgag.spongycastle/pkix
public byte[] getEncoded()
throws IOException
{
return Arrays.concatenate(certificateHolder.getEncoded(), trustBlock.toASN1Sequence().getEncoded());
}
代码示例来源:origin: com.madgag.spongycastle/prov
private byte[] PRF(TLSKeyMaterialSpec parameters, Mac prf)
{
byte[] label = Strings.toByteArray(parameters.getLabel());
byte[] labelSeed = Arrays.concatenate(label, parameters.getSeed());
byte[] secret = parameters.getSecret();
byte[] buf = new byte[parameters.getLength()];
hmac_hash(prf, secret, labelSeed, buf);
return buf;
}
}
代码示例来源:origin: com.madgag.spongycastle/bctls-jdk15on
public static byte[] calculateKeyBlock(TlsCryptoParameters cryptoParams, int length)
{
SecurityParameters securityParameters = cryptoParams.getSecurityParameters();
TlsSecret master_secret = securityParameters.getMasterSecret();
byte[] seed = Arrays.concatenate(securityParameters.getServerRandom(), securityParameters.getClientRandom());
return PRF(cryptoParams, master_secret, ExporterLabel.key_expansion, seed, length).extract();
}
代码示例来源:origin: com.madgag.spongycastle/prov
public static String generateKeyFingerprint(ECPoint publicPoint, org.spongycastle.jce.spec.ECParameterSpec spec)
{
ECCurve curve = spec.getCurve();
ECPoint g = spec.getG();
if (curve != null)
{
return new Fingerprint(Arrays.concatenate(publicPoint.getEncoded(false), curve.getA().getEncoded(), curve.getB().getEncoded(), g.getEncoded(false))).toString();
}
return new Fingerprint(publicPoint.getEncoded(false)).toString();
}
}
内容来源于网络,如有侵权,请联系作者删除!