def _sign_message(self, key_name): key = KEYS[key_name] self.assertTrue(key) with open(key["file"], 'rb') as f: priv_key = f.read() f.close() signer = manta.PrivateKeySigner(key["fp"], priv_key) signed = signer.sign(message) self.assertEqual(len(signed), 3) self.assertTrue(signed[0] == key["sighash"]) signature = base64.b64decode(signed[2]) hash_class = get_hash_class_from_algorithm(signed[0]) vkey = serialization.load_pem_private_key(priv_key, password=None, backend=default_backend()) self.assertTrue(vkey) vkey = vkey.public_key() self.assertTrue(vkey) # vkey.verify() raises exception if verification fails if key["type"] == "RSA": verified = vkey.verify(signature, message, padding.PKCS1v15(), hash_class()) elif key["type"] == "ECDSA": verified = vkey.verify(signature, message, ec.ECDSA(hash_class())) else: self.assertFalse("Unknown Key Type: {}".format(key["type"])) self.assertTrue(verified is None) return
def __init__(self): self.account = os.environ.get('MANTA_USER', None) self.user = os.environ.get('MANTA_SUBUSER', None) self.role = os.environ.get('MANTA_ROLE', None) self.key_id = os.environ.get('MANTA_KEY_ID', None) self.private_key = os.environ.get('MANTA_PRIVATE_KEY') self.url = os.environ.get('MANTA_URL', 'https://us-east.manta.joyent.com') self.bucket = os.environ.get('MANTA_BUCKET', '/{}/stor'.format(self.account)) self.signer = manta.PrivateKeySigner(self.key_id, self.private_key) self.client = manta.MantaClient(self.url, self.account, subuser=self.user, role=self.role, signer=self.signer)
def __init__(self): self.account = get_environ('MANTA_USER', None) self.user = get_environ('MANTA_SUBUSER', None) self.role = get_environ('MANTA_ROLE', None) self.key_id = get_environ('MANTA_KEY_ID', None) self.url = get_environ('MANTA_URL', 'https://us-east.manta.joyent.com') self.bucket = get_environ('MANTA_BUCKET', '/{}/stor'.format(self.account)) # we don't want to use get_environ here because we have a different # de-munging to do self.private_key = os.environ.get('MANTA_PRIVATE_KEY').replace( '#', '\n') self.signer = manta.PrivateKeySigner(self.key_id, self.private_key) self.client = manta.MantaClient(self.url, self.account, subuser=self.user, role=self.role, signer=self.signer)
def __init__(self, envs=os.environ): self.account = env('MANTA_USER', None, envs) self.user = env('MANTA_SUBUSER', None, envs) self.role = env('MANTA_ROLE', None, envs) self.key_id = env('MANTA_KEY_ID', None, envs) self.url = env('MANTA_URL', 'https://us-east.manta.joyent.com', envs) self.bucket = env('MANTA_BUCKET', '/{}/stor'.format(self.account), envs) is_tls = env('MANTA_TLS_INSECURE', False, envs, fn=to_flag) # we don't want to use `env` here because we have a different # de-munging to do self.private_key = envs.get('MANTA_PRIVATE_KEY', '').replace('#', '\n') self.signer = pymanta.PrivateKeySigner(self.key_id, self.private_key) self.client = pymanta.MantaClient( self.url, self.account, subuser=self.user, role=self.role, disable_ssl_certificate_validation=is_tls, signer=self.signer)