private byte[] decrypt(byte[] in) throws GeneralSecurityException { return doCipherOp(decryptor, in, false); }
/** * Validates an encrypted challenge as defined in the protocol, and returns the byte array * that corresponds to the actual challenge data. */ private byte[] validateChallenge(byte[] nonce, byte[] encryptedChallenge) throws GeneralSecurityException { byte[] challenge = decrypt(encryptedChallenge); checkSubArray(appId, challenge, 0); checkSubArray(nonce, challenge, appId.length); return Arrays.copyOfRange(challenge, appId.length + nonce.length, challenge.length); }
void createClient(String secret) throws Exception { createClient(secret, true); }
@Test(expected = IllegalArgumentException.class) public void testWrongAppId() throws Exception { AuthEngine engine = new AuthEngine("appId", "secret", conf); ClientChallenge challenge = engine.challenge(); byte[] badChallenge = engine.challenge(new byte[] { 0x00 }, challenge.nonce, engine.rawResponse(engine.challenge)); engine.respond(new ClientChallenge(challenge.appId, challenge.kdf, challenge.iterations, challenge.cipher, challenge.keyLength, challenge.nonce, badChallenge)); }
/** * Add handlers to channel. * * @param ch the channel for adding handlers * @throws IOException */ public void addToChannel(Channel ch) throws IOException { ch.pipeline() .addFirst(ENCRYPTION_HANDLER_NAME, new EncryptionHandler(this)) .addFirst(DECRYPTION_HANDLER_NAME, new DecryptionHandler(this)); }
void createServer(String secret) throws Exception { createServer(secret, true); }
@Test(expected = IllegalArgumentException.class) public void testWrongAppId() throws Exception { AuthEngine engine = new AuthEngine("appId", "secret", conf); ClientChallenge challenge = engine.challenge(); byte[] badChallenge = engine.challenge(new byte[] { 0x00 }, challenge.nonce, engine.rawResponse(engine.challenge)); engine.respond(new ClientChallenge(challenge.appId, challenge.kdf, challenge.iterations, challenge.cipher, challenge.keyLength, challenge.nonce, badChallenge)); }
/** * Add handlers to channel. * * @param ch the channel for adding handlers * @throws IOException */ public void addToChannel(Channel ch) throws IOException { ch.pipeline() .addFirst(ENCRYPTION_HANDLER_NAME, new EncryptionHandler(this)) .addFirst(DECRYPTION_HANDLER_NAME, new DecryptionHandler(this)); }
private byte[] encrypt(byte[] in) throws GeneralSecurityException { return doCipherOp(encryptor, in, false); }
void createClient(String secret) throws Exception { createClient(secret, true); }
void createServer(String secret) throws Exception { createServer(secret, true); }
@Test(expected = IllegalArgumentException.class) public void testWrongNonce() throws Exception { AuthEngine engine = new AuthEngine("appId", "secret", conf); ClientChallenge challenge = engine.challenge(); byte[] badChallenge = engine.challenge(challenge.appId.getBytes(UTF_8), new byte[] { 0x00 }, engine.rawResponse(engine.challenge)); engine.respond(new ClientChallenge(challenge.appId, challenge.kdf, challenge.iterations, challenge.cipher, challenge.keyLength, challenge.nonce, badChallenge)); }
/** * Add handlers to channel. * * @param ch the channel for adding handlers * @throws IOException */ public void addToChannel(Channel ch) throws IOException { ch.pipeline() .addFirst(ENCRYPTION_HANDLER_NAME, new EncryptionHandler(this)) .addFirst(DECRYPTION_HANDLER_NAME, new DecryptionHandler(this)); }
private byte[] encrypt(byte[] in) throws GeneralSecurityException { return doCipherOp(encryptor, in, false); }
@Test(expected = IllegalArgumentException.class) public void testBadChallenge() throws Exception { AuthEngine engine = new AuthEngine("appId", "secret", conf); ClientChallenge challenge = engine.challenge(); byte[] badChallenge = new byte[challenge.challenge.length]; engine.respond(new ClientChallenge(challenge.appId, challenge.kdf, challenge.iterations, challenge.cipher, challenge.keyLength, challenge.nonce, badChallenge)); }
private byte[] decrypt(byte[] in) throws GeneralSecurityException { return doCipherOp(decryptor, in, false); }
@Test(expected = IllegalArgumentException.class) public void testBadChallenge() throws Exception { AuthEngine engine = new AuthEngine("appId", "secret", conf); ClientChallenge challenge = engine.challenge(); byte[] badChallenge = new byte[challenge.challenge.length]; engine.respond(new ClientChallenge(challenge.appId, challenge.kdf, challenge.iterations, challenge.cipher, challenge.keyLength, challenge.nonce, badChallenge)); }
private byte[] encrypt(byte[] in) throws GeneralSecurityException { return doCipherOp(encryptor, in, false); }
@Test(expected = IllegalArgumentException.class) public void testWrongNonce() throws Exception { AuthEngine engine = new AuthEngine("appId", "secret", conf); ClientChallenge challenge = engine.challenge(); byte[] badChallenge = engine.challenge(challenge.appId.getBytes(UTF_8), new byte[] { 0x00 }, engine.rawResponse(engine.challenge)); engine.respond(new ClientChallenge(challenge.appId, challenge.kdf, challenge.iterations, challenge.cipher, challenge.keyLength, challenge.nonce, badChallenge)); }
private byte[] decrypt(byte[] in) throws GeneralSecurityException { return doCipherOp(decryptor, in, false); }