def handle_key_get(self, job): args = json.loads(job.arguments) tenant = self.sched.abide.tenants.get(args.get("tenant")) project = None if tenant: (trusted, project) = tenant.getProject(args.get("project")) if not project: job.sendWorkComplete("") return job.sendWorkComplete( encryption.serialize_rsa_public_key(project.public_key))
def handle_key_get(self, job): args = json.loads(job.arguments) tenant = self.sched.abide.tenants.get(args.get("tenant")) project = None if tenant: (trusted, project) = tenant.getProject(args.get("project")) if not project: job.sendWorkComplete("") return keytype = args.get('key', 'secrets') if keytype == 'secrets': job.sendWorkComplete( encryption.serialize_rsa_public_key( project.public_secrets_key)) elif keytype == 'ssh': job.sendWorkComplete(project.public_ssh_key) else: job.sendWorkComplete("") return
def test_openssl_pkcs1_oaep(self): "Verify that we can decrypt something encrypted with OpenSSL" orig_plaintext = b"some text to encrypt" pem_public = encryption.serialize_rsa_public_key(self.public) public_file = tempfile.NamedTemporaryFile(delete=False) try: public_file.write(pem_public) public_file.close() p = subprocess.Popen(['openssl', 'rsautl', '-encrypt', '-oaep', '-pubin', '-inkey', public_file.name], stdin=subprocess.PIPE, stdout=subprocess.PIPE) (stdout, stderr) = p.communicate(orig_plaintext) ciphertext = stdout finally: os.unlink(public_file.name) plaintext = encryption.decrypt_pkcs1_oaep(ciphertext, self.private) self.assertEqual(orig_plaintext, plaintext)
def test_openssl_pkcs1_oaep(self): "Verify that we can decrypt something encrypted with OpenSSL" orig_plaintext = b"some text to encrypt" pem_public = encryption.serialize_rsa_public_key(self.public) public_file = tempfile.NamedTemporaryFile(delete=False) try: public_file.write(pem_public) public_file.close() p = subprocess.Popen([ 'openssl', 'rsautl', '-encrypt', '-oaep', '-pubin', '-inkey', public_file.name ], stdin=subprocess.PIPE, stdout=subprocess.PIPE) (stdout, stderr) = p.communicate(orig_plaintext) ciphertext = stdout finally: os.unlink(public_file.name) plaintext = encryption.decrypt_pkcs1_oaep(ciphertext, self.private) self.assertEqual(orig_plaintext, plaintext)