2017-07-06 11:41:06 +00:00
|
|
|
#ifndef SHAPITO_PASSWORD_H
|
|
|
|
#define SHAPITO_PASSWORD_H
|
2017-01-25 08:55:04 +00:00
|
|
|
|
|
|
|
/*
|
2017-07-06 11:44:19 +00:00
|
|
|
* Shapito.
|
2017-01-25 08:55:04 +00:00
|
|
|
*
|
|
|
|
* Protocol-level PostgreSQL client library.
|
|
|
|
*/
|
|
|
|
|
2017-07-06 12:00:13 +00:00
|
|
|
typedef struct shapito_password shapito_password_t;
|
2017-01-25 08:55:04 +00:00
|
|
|
|
2017-07-06 12:00:13 +00:00
|
|
|
struct shapito_password
|
2017-06-28 12:19:24 +00:00
|
|
|
{
|
2017-01-25 08:55:04 +00:00
|
|
|
char *password;
|
|
|
|
int password_len;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline void
|
2017-07-06 12:00:13 +00:00
|
|
|
shapito_password_init(shapito_password_t *pw)
|
2017-01-25 08:55:04 +00:00
|
|
|
{
|
|
|
|
pw->password = NULL;
|
|
|
|
pw->password_len = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2017-07-06 12:00:13 +00:00
|
|
|
shapito_password_free(shapito_password_t *pw)
|
2017-01-25 08:55:04 +00:00
|
|
|
{
|
|
|
|
if (pw->password)
|
|
|
|
free(pw->password);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
2017-07-06 12:00:13 +00:00
|
|
|
shapito_password_compare(shapito_password_t *a, shapito_password_t *b)
|
2017-01-25 08:55:04 +00:00
|
|
|
{
|
|
|
|
return (a->password_len == b->password_len) &&
|
|
|
|
(memcmp(a->password, b->password, a->password_len) == 0);
|
|
|
|
}
|
|
|
|
|
2017-07-06 12:00:13 +00:00
|
|
|
uint32_t shapito_password_salt(shapito_key_t*);
|
|
|
|
int shapito_password_md5(shapito_password_t*, char*, int, char*, int,
|
|
|
|
char[4]);
|
2017-01-25 10:17:34 +00:00
|
|
|
|
2017-07-06 11:41:06 +00:00
|
|
|
#endif /* SHAPITO_PASSWORD_H */
|