def encrypt(self, kap_id, enc_kap_path, sig_key): """Encrypt a KAP for the client and signs it with a key.""" kdata = self.get(kap_id) if not kdata: raise Exception("KAP %s doesn't exists" % kap_id) KAP.write_KAP(kdata, enc_kap_path, do_encrypt = True, teambox_email_skey = sig_key, encrypt_pkey = self.client_conf.get_enc_pkey().key_path)
def add(self, kdata): """Add a KAP to the client configuration.""" # Get an unique name for the KAP file. s = time.strftime("%Y%m%d") kn = "" kp = "" d = 1 while True: kn = "kap_%s_%s_%d" % (kdata.kap_type, s, d) kp = os.path.join(self._kap_dir, kn) + ".tar.gz" if not os.path.exists(kp): break else: d = d + 1 # Write the raw KAP. KAP.write_KAP(kdata, kp, do_encrypt = False) return kn