From 6cf8de4970660cd0ae40fa00fe49c36cb75aa2ef Mon Sep 17 00:00:00 2001 From: Kidong Kim Date: Wed, 22 Aug 2012 13:44:01 +0900 Subject: [PATCH] source code open - secure-storage --- LICENSE | 4 +- TC/scenario1/utc_SecurityFW_ssm_delete_file_func.c | 2 +- TC/scenario1/utc_SecurityFW_ssm_getinfo_func.c | 2 +- TC/scenario1/utc_SecurityFW_ssm_read_func.c | 2 +- .../utc_SecurityFW_ssm_write_buffer_func.c | 2 +- TC/scenario1/utc_SecurityFW_ssm_write_file_func.c | 2 +- client/include/ss_client_intf.h | 2 +- client/include/ss_client_ipc.h | 2 +- client/src/ss_client_intf.c | 2 +- client/src/ss_client_ipc.c | 2 +- client/src/ss_manager.c | 2 +- debian/changelog | 393 ++++++++++++++++++++- include/secure_storage.h | 2 +- include/ss_manager.h | 2 +- packaging/secure-storage.spec | 5 +- server/include/ss_server_ipc.h | 2 +- server/include/ss_server_main.h | 2 +- server/src/ss_server_ipc.c | 18 +- server/src/ss_server_main.c | 82 +++-- 19 files changed, 480 insertions(+), 50 deletions(-) diff --git a/LICENSE b/LICENSE index 9f19478..a795f06 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. +Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. Apache License Version 2.0, January 2004 @@ -188,7 +188,7 @@ Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved + Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/TC/scenario1/utc_SecurityFW_ssm_delete_file_func.c b/TC/scenario1/utc_SecurityFW_ssm_delete_file_func.c index 88f782c..356afd2 100755 --- a/TC/scenario1/utc_SecurityFW_ssm_delete_file_func.c +++ b/TC/scenario1/utc_SecurityFW_ssm_delete_file_func.c @@ -1,7 +1,7 @@ /* * secure storage * - * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd All Rights Reserved * * Contact: Kidong Kim * diff --git a/TC/scenario1/utc_SecurityFW_ssm_getinfo_func.c b/TC/scenario1/utc_SecurityFW_ssm_getinfo_func.c index fb6064f..170d182 100755 --- a/TC/scenario1/utc_SecurityFW_ssm_getinfo_func.c +++ b/TC/scenario1/utc_SecurityFW_ssm_getinfo_func.c @@ -1,7 +1,7 @@ /* * secure storage * - * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd All Rights Reserved * * Contact: Kidong Kim * diff --git a/TC/scenario1/utc_SecurityFW_ssm_read_func.c b/TC/scenario1/utc_SecurityFW_ssm_read_func.c index e976f06..ab80e73 100755 --- a/TC/scenario1/utc_SecurityFW_ssm_read_func.c +++ b/TC/scenario1/utc_SecurityFW_ssm_read_func.c @@ -1,7 +1,7 @@ /* * secure storage * - * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd All Rights Reserved * * Contact: Kidong Kim * diff --git a/TC/scenario1/utc_SecurityFW_ssm_write_buffer_func.c b/TC/scenario1/utc_SecurityFW_ssm_write_buffer_func.c index 50faf2c..badfa97 100755 --- a/TC/scenario1/utc_SecurityFW_ssm_write_buffer_func.c +++ b/TC/scenario1/utc_SecurityFW_ssm_write_buffer_func.c @@ -1,7 +1,7 @@ /* * secure storage * - * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd All Rights Reserved * * Contact: Kidong Kim * diff --git a/TC/scenario1/utc_SecurityFW_ssm_write_file_func.c b/TC/scenario1/utc_SecurityFW_ssm_write_file_func.c index a502992..0ee2795 100755 --- a/TC/scenario1/utc_SecurityFW_ssm_write_file_func.c +++ b/TC/scenario1/utc_SecurityFW_ssm_write_file_func.c @@ -1,7 +1,7 @@ /* * secure storage * - * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd All Rights Reserved * * Contact: Kidong Kim * diff --git a/client/include/ss_client_intf.h b/client/include/ss_client_intf.h index 49255ea..21ff92b 100644 --- a/client/include/ss_client_intf.h +++ b/client/include/ss_client_intf.h @@ -1,7 +1,7 @@ /* * secure storage * - * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd All Rights Reserved * * Contact: Kidong Kim * diff --git a/client/include/ss_client_ipc.h b/client/include/ss_client_ipc.h index 036d49b..eb2f777 100644 --- a/client/include/ss_client_ipc.h +++ b/client/include/ss_client_ipc.h @@ -1,7 +1,7 @@ /* * secure storage * - * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd All Rights Reserved * * Contact: Kidong Kim * diff --git a/client/src/ss_client_intf.c b/client/src/ss_client_intf.c index 27a2282..50a01d8 100644 --- a/client/src/ss_client_intf.c +++ b/client/src/ss_client_intf.c @@ -1,7 +1,7 @@ /* * secure storage * - * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd All Rights Reserved * * Contact: Kidong Kim * diff --git a/client/src/ss_client_ipc.c b/client/src/ss_client_ipc.c index 59899e2..71cd05f 100644 --- a/client/src/ss_client_ipc.c +++ b/client/src/ss_client_ipc.c @@ -1,7 +1,7 @@ /* * secure storage * - * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd All Rights Reserved * * Contact: Kidong Kim * diff --git a/client/src/ss_manager.c b/client/src/ss_manager.c index be8bc0f..8415a6f 100644 --- a/client/src/ss_manager.c +++ b/client/src/ss_manager.c @@ -1,7 +1,7 @@ /* * secure storage * - * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd All Rights Reserved * * Contact: Kidong Kim * diff --git a/debian/changelog b/debian/changelog index 8c5920f..fac1b78 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,398 @@ +secure-storage (0.12.7-18) unstable; urgency=low + + * randomize initial vector of AES_cbc cryptographic algorithm + * Git: slp/pkgs/s/secure-storage + * Tag: secure-storage_0.12.7-18 + + -- Kidong Kim Mon, 14 May 2012 12:00:40 +0900 + +secure-storage (0.12.7-17) unstable; urgency=low + + * flush and sync encrypted file + * Git: slp/pkgs/s/secure-storage + * Tag: secure-storage_0.12.7-17 + + -- Kidong Kim Tue, 08 May 2012 17:24:23 +0900 + +secure-storage (0.12.7-16) unstable; urgency=low + + * sync encrypted file in order to prepare unexpected power down + * Git: slp/pkgs/s/secure-storage + * Tag: secure-storage_0.12.7-16 + + -- Kidong Kim Mon, 23 Apr 2012 16:55:36 +0900 + secure-storage (0.12.7-15) unstable; urgency=low * change starting order of ss-server - * Git: pkgs/s/secure-storage + * Git: slp/pkgs/s/secure-storage * Tag: secure-storage_0.12.7-15 -- Kidong Kim Thu, 19 Jan 2012 16:06:30 +0900 + +secure-storage (0.12.7-14) unstable; urgency=low + + * 11/12/20 + * - remove systemd dependency + * Git: slp/pkgs/s/secure-storage + * Tag: secure-storage_0.12.7-14 + + -- Kidong Kim Tue, 20 Dec 2011 15:03:23 +0900 + +secure-storage (0.12.7-13) unstable; urgency=low + + * 11/12/07 + * - add boiler-plate on testcases + * Git: 165.213.180.234:slp/pkgs/s/secure-storage + * Tag: secure-storage_0.12.7-13 + + -- Kidong Kim Wed, 07 Dec 2011 09:55:30 +0900 + +secure-storage (0.12.7-12) unstable; urgency=low + + * 11/12/02 + * - change license : LGPL -> apache + * Git: 165.213.180.234:slp/pkgs/s/secure-storage + * Tag: secure-storage_0.12.7-12 + + -- Kidong Kim Fri, 02 Dec 2011 17:02:00 +0900 + +secure-storage (0.12.7-11) unstable; urgency=low + + * fix install file + * Git: 165.213.180.234:slp/pkgs/s/secure-storage + * Tag: secure-storage_0.12.7-11 + + -- Kidong Kim Mon, 17 Oct 2011 13:58:06 +0900 + +secure-storage (0.12.7-10) unstable; urgency=low + + * add testcases + * Git: 165.213.180.234:slp/pkgs/s/secure-storage + * Tag: secure-storage_0.12.7-10 + + -- Kidong Kim Fri, 14 Oct 2011 14:10:04 +0900 + +secure-storage (0.12.7-9) unstable; urgency=low + + * fix boiler-plate + * Git: 165.213.180.234:slp/pkgs/s/secure-storage + * Tag: secure-storage_0.12.7-9 + + -- Kidong Kim Wed, 13 Jul 2011 10:23:26 +0900 + +secure-storage (0.12.7-8) unstable; urgency=low + + * fix strncpy problem + * Git: 165.213.180.234:slp/pkgs/s/secure-storage + * Tag: secure-storage_0.12.7-8 + + -- Kidong Kim Wed, 16 Feb 2011 10:07:00 +0900 + +secure-storage (0.12.7-7) unstable; urgency=low + + * fix prevent bugs + * Git: 165.213.180.234:slp/pkgs/s/secure-storage + * Tag: secure-storage_0.12.7-7 + + -- Kidong Kim Thu, 20 Jan 2011 16:52:02 +0900 + +secure-storage (0.12.7-6) unstable; urgency=low + + * fix double free and strtoul problem + * Git: 165.213.180.234:slp/pkgs/s/secure-storage + * Tag: secure-storage_0.12.7-6 + + -- Kidong Kim Tue, 04 Jan 2011 15:09:08 +0900 + +secure-storage (0.12.7-5) unstable; urgency=low + + * fix postinst script + * Git: 165.213.180.234:slp/pkgs/s/secure-storage + * Tag: secure-storage_0.12.7-5 + + -- Kidong Kim Wed, 15 Dec 2010 10:15:03 +0900 + +secure-storage (0.12.7-4) unstable; urgency=low + + * fix strip problem + * Git: 165.213.180.234:/git/slp/pkgs/secure-storage + * Tag: secure-storage_0.12.7-4 + + -- Kidong Kim Wed, 01 Dec 2010 10:34:18 +0900 + +secure-storage (0.12.7-3) unstable; urgency=low + + * add boilerplate in test codes + * Git: 165.213.180.234:/git/slp/pkgs/secure-storage + * Tag: secure-storage_0.12.7-3 + + -- Kidong Kim Fri, 26 Nov 2010 15:32:47 +0900 + +secure-storage (0.12.7-2) unstable; urgency=low + + * add new testcases + * Git: 165.213.180.234:/git/slp/pkgs/secure-storage + * Tag: secure-storage_0.12.7-2 + + -- Kidong Kim Wed, 24 Nov 2010 15:48:28 +0900 + +secure-storage (0.12.7-1) unstable; urgency=low + + * fix doxygen and add new configuration file + * Git: 165.213.180.234:/git/slp/pkgs/secure-storage + * Tag: secure-storage_0.12.7-1 + + -- Kidong Kim Fri, 12 Nov 2010 18:33:40 +0900 + +secure-storage (0.12.6-1) unstable; urgency=low + + * modify APIs - add new parameter 'group_id' + * Git: 165.213.180.234:/git/slp/pkgs/secure-storage + * Tag: secure-storage_0.12.6-1 + + -- Kidong Kim Wed, 03 Nov 2010 09:20:55 +0900 + +secure-storage (0.12.5-11) unstable; urgency=low + + * fix doxygen + * Git: 165.213.180.234:/git/slp/pkgs/secure-storage + * Tag: secure-storage_0.12.5-11 + + -- Kidong Kim Wed, 27 Oct 2010 15:01:16 +0900 + +secure-storage (0.12.5-10) unstable; urgency=low + + * fix bug + * Git: 165.213.180.234:/git/slp/pkgs/secure-storage + * Tag: secure-storage_0.12.5-10 + + -- Kidong Kim Fri, 22 Oct 2010 18:52:59 +0900 + +secure-storage (0.12.5-9) unstable; urgency=low + + * add new boiler-plate + * Git: 165.213.180.234:/git/slp/pkgs/secure-strage + * Tag: secure-storage_0.12.5-9 + + -- Kidong Kim Fri, 22 Oct 2010 17:49:33 +0900 + +secure-storage (0.12.5-8) unstable; urgency=low + + * make another symbolic link + * Git: 165.213.180.234:/git/slp/pkgs/secure-storage + * Tag: secure-storage_0.12.5-8 + + -- Kidong Kim Mon, 18 Oct 2010 14:15:03 +0900 + +secure-storage (0.12.5-7) unstable; urgency=low + + * delete some useless APIs + * Git: 165.213.180.234:/git/slp/pkgs/secure-storage + * Tag: secure-storage_0.12.5-7 + + -- Kidong Kim Fri, 15 Oct 2010 16:58:32 +0900 + +secure-storage (0.12.5-6) unstable; urgency=low + + * modify doxygen group + * Git: 165.213.180.234:/git/slp/pkgs/secure-storage + * Tag: secure-storage_0.12.5-6 + + -- Kidong Kim Mon, 27 Sep 2010 18:01:20 +0900 + +secure-storage (0.12.5-5) unstable; urgency=low + + * change copyright context + * Git: 165.213.180.234:/git/slp/pkgs/secure-storage + * Tag: secure-storage_0.12.5-5 + + -- Kidong Kim Tue, 31 Aug 2010 14:14:00 +0900 + +secure-storage (0.12.5-4) unstable; urgency=low + + * add new API - ssm_delete_file + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/secure-storage-0 + * Tag: secure-storage_0.12.5-4 + + -- Kidong Kim Sat, 12 Jun 2010 14:44:21 +0900 + +secure-storage (0.12.5-3) unstable; urgency=low + + * delete deprecated values + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/secure-storage-0 + * Tag: secure-storage_0.12.5-3 + + -- Kidong Kim Sat, 05 Jun 2010 13:38:31 +0900 + +secure-storage (0.12.5-2) unstable; urgency=low + + * modify deprecated method + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/secure-storage-0 + * Tag: secure-storage_0.12.5-2 + + -- Kidong Kim Mon, 24 May 2010 20:41:56 +0900 + +secure-storage (0.12.5-1) unstable; urgency=low + + * change API names and data structure names + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/secure-storage-0 + * Tag: secure-storage_0.12.5-1 + + -- Kidong Kim Mon, 24 May 2010 18:13:20 +0900 + +secure-storage (0.12.4-6) unstable; urgency=low + + * fix uploader info + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/secure-storage-0 + * Tag: secure-storage_0.12.4-6 + + -- Kidong Kim Wed, 19 May 2010 13:58:43 +0900 + +secure-storage (0.12.4-5) unstable; urgency=low + + * give a 777permission to socket + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/secure-storage-0 + * Tag: secure-storage_0.12.4-5 + + -- root Wed, 19 May 2010 11:43:59 +0900 + +secure-storage (0.12.4-4) unstable; urgency=low + + * fix tagging problem + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/secure-storage-0 + * Tag: secure-storage_0.12.4-4 + + -- Kidong Kim Mon, 19 Apr 2010 18:24:05 +0900 + +secure-storage (0.12.4-3) unstable; urgency=low + + * fix tagging problem + * Tag: secure-storage_0.12.4-3 + + -- Kidong Kim Sat, 17 Apr 2010 17:44:39 +0900 + +secure-storage (0.12.4-2) unstable; urgency=low + + * add postinst scripts + * Tag: secure-storage_0.12.4-2 + + -- Kidong Kim Fri, 16 Apr 2010 19:33:40 +0900 + +secure-storage (0.12.4-1) unstable; urgency=low + + * fix problem regarding version + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/secure-storage-0 + * Tag: secure-storage_0.12.4-1 + + -- Kidong Kim Mon, 12 Apr 2010 21:35:23 +0900 + +secure-storage (0.12.3-1) unstable; urgency=low + + * fix problem regarding version + + -- Kidong Kim Mon, 12 Apr 2010 21:21:08 +0900 + +secure-storage (0.12.2-3) unstable; urgency=low + + * Revert to version 0.12.2-1 + + -- Kidong Kim Mon, 12 Apr 2010 21:09:24 +0900 + +secure-storage (0.12.2-2) unstable; urgency=low + + * Make [pkgname].postinst in order to change file permission and owner + + -- Kidong Kim Mon, 12 Apr 2010 20:33:37 +0900 + +secure-storage (0.12.2-1) unstable; urgency=low + + * add flag 'TEST_TARGET' + + -- Kidong Kim Mon, 12 Apr 2010 17:35:17 +0900 + +secure-storage (0.12.1-1) unstable; urgency=low + + * re-make version + + -- Kidong Kim Thu, 08 Apr 2010 16:37:10 +0900 + +secure-storage (0.2.1-1) unstable; urgency=low + + * case of inhouse package + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/secure-storage-0 + * Tag: secure-storage_0.2.1-1 + + -- Kidong Kim Thu, 08 Apr 2010 12:07:01 +0900 + +secure-storage (0.11) unstable; urgency=low + + * Add new API - for Widget encryption / decrpytion + + -- Kidong Kim Tue, 23 Mar 2010 16:17:46 +0900 + +secure-storage (0.10) unstable; urgency=low + + * In case of parameter which must not be modified, change char* to const char* + + -- Kidong Kim Thu, 18 Mar 2010 15:30:04 +0900 + +secure-storage (0.9) unstable; urgency=low + + * Remove 'SLP' and 'slp' prefix + + -- Kidong Kim Tue, 26 Jan 2010 16:42:27 +0900 + +secure-storage (0.8) unstable; urgency=low + + * Add internal flag + + -- Kidong Kim Sat, 23 Jan 2010 17:17:25 +0900 + +secure-storage (0.7) unstable; urgency=low + + * Modify link name + + -- Kidong Kim Thu, 21 Jan 2010 10:35:18 +0900 + +secure-storage (0.6) unstable; urgency=low + + * Remove dev dependency of binary package. + + -- Kidong Kim Thu, 14 Jan 2010 15:06:32 +0900 + +secure-storage (0.5) unstable; urgency=low + + * export one more function + + -- Kidong Kim Tue, 12 Jan 2010 08:43:44 +0900 + +secure-storage (0.4) unstable; urgency=low + + * Modify ss-server auto-activation code. + + -- Kidong Kim Mon, 11 Jan 2010 15:20:25 +0900 + +secure-storage (0.3) unstable; urgency=low + + * Add prefix SLPAPI - can use APIs of secure storage + + -- Kidong Kim Mon, 11 Jan 2010 11:20:12 +0900 + +secure-storage (0.2) unstable; urgency=low + + * Resolve dependency problem. + + -- Kidong Kim Tue, 05 Jan 2010 19:34:26 +0900 + +secure-storage (0.1) unstable; urgency=low + + * Make CMakeLists.txt and Initial Release. + + -- Kidong Kim Thu, 17 Dec 2009 16:37:03 +0900 + +secure-storage (0) unstable; urgency=low + + * Initial Release. + + -- Ki Dong Kim Wed, 09 Dec 2009 09:55:06 +0900 diff --git a/include/secure_storage.h b/include/secure_storage.h index c1d9cc5..70c3965 100644 --- a/include/secure_storage.h +++ b/include/secure_storage.h @@ -1,7 +1,7 @@ /* * secure storage * - * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd All Rights Reserved * * Contact: Kidong Kim * diff --git a/include/ss_manager.h b/include/ss_manager.h index 942a1a1..b0f548c 100644 --- a/include/ss_manager.h +++ b/include/ss_manager.h @@ -1,7 +1,7 @@ /* * secure storage * - * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd All Rights Reserved * * Contact: Kidong Kim * diff --git a/packaging/secure-storage.spec b/packaging/secure-storage.spec index a79e99a..eb9c070 100644 --- a/packaging/secure-storage.spec +++ b/packaging/secure-storage.spec @@ -3,8 +3,8 @@ Name: secure-storage Summary: Secure storage Version: 0.12.7 Release: 1 -Group: System/Security -License: Apache 2.0 +Group: TO_BE/FILLED_IN +License: LGPL Source0: secure-storage-%{version}.tar.gz Requires(post): /sbin/service Requires(post): /sbin/chkconfig @@ -13,6 +13,7 @@ Requires(postun): /sbin/chkconfig BuildRequires: pkgconfig(openssl) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(security-server) +BuildRequires: pkgconfig(libsystemd-daemon) BuildRequires: cmake %description diff --git a/server/include/ss_server_ipc.h b/server/include/ss_server_ipc.h index 641c075..5d93c84 100644 --- a/server/include/ss_server_ipc.h +++ b/server/include/ss_server_ipc.h @@ -1,7 +1,7 @@ /* * secure storage * - * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd All Rights Reserved * * Contact: Kidong Kim * diff --git a/server/include/ss_server_main.h b/server/include/ss_server_main.h index 2d84c41..95746dc 100644 --- a/server/include/ss_server_main.h +++ b/server/include/ss_server_main.h @@ -1,7 +1,7 @@ /* * secure storage * - * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd All Rights Reserved * * Contact: Kidong Kim * diff --git a/server/src/ss_server_ipc.c b/server/src/ss_server_ipc.c index 95112dd..e1de270 100644 --- a/server/src/ss_server_ipc.c +++ b/server/src/ss_server_ipc.c @@ -1,7 +1,7 @@ /* * secure storage * - * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd All Rights Reserved * * Contact: Kidong Kim * @@ -119,9 +119,11 @@ int make_key_file() int random_dev = -1; int i = 0; char tmp_key[1]; - char key[16] = {0, }; + char key[33]; char* key_path = NULL; + memset(key, 0x00, 33); + key_path = get_key_file_path(); if(key_path == NULL) { @@ -136,16 +138,16 @@ int make_key_file() return 0; } - while(i < 16) + while(i < 32) { read(random_dev, tmp_key, 1); - if((tmp_key[0] < '!') || (tmp_key[0] > '~')) - continue; - - key[i] = tmp_key[0]; - i++; + if((tmp_key[0] >= '!') && (tmp_key[0] <= '~')) { + key[i] = tmp_key[0]; + i++; + } } +SLOGI("key = [%s], [%d]\n", key, strlen(key)); if(!(fp_key = fopen(key_path, "w"))) { diff --git a/server/src/ss_server_main.c b/server/src/ss_server_main.c index 22b6d94..414f72d 100644 --- a/server/src/ss_server_main.c +++ b/server/src/ss_server_main.c @@ -1,7 +1,7 @@ /* * secure storage * - * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd All Rights Reserved * * Contact: Kidong Kim * @@ -106,14 +106,14 @@ char* get_preserved_dir() } /* get key from hardware( ex. OMAP e-fuse random key ) */ -void GetKey(char* key) +void GetKey(char* key, unsigned char* iv) { #ifdef USE_KEY_FILE FILE* fp_key = NULL; - char buf[32]; + char buf[33]; char* key_path = NULL; - memset(buf, 0x00, strlen(buf)); + memset(buf, 0x00, 33); key_path = get_key_file_path(); if(key_path == NULL) @@ -130,7 +130,7 @@ void GetKey(char* key) } else { - if(!fgets(buf, 16, fp_key)) + if(!fgets(buf, 33, fp_key)) { SLOGE("[%s] Secret key file reading error\n", __func__); memcpy(buf, skey, 16); // if fail to get key, set to default value. @@ -140,6 +140,8 @@ void GetKey(char* key) if(key) strncpy(key, buf, 16); + if(iv) + strncpy(iv, buf+16, 16); if(key_path) free(key_path); @@ -149,6 +151,8 @@ void GetKey(char* key) #else if(key) memcpy(key, skey, 16); + if(iv) + memcpy(iv, 0x00, 16); #endif // USE_KEY_FILE } @@ -436,22 +440,21 @@ int ConvertFileName(int sender_pid, char* dest, const char* src, ssm_flag flag, } /* aes crypto function wrapper - p_text : plain text, c_text : cipher text, aes_key : from GetKey, mode : ENCRYPT/DECRYPT, size : data size */ -unsigned char* AES_Crypto(unsigned char* p_text, unsigned char* c_text, char* aes_key, int mode, unsigned long size) +unsigned char* AES_Crypto(unsigned char* p_text, unsigned char* c_text, char* aes_key, unsigned char* iv, int mode, unsigned long size) { AES_KEY e_key, d_key; - unsigned char ivec[16] = {0, }; AES_set_encrypt_key((unsigned char*)aes_key, 128, &e_key); AES_set_decrypt_key((unsigned char*)aes_key, 128, &d_key); if(mode == 1) { - AES_cbc_encrypt(p_text, c_text, size, &e_key, ivec, AES_ENCRYPT); + AES_cbc_encrypt(p_text, c_text, size, &e_key, iv, AES_ENCRYPT); return c_text; } else { - AES_cbc_encrypt(c_text, p_text, size, &d_key, ivec, AES_DECRYPT); + AES_cbc_encrypt(c_text, p_text, size, &d_key, iv, AES_DECRYPT); return p_text; } } @@ -463,13 +466,15 @@ unsigned char* AES_Crypto(unsigned char* p_text, unsigned char* c_text, char* ae int SsServerDataStoreFromFile(int sender_pid, const char* data_filepath, ssm_flag flag, const char* cookie, const char* group_id) { - char key[16]; + char key[16] = {0, }; + unsigned char iv[16] = {0, }; const char* in_filepath = data_filepath; char out_filepath[MAX_FILENAME_LEN] = {0, }; FILE* fd_in = NULL; FILE* fd_out = NULL; struct stat file_info; ssm_file_info_convert_t sfic; + int res = -1; unsigned char p_text[ENCRYPT_SIZE]= {0, }; unsigned char e_text[ENCRYPT_SIZE]= {0, }; @@ -520,11 +525,11 @@ int SsServerDataStoreFromFile(int sender_pid, const char* data_filepath, ssm_fla // 4. encrypt real data read = fread(p_text, 1, ENCRYPT_SIZE, fd_in); - GetKey(key); - + GetKey(key, iv); + while(read == ENCRYPT_SIZE) { - AES_Crypto(p_text, e_text, key, 1, ENCRYPT_SIZE); + AES_Crypto(p_text, e_text, key, iv, 1, ENCRYPT_SIZE); fwrite(e_text, 1, ENCRYPT_SIZE, fd_out); @@ -534,9 +539,23 @@ int SsServerDataStoreFromFile(int sender_pid, const char* data_filepath, ssm_fla } rest = AES_BLOCK_SIZE - (read % AES_BLOCK_SIZE); - AES_Crypto(p_text, e_text, key, 1, read+rest); + AES_Crypto(p_text, e_text, key, iv, 1, read+rest); fwrite(e_text, 1, read + rest, fd_out); + if((res = fflush(fd_out)) != 0) { + SLOGE("[%s] fail to execute fflush().\n", __func__); + return SS_FILE_WRITE_ERROR; + } + else { + SLOGI("[%s] success to execute fflush().\n", __func__); + if((res = fsync(fd_out->_fileno)) == -1) { + SLOGE("[%s] fail to execute fsync().\n", __func__); + return SS_FILE_WRITE_ERROR; + } + else + SLOGI("[%s] success to execute fsync(). read=[%d], rest=[%d]\n", __func__, read, rest); + } + fclose(fd_in); fclose(fd_out); @@ -545,7 +564,8 @@ int SsServerDataStoreFromFile(int sender_pid, const char* data_filepath, ssm_fla int SsServerDataStoreFromBuffer(int sender_pid, char* writebuffer, size_t bufLen, const char* filename, ssm_flag flag, const char* cookie, const char* group_id) { - char key[16]; + char key[16] = {0, }; + unsigned char iv[16] = {0, }; char out_filepath[MAX_FILENAME_LEN+1]; char *buffer = NULL; unsigned int writeLen = 0, loop, rest, count; @@ -553,6 +573,7 @@ int SsServerDataStoreFromBuffer(int sender_pid, char* writebuffer, size_t bufLen ssm_file_info_convert_t sfic; unsigned char p_text[ENCRYPT_SIZE]= {0, }; unsigned char e_text[ENCRYPT_SIZE]= {0, }; + int res = -1; writeLen = (unsigned int)(bufLen / AES_BLOCK_SIZE + 1) * AES_BLOCK_SIZE; buffer = (char*)malloc(writeLen + 1); @@ -594,20 +615,34 @@ int SsServerDataStoreFromBuffer(int sender_pid, char* writebuffer, size_t bufLen // encrypt buffer loop = writeLen / ENCRYPT_SIZE; rest = writeLen % ENCRYPT_SIZE; - GetKey(key); + GetKey(key, iv); for(count = 0; count < loop; count++) { memcpy(p_text, buffer+count*ENCRYPT_SIZE, ENCRYPT_SIZE); - AES_Crypto( p_text, e_text, key, 1, ENCRYPT_SIZE); + AES_Crypto( p_text, e_text, key, iv, 1, ENCRYPT_SIZE); fwrite(e_text, 1, ENCRYPT_SIZE, fd_out); memset(e_text, 0x00, ENCRYPT_SIZE); memset(p_text, 0x00, ENCRYPT_SIZE); } memcpy(p_text, buffer + loop*ENCRYPT_SIZE, rest); - AES_Crypto(p_text, e_text, key, 1, rest); + AES_Crypto(p_text, e_text, key, iv, 1, rest); fwrite(e_text, 1, rest, fd_out); + + if((res = fflush(fd_out)) != 0) { + SLOGE("[%s] fail to execute fflush().\n", __func__); + return SS_FILE_WRITE_ERROR; + } + else { + SLOGI("[%s] success to execute fflush().\n", __func__); + if((res = fsync(fd_out->_fileno)) == -1) { + SLOGE("[%s] fail to execute fsync().\n", __func__); + return SS_FILE_WRITE_ERROR; + } + else + SLOGI("[%s] success to execute fsync(). loop=[%d], rest=[%d]\n", __func__, loop, rest); + } fclose(fd_out); free(buffer); @@ -618,8 +653,9 @@ int SsServerDataStoreFromBuffer(int sender_pid, char* writebuffer, size_t bufLen int SsServerDataRead(int sender_pid, const char* data_filepath, char* pRetBuf, unsigned int count, unsigned int* readLen, ssm_flag flag, const char* cookie, const char* group_id) { unsigned int offset = count * MAX_RECV_DATA_LEN; - char key[16]; - char in_filepath[MAX_FILENAME_LEN] = {0,}; + char key[16] = {0, }; + unsigned char iv[16] = {0, }; + char in_filepath[MAX_FILENAME_LEN] = {0, }; FILE* fd_in = NULL; char *out_data = pRetBuf; unsigned char p_text[ENCRYPT_SIZE]= {0, }; @@ -652,13 +688,13 @@ int SsServerDataRead(int sender_pid, const char* data_filepath, char* pRetBuf, u fseek(fd_in, (long)offset + sizeof(ssm_file_info_t), SEEK_SET); // 4. decrypt data - GetKey(key); + GetKey(key, iv); read = fread(e_text, 1, ENCRYPT_SIZE, fd_in); while((read == ENCRYPT_SIZE)) { - AES_Crypto(p_text, e_text, key, 0, ENCRYPT_SIZE) ; + AES_Crypto(p_text, e_text, key, iv, 0, ENCRYPT_SIZE) ; memcpy(out_data, p_text, ENCRYPT_SIZE); out_data += ENCRYPT_SIZE; @@ -673,7 +709,7 @@ int SsServerDataRead(int sender_pid, const char* data_filepath, char* pRetBuf, u read = fread(e_text, 1, ENCRYPT_SIZE, fd_in); } - AES_Crypto(p_text, e_text, key, 0, read) ; + AES_Crypto(p_text, e_text, key, iv, 0, read) ; memcpy(out_data, p_text, read); out_data += read; -- 2.7.4