Main Page
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-2015 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
#ifdef __cplusplus
20
extern
"C"
{
21
#endif
22
23
#include "citrusleaf/cf_types.h"
24
25
/**
26
* The user name size including null byte.
27
*/
28
#define AS_USER_SIZE 64
29
30
/**
31
* Size of hash buffer including null byte, padded to 8 byte boundary.
32
*/
33
#define AS_PASSWORD_HASH_SIZE 64
34
35
/**
36
* Generate random salt value.
37
* Return true if salt was generated.
38
*/
39
bool
40
as_password_gen_salt
(
char
* salt);
41
42
/**
43
* Create bcrypt hash of password.
44
* Return true if hash was generated.
45
*/
46
bool
47
as_password_gen_hash
(
const
char
* password,
const
char
* salt,
char
* hash);
48
49
/**
50
* Create bcrypt hash of password with constant salt.
51
* Return true if hash was generated.
52
*/
53
bool
54
as_password_gen_constant_hash
(
const
char
* password,
char
* hash);
55
56
/**
57
* If the input password is not hashed, convert to bcrypt hashed password.
58
* Return true if hash was successful.
59
*/
60
bool
61
as_password_get_constant_hash
(
const
char
* password,
char
* hash);
62
63
/**
64
* Prompt for input password from command line if input password is empty.
65
* If the input password is not hashed, convert to bcrypt hashed password.
66
* Return true if hash was successful.
67
*/
68
bool
69
as_password_prompt_hash
(
const
char
* password,
char
* hash);
70
71
/**
72
* Verify password hash. Hash length should always be 60.
73
* Return true if hashes are equal.
74
*/
75
static
inline
bool
76
as_password_verify
(
const
char
* hash1,
const
char
* hash2) {
77
return
! memcmp(hash1, hash2, 60);
78
}
79
80
#ifdef __cplusplus
81
}
// end extern "C"
82
#endif