2 * Copyright (c) 2000-2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Flora License, Version 1.1 (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
8 * http://floralicense.org/license/
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.
19 * @file DTapps2HMAC.cpp
20 * @brief This file includes functions relating to HMAC.
21 * @author Harsha Shekar (h.shekar@samsung.com)
24 #include <openssl/evp.h>
25 #include <openssl/hmac.h>
27 #include "DTapps2HMAC.h"
29 void DTappsCalHMACSHA1(unsigned char* key,int key_len,unsigned char* msg,size_t msglen,unsigned char *md,unsigned int *md_len)
31 HMAC(EVP_sha1(),(void*)key,key_len,msg,msglen,md,md_len);
34 int DTappsGetDeviceKey(unsigned char **pDevKey,unsigned int *DevKeyLen)
37 char passwd[30] = {0,};
38 unsigned int LocalKeyLen = 16;
40 char* pDuk = GetDeviceUniqueKey(passwd, strlen(passwd), 16);
42 if (!pDuk || !pDevKey || !DevKeyLen)
44 DRM_TAPPS_EXCEPTION("pDevKey = %p, DevKeyLen = %p",pDevKey,DevKeyLen);
48 DRM_TAPPS_LOG("LocalKeyLen = %u", LocalKeyLen);
50 *pDevKey = (unsigned char*)DTAPPS_MALLOC(LocalKeyLen + 1);
54 DRM_TAPPS_EXCEPTION("Malloc Failed");
59 DTAPPS_MEMSET(*pDevKey, 0x0, LocalKeyLen + 1);
60 DTAPPS_MEMCPY(*pDevKey, pDuk, LocalKeyLen);
62 *DevKeyLen = LocalKeyLen;
68 DRM_TAPPS_LOG("SUCCESS:ret=%d", ret);
70 DRM_TAPPS_EXCEPTION("FAILED:ret=%d", ret);
77 void DTappsFreeDeviceKey(unsigned char **pDevKey)
81 DRM_TAPPS_EXCEPTION("pDevKey = %p", pDevKey);
86 DTAPPS_FREE(*pDevKey);