At 01:00 PM 2/15/2000 -0800, Mark S. Miller wrote:
>When I try to establish a connection between an E running on a Sun Java
>1.1.8 and a Sun Java 1.2.2, I get the following exception. Bill especially,
>any ideas? Might Sun have made an incompatible change in serialization
>formats or something?
OK, the problem is most likely in a place where I played fast and loose with the Java API. In the Java 1.1 API, there is no way to convert a byte array to a public key. We call methods in the Sun security provider to make the conversion. It looks like the wire formats are incompatible, although when I looked at them in a hex dump, they looked like an ASN.1 DSA public key. The relevant section of the e source is:
//This hack should be revisited with new Java releases. We should not // need to use a sun. class to convert a public key as byte array to // a PublicKey object.
The way we get the byte array is entirely kosher. We get it using the getEncoded() call on the java.security.Key interface:
byte[] key = myIdentityKeys.getPublic().getEncoded();
The problem is that Sun, in its infinite wisdom didn't see a need to be able to go from the byte array to the implementor of Key. (The ASN.1 has enough information since it includes a code for the algorithm == DSA.) Sun has extended the API in 1.2 to include java.security.KeyFactory and java.security.spec.X509EncodedKeySpec, which provide the needed facility.
I think we may have to look at hex dumps of the keys from both Java 1.1 and Java 1.2 and code some manual conversion between them ourselves. We will still need to use the old way for 1.1 compatibility.
>
>If both are running the same version of Java, no such problem appears, even
>when one is running on Windows and the other on Linux. But the problem
>appears when they're communicating between these Java versions, no matter
>which platform each is running on. This exception was reported by a 1.1.8
>trying to connect to the 1.2.2. system. For some reason, the only matching
>source file I've got is from the jdk1.3Beta. Near line 100, it has a
>DSAPublicKey.getParams() with several casts. I include it below as well.
>Unfortunately, because of a previously reported bug, I can't connect at all
>on the 1.3Beta, and therefore I can't reproduce the bug under a debugger
>with sources.
>
>This bug is very important, but not urgent.
>
>Workaround for the moment: Use the same version of Java under all the Es
>that should be able to talk to each other.
>
>
>java.io.IOException: 192.168.0.5:1796: java.lang.ClassCastException:
sun.security.x509.AlgorithmId
> at sun.security.provider.DSAPublicKey.getParams(DSAPublicKey.java:100)
> at sun.security.provider.DSA.engineInitVerify(DSA.java:118)
> at java.security.Signature.initVerify(Signature.java:221)
> at
org.erights.e.net.data.StartUpProtocol.isSigGood(StartUpProtocol.java:967)
> at
org.erights.e.net.data.StartUpProtocol.isSecondDHOK(StartUpProtocol.java:905)
> at