예제 #1
0
    def test_mceliece():
        mce_priv = botan2.private_key('mce', [2960, 57], botan2.rng())
        mce_pub = mce_priv.get_public_key()

        mce_plaintext = 'mce plaintext'
        mce_ad = 'mce AD'
        mce_ciphertext = botan2.mceies_encrypt(mce_pub, botan2.rng(), 'ChaCha20Poly1305', mce_plaintext, mce_ad)

        print("mceies len(pt)=%d  len(ct)=%d" % (len(mce_plaintext), len(mce_ciphertext)))

        mce_decrypt = botan2.mceies_decrypt(mce_priv, 'ChaCha20Poly1305', mce_ciphertext, mce_ad)
        print("  mceies plaintext  \'%s\' (%d)" % (mce_plaintext, len(mce_plaintext)))

        # Since mceies_decrypt() returns bytes in Python3, the following line
        # needs .decode('utf-8') to convert mce_decrypt from bytes to a
        # text string (Unicode).
        # You don't need to add .decode() if
        # (a) your expected output is bytes rather than a text string, or
        # (b) you are using Python2 rather than Python3.
        print("  mceies decrypted  \'%s\' (%d)" % (mce_decrypt.decode('utf-8'), len(mce_decrypt)))

        print("mce_pub %s/SHA-1 fingerprint: %s\nEstimated strength %s bits (len %d)\n" % (
            mce_pub.algo_name(), mce_pub.fingerprint("SHA-1"),
            mce_pub.estimated_strength(), len(mce_pub.encoding())
        ))
예제 #2
0
    def test_mceliece():
        mce_priv = botan2.private_key('mce', [2960, 57], botan2.rng())
        mce_pub = mce_priv.get_public_key()

        mce_plaintext = 'mce plaintext'
        mce_ad = 'mce AD'
        mce_ciphertext = botan2.mceies_encrypt(mce_pub, botan2.rng(), 'ChaCha20Poly1305', mce_plaintext, mce_ad)

        print("mceies len(pt)=%d  len(ct)=%d" % (len(mce_plaintext), len(mce_ciphertext)))

        mce_decrypt = botan2.mceies_decrypt(mce_priv, 'ChaCha20Poly1305', mce_ciphertext, mce_ad)
        print("  mceies plaintext  \'%s\' (%d)" % (mce_plaintext, len(mce_plaintext)))

        # Since mceies_decrypt() returns bytes in Python3, the following line
        # needs .decode('utf-8') to convert mce_decrypt from bytes to a
        # text string (Unicode).
        # You don't need to add .decode() if
        # (a) your expected output is bytes rather than a text string, or
        # (b) you are using Python2 rather than Python3.
        print("  mceies decrypted  \'%s\' (%d)" % (mce_decrypt.decode('utf-8'), len(mce_decrypt)))

        print("mce_pub %s/SHA-1 fingerprint: %s\nEstimated strength %s bits (len %d)\n" % (
            mce_pub.algo_name(), mce_pub.fingerprint("SHA-1"),
            mce_pub.estimated_strength(), len(mce_pub.encoding())
        ))
예제 #3
0
    def test_mceliece(self):
        rng = botan2.RandomNumberGenerator()
        mce_priv = botan2.PrivateKey.create('McEliece', '2960,57', rng)
        mce_pub = mce_priv.get_public_key()
        self.assertEqual(mce_pub.estimated_strength(), 128)

        mce_plaintext = rng.get(16)
        mce_ad = rng.get(48)
        mce_ciphertext = botan2.mceies_encrypt(mce_pub, rng, 'ChaCha20Poly1305', mce_plaintext, mce_ad)

        mce_decrypt = botan2.mceies_decrypt(mce_priv, 'ChaCha20Poly1305', mce_ciphertext, mce_ad)

        self.assertEqual(mce_plaintext, mce_decrypt)
예제 #4
0
    def test_mceliece(self):
        rng = botan2.rng()
        mce_priv = botan2.private_key('mce', [2960, 57], rng)
        mce_pub = mce_priv.get_public_key()
        self.assertEqual(mce_pub.estimated_strength(), 128)

        mce_plaintext = rng.get(16)
        mce_ad = rng.get(48)
        mce_ciphertext = botan2.mceies_encrypt(mce_pub, botan2.rng(), 'ChaCha20Poly1305', mce_plaintext, mce_ad)

        mce_decrypt = botan2.mceies_decrypt(mce_priv, 'ChaCha20Poly1305', mce_ciphertext, mce_ad)

        self.assertEqual(mce_plaintext, mce_decrypt)
예제 #5
0
    def test_mceliece(self):
        rng = botan2.RandomNumberGenerator()
        mce_priv = botan2.PrivateKey.create('McEliece', '2960,57', rng)
        mce_pub = mce_priv.get_public_key()
        self.assertEqual(mce_pub.estimated_strength(), 128)

        mce_plaintext = rng.get(16)
        mce_ad = rng.get(48)
        mce_ciphertext = botan2.mceies_encrypt(mce_pub, rng,
                                               'ChaCha20Poly1305',
                                               mce_plaintext, mce_ad)

        mce_decrypt = botan2.mceies_decrypt(mce_priv, 'ChaCha20Poly1305',
                                            mce_ciphertext, mce_ad)

        self.assertEqual(mce_plaintext, mce_decrypt)
예제 #6
0
파일: test_python.py 프로젝트: auserj/botan
    def test_mceliece(self):
        rng = botan2.rng()
        mce_priv = botan2.private_key('mce', [2960, 57], rng)
        mce_pub = mce_priv.get_public_key()
        self.assertEqual(mce_pub.estimated_strength(), 128)

        mce_plaintext = rng.get(16)
        mce_ad = rng.get(48)
        mce_ciphertext = botan2.mceies_encrypt(mce_pub, botan2.rng(),
                                               'ChaCha20Poly1305',
                                               mce_plaintext, mce_ad)

        mce_decrypt = botan2.mceies_decrypt(mce_priv, 'ChaCha20Poly1305',
                                            mce_ciphertext, mce_ad)

        self.assertEqual(mce_plaintext, mce_decrypt)