public Object clone() { ARCFour copy = new ARCFour(); copy.s = (s != null) ? (byte[]) s.clone() : null; copy.m = m; copy.n = n; copy.buffer = (buffer != null) ? (byte[]) buffer.clone() : null; copy.ndx = ndx; copy.initialised = initialised; return copy; }
public void setup(Map attributes) { byte[] kb = (byte[]) attributes.get(ARCFOUR_KEY_MATERIAL); if (kb == null) { throw new IllegalArgumentException("ARCFOUR needs a key"); } s = new byte[ARCFOUR_SBOX_SIZE]; m = n = 0; byte[] k = new byte[ARCFOUR_SBOX_SIZE]; for (int i = 0; i < ARCFOUR_SBOX_SIZE; i++) { s[i] = (byte) i; } if (kb.length > 0) { for (int i = 0, j = 0; i < ARCFOUR_SBOX_SIZE; i++) { k[i] = kb[j++]; if (j >= kb.length) j = 0; } } for (int i = 0, j = 0; i < ARCFOUR_SBOX_SIZE; i++) { j = j + s[i] + k[i]; byte temp = s[i]; s[i] = s[j & 0xff]; s[j & 0xff] = temp; } buffer = new byte[ARCFOUR_SBOX_SIZE]; try { fillBlock(); } catch (LimitReachedException wontHappen) { } }
IRandom getARCFOUR(byte[] key) { HashMap attrib = new HashMap(); IRandom keystream = new ARCFour(); attrib.put(ARCFour.ARCFOUR_KEY_MATERIAL, key); keystream.init(attrib); return keystream; }
public void setup(Map attributes) { byte[] kb = (byte[]) attributes.get(ARCFOUR_KEY_MATERIAL); if (kb == null) { throw new IllegalArgumentException("ARCFOUR needs a key"); } s = new byte[ARCFOUR_SBOX_SIZE]; m = n = 0; byte[] k = new byte[ARCFOUR_SBOX_SIZE]; for (int i = 0; i < ARCFOUR_SBOX_SIZE; i++) { s[i] = (byte) i; } if (kb.length > 0) { for (int i = 0, j = 0; i < ARCFOUR_SBOX_SIZE; i++) { k[i] = kb[j++]; if (j >= kb.length) j = 0; } } for (int i = 0, j = 0; i < ARCFOUR_SBOX_SIZE; i++) { j = j + s[i] + k[i]; byte temp = s[i]; s[i] = s[j & 0xff]; s[j & 0xff] = temp; } buffer = new byte[ARCFOUR_SBOX_SIZE]; try { fillBlock(); } catch (LimitReachedException wontHappen) { } }
IRandom getARCFOUR(byte[] key) { HashMap attrib = new HashMap(); IRandom keystream = new ARCFour(); attrib.put(ARCFour.ARCFOUR_KEY_MATERIAL, key); keystream.init(attrib); return keystream; }
public void setup(Map attributes) { byte[] kb = (byte[]) attributes.get(ARCFOUR_KEY_MATERIAL); if (kb == null) { throw new IllegalArgumentException("ARCFOUR needs a key"); } s = new byte[ARCFOUR_SBOX_SIZE]; m = n = 0; byte[] k = new byte[ARCFOUR_SBOX_SIZE]; for (int i = 0; i < ARCFOUR_SBOX_SIZE; i++) { s[i] = (byte) i; } if (kb.length > 0) { for (int i = 0, j = 0; i < ARCFOUR_SBOX_SIZE; i++) { k[i] = kb[j++]; if (j >= kb.length) j = 0; } } for (int i = 0, j = 0; i < ARCFOUR_SBOX_SIZE; i++) { j = j + s[i] + k[i]; byte temp = s[i]; s[i] = s[j & 0xff]; s[j & 0xff] = temp; } buffer = new byte[ARCFOUR_SBOX_SIZE]; try { fillBlock(); } catch (LimitReachedException wontHappen) { } }
public Object clone() { ARCFour copy = new ARCFour(); copy.s = (s != null) ? (byte[]) s.clone() : null; copy.m = m; copy.n = n; copy.buffer = (buffer != null) ? (byte[]) buffer.clone() : null; copy.ndx = ndx; copy.initialised = initialised; return copy; }
public Object clone() { ARCFour copy = new ARCFour(); copy.s = (s != null) ? (byte[]) s.clone() : null; copy.m = m; copy.n = n; copy.buffer = (buffer != null) ? (byte[]) buffer.clone() : null; copy.ndx = ndx; copy.initialised = initialised; return copy; }
if (prng.equalsIgnoreCase(ARCFOUR_PRNG) || prng.equalsIgnoreCase(RC4_PRNG)) { result = new ARCFour(); } else if (prng.equalsIgnoreCase(ICM_PRNG)) { result = new ICMGenerator();