| 1 | // | 
|---|---|
| 2 | // CipherFactory.cpp | 
| 3 | // | 
| 4 | // Library: Crypto | 
| 5 | // Package: Cipher | 
| 6 | // Module: CipherFactory | 
| 7 | // | 
| 8 | // Copyright (c) 2008, Applied Informatics Software Engineering GmbH. | 
| 9 | // and Contributors. | 
| 10 | // | 
| 11 | // SPDX-License-Identifier: BSL-1.0 | 
| 12 | // | 
| 13 | |
| 14 | |
| 15 | #include "Poco/Crypto/CipherFactory.h" | 
| 16 | #include "Poco/Crypto/Cipher.h" | 
| 17 | #include "Poco/Crypto/CipherKey.h" | 
| 18 | #include "Poco/Crypto/RSAKey.h" | 
| 19 | #include "Poco/Crypto/CipherImpl.h" | 
| 20 | #include "Poco/Crypto/RSACipherImpl.h" | 
| 21 | #include "Poco/Exception.h" | 
| 22 | #include "Poco/SingletonHolder.h" | 
| 23 | #include <openssl/evp.h> | 
| 24 | #include <openssl/err.h> | 
| 25 | |
| 26 | |
| 27 | namespace Poco { | 
| 28 | namespace Crypto { | 
| 29 | |
| 30 | |
| 31 | CipherFactory::CipherFactory() | 
| 32 | { | 
| 33 | } | 
| 34 | |
| 35 | |
| 36 | CipherFactory::~CipherFactory() | 
| 37 | { | 
| 38 | } | 
| 39 | |
| 40 | |
| 41 | namespace | 
| 42 | { | 
| 43 | static Poco::SingletonHolder<CipherFactory> holder; | 
| 44 | } | 
| 45 | |
| 46 | |
| 47 | CipherFactory& CipherFactory::defaultFactory() | 
| 48 | { | 
| 49 | return *holder.get(); | 
| 50 | } | 
| 51 | |
| 52 | |
| 53 | Cipher* CipherFactory::createCipher(const CipherKey& key) | 
| 54 | { | 
| 55 | return new CipherImpl(key); | 
| 56 | } | 
| 57 | |
| 58 | |
| 59 | Cipher* CipherFactory::createCipher(const RSAKey& key, RSAPaddingMode paddingMode) | 
| 60 | { | 
| 61 | return new RSACipherImpl(key, paddingMode); | 
| 62 | } | 
| 63 | |
| 64 | |
| 65 | } } // namespace Poco::Crypto | 
| 66 | 
