Exemplo n.º 1
0
 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))
Exemplo n.º 2
0
 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
Exemplo n.º 3
0
 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
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    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)