List of usage examples for org.bouncycastle.crypto.engines ISAACEngine ISAACEngine
ISAACEngine
From source file:com.DSC.chat.Create.java
License:Open Source License
@Override public boolean executeCommand() { if (!Pattern.matches("[a-zA-Z_\\s0-9-]+", this.channel)) { return false; }// w w w . j a va 2 s . c o m // Generate seed byte[] seed = new byte[64]; // 512 bit seed SecureRandom random = new SecureRandom(); random.nextBytes(seed); // Create the symmetric key byte[] symmetricKey = new byte[16]; // 128 bit key ISAACRandomGenerator isaac = new ISAACRandomGenerator(new ISAACEngine()); isaac.init(seed); isaac.nextBytes(symmetricKey); ProgramState.symmetricKey = symmetricKey; ProgramState.passphrase = this.passphrase; // Creator of channel is authenticated and has created the key ProgramState.AUTHENTICATED = true; ProgramState.KEY_RECEIVED = true; return true; }
From source file:com.DSC.client.SecureChannel.java
License:Open Source License
/** * @param args//from w w w. j a va 2 s .c om * @throws InterruptedException * @throws IOException */ public static void main(String[] args) throws InterruptedException, IOException { /* Create their private & public keys */ ECKey key = new ECKey(); key.init(); ProgramState.publicKey = (ECPublicKeyParameters) key.getPublic(); ProgramState.privateKey = (ECPrivateKeyParameters) key.getPrivate(); /* Create the IV engine */ byte[] seed = new byte[64]; // 512 bit seed SecureRandom random = new SecureRandom(); random.nextBytes(seed); ProgramState.IVEngine = new ISAACRandomGenerator(new ISAACEngine()); ProgramState.IVEngine.init(seed); /* Create the blacklist and trusted contacts */ ProgramState.blacklist = ConcurrentHashMultiset.create(); ProgramState.trustedKeys = new ConcurrentHashMap<String, Address>(); /* Set the time for the client accurately using a NTP server */ DateTimeUtils.setCurrentMillisOffset(getTimeOffset()); ProgramState.fmt = DateTimeFormat.forPattern("HH:mm:ss"); /* Set the default nick as anonymous */ ProgramState.nick = "anonymous"; /* Initialize ISAACRandomGenerator, set ProgramState.IVEngine */ receiveController = new ReceiveController(); sendController = new SendController(); /* Start input event handler loop */ eventLoop(); }
From source file:org.cryptacular.spec.StreamCipherSpec.java
License:Open Source License
@Override public StreamCipher newInstance() { StreamCipher cipher;/*www .j a v a2 s .c om*/ if ("Grainv1".equalsIgnoreCase(algorithm) || "Grain-v1".equalsIgnoreCase(algorithm)) { cipher = new ISAACEngine(); } else if ("Grain128".equalsIgnoreCase(algorithm) || "Grain-128".equalsIgnoreCase(algorithm)) { cipher = new Grain128Engine(); } else if ("ISAAC".equalsIgnoreCase(algorithm)) { cipher = new ISAACEngine(); } else if ("HC128".equalsIgnoreCase(algorithm)) { cipher = new HC128Engine(); } else if ("HC256".equalsIgnoreCase(algorithm)) { cipher = new HC256Engine(); } else if ("RC4".equalsIgnoreCase(algorithm)) { cipher = new RC4Engine(); } else if ("Salsa20".equalsIgnoreCase(algorithm)) { cipher = new Salsa20Engine(); } else if ("VMPC".equalsIgnoreCase(algorithm)) { cipher = new VMPCEngine(); } else { throw new IllegalStateException("Unsupported cipher algorithm " + algorithm); } return cipher; }