From: peli0101 Date: Fri, 3 Apr 2009 06:00:09 +0000 (+0000) Subject: OI Safe: Fix bug in Trivium implementation. X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=ad102ba90afece2009b67375e74f824d10a3aa6b;p=android-vcpass-oisafe OI Safe: Fix bug in Trivium implementation. Now several blocks of Trivium encrypted parts can be concatenated without problems. (each block has to be a multiple of 4 bytes). git-svn-id: http://openintents.googlecode.com/svn/trunk/Safe@2011 72b678ce-9140-0410-bee8-679b907dd61a --- diff --git a/src/estreamj/ciphers/trivium/Trivium.java b/src/estreamj/ciphers/trivium/Trivium.java index 9b7d1f1..6f007d2 100644 --- a/src/estreamj/ciphers/trivium/Trivium.java +++ b/src/estreamj/ciphers/trivium/Trivium.java @@ -1,7 +1,11 @@ package estreamj.ciphers.trivium; -import estreamj.framework.*; +import estreamj.framework.ESJException; +import estreamj.framework.Engine; +import estreamj.framework.ICipher; +import estreamj.framework.ICipherMaker; +import estreamj.framework.Utils; public class Trivium implements ICipher { @@ -81,7 +85,8 @@ public class Trivium implements ICipher // NOTE: could save some code memory by merging the two blocks, but that // would decrease the speed because of additional conditional jumps... outEnd = outOfs + (len & 3); - if (0 < outEnd) + //if (0 < outEnd) + if (outOfs < outEnd) // Peli: Apr 3, 2009: BUGFIX { int t1, t2, t3, reg; diff --git a/src/org/openintents/safe/CryptoHelper.java b/src/org/openintents/safe/CryptoHelper.java index 51bcca3..9400f74 100644 --- a/src/org/openintents/safe/CryptoHelper.java +++ b/src/org/openintents/safe/CryptoHelper.java @@ -637,8 +637,8 @@ public class CryptoHelper { int offset = 0; int numRead = 0; while ((numRead = is.read(bytesIn, 0, bytesLen)) >= 0) { - if ((numRead | 3) != 0) { - Log.d(TAG, "Bytes read is inappropriate number: " + numRead); + if ((numRead & 3) != 0) { + Log.d(TAG, "Bytes read is inappropriate number: " + numRead + " : " + (numRead | 3)); } tri.process(bytesIn, 0, @@ -777,7 +777,7 @@ public class CryptoHelper { int offset = 0; numRead = 0; while ((numRead = is.read(bytesIn, 0, bytesLen)) >= 0) { - if ((numRead | 3) != 0) { + if ((numRead & 3) != 0) { Log.d(TAG, "Bytes read is inappropriate number: " + numRead); }