]> hydra-www.ietfng.org Git - android-vcpass-oisafe/commitdiff
OI Safe: Fix bug in Trivium implementation.
authorpeli0101 <peli0101@72b678ce-9140-0410-bee8-679b907dd61a>
Fri, 3 Apr 2009 06:00:09 +0000 (06:00 +0000)
committerpeli0101 <peli0101@72b678ce-9140-0410-bee8-679b907dd61a>
Fri, 3 Apr 2009 06:00:09 +0000 (06:00 +0000)
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

src/estreamj/ciphers/trivium/Trivium.java
src/org/openintents/safe/CryptoHelper.java

index 9b7d1f13ca87f345c7fe3a8dcee89cdc1b518229..6f007d235dd63dd434bddb326f35e13912fbbf65 100644 (file)
@@ -1,7 +1,11 @@
 \r
 package estreamj.ciphers.trivium;\r
 \r
-import estreamj.framework.*;\r
+import estreamj.framework.ESJException;\r
+import estreamj.framework.Engine;\r
+import estreamj.framework.ICipher;\r
+import estreamj.framework.ICipherMaker;\r
+import estreamj.framework.Utils;\r
 \r
 public class Trivium implements ICipher \r
 {\r
@@ -81,7 +85,8 @@ public class Trivium implements ICipher
         // NOTE: could save some code memory by merging the two blocks, but that\r
         // would decrease the speed because of additional conditional jumps...\r
         outEnd = outOfs + (len & 3);\r
-        if (0 < outEnd)\r
+        //if (0 < outEnd)\r
+        if (outOfs < outEnd) // Peli: Apr 3, 2009: BUGFIX\r
         {\r
                int t1, t2, t3, reg;\r
                \r
index 51bcca3838ebeada5b37a53ecba75d6be07c3fab..9400f74050f42f1e4b8bd64ffa38e5fe83d52a60 100644 (file)
@@ -637,8 +637,8 @@ public class CryptoHelper {
                                int offset = 0;\r
                                int numRead = 0;\r
                                while ((numRead = is.read(bytesIn, 0, bytesLen)) >= 0) {\r
-                                       if ((numRead | 3) != 0) {\r
-                                               Log.d(TAG, "Bytes read is inappropriate number: " + numRead);\r
+                                       if ((numRead & 3) != 0) {\r
+                                               Log.d(TAG, "Bytes read is inappropriate number: " + numRead + " : " + (numRead | 3));\r
                                        }\r
                                        \r
                                    tri.process(bytesIn, 0,\r
@@ -777,7 +777,7 @@ public class CryptoHelper {
                                int offset = 0;\r
                                numRead = 0;\r
                                while ((numRead = is.read(bytesIn, 0, bytesLen)) >= 0) {\r
-                                       if ((numRead | 3) != 0) {\r
+                                       if ((numRead & 3) != 0) {\r
                                                Log.d(TAG, "Bytes read is inappropriate number: " + numRead);\r
                                        }\r
                                        \r