2 * Copyright (c) 2000 - 2015 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
24 #include <certificate-impl.h>
25 #include <ckm/ckm-type.h>
26 #include <openssl/evp.h>
29 #define EVP_SUCCESS 1 // DO NOTCHANGE THIS VALUE
30 #define EVP_FAIL 0 // DO NOTCHANGE THIS VALUE
32 #define CKM_CRYPTO_INIT_SUCCESS 1
33 #define CKM_CRYPTO_CREATEKEY_SUCCESS 2
34 #define CKM_VERIFY_CHAIN_SUCCESS 5
35 #define NOT_DEFINED -1
42 // During initialization, FIPS_MODE and the entropy source are set
43 // and system certificates are loaded to memory.
44 // FIPS_MODE - ON, OFF(Default)
45 // entropy source - /dev/random,/dev/urandom(Default)
48 TokenPair createKeyPairRSA(CryptoBackend backendId, const int size);
49 TokenPair createKeyPairDSA(CryptoBackend backendId, const int size);
50 TokenPair createKeyPairECDSA(CryptoBackend backendId, ElipticCurve type1);
51 Token createKeyAES(CryptoBackend backendId, const int sizeBits);
53 TokenPair generateAKey(CryptoBackend backendId, const CryptoAlgorithm &algorithm);
54 Token generateSKey(CryptoBackend backendId, const CryptoAlgorithm &algorithm);
56 RawBuffer symmetricEncrypt(const RawBuffer &key,
57 const CryptoAlgorithm &alg,
58 const RawBuffer &data);
59 RawBuffer symmetricDecrypt(const RawBuffer &key,
60 const CryptoAlgorithm &alg,
61 const RawBuffer &cipher);
63 std::pair<RawBuffer, RawBuffer> encryptDataAesGcm(const RawBuffer &key,
64 const RawBuffer &data,
68 RawBuffer decryptDataAesGcm(const RawBuffer &key,
69 const RawBuffer &data,
71 const RawBuffer &tag);
73 RawBuffer encryptDataAes(AlgoType type,
75 const RawBuffer &data,
78 RawBuffer decryptDataAes(AlgoType type,
80 const RawBuffer &data,
83 RawBuffer sign(EVP_PKEY *pkey,
84 const CryptoAlgorithm &alg,
85 const RawBuffer &message);
87 int verify(EVP_PKEY *pkey,
88 const CryptoAlgorithm &alg,
89 const RawBuffer &message,
90 const RawBuffer &signature);
92 const EVP_MD *getMdAlgo(const HashAlgorithm hashAlgo);
93 int getRsaPadding(const RSAPaddingAlgorithm padAlgo);
95 RawBuffer signMessage(EVP_PKEY *privKey,
96 const RawBuffer &message,
97 const int rsa_padding);
99 RawBuffer digestSignMessage(EVP_PKEY *privKey,
100 const RawBuffer &message,
101 const EVP_MD *md_algo,
102 const int rsa_padding);
104 int verifyMessage(EVP_PKEY *pubKey,
105 const RawBuffer &message,
106 const RawBuffer &signature,
107 const int rsa_padding);
109 int digestVerifyMessage(EVP_PKEY *pubKey,
110 const RawBuffer &message,
111 const RawBuffer &signature,
112 const EVP_MD *md_algo,
113 const int rsa_padding);
115 } // namespace Internals
117 } // namespace Crypto