Christian Werner schrieb:
> I implemented a ECC encryption on J2ME using Bouncycastle. On Nokia S60
> phones and in emulator its working fine, but on Nokia S40 I get the
> following exception:
> java/lang/NoSuchFieldError: No such field
> ONE.Lorg/bouncycastle/math/BigInteger;.
>
> I moved BigInteger to org.bouncycastle.math package, so I don't have to
> obfuscate it which is horrible for tracing errors.
Not sure if I understand that correctly. You moved
java.math.BigInteger to org.bouncycastle.math?
Or are we talking about org.bouncycastle.util.BigIntegers?
BigIntegers doesn't contain ONE, but ECCConstants does
(using BigInteger.valueOf(1)).
The whole codebase of BouncyCastle (I have the CVS-version
here) don't use java.math.BigInteger.ONE, so I don't think
that BouncyCastle can be "fixed" by establishing a workaround.
> I tried Bouncycastle 1.35 and 1.42 and also BigInteger of 1.44 - but
> nowhere it's working.
If we are really talking about java.math.BigInteger it seems
that the JVM in that specific Nokia device lacks this field
which would be a bug in the Nokia device.
>
> The following code seems to create the problem:
>
> public final static ECCurve FP192_V1 = new ECCurve.Fp(
> new
> BigInteger("6277101735386680763835789423207666416083908700390324961279"),
> new
> BigInteger("fffffffffffffffffffffffffffffffefffffffffffffffc", 16),
> new
> BigInteger("64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", 16));
I don't see BigInteger.ONE there.
> public final static ECDomainParameters PRIME192_V1_BASED_DOMAIN_PARAMS =
> new ECDomainParameters(
> FP192_V1,
> FP192_V1.decodePoint(
>
> Hex.decode("03188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012")),
> new
> BigInteger("ffffffffffffffffffffffff99def836146bc9b1b4d22831", 16));
>
> ... but this are the standard constants also used in X962NamedCurves
> class ...
There is no BigInteger.ONE, either.
> What I'm wondering is, that this exception is NOT caught with a general
> exception.
It's an error that is derived from Throwable and not Exception.
> Also I'm using Netbeans and I can not compile catching the
> NoSuchFieldError exception, since it does not exist.
Sounds strange. You might try catch(Throwable) but preferably
you should first check where the BigInteger.ONE is used any-
way, because it seems more likely to happen in your own code
rather than BC.
> Also what I
> understood is, that this exception should be prevented by compiler in
> most cases: "Normally, this error is caught by the compiler; this error
> can only occur at run time if the definition of a class has incompatibly
> changed." But where the class is changed at runtime and I also wonder if
> this is possible in J2ME (MIDP2)...
The description is a bit confusing. It means that this error can
only happen if you compile against other classes than you use
for execution.
Exactly that seems to be the case here.
Regards, Lothar