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 TokenPair createKeyPairRSA(CryptoBackend backendId, const int size);
43 TokenPair createKeyPairDSA(CryptoBackend backendId, const int size);
44 TokenPair createKeyPairECDSA(CryptoBackend backendId, ElipticCurve type1);
45 Token createKeyAES(CryptoBackend backendId, const int sizeBits);
47 TokenPair generateAKey(CryptoBackend backendId, const CryptoAlgorithm &algorithm);
48 Token generateSKey(CryptoBackend backendId, const CryptoAlgorithm &algorithm);
50 RawBuffer symmetricEncrypt(const RawBuffer &key,
51 const CryptoAlgorithm &alg,
52 const RawBuffer &data);
53 RawBuffer symmetricDecrypt(const RawBuffer &key,
54 const CryptoAlgorithm &alg,
55 const RawBuffer &cipher);
57 std::pair<RawBuffer, RawBuffer> encryptDataAesGcm(const RawBuffer &key,
58 const RawBuffer &data,
62 RawBuffer decryptDataAesGcm(const RawBuffer &key,
63 const RawBuffer &data,
65 const RawBuffer &tag);
67 RawBuffer encryptDataAes(AlgoType type,
69 const RawBuffer &data,
72 RawBuffer decryptDataAes(AlgoType type,
74 const RawBuffer &data,
77 RawBuffer sign(EVP_PKEY *pkey,
78 const CryptoAlgorithm &alg,
79 const RawBuffer &message);
81 int verify(EVP_PKEY *pkey,
82 const CryptoAlgorithm &alg,
83 const RawBuffer &message,
84 const RawBuffer &signature);
86 const EVP_MD *getMdAlgo(const HashAlgorithm hashAlgo);
87 int getRsaPadding(const RSAPaddingAlgorithm padAlgo);
89 RawBuffer signMessage(EVP_PKEY *privKey,
90 const RawBuffer &message,
91 const int rsa_padding);
93 RawBuffer digestSignMessage(EVP_PKEY *privKey,
94 const RawBuffer &message,
95 const EVP_MD *md_algo,
96 const int rsa_padding);
98 int verifyMessage(EVP_PKEY *pubKey,
99 const RawBuffer &message,
100 const RawBuffer &signature,
101 const int rsa_padding);
103 int digestVerifyMessage(EVP_PKEY *pubKey,
104 const RawBuffer &message,
105 const RawBuffer &signature,
106 const EVP_MD *md_algo,
107 const int rsa_padding);
109 } // namespace Internals
111 } // namespace Crypto