client module

Secure client implementation

This is a skeleton file for you to build your secure file store client.

Fill in the methods for the class Client per the project specification.

You may add additional functions and classes as desired, as long as your Client class conforms to the specification. Be sure to test against the included functionality tests.

class client.Client(storage_server, public_key_server, crypto_object, username)

Bases: base_client.BaseClient

download(name)

Returns the last value stored at name by the owner or anyone with whom it has been shared, or None if the file does not exist.

A secure client implementation of this method should meet all of the required properties listed in the project specification.

Parameters:name (str) – The name of the file. You can assume file names are alphanumeric (that is, they match the regex [A-Za-z0-9]+).
Returns:A string, the last value stored at name, or None if the file does not exist.
receive_share(from_username, newname, message)

Receive a share message generated by the share method of another client with username from_username. Once this is done, the client calling this method should now be able to access the shared file under the name newname.

A secure client implementation of this method should meet all of the required properties listed in the project specification.

share and receive_share work together as follows:

msg = alice.share("bob", filename)
bob.receive_share("alice", msg, newfilename)
Parameters:
  • from_username (str) – The username of the sharing client.
  • newname (str) – The new filename under which this client will access the file.
  • message (str) – The message generated by the sharing client’s share method.
revoke(user, name)

Revokes user’s access to the file name.

user should not be able to observe new updated to name, and should not be able update it.

Anyone with whom user shared this file should also be revoked.

You may not send any messages during revocation.

A secure client implementation of this method should meet all of the required properties listed in the project specification.

Parameters:
  • user (str) – The username of the user whose access will be revoked
  • name (str) – The name of the file
share(user, name)

Share a file name with user.

A secure client implementation of this method should meet all of the required properties listed in the project specification.

share and receive_share work together as follows:

msg = alice.share("bob", filename)
bob.receive_share("alice", msg, newfilename)
Parameters:
  • user (str) – The username of the user you are sharing with.
  • name (str) – The name of the file you are sharing with user.
Returns:

A string, containing the message to give to user through an out-of-band channel that will let them access the file.

upload(name, value)

Places the string value at name so that future calls to download for name return value.

A secure client implementation of this method should meet all of the required properties listed in the project specification.

Parameters:
  • name (str) – The name of the file. You can assume file names are alphanumeric (that is, they match the regex [A-Za-z0-9]+).
  • value (str) – The value to upload.