aisl-sdk/components/passwd.h

58 lines
1.2 KiB
C
Raw Normal View History

2019-07-17 22:50:08 +02:00
/******************************************************************************
*
* Copyright (c) 2017-2019 by Löwenware Ltd
* Please, refer LICENSE file for legal information
*
******************************************************************************/
/**
* @file passwd.h
* @author Ilja Kartašov <ik@lowenware.com>
* @brief
*
* @see https://lowenware.com/
*/
#ifndef AX_PASSWD_H_0DE6E254_27E2_4DEF_A88A_4EE84D5C00DA
#define AX_PASSWD_H_0DE6E254_27E2_4DEF_A88A_4EE84D5C00DA
#include <stdint.h>
#include <stdbool.h>
#include <openssl/sha.h>
#define AX_PASSWD_TOKENS 4
#define AX_PASSWD_SALT_SIZE 16
#define AX_PASSWD_HASH_SIZE SHA1_DIGEST_LENGTH
struct ax_passwd {
uint32_t uid;
uint32_t gid;
char *name;
char salt[AX_PASSWD_SALT_SIZE];
char hash[AX_PASSWD_HASH_SIZE];
};
typedef struct ax_passwd * AxPasswd;
int
ax_passwd_import(struct ax_passwd **p_out, const char *file);
int
ax_passwd_export(const struct ax_passwd *in, int size, const char *file);
int
ax_passwd_verify(const struct ax_passwd *passwd, const char *password);
int
ax_passwd_set_hash(struct ax_passwd *out, const char *password);
int
ax_passwd_free(struct ax_passwd **p_out, int size);
#endif /* !AX_PASSWD_H */