public void engineSetSeed(byte[] seed) { HashMap attributes = new HashMap(); attributes.put(ARCFour.ARCFOUR_KEY_MATERIAL, seed); adaptee.init(attributes); virgin = false; } }
IRandom getARCFOUR(byte[] key) { HashMap attrib = new HashMap(); IRandom keystream = new ARCFour(); attrib.put(ARCFour.ARCFOUR_KEY_MATERIAL, key); keystream.init(attrib); return keystream; }
IRandom getARCFOUR(byte[] key) { HashMap attrib = new HashMap(); IRandom keystream = new ARCFour(); attrib.put(ARCFour.ARCFOUR_KEY_MATERIAL, key); keystream.init(attrib); return keystream; }
protected void engineInit(int mode, Key key, SecureRandom r) throws InvalidKeyException { if (mode != Cipher.ENCRYPT_MODE && mode != Cipher.DECRYPT_MODE) { throw new IllegalArgumentException("arcfour is for encryption or decryption only"); } if (key == null || !key.getFormat().equalsIgnoreCase("RAW")) { throw new InvalidKeyException("key must be non-null raw bytes"); } HashMap attrib = new HashMap(); attrib.put(ARCFour.ARCFOUR_KEY_MATERIAL, key.getEncoded()); keystream.init(attrib); }
map.put(MDGenerator.SEEED, seed); singleton.init(map); // default is to use SHA-1 hash singleton.nextBytes(buffer, offset, length); } catch (Exception y) {
private SecretKeySpec genkey(PBEKey key) throws InvalidKeyException { IRandom kdf = PRNGFactory.getInstance("PBKDF2-" + macName); if (kdf == null) { throw new IllegalArgumentException("no such KDF: PBKDF2-" + macName); } HashMap attrib = new HashMap(); attrib.put(IPBE.ITERATION_COUNT, new Integer(key.getIterationCount())); attrib.put(IPBE.PASSWORD, key.getPassword()); attrib.put(IPBE.SALT, key.getSalt()); try { kdf.init(attrib); } catch (IllegalArgumentException iae) { throw new InvalidKeyException(iae.toString()); } byte[] dk = new byte[mode.defaultKeySize()]; try { kdf.nextBytes(dk, 0, dk.length); } catch (LimitReachedException shouldNotHappen) { // throw new Error(shouldNotHappen); throw new Error(String.valueOf(shouldNotHappen)); } return new SecretKeySpec(dk, cipher.name()); }
keystream.init(kAttributes);
kdf.init(map); byte[] Kp = new byte[KEY_LEN]; try {
kdf.init(attr); int len = ((PBEKeySpec) spec).getKeyLength(); if (len <= 0) {
pbAttr.put(IPBE.ITERATION_COUNT, ITERATION_COUNT); IRandom kdf = PRNGFactory.getInstance("PBKDF2-HMAC-SHA"); kdf.init(pbAttr);
pbAttr.put(IPBE.ITERATION_COUNT, ITERATION_COUNT); IRandom kdf = PRNGFactory.getInstance("PBKDF2-HMAC-SHA"); kdf.init(pbAttr);