2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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.
18 * @file FSecCrypto_SymmetricCipher.h
19 * @brief This header file contains declarations of common operations for Symmetric Ciphers available.
21 #ifndef _FSEC_CRYPTO_INTERNAL_SYMMETRIC_CIPHER_H_
22 #define _FSEC_CRYPTO_INTERNAL_SYMMETRIC_CIPHER_H_
24 #include <unique_ptr.h>
25 #include <FSecCryptoTypes.h>
26 #include <FBaseByteBuffer.h>
29 struct evp_cipher_ctx_st;
32 namespace Tizen { namespace Security { namespace Crypto
35 class _SymmetricCipher
39 _SymmetricCipher(void);
40 virtual ~_SymmetricCipher(void);
41 result SetCipherAlgorithm(const Tizen::Base::String& cipherAlgorithm);
42 result SetKey(const Tizen::Security::ISecretKey& key);
43 result SetInitialVector(const Tizen::Base::ByteBuffer& initialVector);
44 result SetTransformation(const evp_cipher_st* pCipherAlgorithm, bool padding);
45 result SetCipherOperation(CipherOperation opMode);
46 Tizen::Base::ByteBuffer* DoCipherN(const Tizen::Base::ByteBuffer& input, bool variableKeyFlag = false);
47 result Initialize(bool variableKeyFlag = false);
48 Tizen::Base::ByteBuffer* UpdateN(const Tizen::Base::ByteBuffer& input);
49 Tizen::Base::ByteBuffer* FinalizeN(void);
50 Tizen::Base::ByteBuffer* WrapN(const Tizen::Base::ByteBuffer& secretKey);
51 Tizen::Base::ByteBuffer* UnwrapN(const Tizen::Base::ByteBuffer& wrappedKey);
54 _SymmetricCipher(const _SymmetricCipher& rhs);
55 _SymmetricCipher& operator =(const _SymmetricCipher& rhs);
56 Tizen::Base::ByteBuffer* DoWrapN(const Tizen::Base::ByteBuffer& secretKey);
57 Tizen::Base::ByteBuffer* DoUnwrapN(const Tizen::Base::ByteBuffer& wrappedKey);
60 const evp_cipher_st* __pCipherAlgorithm;
61 Tizen::Base::String __cipherAlgorithm;
62 std::unique_ptr <evp_cipher_ctx_st> __pCipherCtx;
63 CipherOperation __opMode;
65 Tizen::Base::ByteBuffer __initVector;
66 Tizen::Base::ByteBuffer __keyBytes;
70 } } } // Tizen::Security::Crypto
72 #endif //_FSEC_CRYPTO_INTERNAL_SYMMETRIC_CIPHER_H_