예제 #1
0
 def testFingerprints12(self):
     '''Test the fingerprints of our loaded keys 1 and 2 together'''
     ourFingerprint = CryptoClient.getFingerprint(self.KEYID_1)
     self.assertIsNotNone(ourFingerprint,
                          "Our fingerprint shouldn't be blank")
     theirFingerprint = CryptoClient.getFingerprint(self.KEYID_2)
     self.assertIsNotNone(theirFingerprint,
                          "Their fingerprint shouldn't be blank")
     self.assertNotEqual(ourFingerprint, theirFingerprint,
                         "Fingerprints shouldn't be equal")
     print(ourFingerprint, theirFingerprint)
     # Generate our set of words
     checker = FingerprintChecker(ourFingerprint, theirFingerprint)
     self.assertEqual(checker.getCorrectAnswer(), 0,
                      "Correct answer should be 0")
     myWords = checker.getCodeWords(True, 0, "en")
     self.assertEqual(myWords, "connection microscope secrecy power dragon")
     myWordsGerman = checker.getCodeWords(True, 0, "de")
     self.assertEqual(myWordsGerman,
                      "Nachbarn Navigation Fußball Tintenfisch abwaschen")
     theirWords0 = checker.getCodeWords(False, 0, "en")
     theirWords1 = checker.getCodeWords(False, 1, "en")
     theirWords2 = checker.getCodeWords(False, 2, "en")
     self.assertNotEqual(theirWords0, theirWords1,
                         "Generated words 0 shouldn't equal 1")
     self.assertNotEqual(theirWords0, theirWords2,
                         "Generated words 0 shouldn't equal 2")
     self.assertNotEqual(theirWords1, theirWords2,
                         "Generated words 1 shouldn't equal 2")
     # Now again but from their side
     checker = FingerprintChecker(theirFingerprint, ourFingerprint)
     self.assertEqual(checker.getCorrectAnswer(), 0,
                      "Correct answer should be 0")
     theirCorrectWords = checker.getCodeWords(True, 0, "en")
     self.assertEqual(theirWords0, theirCorrectWords,
                      "Their words should match what we calculate")
     myWords0 = checker.getCodeWords(False, 0, "en")
     myWords1 = checker.getCodeWords(False, 1, "en")
     myWords2 = checker.getCodeWords(False, 2, "en")
     self.assertNotEqual(myWords0, myWords1,
                         "Generated words 0 shouldn't equal 1")
     self.assertNotEqual(myWords0, myWords2,
                         "Generated words 0 shouldn't equal 2")
     self.assertNotEqual(myWords1, myWords2,
                         "Generated words 1 shouldn't equal 2")
     self.assertEqual(myWords0, myWords,
                      "My words should match what they calculate")
예제 #2
0
 def _makeFingerprintChecker(self, userid):
     '''Use the given userid to make a FingerprintChecker between me and them'''
     person = DbI.getProfile(userid)
     ownFingerprint = CryptoClient.getFingerprint(DbI.getOwnKeyid())
     usrFingerprint = CryptoClient.getFingerprint(person['keyid'])
     return FingerprintChecker(ownFingerprint, usrFingerprint)