Update of /cvsroot/freenet/freenet/src/freenet/crypt
In directory sc8-pr-cvs1:/tmp/cvs-serv1629

Modified Files:
        DSA.java 
Log Message:
catch an ArithmeticException that's raised when bad DSA params try to be verified


Index: DSA.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/crypt/DSA.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -w -r1.1.1.1 -r1.2
--- DSA.java    13 Jan 2002 05:24:23 -0000      1.1.1.1
+++ DSA.java    20 Oct 2003 16:05:16 -0000      1.2
@@ -71,6 +71,7 @@
     public static boolean verify(DSAPublicKey kp,
                                 DSASignature sig,
                                 BigInteger m) {
+       try {
        BigInteger w=sig.getS().modInverse(kp.getQ());
        BigInteger u1=m.multiply(w).mod(kp.getQ());
        BigInteger u2=sig.getR().multiply(w).mod(kp.getQ());
@@ -78,6 +79,12 @@
        BigInteger v2=kp.getY().modPow(u2, kp.getP());
        BigInteger v=v1.multiply(v2).mod(kp.getP()).mod(kp.getQ());
        return v.equals(sig.getR());
+
+
+           //FIXME: is there a better way to handle this exception raised on the 'w=' 
line above?
+       } catch (ArithmeticException e) {  // catch error raised by invalid data
+           return false;                  // and report that that data is bad.
+       }
     }
 
     public static void main(String[] args) throws Exception {

_______________________________________________
cvs mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to