2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FSecCrypto_SymmetricCipher.h
20 * @brief This header file contains declarations of common operations for Symmetric Ciphers available.
22 #ifndef _FSEC_CRYPTO_INTERNAL_SYMMETRIC_CIPHER_H_
23 #define _FSEC_CRYPTO_INTERNAL_SYMMETRIC_CIPHER_H_
25 #include <unique_ptr.h>
26 #include <FSecCryptoTypes.h>
27 #include <FBaseByteBuffer.h>
30 struct evp_cipher_ctx_st;
33 namespace Tizen { namespace Security { namespace Crypto
36 class _SymmetricCipher
40 _SymmetricCipher(void);
41 virtual ~_SymmetricCipher(void);
42 result SetCipherAlgorithm(const Tizen::Base::String& cipherAlgorithm);
43 result SetKey(const Tizen::Security::ISecretKey& key);
44 result SetInitialVector(const Tizen::Base::ByteBuffer& initialVector);
45 result SetTransformation(const evp_cipher_st* pCipherAlgorithm, bool padding);
46 result SetCipherOperation(CipherOperation opMode);
47 Tizen::Base::ByteBuffer* DoCipherN(const Tizen::Base::ByteBuffer& input, bool variableKeyFlag = false);
48 result Initialize(bool variableKeyFlag = false);
49 Tizen::Base::ByteBuffer* UpdateN(const Tizen::Base::ByteBuffer& input);
50 Tizen::Base::ByteBuffer* FinalizeN(void);
51 Tizen::Base::ByteBuffer* WrapN(const Tizen::Base::ByteBuffer& secretKey);
52 Tizen::Base::ByteBuffer* UnwrapN(const Tizen::Base::ByteBuffer& wrappedKey);
55 _SymmetricCipher(const _SymmetricCipher& rhs);
56 _SymmetricCipher& operator =(const _SymmetricCipher& rhs);
57 Tizen::Base::ByteBuffer* DoWrapN(const Tizen::Base::ByteBuffer& secretKey);
58 Tizen::Base::ByteBuffer* DoUnwrapN(const Tizen::Base::ByteBuffer& wrappedKey);
61 const evp_cipher_st* __pCipherAlgorithm;
62 Tizen::Base::String __cipherAlgorithm;
63 std::unique_ptr <evp_cipher_ctx_st> __pCipherCtx;
64 CipherOperation __opMode;
66 Tizen::Base::ByteBuffer __initVector;
67 Tizen::Base::ByteBuffer __keyBytes;
71 } } } // Tizen::Security::Crypto
73 #endif //_FSEC_CRYPTO_INTERNAL_SYMMETRIC_CIPHER_H_