1 // 2 // RSACipherImpl.h 3 // 4 // Library: Crypto 5 // Package: RSA 6 // Module: RSACipherImpl 7 // 8 // Definition of the RSACipherImpl class. 9 // 10 // Copyright (c) 2008, Applied Informatics Software Engineering GmbH. 11 // and Contributors. 12 // 13 // SPDX-License-Identifier: BSL-1.0 14 // 15 16 17 #ifndef Crypto_RSACipherImpl_INCLUDED 18 #define Crypto_RSACipherImpl_INCLUDED 19 20 21 #include "Poco/Crypto/Crypto.h" 22 #include "Poco/Crypto/Cipher.h" 23 #include "Poco/Crypto/RSAKey.h" 24 #include "Poco/Crypto/OpenSSLInitializer.h" 25 #include <openssl/evp.h> 26 27 28 namespace Poco { 29 namespace Crypto { 30 31 32 class RSACipherImpl: public Cipher 33 /// An implementation of the Cipher class for 34 /// asymmetric (public-private key) encryption 35 /// based on the the RSA algorithm in OpenSSL's 36 /// crypto library. 37 /// 38 /// Encryption is using the public key, decryption 39 /// requires the private key. 40 { 41 public: 42 RSACipherImpl(const RSAKey& key, RSAPaddingMode paddingMode); 43 /// Creates a new RSACipherImpl object for the given RSAKey 44 /// and using the given padding mode. 45 46 virtual ~RSACipherImpl(); 47 /// Destroys the RSACipherImpl. 48 49 const std::string& name() const; 50 /// Returns the name of the Cipher. 51 52 CryptoTransform::Ptr createEncryptor(); 53 /// Creates an encryptor object. 54 55 CryptoTransform::Ptr createDecryptor(); 56 /// Creates a decryptor object. 57 58 private: 59 RSAKey _key; 60 RSAPaddingMode _paddingMode; 61 OpenSSLInitializer _openSSLInitializer; 62 }; 63 64 65 // 66 // Inlines 67 // name()68inline const std::string& RSACipherImpl::name() const 69 { 70 return _key.name(); 71 } 72 73 74 } } // namespace Poco::Crypto 75 76 77 #endif // Crypto_RSACipherImpl_INCLUDED 78