RSACipherImpl.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #ifndef Crypto_RSACipherImpl_INCLUDED
  16. #define Crypto_RSACipherImpl_INCLUDED
  17. #include "Poco/Crypto/Crypto.h"
  18. #include "Poco/Crypto/Cipher.h"
  19. #include "Poco/Crypto/RSAKey.h"
  20. #include "Poco/Crypto/OpenSSLInitializer.h"
  21. #include <openssl/evp.h>
  22. namespace Poco {
  23. namespace Crypto {
  24. class RSACipherImpl: public Cipher
  25. /// An implementation of the Cipher class for
  26. /// asymmetric (public-private key) encryption
  27. /// based on the the RSA algorithm in OpenSSL's
  28. /// crypto library.
  29. ///
  30. /// Encryption is using the public key, decryption
  31. /// requires the private key.
  32. {
  33. public:
  34. RSACipherImpl(const RSAKey& key, RSAPaddingMode paddingMode);
  35. /// Creates a new RSACipherImpl object for the given RSAKey
  36. /// and using the given padding mode.
  37. virtual ~RSACipherImpl();
  38. /// Destroys the RSACipherImpl.
  39. const std::string& name() const;
  40. /// Returns the name of the Cipher.
  41. CryptoTransform* createEncryptor();
  42. /// Creates an encryptor object.
  43. CryptoTransform* createDecryptor();
  44. /// Creates a decryptor object.
  45. private:
  46. RSAKey _key;
  47. RSAPaddingMode _paddingMode;
  48. OpenSSLInitializer _openSSLInitializer;
  49. };
  50. //
  51. // Inlines
  52. //
  53. inline const std::string& RSACipherImpl::name() const
  54. {
  55. return _key.name();
  56. }
  57. } } // namespace Poco::Crypto
  58. #endif // Crypto_RSACipherImpl_INCLUDED