add encryption/decryption API for preloaded web app
authorjc815.lee <jc815.lee@samsung.com>
Thu, 23 May 2013 07:22:41 +0000 (16:22 +0900)
committerjc815.lee <jc815.lee@samsung.com>
Thu, 23 May 2013 07:22:58 +0000 (16:22 +0900)
Change-Id: If9d4daec3968d7e7bf204d25a32ae58ccf9e3090
Signed-off-by: jc815.lee <jc815.lee@samsung.com>
client/include/ss_client_intf.h
client/src/ss_client_intf.c
client/src/ss_manager.c
include/ss_manager.h

index 142958b..88a54ea 100755 (executable)
@@ -71,3 +71,5 @@ int SsClientEncrypt(const char* pAppId, int idLen, const char* pBuffer, int bufL
 
 int SsClientDecrypt(const char* pAppId, int idLen, const char* pBuffer, int bufLen, char** ppDecryptedBuffer, int* pDecryptedBufLen);
 
+int SsClientEncryptPreloadedApplication(const char* pBuffer, int bufLen, char** ppEncryptedBuffer, int* pEncryptedBufLen);
+int SsClientDecryptPreloadedApplication(const char* pBuffer, int bufLen, char** ppDecryptedBuffer, int* pEncryptedBufLen);
index f3c38fd..7eb6314 100755 (executable)
@@ -535,3 +535,53 @@ Error:
                free(pDuk);
        return result;
 }
+
+int SsClientEncryptPreloadedApplication(const char* pBuffer, int bufLen, char** ppEncryptedBuffer, int* pEncryptedBufLen)
+{
+       int result = 0;
+       char duk[36] = {0,};
+       
+       if(!pBuffer || bufLen ==0)
+       {
+               SLOGE("Parameter error");
+               result  = SS_PARAM_ERROR;
+               goto Final;
+       }
+
+       if(DoCipher(pBuffer, bufLen, ppEncryptedBuffer, pEncryptedBufLen, duk, 1) != 1)
+       {
+               SLOGE("failed to decrypt data");
+               result  = SS_ENCRYPTION_ERROR;
+               goto Final;
+       }
+       
+       result = 1;
+
+Final:
+       return result;
+}
+
+int SsClientDecryptPreloadedApplication(const char* pBuffer, int bufLen, char** ppDecryptedBuffer, int* pDecryptedBufLen)
+{
+       int result = 0;
+       char duk[36] = {0,};
+       
+       if(!pBuffer || bufLen ==0)
+       {
+               SLOGE("Parameter error");
+               result  = SS_PARAM_ERROR;
+               goto Final;
+       }
+
+       if(DoCipher(pBuffer, bufLen, ppDecryptedBuffer, pDecryptedBufLen, duk, 0) != 1)
+       {
+               SLOGE("failed to decrypt data");
+               result  = SS_DECRYPTION_ERROR;
+               goto Final;
+       }
+       
+       result = 1;
+
+Final:
+       return result;
+}
index 9dffc38..2edda6f 100755 (executable)
@@ -264,3 +264,53 @@ int ssm_decrypt(const char* pAppId, int idLen, const char* pBuffer, int bufLen,
 Error:
        return -(ret);
 }
+
+SS_API
+int ssm_encrypt_preloaded_application(const char* pBuffer, int bufLen, char** ppEncryptedBuffer, int* pEncryptedBufLen)
+{
+       int ret = 0;
+       
+       if(!pBuffer || bufLen ==0)
+       {
+               SLOGE("Parameter error.\n");
+               ret = SS_PARAM_ERROR;
+               goto Error;
+       }
+
+       ret = SsClientEncryptPreloadedApplication(pBuffer, bufLen, ppEncryptedBuffer, pEncryptedBufLen);
+       if(ret == 1)    // success
+       {
+               SLOGI("Application decryption succeeded.\n");
+               return 0;
+       }
+       else    // fail
+               SLOGE("Application decryption failed.\n");
+
+Error:
+       return -(ret);
+}
+
+SS_API
+int ssm_decrypt_preloaded_application(const char* pBuffer, int bufLen, char** ppDecryptedBuffer, int* pDecryptedBufLen)
+{
+       int ret = 0;
+
+       if(!pBuffer || bufLen ==0)
+       {
+               SLOGE("Parameter error.\n");
+               ret = SS_PARAM_ERROR;
+               goto Error;
+       }
+
+       ret = SsClientDecryptPreloadedApplication(pBuffer, bufLen, ppDecryptedBuffer, pDecryptedBufLen);
+       if(ret == 1)    // success
+       {
+               SLOGI("Application decryption succeeded.\n");
+               return 0;
+       }
+       else    // fail
+               SLOGE("Application decryption failed.\n");
+
+Error:
+       return -(ret);
+}
index 1885c74..f9e277c 100755 (executable)
@@ -393,6 +393,10 @@ int ssm_delete_file(const char* pFilePath, ssm_flag flag, const char* group_id);
 int ssm_encrypt(const char* pAppId, int idLen, const char* pBuffer, int bufLen, char** ppEncryptedBuffer, int* pEncryptedBufLen);
 int ssm_decrypt(const char* pAppId, int idLen, const char* pBuffer, int bufLen, char** ppDecryptedBuffer, int* pDecryptedBufLen);
 
+int ssm_encrypt_preloaded_application(const char* pBuffer, int bufLen, char** ppEncryptedBuffer, int* pEncryptedBufLen);
+int ssm_decrypt_preloaded_application(const char* pBuffer, int bufLen, char** ppDecryptedBuffer, int* pDecryptedBufLen); 
+
+
 #ifdef __cplusplus
 }
 #endif