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 RawBuffer sign(EVP_PKEY *pkey,
54 const CryptoAlgorithm &alg,
55 const RawBuffer &message);
57 int verify(EVP_PKEY *pkey,
58 const CryptoAlgorithm &alg,
59 const RawBuffer &message,
60 const RawBuffer &signature);
62 const EVP_MD *getMdAlgo(const HashAlgorithm hashAlgo);
63 int getRsaPadding(const RSAPaddingAlgorithm padAlgo);
65 RawBuffer signMessage(EVP_PKEY *privKey,
66 const RawBuffer &message,
67 const int rsa_padding);
69 RawBuffer digestSignMessage(EVP_PKEY *privKey,
70 const RawBuffer &message,
71 const EVP_MD *md_algo,
72 const int rsa_padding);
74 int verifyMessage(EVP_PKEY *pubKey,
75 const RawBuffer &message,
76 const RawBuffer &signature,
77 const int rsa_padding);
79 int digestVerifyMessage(EVP_PKEY *pubKey,
80 const RawBuffer &message,
81 const RawBuffer &signature,
82 const EVP_MD *md_algo,
83 const int rsa_padding);
85 } // namespace Internals