2 * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (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://www.apache.org/licenses/LICENSE-2.0
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
18 * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com)
20 * @brief Main header file for client library.
27 #include <ckm/ckm-certificate.h>
28 #include <ckm/ckm-error.h>
29 #include <ckm/ckm-key.h>
30 #include <ckm/ckm-type.h>
32 // Central Key Manager namespace
36 typedef std::shared_ptr<Manager> ManagerShPtr;
42 virtual int saveKey(const Alias &alias, const KeyShPtr &key, const Policy &policy) = 0;
43 virtual int saveCertificate(const Alias &alias, const CertificateShPtr &cert, const Policy &policy) = 0;
46 * Data must be extractable. If you set extractable bit to false funciton will
47 * return ERROR_INPUT_PARAM.
49 virtual int saveData(const Alias &alias, const RawBuffer &data, const Policy &policy) = 0;
51 virtual int removeKey(const Alias &alias) = 0;
52 virtual int removeCertificate(const Alias &alias) = 0;
53 virtual int removeData(const Alias &alias) = 0;
55 virtual int getKey(const Alias &alias, const Password &password, KeyShPtr &key) = 0;
56 virtual int getCertificate(
58 const Password &password,
59 CertificateShPtr &certificate) = 0;
60 virtual int getData(const Alias &alias, const Password &password, RawBuffer &data) = 0;
62 // send request for list of all keys/certificates/data that application/user may use
63 virtual int getKeyAliasVector(AliasVector &aliasVector) = 0;
64 virtual int getCertificateAliasVector(AliasVector &aliasVector) = 0;
65 virtual int getDataAliasVector(AliasVector &aliasVector) = 0;
67 virtual int createKeyPairRSA(
68 const int size, // size in bits [1024, 2048, 4096]
69 const Alias &privateKeyAlias,
70 const Alias &publicKeyAlias,
71 const Policy &policyPrivateKey = Policy(),
72 const Policy &policyPublicKey = Policy()) = 0;
74 virtual int createKeyPairDSA(
75 const int size, // size in bits [1024, 2048, 3072, 4096]
76 const Alias &privateKeyAlias,
77 const Alias &publicKeyAlias,
78 const Policy &policyPrivateKey = Policy(),
79 const Policy &policyPublicKey = Policy()) = 0;
81 virtual int createKeyPairECDSA(
82 const ElipticCurve type,
83 const Alias &privateKeyAlias,
84 const Alias &publicKeyAlias,
85 const Policy &policyPrivateKey = Policy(),
86 const Policy &policyPublicKey = Policy()) = 0;
88 virtual int getCertificateChain(
89 const CertificateShPtr &certificate,
90 const CertificateShPtrVector &untrustedCertificates,
91 CertificateShPtrVector &certificateChainVector) = 0;
93 virtual int getCertificateChain(
94 const CertificateShPtr &certificate,
95 const AliasVector &untrustedCertificates,
96 CertificateShPtrVector &certificateChainVector) = 0;
98 virtual int createSignature(
99 const Alias &privateKeyAlias,
100 const Password &password, // password for private_key
101 const RawBuffer &message,
102 const HashAlgorithm hash,
103 const RSAPaddingAlgorithm padding,
104 RawBuffer &signature) = 0;
106 virtual int verifySignature(
107 const Alias &publicKeyOrCertAlias,
108 const Password &password, // password for public_key (optional)
109 const RawBuffer &message,
110 const RawBuffer &signature,
111 const HashAlgorithm hash,
112 const RSAPaddingAlgorithm padding) = 0;
114 // This function will check all certificates in chain except Root CA.
115 // This function will delegate task to service. You may use this even
116 // if application does not have permission to use network.
117 virtual int ocspCheck(const CertificateShPtrVector &certificateChainVector, int &ocspStatus) = 0;
119 virtual int setPermission(const Alias &alias, const Label &accessor, Permission newPermission) = 0;
122 static ManagerShPtr create();
123 // static ManagerShPtr getManager(int uid); // TODO