Author: dbkr
Date: 2006-07-20 13:34:13 +0000 (Thu, 20 Jul 2006)
New Revision: 9671

Modified:
   trunk/apps/Freemail/src/freemail/RTSFetcher.java
Log:
Working RTS messages :)


Modified: trunk/apps/Freemail/src/freemail/RTSFetcher.java
===================================================================
--- trunk/apps/Freemail/src/freemail/RTSFetcher.java    2006-07-20 12:07:41 UTC 
(rev 9670)
+++ trunk/apps/Freemail/src/freemail/RTSFetcher.java    2006-07-20 13:34:13 UTC 
(rev 9671)
@@ -227,14 +227,13 @@
                }

                // verify the signature
-               String their_mailsite = rtsprops.get("mailsite");
+               String their_mailsite_raw = rtsprops.get("mailsite");

-               MessageDigest md;
+               MessageDigest md = null;
                try {
-                       md = MessageDigest.getInstance("MD5");
+                       md = MessageDigest.getInstance("SHA-256");
                } catch (NoSuchAlgorithmException alge) {
-                       System.out.println("No MD5 implementation available - 
sorry, Freemail cannot work!");
-                       rtsfile.delete();
+                       System.out.println("No SHA 256 implementation available 
- Freemail cannot work!");
                        return false;
                }
                md.update(plaintext, 0, messagebytes);
@@ -242,6 +241,23 @@

                HighLevelFCPClient fcpcli = new HighLevelFCPClient();

+               FreenetURI their_mailsite_furi;
+               try {
+                       their_mailsite_furi = new 
FreenetURI(their_mailsite_raw);
+               } catch (MalformedURLException mfue) {
+                       System.out.println("Mailsite in the RTS message is not 
a valid Freenet URI. Discarding RTS message.");
+                       rtsfile.delete();
+                       return true;
+               }
+               
+               String their_mailsite = 
"USK@"+their_mailsite_furi.getKeyBody()+"/"+their_mailsite_furi.getSuffix();
+               
+               if (!their_mailsite.endsWith("/")) {
+                       their_mailsite += "/";
+               }
+               their_mailsite += "1/"+MailSite.MAILPAGE;
+               
+               
                System.out.println("Trying to fetch sender's mailsite: 
"+their_mailsite);

                File msfile = fcpcli.fetch(their_mailsite);
@@ -278,7 +294,7 @@
                // finally we can now check that our hash and their hash
                // match!
                if (their_hash.length != our_hash.length) {
-                       System.out.println("The signature of the RTS message is 
not valid. Discarding the RTS message.");
+                       System.out.println("The signature of the RTS message is 
not valid (our hash: "+our_hash.length+"bytes, their hash: 
"+their_hash.length+"bytes. Discarding the RTS message.");
                        msfile.delete();
                        rtsfile.delete();
                        return true;
@@ -314,15 +330,6 @@
                System.out.println("Original message intended for us :)");

                // create the inbound contact
-               FreenetURI their_mailsite_furi;
-               try {
-                       their_mailsite_furi = new FreenetURI(their_mailsite);
-               } catch (MalformedURLException mfue) {
-                       System.out.println("Mailsite in the RTS message is not 
a valid Freenet URI. Discarding RTS message.");
-                       msfile.delete();
-                       rtsfile.delete();
-                       return true;
-               }
                InboundContact ibct = new InboundContact(this.contact_dir, 
their_mailsite_furi);

                ibct.setProp("commssk", rtsprops.get("commssk"));


Reply via email to