Java Code Examples for org.bouncycastle.util.Arrays#fill()
The following examples show how to use
org.bouncycastle.util.Arrays#fill() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EthereumIESEncryptionEngine.java From incubator-tuweni with Apache License 2.0 | 6 votes |
public byte[] processBlock(byte[] in, int inOff, int inLen) throws InvalidCipherTextException { // Compute the common value and convert to byte array. agree.init(privParam); BigInteger z = agree.calculateAgreement(pubParam); byte[] Z = BigIntegers.asUnsignedByteArray(agree.getFieldSize(), z); // Create input to KDF. if (V.length != 0) { byte[] VZ = Arrays.concatenate(V, Z); Arrays.fill(Z, (byte) 0); Z = VZ; } try { // Initialise the KDF. KDFParameters kdfParam = new KDFParameters(Z, param.getDerivationV()); kdf.init(kdfParam); return forEncryption ? encryptBlock(in, inOff, inLen) : decryptBlock(in, inOff, inLen); } finally { Arrays.fill(Z, (byte) 0); } }
Example 2
Source File: HashTreeRootTest.java From incubator-tuweni with Apache License 2.0 | 5 votes |
@Test void list2() { byte[] _1s = new byte[32]; byte[] _2s = new byte[32]; byte[] _3s = new byte[32]; byte[] _4s = new byte[32]; byte[] _5s = new byte[32]; byte[] _6s = new byte[32]; byte[] _7s = new byte[32]; byte[] _8s = new byte[32]; byte[] _9s = new byte[32]; byte[] _as = new byte[32]; Arrays.fill(_1s, (byte) 1); Arrays.fill(_2s, (byte) 2); Arrays.fill(_3s, (byte) 3); Arrays.fill(_4s, (byte) 4); Arrays.fill(_5s, (byte) 5); Arrays.fill(_6s, (byte) 6); Arrays.fill(_7s, (byte) 7); Arrays.fill(_8s, (byte) 8); Arrays.fill(_9s, (byte) 9); Arrays.fill(_as, (byte) 10); assertEquals( Bytes.fromHexString("0x55DC6699E7B5713DD9102224C302996F931836C6DAE9A4EC6AB49C966F394685"), SSZ .hashTreeRoot( Bytes.wrap(_1s), Bytes.wrap(_2s), Bytes.wrap(_3s), Bytes.wrap(_4s), Bytes.wrap(_5s), Bytes.wrap(_6s), Bytes.wrap(_7s), Bytes.wrap(_8s), Bytes.wrap(_9s), Bytes.wrap(_as))); }
Example 3
Source File: Blake2bfMessageDigest.java From besu with Apache License 2.0 | 5 votes |
/** Reset the digest back to it's initial state. */ @Override public void reset() { bufferPos = 0; Arrays.fill(buffer, (byte) 0); Arrays.fill(h, 0); Arrays.fill(m, (byte) 0); Arrays.fill(t, 0); f = false; rounds = 12; Arrays.fill(v, 0); }
Example 4
Source File: HashTreeRootTest.java From cava with Apache License 2.0 | 5 votes |
@Test void list2() { byte[] _1s = new byte[32]; byte[] _2s = new byte[32]; byte[] _3s = new byte[32]; byte[] _4s = new byte[32]; byte[] _5s = new byte[32]; byte[] _6s = new byte[32]; byte[] _7s = new byte[32]; byte[] _8s = new byte[32]; byte[] _9s = new byte[32]; byte[] _as = new byte[32]; Arrays.fill(_1s, (byte) 1); Arrays.fill(_2s, (byte) 2); Arrays.fill(_3s, (byte) 3); Arrays.fill(_4s, (byte) 4); Arrays.fill(_5s, (byte) 5); Arrays.fill(_6s, (byte) 6); Arrays.fill(_7s, (byte) 7); Arrays.fill(_8s, (byte) 8); Arrays.fill(_9s, (byte) 9); Arrays.fill(_as, (byte) 10); assertEquals( Bytes.fromHexString("0x55DC6699E7B5713DD9102224C302996F931836C6DAE9A4EC6AB49C966F394685"), SSZ.hashTreeRoot( Bytes.wrap(_1s), Bytes.wrap(_2s), Bytes.wrap(_3s), Bytes.wrap(_4s), Bytes.wrap(_5s), Bytes.wrap(_6s), Bytes.wrap(_7s), Bytes.wrap(_8s), Bytes.wrap(_9s), Bytes.wrap(_as))); }
Example 5
Source File: P11Actions.java From xipki with Apache License 2.0 | 4 votes |
@Override protected Object execute0() throws Exception { if (keysize % 8 != 0) { throw new IllegalCmdParamException("keysize is not multiple of 8: " + keysize); } long p11KeyType; if ("AES".equalsIgnoreCase(keyType)) { p11KeyType = PKCS11Constants.CKK_AES; } else if ("DES3".equalsIgnoreCase(keyType)) { p11KeyType = PKCS11Constants.CKK_DES3; } else if ("GENERIC".equalsIgnoreCase(keyType)) { p11KeyType = PKCS11Constants.CKK_GENERIC_SECRET; } else { throw new IllegalCmdParamException("invalid keyType " + keyType); } P11Slot slot = getSlot(); P11NewKeyControl control = getControl(); P11IdentityId identityId = null; try { identityId = slot.generateSecretKey(p11KeyType, keysize, control); finalize(keyType, identityId); } catch (P11UnsupportedMechanismException ex) { if (!createExternIfGenUnsupported) { throw ex; } String msgPrefix = "could not generate secret key "; if (control.getId() != null) { msgPrefix += "id=" + Hex.encode(control.getId()); if (control.getLabel() != null) { msgPrefix += " and "; } } if (control.getLabel() != null) { msgPrefix += "label=" + control.getLabel(); } if (LOG.isInfoEnabled()) { LOG.info(msgPrefix + ex.getMessage()); } if (LOG.isDebugEnabled()) { LOG.debug(msgPrefix, ex); } byte[] keyValue = new byte[keysize / 8]; securityFactory.getRandom4Key().nextBytes(keyValue); P11ObjectIdentifier objId = slot.importSecretKey(p11KeyType, keyValue, control); Arrays.fill(keyValue, (byte) 0); // clear the memory println("generated in memory and imported " + keyType + " key " + objId); } return null; }