BigBrotherBot v1.8.0
System Development Information for the BigBrotherBot project.

b3::lib::beaker::crypto::pbkdf2 Namespace Reference

Classes

class  PBKDF2

Functions

def strxor
def crypt
def _makesalt
def test_pbkdf2

Variables

string __version__ = "1.1"
 PBKDF2.py - PKCS#5 v2.0 Password-Based Key Derivation.

Function Documentation

def b3::lib::beaker::crypto::pbkdf2::_makesalt ( ) [private]
Return a 48-bit pseudorandom salt for crypt().

This function is not suitable for generating cryptographic secrets.
def b3::lib::beaker::crypto::pbkdf2::crypt (   word,
  salt = None,
  iterations = None 
)
PBKDF2-based unix crypt(3) replacement.

The number of iterations specified in the salt overrides the 'iterations'
parameter.

The effective hash length is 192 bits.
def b3::lib::beaker::crypto::pbkdf2::strxor (   a,
  b 
)
def b3::lib::beaker::crypto::pbkdf2::test_pbkdf2 ( )
Module self-test

Variable Documentation

PBKDF2.py - PKCS#5 v2.0 Password-Based Key Derivation.

Copyright (C) 2007 Dwayne C. Litzenberger <[email protected]> All rights reserved.

Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation.

THE AUTHOR PROVIDES THIS SOFTWARE ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Country of origin: Canada

Sample PBKDF2 usage: from Crypto.Cipher import AES from PBKDF2 import PBKDF2 import os

salt = os.urandom(8) # 64-bit salt key = PBKDF2("This passphrase is a secret.", salt).read(32) # 256-bit key iv = os.urandom(16) # 128-bit IV cipher = AES.new(key, AES.MODE_CBC, iv) ...

Sample crypt() usage: from PBKDF2 import crypt pwhash = crypt("secret") alleged_pw = raw_input("Enter password: ") if pwhash == crypt(alleged_pw, pwhash): print "Password good" else: print "Invalid password"

History:

2007-07-27 Dwayne C. Litzenberger <[email protected]>

  • Initial Release (v1.0)

2007-07-31 Dwayne C. Litzenberger <[email protected]>

  • Bugfix release (v1.1)
  • SECURITY: The PyCrypto XOR cipher (used, if available, in the _strxor function in the previous release) silently truncates all keys to 64 bytes. The way it was used in the previous release, this would only be problem if the pseudorandom function that returned values larger than 64 bytes (so SHA1, SHA256 and SHA512 are fine), but I don't like anything that silently reduces the security margin from what is expected.
 All Classes Namespaces Files Functions Variables Properties