Implement key retrieval in encryption service
[platform/core/security/key-manager.git] / src / manager / service / ckm-logic.h
index 341d23d..b6dc1eb 100644 (file)
@@ -35,6 +35,7 @@
 #include <access-control.h>
 #include <certificate-impl.h>
 #include <sys/types.h>
+#include <generic-backend/gkey.h>
 
 #include <platform/decider.h>
 
@@ -49,12 +50,6 @@ struct UserData {
 class CKMLogic {
 public:
     static const uid_t SYSTEM_DB_UID;
-    class Exception
-    {
-    public:
-        DECLARE_EXCEPTION_TYPE(CKM::Exception, Base)
-        DECLARE_EXCEPTION_TYPE(Base, DatabaseLocked)
-    };
 
     CKMLogic();
     CKMLogic(const CKMLogic &) = delete;
@@ -127,9 +122,8 @@ public:
 
     RawBuffer createKeyPair(
         const Credentials &cred,
-        LogicCommand protocol_cmd,
         int commandId,
-        const int additional_param,
+        const CryptoAlgorithmSerializable & keyGenParams,
         const Name &namePrivate,
         const Label &labelPrivate,
         const Name &namePublic,
@@ -137,6 +131,14 @@ public:
         const PolicySerializable &policyPrivate,
         const PolicySerializable &policyPublic);
 
+    RawBuffer createKeyAES(
+        const Credentials &cred,
+        int commandId,
+        const int size,
+        const Name &name,
+        const Label &label,
+        const PolicySerializable &policy);
+
     RawBuffer getCertificateChain(
         const Credentials &cred,
         int commandId,
@@ -200,6 +202,12 @@ public:
         DataType dataType,
         const PolicySerializable &policy);
 
+    int getKeyForService(const Credentials &cred,
+                         const Name &name,
+                         const Label &label,
+                         const Password& pass,
+                         Crypto::GKeyShPtr& key);
+
 private:
 
     // select private/system database depending on asking uid and owner label.
@@ -322,10 +330,16 @@ private:
         const Password &password,
         DB::RowVector &rows);
 
+    int createKeyAESHelper(
+        const Credentials &cred,
+        const int size,
+        const Name &name,
+        const Label &label,
+        const PolicySerializable &policy);
+
     int createKeyPairHelper(
         const Credentials &cred,
-        const KeyType key_type,
-        const int additional_param,
+        const CryptoAlgorithmSerializable & keyGenParams,
         const Name &namePrivate,
         const Label &labelPrivate,
         const Name &namePublic,