Commits

Cédric Bonhomme committed 631b7e1

Remplaced sha1 by sha256. RSA keys are loaded with 'with' statement.

Comments (0)

Files changed (2)

                 bd = 1, relief = SUNKEN, anchor = W)
         self.status.grid(row = 4, columnspan = 5, sticky = W+E+N+S, pady = 5)
 
-        # Load local RSA keys
-        self.load_rsa_keys()
-
         # Main loop
         self.master.mainloop()
 
             # set the outgoing message
             pubkey = str(self.my_rsa_keys.b) + "-" + str(self.my_rsa_keys.n)
 
-            sha1_hash = hashlib.sha1()
-            sha1_hash.update(password1)
-            hashed_passwd = sha1_hash.hexdigest()
+            sha256_hash = hashlib.sha256()
+            sha256_hash.update(password1)
+            hashed_passwd = sha256_hash.hexdigest()
 
             self.client_agent.outgoing_message = "signin:" + \
                                         self.agent_name + \
         ontology_entry.grid(row = 3, column = 1, pady = 2, sticky = W)
         ontology_entry.insert(0, self.ontology)
 
-        Scale(msg, length=400, orient = HORIZONTAL, \
+        Scale(msg, length=450, orient = HORIZONTAL, \
             sliderlength = 25, label = 'RSA key length :', \
             from_=128, to=3072, tickinterval = 256, \
             resolution = 128, showvalue = self.rsa_nb_bits, \
-            command = self.rsa_key_length).grid(row = 4, columnspan = 2, pady = 2)
+            command = self.rsa_key_length).grid(row = 4, columnspan = 2, \
+                                                pady = 2, sticky = W)
 
         Button(msg, text="Generate RSA key", \
             command = self.generate_rsa_keys).grid(row = 5, columnspan = 2, pady = 2)
                 tkMessageBox.showerror('Error', 'Bad entry')
                 return
 
-            sha1_hash = hashlib.sha1()
-            sha1_hash.update(password)
-            hashed_passwd = sha1_hash.hexdigest()
+            sha256_hash = hashlib.sha256()
+            sha256_hash.update(password)
+            hashed_passwd = sha256_hash.hexdigest()
 
             self.client_agent.outgoing_message = "login:" + \
                 self.agent_name + ":" + hashed_passwd
 
             msg.destroy()
 
-            self.load_rsa_keys()
+            if self.my_rsa_keys == None:
+                self.load_rsa_keys()
 
         if self.client_agent == None:
             self.show_info('You are not connected to the SPADE platform.')
         """
         Load the RSA keys of the local client.
         """
-        try:
-            keys = open("./security/keys" + self.user_name, "r")
+        with open("./security/keys" + self.user_name, "r") as keys:
             self.my_rsa_keys = pickle.load(keys)
             print "RSA keys loaded."
-        except Exception , e:
-            self.my_rsa_keys = None
 
     def clear_window(self):
         """

source/spade/user_db.xml

Binary file modified.