blob: f36f6ea98e5a74ecdf946e5f9a8ee12c70204ce7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __FWDLOCKGLUE_H__
#define __FWDLOCKGLUE_H__
#ifdef __cplusplus
extern "C" {
#endif
/**
* Generates the specified number of cryptographically secure random bytes.
*
* @param[out] pBuffer A reference to the buffer that should receive the random data.
* @param[in] numBytes The number of random bytes to generate.
*
* @return A Boolean value indicating whether the operation was successful.
*/
int FwdLockGlue_GetRandomNumber(void *pBuffer, size_t numBytes);
/**
* Performs initialization of the key-encryption key. Should be called once during startup to
* facilitate encryption and decryption of session keys.
*
* @return A Boolean value indicating whether the operation was successful.
*/
int FwdLockGlue_InitializeKeyEncryption();
/**
* Returns the length of the encrypted key, given the length of the plaintext key.
*
* @param[in] plaintextKeyLength The length in bytes of the plaintext key.
*
* @return The length in bytes of the encrypted key.
*/
size_t FwdLockGlue_GetEncryptedKeyLength(size_t plaintextKeyLength);
/**
* Encrypts the given session key using a key-encryption key unique to this device.
*
* @param[in] pPlaintextKey A reference to the buffer containing the plaintext key.
* @param[in] plaintextKeyLength The length in bytes of the plaintext key.
* @param[out] pEncryptedKey A reference to the buffer containing the encrypted key.
* @param[in] encryptedKeyLength The length in bytes of the encrypted key.
*
* @return A Boolean value indicating whether the operation was successful.
*/
int FwdLockGlue_EncryptKey(const void *pPlaintextKey,
size_t plaintextKeyLength,
void *pEncryptedKey,
size_t encryptedKeyLength);
/**
* Decrypts the given session key using a key-encryption key unique to this device.
*
* @param[in] pEncryptedKey A reference to the buffer containing the encrypted key.
* @param[in] encryptedKeyLength The length in bytes of the encrypted key.
* @param[out] pDecryptedKey A reference to the buffer containing the decrypted key.
* @param[in] decryptedKeyLength The length in bytes of the decrypted key.
*
* @return A Boolean value indicating whether the operation was successful.
*/
int FwdLockGlue_DecryptKey(const void *pEncryptedKey,
size_t encryptedKeyLength,
void *pDecryptedKey,
size_t decryptedKeyLength);
#ifdef __cplusplus
}
#endif
#endif // __FWDLOCKGLUE_H__
|