def pbkdf2KAT(self,testDescription, password, salt, iterations, keySize, ka): """ Know Answer Tests from IEEE """ knownAnswer = a2b_p(ka) # convert ascii 2 binary derivedKey = pbkdf2(password, salt, iterations, keySize) print "========== %s ==========" % testDescription print 'password = "******"' % password print "salt/ssid = %s" % b2a_pter(salt, frnt=' ')[15:] print "iterations =", iterations print "keySize =", keySize print "derivedKey =", b2a_p(derivedKey, frnt=' ')[15:] #print "knownAnswer =", b2a_p(knownAnswer, frnt=' ')[15:] self.assertEqual(derivedKey, knownAnswer), "KAT Failed-> %s "% testDescription
def pbkdf2KAT(self, testDescription, password, salt, iterations, keySize, ka): """ Know Answer Tests from IEEE """ knownAnswer = a2b_p(ka) # convert ascii 2 binary derivedKey = pbkdf2(password, salt, iterations, keySize) print "========== %s ==========" % testDescription print 'password = "******"' % password print "salt/ssid = %s" % b2a_pter(salt, frnt=' ')[15:] print "iterations =", iterations print "keySize =", keySize print "derivedKey =", b2a_p(derivedKey, frnt=' ')[15:] #print "knownAnswer =", b2a_p(knownAnswer, frnt=' ')[15:] self.assertEqual(derivedKey, knownAnswer), "KAT Failed-> %s " % testDescription
def setPassphrase(self, passphrase): """ Use pbkdf2 to hash passphrase into a key """ self.setKey(pbkdf2(passphrase, self.name, 4096, self.keySize))
def setPassphrase(self,passphrase): """ Use pbkdf2 to hash passphrase into a key """ self.setKey( pbkdf2( passphrase, self.name, 4096, self.keySize) )