[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNU Crypto] GNU crypto and gcj
From: |
Casey Marshall |
Subject: |
[GNU Crypto] GNU crypto and gcj |
Date: |
Fri, 11 Oct 2002 15:00:04 -0700 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello,
I think I've found the reason why all the cipher tests fail when
compiled natively with gcj -O2: the toBytesFromString method in
gnu.crypto.util.Util.
This program:
- ------
import gnu.crypto.util.Util;
class utilTest {
public static void main(String[] argv) throws Throwable {
byte[] b = new byte[] {
0x01, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xab,
(byte) 0xcd, (byte) 0xef
};
String s = "0123456789abcdef";
System.err.println(Util.toString(b));
System.err.println(s);
System.err.println(Util.toString(Util.toBytesFromString(s)));
}
}
- ------
when compiled, linked, and run with the gnu-crypto libraries prints out
0123456789abcdef
0123456789abcdef
1032547698badcfe
So it appears that when gcj -O2 compiles the statement
result[j++] = (byte)((fromDigit(s.charAt(i++)) << 4) |
fromDigit(s.charAt(i++)));
it flips the order of the two calls to 'fromDigit(s.charAt(i++))',
swapping the lower four bits and the top four for each byte.
The attached patch will fix the gcj build. If someone can confirm this
fix I'll check it in.
This result is with GCC 3.1; I don't know if the problem exists with
more recent versions.
Cheers,
- --
Casey Marshall < address@hidden > http://metastatic.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
Comment: Using GnuPG with Netscape - http://enigmail.mozdev.org
iD8DBQE9p0nkgAuWMgRGsWsRAhtgAJ9k81riuFZYNcu0ethlq/BcDmwdqACdFG5h
/lbpfa3cPdeKjgT1w/nNkVU=
=pLgZ
-----END PGP SIGNATURE-----
util-patch
Description: application/java-vm
- [GNU Crypto] GNU crypto and gcj,
Casey Marshall <=