Exemplo n.º 1
0
def make_contact_path( pubkey_str, email_addr ):
   global STORAGE_DIR
   
   """
   enc_filename = storage.encrypt_data( pubkey_str, email_addr )
   enc_filename_salted = storage.salt_string( enc_filename )
   enc_filename_b64 = base64.b64encode( enc_filename_salted )
   """
   # TODO: make this scheme IND-CPA
   filename_salted = storage.salt_string( email_addr )
   filename_b64 = base64.b64encode( filename_salted )
   return storage.volume_path( STORAGE_DIR, filename_b64 )
Exemplo n.º 2
0
def list_contacts( pubkey_str, privkey_str, start_idx=None, length=None ):
   global STORAGE_DIR, CACHED_CONTACT_LIST
   
   cached_contacts = storage.get_cached_data( privkey_str, CACHED_CONTACT_LIST )
   if cached_contacts == None:
      log.info("No cached contacts")
   else:
      return cached_contacts
   
   contact_dir = storage.volume_path( STORAGE_DIR )   
   dir_ents = storage.listdir( contact_dir )
   dir_ents.sort()
   
   if start_idx == None:
      start_idx = 0
      
   if length == None:
      length = len(dir_ents)
   
   if start_idx + length > len(dir_ents):
      length = len(dir_ents) - start_idx
      
   dir_ents = dir_ents[start_idx:start_idx + length]
   
   contact_emails = []
   
   for contact_filename in dir_ents:
      contact_path = storage.path_join( contact_dir, contact_filename )
      contact = read_contact_from_path( privkey_str, contact_path )
      if contact == None:
         log.warning("Failed to read contact file %s" % contact_path)
         continue
   
      contact_emails.append( contact.addr )
   
   storage.cache_data( pubkey_str, CACHED_CONTACT_LIST, contact_emails )
   return contact_emails
Exemplo n.º 3
0
def delete_syndicate_user_id( volume ):
   uid_path = storage.volume_path( USER_STORAGE_DIR, "syndicate_user_id" )
   return storage.delete_file( uid_path, volume=volume )
Exemplo n.º 4
0
def write_syndicate_user_id( pubkey_pem, user_id, volume ):
   uid_path = storage.volume_path( USER_STORAGE_DIR, "syndicate_user_id" )
   return storage.write_encrypted_file( pubkey_pem, uid_path, user_id, volume=volume )
Exemplo n.º 5
0
def read_syndicate_user_id( privkey_pem, volume ):
   uid_path = storage.volume_path( USER_STORAGE_DIR, "syndicate_user_id" )
   return storage.read_encrypted_file( privkey_pem, uid_path, volume=volume )
Exemplo n.º 6
0
def attachment_path( message_timestamp, message_id, attachment ):
   name = attachment_storage_name( message_timestamp, message_id, attachment )
   return storage.volume_path( ATTACHMENTS_DIR, name )
Exemplo n.º 7
0
def incoming_message_path( message_timestamp, message_id ):
   # message path for remotely-hosted messages that we know about from our server
   global INCOMING_DIR
   
   return storage.volume_path( INCOMING_DIR, message_handle(message_timestamp, message_id))
Exemplo n.º 8
0
def incoming_dir():
   global INCOMING_DIR
   
   return storage.volume_path( INCOMING_DIR )
Exemplo n.º 9
0
def folder_dir( folder_name ):
   global FOLDERS_DIR
   
   return storage.volume_path( folder_dir_atroot(folder_name) )
Exemplo n.º 10
0
def make_key_volume_path( name ):
   global STORAGE_DIR
   
   # used for loading the private key from the Volume
   return storage.volume_path( STORAGE_DIR, name )