def _modified(self):
    # Look up the signature of the previous whole file (from the src_path index?)
    logging.info('Getting local view of previous.')
    latest = self.metadata_store.local_view_of_previous(
      hash_string(self.src_path))
    if not latest:
      logging.error('Have not seen this file before (%s), yet '
                    'we are shepherding a modification.' % self.src_path)
      return False

    logging.info('Getting signature of hash_of_blob (%s).' % latest)
    latest_signature = self.metadata_store.lookup_signature(latest)
    if not latest_signature:
      logging.error('We do not have the latest signature.')
      return False

    logging.info('Computing the delta.')
    # compute_cleartext_delta(prev_sig, latest_filename)
    delta_file_name = self.crypto.compute_cleartext_delta(
      latest_signature, self.src_path)
    logging.info('Updating crypto file path to delta file (%s).' %
                 delta_file_name)


    logging.info('Encrypting.')
    # encrypt delta (get back the hash_of_encrypted_blob)
    self.crypto.rsync_signature()
    self.crypto.encrypt_delta_file()

    # Locally store: hash(gpg(delta)) -> signature(file)
    logging.info('Setting new signature (%s) : (%s).' %
                 (self.crypto.hash_of_encrypted_blob,
                  self.crypto.ascii_signature))
    self.metadata_store.set_signature(self.crypto.hash_of_encrypted_blob,
                                      self.crypto.ascii_signature)
Example #2
0
 def hash_file_path(self):
   try:
     os.path.exists(self.file_path)
     self.hash_of_file_path = hash_string(self.file_path)
   except Exception, e:
     logging.error(e)
     raise
Example #3
0
  def encrypt(self):
    self.encrypt_file(self.file_path)
    self.hash_of_encrypted_blob = hash_filename(self.path_to_encrypted_blob)

    # File path encryption.
    encrypted_blob_path = self.gpg.encrypt(self.file_path, self.recipients,
                                           always_trust=True, armor=False)
    self.raw_data_of_encrypted_blob_path = encrypted_blob_path.data
    self.hash_of_raw_data_of_encrypted_blob_path =\
      hash_string(self.raw_data_of_encrypted_blob_path)
Example #4
0
def key_limit():
    gpg = gnupg.GPG()
    keyid = "3fa60037"
    exported_keys = gpg.export_keys(keyid)
    print exported_keys
    print len(exported_keys)
    connection = connect_sdb()
    gpg_test_domain_name = "gpg_test_domain"

    if not connection.lookup(gpg_test_domain_name):
        domain = connection.create_domain(gpg_test_domain_name)
    else:
        domain = connection.get_domain(gpg_test_domain_name, validate=True)

    item = domain.new_item("keys")
    item[keyid] = hash_string(exported_keys)
    item.save()

    connection.delete_domain(gpg_test_domain_name)