Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 114 additions & 2 deletions include/libpolypasswordhasher.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ typedef enum{
PPH_CONTEXT_IS_LOCKED,
PPH_VALUE_OUT_OF_RANGE,
PPH_SECRET_IS_INVALID,
PPH_CANT_FIND_USER,
PPH_CANT_DELETE,


// system or user is being brilliant.
PPH_FILE_ERR,
Expand Down Expand Up @@ -692,12 +695,121 @@ pph_context *pph_reload_context(const unsigned char *filename);
int PHS(void *out, size_t outlen, const void *in, size_t inlen,
const void* salt, size_t saltlen, int tcost, int mcost);


/*******************************************************************
* NAME : pph_delete_account
*
* DESCRIPTION : Gaven the context and a username, the fuction will look into the
* context and delete the user data permanently. If deleting an
* account will cause the share distributed be less than threshold,
* then the function will return an error and won't delete.
* If the given user doesn't exist, it will return an error.
*
* INPUTS :
* PARAMETERS:
* pph_context *ctxt: This is the context in which the account will be deleted
*
* const unit8 *username: This is the desirerd user to be deleted
*
* unsigned int username_length: The length of the username
*
* OUTPUTS :
* PARAMETERS:
* None
*
* GLOBALS :
* None
*
* RETURN :
* Type: int PPH_ERROR
*
* Values: When:
* PPH_ERROR_OK The desired user has been deleted
*
* PPH_BAD_PTR One of the fields is unallocated
*
* PPH_CANT_FIND_USER The username doesn't exist
*
* PPH_USERNAME_IS_TOO_LONG The username won't fit in the buffer
*
* PPH_CANT_DELETE Due to inefficient amount of shares available
* after deletion, or other reasons, PPH can't
* delete account currently.
*
* PROCESS :
* 1) Sanitize data and report errors.
* 2) Go through the list to try to find the user, meanwhile, counting the shares.
* 3) If didn't find the user, or run into a situation we can't delete the account, report error.
* 4) If not, delete the user.
* 5) Return.
*
* CHANGES :
* This function is added in July 2016
*/

PPH_ERROR pph_delete_account(pph_context *ctx, const uint8 *username,
unsigned int username_length);

// helper functions //////////////////////////

/*******************************************************************
* NAME : pph_change_password
*
* DESCRIPTION : Gaven the context a username and the new password, the fuction will look
* into the context and change the user's password. The application is responsible
* to make sure that the user is authenticated before having the ability to
* change password.
*
* INPUTS :
* PARAMETERS:
* pph_context *ctxt: This is the context in which the account will change password
*
* const unit8 *username: This is the desirerd user to be deleted
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

desired user whose password needs to be changed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the catch!

*
* unsigned int username_length: The length of the username
*
* const unit8 *new_password: The new password as
*
* unsigned int new_password_length: The length of the new password
*
* OUTPUTS :
* PARAMETERS:
* None
*
* GLOBALS :
* None
*
* RETURN :
* Type: int PPH_ERROR
*
* Values: When:
* PPH_ERROR_OK The password is changed for user successfully
*
* PPH_BAD_PTR One of the fields is unallocated
*
* PPH_ERROR_UNKNOWN something unexpected happens
*
* PPH_CANT_FIND_USER The username doesn't exist
*
* PPH_USERNAME_IS_TOO_LONG The username_length is larger than MAX_USERNAME_LENGTH
*
* PPH_PASSWORD_IS_TOO_LONG The new_password_length is larger than MAX_PASSWORD_LENGTH
*
* PPH_CONTEXT_IS_LOCKED Can't change password for protector account
* when the secret is unavailable
* PROCESS :
* 1) Sanitize data and report errors.
* 2) Go through the list to find the user, if not, report an error.
* 3) Change the password for diffrent type of users: protector, shielded and bootstrap
* 4) Return
*
* CHANGES :
* This function is added in July 2016
*/

PPH_ERROR pph_change_password (pph_context *ctx, const uint8 *username, unsigned int username_length,
uint8 *new_password, unsigned int new_password_length);


// helper functions //////////////////////////
// used to generate a random secret and add its hash
uint8 *generate_pph_secret( uint8 *integrity_check);

Expand Down
Loading