2 * Copyright (c) 2011 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.
16 #ifndef _CERTIFICATELOADER_H_
17 #define _CERTIFICATELOADER_H_
22 #include <dpl/noncopyable.h>
23 #include <openssl/ssl.h>
25 #include <cert-service.h>
27 #include <vcore/Certificate.h>
29 namespace ValidationCore {
30 class CertificateLoader : public VcoreDPL::Noncopyable
33 class CertificateLoaderComparator
36 virtual bool compare(X509 *x509cert) = 0;
37 virtual ~CertificateLoaderComparator()
42 enum CertificateLoaderResult
45 CERTIFICATE_NOT_FOUND,
46 UNSUPPORTED_CERTIFICATE_FIELD,
48 CERTIFICATE_SECURITY_ERROR, //!< there are some issues with certificate security (i.e. key too short)
56 virtual ~CertificateLoader()
60 CertificateLoaderResult loadCertificate(const std::string& storage,
61 CertificateLoaderComparator *cmp);
63 CertificateLoaderResult loadCertificateBasedOnSubjectName(
64 const std::string &subjectName);
65 CertificateLoaderResult loadCertificateBasedOnExponentAndModulus(
66 const std::string &m_modulus,
67 const std::string &m_exponent);
68 // KW CertificateLoaderResult loadCertificateBasedOnIssuerName(const std::string &isserName,
69 // KW const std::string &serialNumber);
71 CertificateLoaderResult loadCertificateFromRawData(
72 const std::string &rawData);
74 CertificateLoaderResult loadCertificateBasedOnDSAComponents(
75 const std::string& strP,
76 const std::string& strQ,
77 const std::string& strG,
78 const std::string& strY,
79 const std::string& strJ,
80 const std::string& strSeed,
81 const std::string& strPGenCounter);
83 CertificateLoaderResult loadCertificateWithECKEY(
84 const std::string &curveName,
85 const std::string &publicKey);
88 * converts base64 encoded node to SSL bignum
89 * allocates mem on *ppBigNum, don't forget to free it later with BN_free!
90 * returns conversion status
92 static bool convertBase64NodeToBigNum(const std::string& strNode,
96 * encodes SSL bignum into base64 octstring
97 * returns conversion status
99 // KW static bool convertBigNumToBase64Node(const BIGNUM* pBigNum, std::string& strNode);
101 CertificatePtr getCertificatePtr() const
103 return m_certificatePtr;
106 CertificatePtr m_certificatePtr;
108 } // namespace ValidationCore
110 #endif // _CERTIFICATELOADER_H_