2 * libcryptsvc - device unique key
4 * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 #ifndef _SEC_CRYPTO_SVC_H
21 #define _SEC_CRYPTO_SVC_H
30 //#ifdef OPENSSL_NO_ENGINE
31 //#error Do not use define <OPENSSL_NO_ENGINE>
33 #include <openssl/engine.h>
38 SEC_CRYPTO_CIPHER_NULL = 0,
39 SEC_CRYPTO_CIPHER_AES_CBC_128,
40 SEC_CRYPTO_CIPHER_SEED_CBC,
41 SEC_CRYPTO_CIPHER_AES_CBC_192,
42 SEC_CRYPTO_CIPHER_AES_CBC_256,
43 SEC_CRYPTO_CIPHER_AES_CTR_128,
44 SEC_CRYPTO_CIPHER_AES_ECB_128,
45 SEC_CRYPTO_CIPHER_AES_ECB_192,
46 SEC_CRYPTO_CIPHER_AES_ECB_256
52 SEC_CRYPTO_ERROR_1, //algorithm error
53 SEC_CRYPTO_ERROR_2, //init error
54 SEC_CRYPTO_ERROR_3, //update error
55 SEC_CRYPTO_ERROR_4, //final error
56 SEC_CRYPTO_ERROR_5, //wrong param
57 SEC_CRYPTO_ERROR_6, //Memory alloc
58 SEC_CRYPTO_ERROR_7, //Internal error
76 #define ULONG unsigned int
79 #define UINT8 unsigned char
82 #define UINT32 unsigned int
86 //#define SEC_CRYPTO_ENCRYPT 1
87 //#define SEC_CRYPTO_DECRYPT 0
88 #define SEC_DUK_SIZE 16
89 //#define SEC_CRYPTO_KEY_LENGTH 16
90 //#define SEC_CRYPTP_ARR_LENGTH 1024
91 #define SEC_FRAME_OSP_KEY "uniqueKey"
92 //#define SHA1_DIGEST_VALUE_LEN 20
93 #define SHA256_DIGEST_VALUE_LEN 32
94 //#define KDF_KEYLEN 16
96 //#define SEC_KEYMGR_FEK_SIZE 16
98 /*------ Base64 Encoding Table ------*/
99 static const char Base64EncodingTable[] = {
100 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
101 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
102 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
103 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
104 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
105 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
106 'w', 'x', 'y', 'z', '0', '1', '2', '3',
107 '4', '5', '6', '7', '8', '9', '+', '/'
111 * This function provides Device UniqueKey for crypto with Hash
112 * @return This function returns TRUE on success
113 * @param[in] uLen Length of Device UniqueKey
114 * @param[in,out] pCek Device UniqueKey(Hashed)
116 __attribute__((visibility("default")))
117 bool SecFrameGeneratePlatformUniqueKey(IN UINT32 uLen,IN OUT UINT8 *pCek);
119 __attribute__((visibility("default")))
120 char* Base64Encoding(char* pData, int size);
122 __attribute__((visibility("default")))
123 char* GetDuid(int size);
129 #endif // _SEC_CRYPTO_SVC_H