Exemplo n.º 1
0
 def test_encrypt_decrypt_x509(self):
     with utils.tempdir() as tmpdir:
         self.flags(ca_path=tmpdir)
         project_id = "fake"
         crypto.ensure_ca_filesystem()
         cert = crypto.fetch_ca(project_id)
         public_key = os.path.join(tmpdir, "public.pem")
         with open(public_key, "w") as keyfile:
             keyfile.write(cert)
         text = "some @#!%^* test text"
         enc, _err = utils.execute(
             "openssl", "rsautl", "-certin", "-encrypt", "-inkey", "%s" % public_key, process_input=text
         )
         dec = crypto.decrypt_text(project_id, enc)
         self.assertEqual(text, dec)
Exemplo n.º 2
0
 def test_encrypt_decrypt_x509(self):
     with utils.tempdir() as tmpdir:
         self.flags(ca_path=tmpdir)
         project_id = "fake"
         crypto.ensure_ca_filesystem()
         cert = crypto.fetch_ca(project_id)
         public_key = os.path.join(tmpdir, "public.pem")
         with open(public_key, 'w') as keyfile:
             keyfile.write(cert)
         text = "some @#!%^* test text"
         enc, _err = utils.execute('openssl',
                                   'rsautl',
                                   '-certin',
                                   '-encrypt',
                                   '-inkey',
                                   '%s' % public_key,
                                   process_input=text)
         dec = crypto.decrypt_text(project_id, enc)
         self.assertEqual(text, dec)
Exemplo n.º 3
0
 def decrypt_text(self, context, project_id, text):
     """Decrypt base64 encoded text using the projects private key."""
     return crypto.decrypt_text(project_id, base64.b64decode(text))
Exemplo n.º 4
0
 def decrypt_text(self, context, project_id, text):
     """Decrypt base64 encoded text using the projects private key."""
     return crypto.decrypt_text(project_id, base64.b64decode(text))