Skip to content
Snippets Groups Projects
Commit c0eb7174 authored by akwizgran's avatar akwizgran
Browse files

Removed an unnecessary allocation.

parent 4ca5be7c
No related branches found
No related tags found
No related merge requests found
...@@ -28,13 +28,10 @@ class TagEncoder { ...@@ -28,13 +28,10 @@ class TagEncoder {
if(tag.length < TAG_LENGTH) throw new IllegalArgumentException(); if(tag.length < TAG_LENGTH) throw new IllegalArgumentException();
try { try {
tagCipher.init(Cipher.DECRYPT_MODE, tagKey); tagCipher.init(Cipher.DECRYPT_MODE, tagKey);
byte[] plaintext = tagCipher.doFinal(tag, 0, TAG_LENGTH); int decrypted = tagCipher.doFinal(tag, 0, TAG_LENGTH, tag);
if(plaintext.length != TAG_LENGTH) if(decrypted != TAG_LENGTH) throw new IllegalArgumentException();
throw new IllegalArgumentException();
//The plaintext should be blank //The plaintext should be blank
for(int i = 0; i < TAG_LENGTH; i++) { for(int i = 0; i < TAG_LENGTH; i++) if(tag[i] != 0) return false;
if(plaintext[i] != 0) return false;
}
return true; return true;
} catch(GeneralSecurityException e) { } catch(GeneralSecurityException e) {
// Unsuitable cipher or key // Unsuitable cipher or key
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
<test name='net.sf.briar.db.BasicH2Test'/> <test name='net.sf.briar.db.BasicH2Test'/>
<test name='net.sf.briar.db.DatabaseCleanerImplTest'/> <test name='net.sf.briar.db.DatabaseCleanerImplTest'/>
<test name='net.sf.briar.db.DatabaseComponentImplTest'/> <test name='net.sf.briar.db.DatabaseComponentImplTest'/>
<test name='net.sf.briar.i18n.FontManagerTest'/>
<test name='net.sf.briar.i18n.I18nTest'/> <test name='net.sf.briar.i18n.I18nTest'/>
<test name='net.sf.briar.invitation.InvitationWorkerTest'/> <test name='net.sf.briar.invitation.InvitationWorkerTest'/>
<test name='net.sf.briar.lifecycle.ShutdownManagerImplTest'/> <test name='net.sf.briar.lifecycle.ShutdownManagerImplTest'/>
...@@ -78,6 +77,7 @@ ...@@ -78,6 +77,7 @@
</classpath> </classpath>
<jvmarg value='-Djava.library.path=../lib'/> <jvmarg value='-Djava.library.path=../lib'/>
<test name='net.sf.briar.db.H2DatabaseTest'/> <test name='net.sf.briar.db.H2DatabaseTest'/>
<test name='net.sf.briar.i18n.FontManagerTest'/>
<test name='net.sf.briar.plugins.tor.TorPluginTest'/> <test name='net.sf.briar.plugins.tor.TorPluginTest'/>
</junit> </junit>
</target> </target>
......
...@@ -89,7 +89,7 @@ public class FrameReadWriteTest extends BriarTestCase { ...@@ -89,7 +89,7 @@ public class FrameReadWriteTest extends BriarTestCase {
byte[] recoveredTag = new byte[TAG_LENGTH]; byte[] recoveredTag = new byte[TAG_LENGTH];
assertEquals(TAG_LENGTH, in.read(recoveredTag)); assertEquals(TAG_LENGTH, in.read(recoveredTag));
assertArrayEquals(tag, recoveredTag); assertArrayEquals(tag, recoveredTag);
assertTrue(TagEncoder.decodeTag(tag, tagCipher, tagKey)); assertTrue(TagEncoder.decodeTag(recoveredTag, tagCipher, tagKey));
// Read the frames back // Read the frames back
FrameReader encryptionIn = new IncomingEncryptionLayerImpl(in, FrameReader encryptionIn = new IncomingEncryptionLayerImpl(in,
tagCipher, frameCipher, tagKey, frameKey, false); tagCipher, frameCipher, tagKey, frameKey, false);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment