PageRenderTime 16ms CodeModel.GetById 13ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/drm/libdrmframework/plugins/forward-lock/internal-format/common/FwdLockGlue.h

http://github.com/CyanogenMod/android_frameworks_base
C++ Header | 85 lines | 20 code | 9 blank | 56 comment | 0 complexity | 8a4dda8d894eb4d2ca074220ac5032da MD5 | raw file
Possible License(s): LGPL-2.1, MPL-2.0-no-copyleft-exception, CC0-1.0, BitTorrent-1.0, BSD-3-Clause
 1/*
 2 * Copyright (C) 2010 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 __FWDLOCKGLUE_H__
18#define __FWDLOCKGLUE_H__
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24/**
25 * Generates the specified number of cryptographically secure random bytes.
26 *
27 * @param[out] pBuffer A reference to the buffer that should receive the random data.
28 * @param[in] numBytes The number of random bytes to generate.
29 *
30 * @return A Boolean value indicating whether the operation was successful.
31 */
32int FwdLockGlue_GetRandomNumber(void *pBuffer, size_t numBytes);
33
34/**
35 * Performs initialization of the key-encryption key. Should be called once during startup to
36 * facilitate encryption and decryption of session keys.
37 *
38 * @return A Boolean value indicating whether the operation was successful.
39 */
40int FwdLockGlue_InitializeKeyEncryption();
41
42/**
43 * Returns the length of the encrypted key, given the length of the plaintext key.
44 *
45 * @param[in] plaintextKeyLength The length in bytes of the plaintext key.
46 *
47 * @return The length in bytes of the encrypted key.
48 */
49size_t FwdLockGlue_GetEncryptedKeyLength(size_t plaintextKeyLength);
50
51/**
52 * Encrypts the given session key using a key-encryption key unique to this device.
53 *
54 * @param[in] pPlaintextKey A reference to the buffer containing the plaintext key.
55 * @param[in] plaintextKeyLength The length in bytes of the plaintext key.
56 * @param[out] pEncryptedKey A reference to the buffer containing the encrypted key.
57 * @param[in] encryptedKeyLength The length in bytes of the encrypted key.
58 *
59 * @return A Boolean value indicating whether the operation was successful.
60 */
61int FwdLockGlue_EncryptKey(const void *pPlaintextKey,
62                           size_t plaintextKeyLength,
63                           void *pEncryptedKey,
64                           size_t encryptedKeyLength);
65
66/**
67 * Decrypts the given session key using a key-encryption key unique to this device.
68 *
69 * @param[in] pEncryptedKey A reference to the buffer containing the encrypted key.
70 * @param[in] encryptedKeyLength The length in bytes of the encrypted key.
71 * @param[out] pDecryptedKey A reference to the buffer containing the decrypted key.
72 * @param[in] decryptedKeyLength The length in bytes of the decrypted key.
73 *
74 * @return A Boolean value indicating whether the operation was successful.
75 */
76int FwdLockGlue_DecryptKey(const void *pEncryptedKey,
77                           size_t encryptedKeyLength,
78                           void *pDecryptedKey,
79                           size_t decryptedKeyLength);
80
81#ifdef __cplusplus
82}
83#endif
84
85#endif // __FWDLOCKGLUE_H__