mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-07-13 12:27:10 +02:00
bin
module
vendor
CPR
ConcurrentQueue
Fmt
POCO
ApacheConnector
CppParser
CppUnit
Crypto
cmake
include
Poco
Crypto
Cipher.h
CipherFactory.h
CipherImpl.h
CipherKey.h
CipherKeyImpl.h
Crypto.h
CryptoException.h
CryptoStream.h
CryptoTransform.h
DigestEngine.h
ECDSADigestEngine.h
ECKey.h
ECKeyImpl.h
EVPPKey.h
KeyPair.h
KeyPairImpl.h
OpenSSLInitializer.h
PKCS12Container.h
RSACipherImpl.h
RSADigestEngine.h
RSAKey.h
RSAKeyImpl.h
X509Certificate.h
samples
src
testsuite
CMakeLists.txt
Crypto.progen
Crypto_VS90.sln
Crypto_VS90.vcproj
Crypto_vs140.sln
Crypto_vs140.vcxproj
Crypto_vs140.vcxproj.filters
Crypto_vs150.sln
Crypto_vs150.vcxproj
Crypto_vs150.vcxproj.filters
Crypto_vs160.sln
Crypto_vs160.vcxproj
Crypto_vs160.vcxproj.filters
Makefile
dependencies
Data
Encodings
Foundation
JSON
JWT
MongoDB
Net
NetSSL_OpenSSL
NetSSL_Win
PDF
PageCompiler
PocoDoc
ProGen
Redis
SevenZip
Util
XML
Zip
appveyor
build
cmake
contrib
doc
packaging
patches
release
travis
CHANGELOG
CMakeLists.txt
CODE_OF_CONDUCT.md
CONTRIBUTING.md
CONTRIBUTORS
LICENSE
Makefile
NEWS
README
README.md
VERSION
appveyor.yml
build_cmake.cmd
build_cmake.sh
build_vs140.cmd
build_vs150.cmd
build_vs160.cmd
buildwin.cmd
buildwin.ps1
components
configure
cppignore.lnx
cppignore.win
env.bat
env.sh
libversion
SimpleIni
Squirrel
TinyDir
CMakeLists.txt
.gitignore
.gitmodules
CMakeLists.txt
LICENSE
README.md
Switched to POCO library for unified platform/library interface. Deprecated the external module API. It was creating more problems than solving. Removed most built-in libraries in favor of system libraries for easier maintenance. Cleaned and secured code with help from static analyzers.
145 lines
3.0 KiB
C++
145 lines
3.0 KiB
C++
//
|
|
// KeyPair.h
|
|
//
|
|
// Library: Crypto
|
|
// Package: CryptoCore
|
|
// Module: KeyPair
|
|
//
|
|
// Definition of the KeyPair class.
|
|
//
|
|
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
|
// and Contributors.
|
|
//
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
//
|
|
|
|
|
|
#ifndef Crypto_KeyPair_INCLUDED
|
|
#define Crypto_KeyPair_INCLUDED
|
|
|
|
|
|
#include "Poco/Crypto/Crypto.h"
|
|
#include "Poco/Crypto/KeyPairImpl.h"
|
|
|
|
|
|
namespace Poco {
|
|
namespace Crypto {
|
|
|
|
|
|
class X509Certificate;
|
|
|
|
|
|
class Crypto_API KeyPair
|
|
/// This is a parent class for classes storing a key pair, consisting
|
|
/// of private and public key. Storage of the private key is optional.
|
|
///
|
|
/// If a private key is available, the KeyPair can be
|
|
/// used for decrypting data (encrypted with the public key)
|
|
/// or computing secure digital signatures.
|
|
{
|
|
public:
|
|
enum Type
|
|
{
|
|
KT_RSA = KeyPairImpl::KT_RSA_IMPL,
|
|
KT_EC = KeyPairImpl::KT_EC_IMPL
|
|
};
|
|
|
|
explicit KeyPair(KeyPairImpl::Ptr pKeyPairImpl = 0);
|
|
/// Extracts the RSA public key from the given certificate.
|
|
|
|
KeyPair(const KeyPair& other);
|
|
/// Copy constructor.
|
|
|
|
KeyPair(KeyPair&& other) noexcept;
|
|
/// Move constructor.
|
|
|
|
KeyPair& operator = (const KeyPair& other);
|
|
/// Assignment.
|
|
|
|
KeyPair& operator = (KeyPair&& other) noexcept;
|
|
/// Move assignment.
|
|
|
|
virtual ~KeyPair();
|
|
/// Destroys the KeyPair.
|
|
|
|
virtual int size() const;
|
|
/// Returns the RSA modulus size.
|
|
|
|
virtual void save(const std::string& publicKeyPairFile,
|
|
const std::string& privateKeyPairFile = "",
|
|
const std::string& privateKeyPairPassphrase = "") const;
|
|
/// Exports the public and private keys to the given files.
|
|
///
|
|
/// If an empty filename is specified, the corresponding key
|
|
/// is not exported.
|
|
|
|
virtual void save(std::ostream* pPublicKeyPairStream,
|
|
std::ostream* pPrivateKeyPairStream = 0,
|
|
const std::string& privateKeyPairPassphrase = "") const;
|
|
/// Exports the public and private key to the given streams.
|
|
///
|
|
/// If a null pointer is passed for a stream, the corresponding
|
|
/// key is not exported.
|
|
|
|
KeyPairImpl::Ptr impl() const;
|
|
/// Returns the impl object.
|
|
|
|
const std::string& name() const;
|
|
/// Returns key pair name
|
|
|
|
Type type() const;
|
|
/// Returns key pair type
|
|
|
|
private:
|
|
KeyPairImpl::Ptr _pImpl;
|
|
};
|
|
|
|
|
|
//
|
|
// inlines
|
|
//
|
|
inline int KeyPair::size() const
|
|
{
|
|
return _pImpl->size();
|
|
}
|
|
|
|
|
|
inline void KeyPair::save(const std::string& publicKeyFile,
|
|
const std::string& privateKeyFile,
|
|
const std::string& privateKeyPassphrase) const
|
|
{
|
|
_pImpl->save(publicKeyFile, privateKeyFile, privateKeyPassphrase);
|
|
}
|
|
|
|
|
|
inline void KeyPair::save(std::ostream* pPublicKeyStream,
|
|
std::ostream* pPrivateKeyStream,
|
|
const std::string& privateKeyPassphrase) const
|
|
{
|
|
_pImpl->save(pPublicKeyStream, pPrivateKeyStream, privateKeyPassphrase);
|
|
}
|
|
|
|
|
|
inline const std::string& KeyPair::name() const
|
|
{
|
|
return _pImpl->name();
|
|
}
|
|
|
|
|
|
inline KeyPairImpl::Ptr KeyPair::impl() const
|
|
{
|
|
return _pImpl;
|
|
}
|
|
|
|
|
|
inline KeyPair::Type KeyPair::type() const
|
|
{
|
|
return (KeyPair::Type)impl()->type();
|
|
}
|
|
|
|
|
|
} } // namespace Poco::Crypto
|
|
|
|
|
|
#endif // Crypto_KeyPair_INCLUDED
|