예제 #1
0
 def create_cert(master_sk, signer_pk, cert_start, cert_stop):
     assert int(time.time()) < cert_start < cert_stop, 'wrong time setting of cert.'
     master_ecc = Encryption()
     master_ecc.sk = master_sk
     cert_raw = bjson.dumps((master_ecc.pk, signer_pk, cert_start, cert_stop), compress=False)
     cert = {
         'master': master_ecc.pk,
         'start': cert_start,
         'stop': cert_stop,
         'sign': master_ecc.sign(cert_raw, encode='hex')}
     return cert
예제 #2
0
 def remove_file_by_master(self, signer_sk, cert, file_hash):
     file_hash = file_hash.lower()
     file_path = os.path.join(V.DATA_PATH, 'file.' + file_hash + '.dat')
     uuid = random.randint(10, 99999999)
     signer_ecc = Encryption()
     signer_ecc.sk = signer_sk
     try:
         os.remove(file_path)
         sign_raw = bjson.dumps((file_hash, uuid), compress=False)
         send_data = {
             'signer': signer_ecc.pk,
             'sign': signer_ecc.sign(msg=sign_raw, encode='hex'),
             'cert': cert}
         dummy, result = self.send_command(ClientCmd.FILE_DELETE, send_data, uuid=uuid)
         logging.debug("File delete success.")
     except:
         logging.debug("Failed delete file.")
         pass