コード例 #1
0
 def __init__(self):
     """
     Setup keys, secret message and encryption/decryption schemes.
     """
     self._key = generateRSAKey(1024)
     self._secret = b'This is how Daniel Bleichenbachers adaptive chosen-ciphertext attack works...'
     self._pkcsmsg = bytes(self._key.encrypt(self._secret))
コード例 #2
0
def GenerateKey(public_keyfile, private_keyfile, key_bits=2048):
    """Generate an RSA key pair."""
    public = open(public_keyfile, 'w')
    os.fchmod(public.fileno(), 0400)
    private = open(private_keyfile, 'w')
    os.fchmod(private.fileno(), 0400)
    key = keyfactory.generateRSAKey(key_bits)
    public.write(key.writeXMLPublicKey() + '\n')
    private.write(key.write() + '\n')
コード例 #3
0
ファイル: utils.py プロジェクト: 3manuek/mysql-tools
def GenerateKey(public_keyfile, private_keyfile, key_bits=2048):
  """Generate an RSA key pair."""
  public = open(public_keyfile, 'w')
  os.fchmod(public.fileno(), 0400)
  private = open(private_keyfile, 'w')
  os.fchmod(private.fileno(), 0400)
  key = keyfactory.generateRSAKey(key_bits)
  public.write(key.writeXMLPublicKey() + '\n')
  private.write(key.write() + '\n')
コード例 #4
0
    def test_generate_TLS_1_1(self):
        priv_key = generateRSAKey(1024)
        cert_ver_g = CertificateVerifyGenerator(priv_key)
        state = ConnectionState()
        state.version = (3, 2)

        msg = cert_ver_g.generate(state)

        self.assertIsNotNone(msg)
        self.assertEqual(len(msg.signature), 128)
コード例 #5
0
    def test_generate_TLS_1_2(self):
        priv_key = generateRSAKey(1024)
        cert_ver_g = CertificateVerifyGenerator(priv_key)
        state = ConnectionState()
        state.version = (3, 3)

        msg = cert_ver_g.generate(state)

        self.assertIsNotNone(msg)
        self.assertEqual(len(msg.signature), 128)
        self.assertEqual(msg.signatureAlgorithm,
                         (constants.HashAlgorithm.sha1,
                          constants.SignatureAlgorithm.rsa))
コード例 #6
0
    def test_generate_TLS_1_2_with_cert_request(self):
        priv_key = generateRSAKey(1024)
        cert_ver_g = CertificateVerifyGenerator(priv_key)
        state = ConnectionState()
        state.version = (3, 3)
        req = CertificateRequest((3, 3)).create([], [],
            [(constants.HashAlgorithm.sha256,
              constants.SignatureAlgorithm.rsa),
             (constants.HashAlgorithm.sha1,
              constants.SignatureAlgorithm.rsa)])
        state.handshake_messages = [req]

        msg = cert_ver_g.generate(state)

        self.assertIsNotNone(msg)
        self.assertEqual(len(msg.signature), 128)
        self.assertEqual(msg.signatureAlgorithm,
                         (constants.HashAlgorithm.sha256,
                          constants.SignatureAlgorithm.rsa))
コード例 #7
0
 def setUpClass(cls):
     cls.priv_key = keyfactory.generateRSAKey(1024)
コード例 #8
0
 def setUpClass(cls):
     cls.priv_key = keyfactory.generateRSAKey(1024)