52 #ifndef __PCL_Cryptography_h
53 #define __PCL_Cryptography_h
58 #include <pcl/Diagnostics.h>
147 Update( data.Begin(), data.Size() );
157 DoFinalize( hash.
Begin() );
171 Update( data, length );
182 Hash( hash.
Begin(), data, length );
198 return Hash( data.Begin(), data.Size() );
277 void* m_context =
nullptr;
281 void DoFinalize(
void* hash )
override;
349 void* m_context =
nullptr;
353 void DoFinalize(
void* hash )
override;
421 void* m_context =
nullptr;
425 void DoFinalize(
void* hash )
override;
492 void* m_context =
nullptr;
496 void DoFinalize(
void* hash )
override;
563 void* m_context =
nullptr;
567 void DoFinalize(
void* hash )
override;
634 void* m_context =
nullptr;
638 void DoFinalize(
void* hash )
override;
674 switch ( algorithmName.Trimmed().CaseFolded().
Hash32() )
676 case 0x445dd715: m_hash =
new MD5;
break;
677 case 0x3cac24af: m_hash =
new SHA1;
break;
678 case 0x7e50b015: m_hash =
new SHA224;
break;
679 case 0xcbbce793: m_hash =
new SHA256;
break;
680 case 0x858a0d3d: m_hash =
new SHA384;
break;
681 case 0xb24dfd53: m_hash =
new SHA512;
break;
683 throw Error(
"CryptographicHashFactory: Unknown/unsupported algorithm \'" + algorithmName +
'\'' );
704 return m_hash->AlgorithmName();
713 return m_hash->HashLength();
721 m_hash->Initialize();
730 m_hash->Update( data, length );
737 void DoFinalize(
void* hash )
override
739 m_hash->DoFinalize( hash );
837 void Encrypt(
void* output,
const C& input )
const
839 Encrypt( output, input.Begin(), input.Size() );
863 Encrypt( output.
Begin(), input.Begin(), input.Size() );
884 void Decrypt(
void* output,
const C& input )
const
886 Decrypt( output, input.Begin(), input.Size() );
909 Decrypt( output.
Begin(), input.Begin(), input.Size() );
937 enum { key_length = 32, block_length = 16 };
990 for (
int i = 1; i < 20; ++i )
1093 void SetKey(
void* key );
String AlgorithmName() const override
void Decrypt(void *output, const void *input, size_type length) const override
AES256(const AES256 &)=default
size_type KeyLength() const override
uint8[block_length] block_type
void DecryptBlock(void *output, const void *input) const
void Encrypt(void *output, const void *input, size_type length) const override
void EncryptBlock(void *output, const void *input) const
uint8[key_length] key_type
A smart pointer with exclusive object ownership and optional automatic object destruction.
Abstract base class for cipher algorithm implementations.
virtual void Encrypt(void *output, const void *input, size_type length) const =0
virtual void Decrypt(void *output, const void *input, size_type length) const =0
ByteArray Decrypt(const C &input) const
void Encrypt(void *output, const C &input) const
virtual String AlgorithmName() const =0
void Decrypt(void *output, const C &input) const
Cipher(const Cipher &)=default
ByteArray Encrypt(const C &input) const
virtual size_type KeyLength() const =0
Selectable cryptographic hashing algorithm.
void Initialize() override
CryptographicHashFactory(const IsoString &algorithmName)
~CryptographicHashFactory() override
void Update(const void *data, size_type length) override
size_type HashLength() const override
String AlgorithmName() const override
Abstract base class for cryptographic hashing algorithm implementations.
virtual void DoFinalize(void *hash)=0
virtual String AlgorithmName() const =0
virtual ~CryptographicHash()
ByteArray Hash(const void *data, size_type length)
void UpdateWithContainer(const C &data)
ByteArray Hash(const C &data)
CryptographicHash()=default
virtual size_type HashLength() const =0
CryptographicHash(const CryptographicHash &)=delete
virtual void Update(const void *data, size_type length)=0
virtual void Initialize()=0
void Hash(uint8 *hash, const void *data, size_type length)
A simple exception with an associated error message.
void SecureFill(char c='\0') noexcept
uint32 Hash32(uint32 seed=0) const noexcept
Eight-bit string (ISO/IEC-8859-1 or UTF-8 string)
static IsoString ToHex(const void *data, size_type length)
Implementation of the MD5 cryptographic hashing algorithm.
String AlgorithmName() const override
size_type HashLength() const override
void Update(const void *data, size_type length) override
void Initialize() override
Implementation of the SHA-1 cryptographic hashing algorithm.
size_type HashLength() const override
void Initialize() override
String AlgorithmName() const override
void Update(const void *data, size_type length) override
Implementation of the SHA-224 cryptographic hashing algorithm.
size_type HashLength() const override
void Initialize() override
void Update(const void *data, size_type length) override
String AlgorithmName() const override
Implementation of the SHA-256 cryptographic hashing algorithm.
void Initialize() override
void Update(const void *data, size_type length) override
size_type HashLength() const override
String AlgorithmName() const override
Implementation of the SHA-384 cryptographic hashing algorithm.
String AlgorithmName() const override
void Update(const void *data, size_type length) override
void Initialize() override
size_type HashLength() const override
Implementation of the SHA-512 cryptographic hashing algorithm.
void Initialize() override
size_type HashLength() const override
void Update(const void *data, size_type length) override
String AlgorithmName() const override