List of usage examples for org.bouncycastle.util Arrays clone
public static byte[][][] clone(byte[][][] data)
From source file:com.bitsofproof.supernode.api.ECKeyPair.java
License:Apache License
@Override public ECKeyPair clone() throws CloneNotSupportedException { ECKeyPair c = (ECKeyPair) super.clone(); c.priv = new BigInteger(c.priv.toByteArray()); c.pub = Arrays.clone(pub); c.compressed = compressed;/* ww w.j av a2 s .c o m*/ return c; }
From source file:com.bitsofproof.supernode.api.ECKeyPair.java
License:Apache License
@Override public byte[] getPublic() { return Arrays.clone(pub); }
From source file:com.bitsofproof.supernode.api.ECPublicKey.java
License:Apache License
@Override public ECPublicKey clone() throws CloneNotSupportedException { ECPublicKey c = (ECPublicKey) super.clone(); c.pub = Arrays.clone(pub); return c;//from w w w . j a v a 2 s . co m }
From source file:com.bitsofproof.supernode.api.ExtendedKey.java
License:Apache License
public byte[] getChainCode() { return Arrays.clone(chainCode); }
From source file:com.igeekinc.util.EthernetID.java
License:Open Source License
public EthernetID(byte[] inID) { if (inID.length != 6) { throw new IllegalArgumentException("Ethernet ID's must be 6 digits in length"); }/*from w ww . ja v a 2 s.com*/ id = Arrays.clone(inID); }
From source file:com.igeekinc.util.EthernetID.java
License:Open Source License
public byte[] getBytes() { return Arrays.clone(id); }
From source file:freenet.crypt.OCBBlockCipher_v149.java
License:Open Source License
public void init(boolean forEncryption, CipherParameters parameters) throws IllegalArgumentException { this.forEncryption = forEncryption; this.macBlock = null; KeyParameter keyParameter;/*from w ww . j a v a 2s. c o m*/ byte[] N; if (parameters instanceof AEADParameters) { AEADParameters aeadParameters = (AEADParameters) parameters; N = aeadParameters.getNonce(); initialAssociatedText = aeadParameters.getAssociatedText(); int macSizeBits = aeadParameters.getMacSize(); if (macSizeBits < 64 || macSizeBits > 128 || macSizeBits % 8 != 0) { throw new IllegalArgumentException("Invalid value for MAC size: " + macSizeBits); } macSize = macSizeBits / 8; keyParameter = aeadParameters.getKey(); } else if (parameters instanceof ParametersWithIV) { ParametersWithIV parametersWithIV = (ParametersWithIV) parameters; N = parametersWithIV.getIV(); initialAssociatedText = null; macSize = 16; keyParameter = (KeyParameter) parametersWithIV.getParameters(); } else { throw new IllegalArgumentException("invalid parameters passed to OCB"); } this.hashBlock = new byte[16]; this.mainBlock = new byte[forEncryption ? BLOCK_SIZE : (BLOCK_SIZE + macSize)]; if (N == null) { N = new byte[0]; } /* * TODO There's currently a thread on CFRG * (http://www.ietf.org/mail-archive/web/cfrg/current/msg03433.html) debating including * (macSize % 128) in the nonce, in which case this test becomes simpler: */ // if (N.length > 15) // { // throw new IllegalArgumentException("IV must be no more than 120 bits"); // } if (N.length > 16 || (N.length == 16 && (N[0] & 0x80) != 0)) { /* * NOTE: We don't just ignore bit 128 because it would hide from the caller the fact * that two nonces differing only in bit 128 are not different. */ throw new IllegalArgumentException("IV must be no more than 127 bits"); } /* * KEY-DEPENDENT INITIALISATION */ if (keyParameter == null) { // TODO If 'keyParameter' is null we're re-using the last key. } // hashCipher always used in forward mode hashCipher.init(true, keyParameter); mainCipher.init(forEncryption, keyParameter); this.L_Asterisk = new byte[16]; hashCipher.processBlock(L_Asterisk, 0, L_Asterisk, 0); this.L_Dollar = OCB_double(L_Asterisk); this.L = new Vector(); this.L.addElement(OCB_double(L_Dollar)); /* * NONCE-DEPENDENT AND PER-ENCRYPTION/DECRYPTION INITIALISATION */ byte[] nonce = new byte[16]; System.arraycopy(N, 0, nonce, nonce.length - N.length, N.length); /* * TODO There's currently a thread on CFRG * (http://www.ietf.org/mail-archive/web/cfrg/current/msg03433.html) debating including * (macSize % 128) in the nonce, in which case this code becomes simpler: */ // nonce[0] = (byte)(macSize << 4); // nonce[15 - N.length] |= 1; if (N.length == 16) { nonce[0] &= 0x80; } else { nonce[15 - N.length] = 1; } int bottom = nonce[15] & 0x3F; // System.out.println("bottom: " + bottom); byte[] Ktop = new byte[16]; nonce[15] &= 0xC0; hashCipher.processBlock(nonce, 0, Ktop, 0); byte[] Stretch = new byte[24]; System.arraycopy(Ktop, 0, Stretch, 0, 16); for (int i = 0; i < 8; ++i) { Stretch[16 + i] = (byte) (Ktop[i] ^ Ktop[i + 1]); } this.OffsetMAIN_0 = new byte[16]; int bits = bottom % 8, bytes = bottom / 8; if (bits == 0) { System.arraycopy(Stretch, bytes, OffsetMAIN_0, 0, 16); } else { for (int i = 0; i < 16; ++i) { int b1 = Stretch[bytes] & 0xff; int b2 = Stretch[++bytes] & 0xff; this.OffsetMAIN_0[i] = (byte) ((b1 << bits) | (b2 >>> (8 - bits))); } } this.hashBlockPos = 0; this.mainBlockPos = 0; this.hashBlockCount = 0; this.mainBlockCount = 0; this.OffsetHASH = new byte[16]; this.Sum = new byte[16]; this.OffsetMAIN = Arrays.clone(this.OffsetMAIN_0); this.Checksum = new byte[16]; if (initialAssociatedText != null) { processAADBytes(initialAssociatedText, 0, initialAssociatedText.length); } }
From source file:freenet.crypt.OCBBlockCipher_v149.java
License:Open Source License
public byte[] getMac() { return Arrays.clone(macBlock); }
From source file:index.kmer.java
/** * Copy constructor// w w w . ja v a2s . com * * @param k_mer The kmer object we want to copy. */ public kmer(kmer k_mer) { K = k_mer.K; prefix_length = k_mer.prefix_length; suffix_length = k_mer.suffix_length; prefix_mask = k_mer.prefix_mask; shift = k_mer.shift; fwd_prefix = k_mer.fwd_prefix; fwd_suffix = Arrays.clone(k_mer.fwd_suffix); rev_prefix = k_mer.rev_prefix; rev_suffix = Arrays.clone(k_mer.rev_suffix); canonical = k_mer.canonical; }
From source file:index.kmer.java
/** * Recalculates the suffix and, in turn, the prefix based on the new suffix length * /*from w w w .j ava 2 s .c om*/ * @param s_len The new suffix length for the k-mer */ public static void adjust_fwd_kmer(kmer kmer2, kmer kmer1) { int i, j, k, suffix_length1, suffix_length2; suffix_length1 = kmer1.suffix_length; suffix_length2 = kmer2.suffix_length; if (suffix_length1 != suffix_length2) { for (i = suffix_length1 / 4 - 1, j = suffix_length2 / 4 - 1; i >= 0 && j >= 0; --i, --j) kmer2.fwd_suffix[j] = kmer1.fwd_suffix[i]; if (i >= 0) { for (kmer2.fwd_prefix = kmer1.fwd_prefix, k = 0; k <= i; ++k) kmer2.fwd_prefix = (kmer2.fwd_prefix << 8) | (kmer1.fwd_suffix[k] & 0x00FF); } if (j >= 0) { kmer2.fwd_prefix = kmer1.fwd_prefix; for (; j >= 0; --j) { kmer2.fwd_suffix[j] = (byte) (kmer2.fwd_prefix & 0x0FF); kmer2.fwd_prefix = kmer2.fwd_prefix >> 8; } } } else { kmer2.set_fwd_suffix(Arrays.clone(kmer1.get_fwd_suffix())); kmer2.set_fwd_prefix(kmer1.get_fwd_prefix()); //kmer2 = kmer1; } kmer2.canonical = true; // to be found by find() }