Add defense code for null input
authorDongsun Lee <ds73.lee@samsung.com>
Thu, 27 Oct 2016 03:58:17 +0000 (12:58 +0900)
committerDongsun Lee <ds73.lee@samsung.com>
Mon, 31 Oct 2016 04:48:01 +0000 (13:48 +0900)
Change-Id: Id9c5563d3789853432b5d88bb54f4babbbaa3600
Signed-off-by: Dongsun Lee <ds73.lee@samsung.com>
Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Certificate.cs
Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Key.cs
Tizen.Security.SecureRepository/Tizen.Security.SecureRepository/Pkcs12.cs
packaging/csapi-security.spec

index 91236c1..0dfaae2 100755 (executable)
@@ -81,7 +81,8 @@ namespace Tizen.Security.SecureRepository
 
         internal CkmcCert ToCkmcCert()
         {
-            return new Interop.CkmcCert(new PinnedObject(Binary), Binary.Length, (int)Format);
+            byte[] bin = (Binary != null) ? Binary : new byte[0];
+            return new Interop.CkmcCert(new PinnedObject(bin), bin.Length, (int)Format);
         }
 
         /// <summary>
index c64b32b..615f2a9 100755 (executable)
@@ -76,8 +76,9 @@ namespace Tizen.Security.SecureRepository
 
         internal CkmcKey ToCkmcKey()
         {
-            return new Interop.CkmcKey(new PinnedObject(Binary),
-                                       Binary.Length,
+            byte[] bin = (Binary != null) ? Binary : new byte[0] ;
+            return new Interop.CkmcKey(new PinnedObject(bin),
+                                       bin.Length,
                                        (int)Type,
                                        new PinnedObject(BinaryPassword));
         }
index e682c65..cc5c52c 100755 (executable)
@@ -116,13 +116,10 @@ namespace Tizen.Security.SecureRepository
 
         internal CkmcPkcs12 ToCkmcPkcs12()
         {
-            Interop.CkmcKey ckmcKey = new Interop.CkmcKey(new PinnedObject(PrivateKey.Binary),
-                                            PrivateKey.Binary.Length,
-                                            (int)PrivateKey.Type,
-                                            new PinnedObject(PrivateKey.BinaryPassword));
-            Interop.CkmcCert ckmcCert = new Interop.CkmcCert(new PinnedObject(Certificate.Binary),
-                                            Certificate.Binary.Length,
-                                            (int)Certificate.Format);
+            Interop.CkmcKey ckmcKey = (PrivateKey != null) ?
+                                            PrivateKey.ToCkmcKey() : new Interop.CkmcKey(IntPtr.Zero, 0, 0, IntPtr.Zero);
+            Interop.CkmcCert ckmcCert = (Certificate != null) ?
+                                            Certificate.ToCkmcCert() : new Interop.CkmcCert(IntPtr.Zero, 0, 0);
             SafeCertificateListHandle ckmcCaCerts = new SafeCertificateListHandle(CaChain);
 
             return new Interop.CkmcPkcs12(new PinnedObject(ckmcKey),
index 54cdb67..1891860 100644 (file)
@@ -8,7 +8,7 @@
 
 Name:       csapi-security
 Summary:    Tizen Security API for C#
-Version:    1.0.1
+Version:    1.0.2
 Release:    1
 Group:      Development/Libraries
 License:    Apache-2.0