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
28 //#ifdef OPENSSL_NO_ENGINE
29 //#error Do not use define <OPENSSL_NO_ENGINE>
31 #include <openssl/engine.h>
36 SEC_CRYPTO_CIPHER_NULL = 0,
37 SEC_CRYPTO_CIPHER_AES_CBC_128,
38 SEC_CRYPTO_CIPHER_SEED_CBC,
39 SEC_CRYPTO_CIPHER_AES_CBC_192,
40 SEC_CRYPTO_CIPHER_AES_CBC_256,
41 SEC_CRYPTO_CIPHER_AES_CTR_128,
42 SEC_CRYPTO_CIPHER_AES_ECB_128,
43 SEC_CRYPTO_CIPHER_AES_ECB_192,
44 SEC_CRYPTO_CIPHER_AES_ECB_256
50 SEC_CRYPTO_ERROR_1, //algorithm error
51 SEC_CRYPTO_ERROR_2, //init error
52 SEC_CRYPTO_ERROR_3, //update error
53 SEC_CRYPTO_ERROR_4, //final error
54 SEC_CRYPTO_ERROR_5, //wrong param
55 SEC_CRYPTO_ERROR_6, //Memory alloc
56 SEC_CRYPTO_ERROR_7, //Internal error
61 typedef enum {false, true} bool;
78 #define ULONG unsigned int
81 #define UINT8 unsigned char
84 #define UINT32 unsigned int
88 //#define SEC_CRYPTO_ENCRYPT 1
89 //#define SEC_CRYPTO_DECRYPT 0
90 #define SEC_DUK_SIZE 16
91 //#define SEC_CRYPTO_KEY_LENGTH 16
92 //#define SEC_CRYPTP_ARR_LENGTH 1024
93 #define SEC_FRAME_OSP_KEY "uniqueKey"
94 //#define SHA1_DIGEST_VALUE_LEN 20
95 #define SHA256_DIGEST_VALUE_LEN 32
96 //#define KDF_KEYLEN 16
98 //#define SEC_KEYMGR_FEK_SIZE 16
100 /*------ Base64 Encoding Table ------*/
101 static const char Base64EncodingTable[] = {
102 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
103 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
104 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
105 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
106 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
107 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
108 'w', 'x', 'y', 'z', '0', '1', '2', '3',
109 '4', '5', '6', '7', '8', '9', '+', '/'
113 * This function provides Device UniqueKey for crypto with Hash
114 * @return This function returns TRUE on success
115 * @param[in] uLen Length of Device UniqueKey
116 * @param[in,out] pCek Device UniqueKey(Hashed)
118 __attribute__((visibility("default")))
119 bool SecFrameGeneratePlatformUniqueKey(IN UINT32 uLen,IN OUT UINT8 *pCek);
121 __attribute__((visibility("default")))
122 char* Base64Encoding(char* pData, int size);
124 __attribute__((visibility("default")))
125 char* GetDuid(int size);
131 #endif // _SEC_CRYPTO_SVC_H