blob: 9a9bb2e706ecbff4b392c695358574f9a6be07e1 [file] [log] [blame]
Joel Galensonca0efb12020-10-01 14:32:30 -07001/*
2 * Copyright (C) 2020 The Android Open Source 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 __CRYPTO_H__
18#define __CRYPTO_H__
19
20#include <stdbool.h>
21#include <stdint.h>
22#include <stddef.h>
23
24extern "C" {
25 bool AES_gcm_encrypt(const uint8_t* in, uint8_t* out, size_t len,
26 const uint8_t* key, size_t key_size, const uint8_t* iv, uint8_t* tag);
27 bool AES_gcm_decrypt(const uint8_t* in, uint8_t* out, size_t len,
28 const uint8_t* key, size_t key_size, const uint8_t* iv,
29 const uint8_t* tag);
30
31 // Copied from system/security/keystore/keymaster_enforcement.h.
32 typedef uint64_t km_id_t;
33
34 bool CreateKeyId(const uint8_t* key_blob, size_t len, km_id_t* out_id);
35
36 void generateKeyFromPassword(uint8_t* key, size_t key_len, const char* pw,
37 size_t pw_len, uint8_t* salt);
38}
39
40#endif // __CRYPTO_H__