Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
aerospike
as_password.h
Go to the documentation of this file.
1
/*
2
* Copyright 2008-2017 Aerospike, Inc.
3
*
4
* Portions may be licensed to Aerospike, Inc. under one or more contributor
5
* license agreements.
6
*
7
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
8
* use this file except in compliance with the License. You may obtain a copy of
9
* the License at http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
* License for the specific language governing permissions and limitations under
15
* the License.
16
*/
17
#pragma once
18
19
#include <string.h>
20
#include "citrusleaf/cf_types.h"
21
22
#ifdef __cplusplus
23
extern
"C"
{
24
#endif
25
26
/**
27
* The user name size including null byte.
28
*/
29
#define AS_USER_SIZE 64
30
31
/**
32
* Size of hash buffer including null byte, padded to 8 byte boundary.
33
*/
34
#define AS_PASSWORD_HASH_SIZE 64
35
36
/**
37
* Generate random salt value.
38
* Return true if salt was generated.
39
*/
40
bool
41
as_password_gen_salt
(
char
* salt);
42
43
/**
44
* Create bcrypt hash of password.
45
* Return true if hash was generated.
46
*/
47
bool
48
as_password_gen_hash
(
const
char
* password,
const
char
* salt,
char
* hash);
49
50
/**
51
* Create bcrypt hash of password with constant salt.
52
* Return true if hash was generated.
53
*/
54
bool
55
as_password_gen_constant_hash
(
const
char
* password,
char
* hash);
56
57
/**
58
* If the input password is not hashed, convert to bcrypt hashed password.
59
* Return true if hash was successful.
60
*/
61
bool
62
as_password_get_constant_hash
(
const
char
* password,
char
* hash);
63
64
/**
65
* Prompt for input password from command line if input password is empty.
66
* If the input password is not hashed, convert to bcrypt hashed password.
67
* Return true if hash was successful.
68
*/
69
bool
70
as_password_prompt_hash
(
const
char
* password,
char
* hash);
71
72
/**
73
* Verify password hash. Hash length should always be 60.
74
* Return true if hashes are equal.
75
*/
76
static
inline
bool
77
as_password_verify
(
const
char
* hash1,
const
char
* hash2) {
78
return
! memcmp(hash1, hash2, 60);
79
}
80
81
#ifdef __cplusplus
82
}
// end extern "C"
83
#endif