mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-28 19:51:58 +01:00
code cleanup; fix move ctors and assignment
This commit is contained in:
@@ -38,7 +38,7 @@ class Crypto_API CipherKey
|
||||
/// file.
|
||||
///
|
||||
/// To create a key using a human-readable password
|
||||
/// string, use the following code. We create a AES Cipher and
|
||||
/// string, use the following code. We create a AES Cipher and
|
||||
/// use a salt value to make the key more robust:
|
||||
///
|
||||
/// std::string password = "secret";
|
||||
@@ -68,16 +68,16 @@ public:
|
||||
/// an iteration count of at least 1000.
|
||||
};
|
||||
|
||||
CipherKey(const std::string& name,
|
||||
const std::string& passphrase,
|
||||
CipherKey(const std::string& name,
|
||||
const std::string& passphrase,
|
||||
const std::string& salt = "",
|
||||
int iterationCount = DEFAULT_ITERATION_COUNT,
|
||||
const std::string& digest = "md5");
|
||||
/// Creates a new CipherKeyImpl object using the given
|
||||
/// cipher name, passphrase, salt value, iteration count and digest.
|
||||
|
||||
CipherKey(const std::string& name,
|
||||
const ByteVec& key,
|
||||
CipherKey(const std::string& name,
|
||||
const ByteVec& key,
|
||||
const ByteVec& iv);
|
||||
/// Creates a new CipherKeyImpl object using the given cipher
|
||||
/// name, key and initialization vector (IV).
|
||||
@@ -87,12 +87,24 @@ public:
|
||||
/// a custom IV size.
|
||||
|
||||
CipherKey(const std::string& name);
|
||||
/// Creates a new CipherKeyImpl object. Autoinitializes key and
|
||||
/// Creates a new CipherKeyImpl object. Autoinitializes key and
|
||||
/// initialization vector.
|
||||
|
||||
CipherKey(const CipherKey& other);
|
||||
/// Copy constructor.
|
||||
|
||||
CipherKey(CipherKey&& other) noexcept;
|
||||
/// Copy constructor.
|
||||
|
||||
~CipherKey();
|
||||
/// Destroys the CipherKeyImpl.
|
||||
|
||||
CipherKey& operator = (const CipherKey& other);
|
||||
/// Assignment.
|
||||
|
||||
CipherKey& operator = (CipherKey&& other) noexcept;
|
||||
/// Move assignment.
|
||||
|
||||
const std::string& name() const;
|
||||
/// Returns the name of the Cipher.
|
||||
|
||||
@@ -107,7 +119,7 @@ public:
|
||||
|
||||
Mode mode() const;
|
||||
/// Returns the Cipher's mode of operation.
|
||||
|
||||
|
||||
const ByteVec& getKey() const;
|
||||
/// Returns the key for the Cipher.
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ class X509Certificate;
|
||||
class PKCS12Container;
|
||||
|
||||
|
||||
class Crypto_API ECKey : public KeyPair
|
||||
class Crypto_API ECKey: public KeyPair
|
||||
/// This class stores an EC key pair, consisting
|
||||
/// of private and public key. Storage of the private
|
||||
/// key is optional.
|
||||
@@ -73,9 +73,21 @@ public:
|
||||
/// If a private key is specified, you don't need to specify a public key file.
|
||||
/// OpenSSL will auto-create the public key from the private key.
|
||||
|
||||
ECKey(const ECKey& key);
|
||||
/// Creates the ECKey by copying another one.
|
||||
|
||||
ECKey(ECKey&& key) noexcept;
|
||||
/// Creates the ECKey by moving another one.
|
||||
|
||||
~ECKey();
|
||||
/// Destroys the ECKey.
|
||||
|
||||
ECKey& operator = (const ECKey& other);
|
||||
/// Assignment.
|
||||
|
||||
ECKey& operator = (ECKey&& other) noexcept;
|
||||
/// Move assignment.
|
||||
|
||||
ECKeyImpl::Ptr impl() const;
|
||||
/// Returns the impl object.
|
||||
|
||||
@@ -97,9 +109,6 @@ public:
|
||||
static bool hasCurve(const std::string& name);
|
||||
/// Returns true if the named curve is found,
|
||||
/// false otherwise.
|
||||
|
||||
private:
|
||||
ECKeyImpl::Ptr _pImpl;
|
||||
};
|
||||
|
||||
|
||||
@@ -108,7 +117,7 @@ private:
|
||||
//
|
||||
inline ECKeyImpl::Ptr ECKey::impl() const
|
||||
{
|
||||
return _pImpl;
|
||||
return KeyPair::impl().cast<ECKeyImpl>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
//
|
||||
// KeyPair.h
|
||||
//
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: CryptoCore
|
||||
// Module: KeyPair
|
||||
@@ -48,6 +47,18 @@ public:
|
||||
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.
|
||||
|
||||
@@ -57,7 +68,7 @@ public:
|
||||
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.
|
||||
/// Exports the public and private keys to the given files.
|
||||
///
|
||||
/// If an empty filename is specified, the corresponding key
|
||||
/// is not exported.
|
||||
@@ -78,7 +89,7 @@ public:
|
||||
|
||||
Type type() const;
|
||||
/// Returns key pair type
|
||||
|
||||
|
||||
private:
|
||||
KeyPairImpl::Ptr _pImpl;
|
||||
};
|
||||
@@ -87,7 +98,6 @@ private:
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
|
||||
inline int KeyPair::size() const
|
||||
{
|
||||
return _pImpl->size();
|
||||
@@ -115,6 +125,7 @@ inline const std::string& KeyPair::name() const
|
||||
return _pImpl->name();
|
||||
}
|
||||
|
||||
|
||||
inline KeyPairImpl::Ptr KeyPair::impl() const
|
||||
{
|
||||
return _pImpl;
|
||||
|
||||
@@ -31,7 +31,7 @@ class X509Certificate;
|
||||
class PKCS12Container;
|
||||
|
||||
|
||||
class Crypto_API RSAKey : public KeyPair
|
||||
class Crypto_API RSAKey: public KeyPair
|
||||
/// This class stores an RSA key pair, consisting
|
||||
/// of private and public key. Storage of the private
|
||||
/// key is optional.
|
||||
@@ -90,9 +90,21 @@ public:
|
||||
/// If a private key is specified, you don't need to specify a public key file.
|
||||
/// OpenSSL will auto-create the public key from the private key.
|
||||
|
||||
RSAKey(const RSAKey& other);
|
||||
/// Copy constructor.
|
||||
|
||||
RSAKey(RSAKey&& other) noexcept;
|
||||
/// Move constructor.
|
||||
|
||||
~RSAKey();
|
||||
/// Destroys the RSAKey.
|
||||
|
||||
RSAKey& operator = (const RSAKey& other);
|
||||
/// Assignment.
|
||||
|
||||
RSAKey& operator = (RSAKey&& other) noexcept;
|
||||
/// Move assignment.
|
||||
|
||||
RSAKeyImpl::ByteVec modulus() const;
|
||||
/// Returns the RSA modulus.
|
||||
|
||||
@@ -104,9 +116,6 @@ public:
|
||||
|
||||
RSAKeyImpl::Ptr impl() const;
|
||||
/// Returns the impl object.
|
||||
|
||||
private:
|
||||
RSAKeyImpl::Ptr _pImpl;
|
||||
};
|
||||
|
||||
|
||||
@@ -115,7 +124,7 @@ private:
|
||||
//
|
||||
inline RSAKeyImpl::Ptr RSAKey::impl() const
|
||||
{
|
||||
return _pImpl;
|
||||
return KeyPair::impl().cast<RSAKeyImpl>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user