Skip to content
This repository

Decrease urandom entropy drain #15

Merged
merged 1 commit into from almost 2 years ago

2 participants

Federico Ceratto Ben Bangert
Federico Ceratto

6 bytes from /dev/urandom should be enough to produce 8 bytes of base-64 data.
In theory entropy should be used only when needed as the entropy pool is a limited resource.

Thanks!

Ben Bangert bbangert merged commit bdd66a4 into from May 09, 2012
Ben Bangert bbangert closed this May 09, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Apr 21, 2012
Federico Ceratto Decrease urandom entropy drain 6539442
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 1 addition and 1 deletion. Show diff stats Hide diff stats

  1. 2  beaker/session.py
2  beaker/session.py
@@ -252,7 +252,7 @@ def _encrypt_data(self, session_data=None):
252 252
         """Serialize, encipher, and base64 the session dict"""
253 253
         session_data = session_data or self.copy()
254 254
         if self.encrypt_key:
255  
-            nonce = b64encode(os.urandom(40))[:8]
  255
+            nonce = b64encode(os.urandom(6))[:8]
256 256
             encrypt_key = crypto.generateCryptoKeys(self.encrypt_key,
257 257
                                              self.validate_key + nonce, 1)
258 258
             data = util.pickle.dumps(session_data, 2)
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.