List of usage examples for org.bouncycastle.util Arrays clone
public static byte[][][] clone(byte[][][] data)
From source file:org.apache.pdfbox.pdmodel.interactive.digitalsignature.visible.PDVisibleSignDesigner.java
License:Apache License
/** * //from w w w . jav a2 s. c o m * @param imgageStream- stream of your visible signature image * @return Visible Signature Configuration Object * @throws IOException - If we can't read, flush, or close stream of image */ private PDVisibleSignDesigner signatureImageStream(InputStream imageStream) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int len; while ((len = imageStream.read(buffer)) > -1) { baos.write(buffer, 0, len); } baos.flush(); baos.close(); byte[] byteArray = baos.toByteArray(); byte[] byteArraySecond = Arrays.clone(byteArray); InputStream inputForBufferedImage = new ByteArrayInputStream(byteArray); InputStream revertInputStream = new ByteArrayInputStream(byteArraySecond); if (sigImgHeight == null || sigImgWidth == null) { calcualteImageSize(inputForBufferedImage); } this.imgageStream = revertInputStream; return this; }
From source file:org.ethereum.vm.DataWord.java
License:Open Source License
public DataWord clone() { return new DataWord(Arrays.clone(data)); }
From source file:org.hyperledger.common.Address.java
License:Apache License
/** * Create an address//from w w w.j a va 2 s .co m * * @param type - COMMON or P2SH or P2KEY * @param address - SHA256(RIPEM160(key)) digest of public key (COMMON, P2KEY) or spend script (P2SH) * @throws HyperLedgerException - thrown if digest length is not 20 bytes */ public Address(Type type, byte[] address) throws HyperLedgerException { this.type = type; if (address.length != 20) { throw new HyperLedgerException("invalid digest length for an address"); } this.bytes = Arrays.clone(address); }
From source file:org.hyperledger.common.MasterPrivateKey.java
License:Apache License
@Override public byte[] getChainCode() { return Arrays.clone(chainCode); }
From source file:org.hyperledger.common.PublicKey.java
License:Apache License
@Override public byte[] toByteArray() { return Arrays.clone(pub); }
From source file:org.hyperledger.core.BloomFilter.java
License:Apache License
/** * Create a bloom filter/*from w w w . j av a2s . c o m*/ * * @param data filter content * @param hashFunctions - number of hash functions to use * @param tweak - obfuscation parameter * @param update - a flag if transactions identified by the filter should update the filter */ public BloomFilter(byte[] data, int hashFunctions, int tweak, UpdateMode update) { filter = Arrays.clone(data); this.hashFunctions = Math.min(hashFunctions, MAX_HASH_FUNCS); this.tweak = tweak; this.update = update; }
From source file:org.syncany.tests.crypto.AesGcmWithBcInputStreamTest.java
License:Open Source License
@Test public void testD_BouncyCastleCipherInputStreamWithAesGcm() throws InvalidKeyException, InvalidAlgorithmParameterException, IOException, NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException { // Encrypt (not interesting in this example) byte[] randomKey = createRandomArray(16); byte[] randomIv = createRandomArray(16); byte[] originalPlaintext = "Confirm 100$ pay".getBytes("ASCII"); byte[] originalCiphertext = encryptWithAesGcm(originalPlaintext, randomKey, randomIv); // Attack / alter ciphertext (an attacker would do this!) byte[] alteredCiphertext = Arrays.clone(originalCiphertext); alteredCiphertext[8] = (byte) (alteredCiphertext[8] ^ 0x08); // <<< Change 100$ to 900$ // Decrypt with BouncyCastle implementation of CipherInputStream AEADBlockCipher cipher = new GCMBlockCipher(new AESEngine()); cipher.init(false, new AEADParameters(new KeyParameter(randomKey), 128, randomIv)); try {/*from w ww. ja v a 2s. co m*/ readFromStream(new org.bouncycastle.crypto.io.CipherInputStream( new ByteArrayInputStream(alteredCiphertext), cipher)); // ^^^^^^^^^^^^^^^ INTERESTING PART ^^^^^^^^^^^^^^^^ // // The BouncyCastle implementation of the CipherInputStream detects MAC verification errors and // throws a InvalidCipherTextIOException if an error occurs. Nice! A more or less minor issue // however is that it is incompatible with the standard JCE Cipher class from the javax.crypto // package. The new interface AEADBlockCipher must be used. The code below is not executed. fail("Test D: org.bouncycastle.crypto.io.CipherInputStream: NOT OK, tampering not detected"); } catch (InvalidCipherTextIOException e) { System.out .println("Test D: org.bouncycastle.crypto.io.CipherInputStream: OK, tampering detected"); } }
From source file:org.xipki.ca.api.X509CertWithDBCertId.java
License:Open Source License
public byte[] getSubjectKeyIdentifier() { return Arrays.clone(subjectKeyIdentifer); }
From source file:org.xipki.ca.qa.api.X509IssuerInfo.java
License:Open Source License
public byte[] getSubjectKeyIdentifier() { return Arrays.clone(ski); }
From source file:org.xipki.ca.qa.impl.internal.QaAdmission.java
License:Open Source License
public byte[] getAddProfessionInfo() { return Arrays.clone(addProfessionInfo); }