blob: 73880b1ba91223b7c44d2813255f5a9936a62fcb [file] [log] [blame]
Ethan Yonkerbd7492d2016-12-07 13:55:01 -06001/*
2 * Copyright (C) 2016 Team Win Recovery Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef __HASH_PASSWORD_H
18#define __HASH_PASSWORD_H
19
20#include <string>
21
Ethan Yonkerfefe5912017-09-30 22:22:13 -050022#define FBE_PERSONALIZATION "Android FBE credential hash"
23#define PERSONALISATION_WEAVER_KEY "weaver-key"
24#define PERSONALISATION_WEAVER_PASSWORD "weaver-pwd"
25#define PERSONALISATION_APPLICATION_ID "application-id"
26#define PERSONALIZATION_FBE_KEY "fbe-key"
Ethan Yonkere131bec2017-12-15 23:48:02 -060027#define PERSONALIZATION_USER_GK_AUTH "user-gk-authentication"
28#define PERSONALISATION_SECDISCARDABLE "secdiscardable-transform"
Peter Caiea1764c2019-05-23 21:44:35 +080029#define PERSONALISATION_CONTEXT "android-synthetic-password-personalization-context"
Ethan Yonkerfefe5912017-09-30 22:22:13 -050030
31void* PersonalizedHashBinary(const char* prefix, const char* key, const size_t key_size);
32
33std::string PersonalizedHash(const char* prefix, const char* key, const size_t key_size);
34std::string PersonalizedHash(const char* prefix, const std::string& Password);
Peter Caiea1764c2019-05-23 21:44:35 +080035std::string PersonalizedHashSP800(const char* label, const char* context, const char* key, const size_t key_size);
Ethan Yonkerbd7492d2016-12-07 13:55:01 -060036std::string HashPassword(const std::string& Password);
37
Peter Caiea1764c2019-05-23 21:44:35 +080038template <class T>
39void endianswap(T *objp) {
40 unsigned char *memp = reinterpret_cast<unsigned char*>(objp);
41 std::reverse(memp, memp + sizeof(T));
42}
43
Ethan Yonkerbd7492d2016-12-07 13:55:01 -060044#endif