Cryptography

Detailed Description

Classes

class  CryptographyStreamConversionInterface
 
class  CryptoKeyInterface
 
class  CryptoKey
 

Typedefs

using BLOCK_CIPHER_CTR_CALLBACK = Delegate< void(Int block, Int blockSize, UChar *nonce)>
 

Enumerations

enum class  BLOCK_CIPHER_MODE : UInt64 {
  ECB ,
  CBC ,
  PCBC ,
  CFB ,
  OFB ,
  CTR ,
  KEEP_STATE
}
 

Functions

enum maxon::BLOCK_CIPHER_MODE UInt64 MAXON_ENUM_FLAGS (BLOCK_CIPHER_MODE)
 
Result< StringGetHashString (const BaseArray< UChar > &hashValue)
 
Result< StringGetPasswordHash (const String &password, const StreamConversionFactory &hashClass, const DataDictionary &settings=DataDictionary())
 
Result< StringGetPasswordHash (const Block< const Char > &password, const StreamConversionFactory &hashClass, const DataDictionary &settings=DataDictionary())
 
Result< Tuple< String, String > > HashPasswordWithSalt (const String &password, const StreamConversionFactory &hashClass=StreamConversions::HashSHA256())
 
Result< void > AddConversionTestSetting (MAXON_SOURCE_LOCATION_DECLARATION, BaseArray< DataDictionary > &resultArray, const Id &encoderId, const Id &decoderId, Int blockSizeBits, const void *key1, Int key1BitSize, const void *key2=nullptr, Int key2BitSize=0, UInt64 flags=0, BLOCK_CIPHER_CTR_CALLBACK &&callback=BLOCK_CIPHER_CTR_CALLBACK(), const Char *srcData=nullptr, const Char *compareData=nullptr)
 

Typedef Documentation

◆ BLOCK_CIPHER_CTR_CALLBACK

using BLOCK_CIPHER_CTR_CALLBACK = Delegate<void(Int block, Int blockSize, UChar* nonce)>

param[in] block The block number. param[in] blockSize The size in bytes. param[in] userData User data that was originally passed to the Encrypt and Decrypt function. param[out] nonce A buffer that is filled with the Nonce data. You may only write blockSize bytes.

Enumeration Type Documentation

◆ BLOCK_CIPHER_MODE

enum BLOCK_CIPHER_MODE : UInt64
strong

Block cipher modes. See documentation of the encryption method for details.

Enumerator
ECB 

Electronic codebook.

CBC 

Cipher-block chaining.

PCBC 

Propagating cipher-block chaining.

CFB 

Cipher feedback.

OFB 

Output feedback.

CTR 

Counter.

KEEP_STATE 

for CBC, PCBC, CFB, OFB: Store the current state in the instance. Otherwise the next Encrypt call will use the original initialization vector.

Function Documentation

◆ MAXON_ENUM_FLAGS()

enum maxon::BLOCK_CIPHER_MODE UInt64 maxon::MAXON_ENUM_FLAGS ( BLOCK_CIPHER_MODE  )

◆ GetHashString()

Result<String> maxon::GetHashString ( const BaseArray< UChar > &  hashValue)

Returns the hash value as a hexadecimal string. The length of the value depends on the algorithm.

Parameters
[in]hashValueThe input (byte) values.
Returns
The hexadecimal string.

◆ GetPasswordHash() [1/2]

Result<String> maxon::GetPasswordHash ( const String password,
const StreamConversionFactory hashClass,
const DataDictionary &  settings = DataDictionary() 
)

Returns the hash value string of a password.

Parameters
[in]passwordThe input password.
[in]hashClassThe algorithm to use, e.g. StreamConversions::HashMD5()
[in]settingsSettings for the hash algorithm which will be passed to the Init() function.
Returns
The hash value string.

◆ GetPasswordHash() [2/2]

Result<String> maxon::GetPasswordHash ( const Block< const Char > &  password,
const StreamConversionFactory hashClass,
const DataDictionary &  settings = DataDictionary() 
)

◆ HashPasswordWithSalt()

Result<Tuple<String, String> > maxon::HashPasswordWithSalt ( const String password,
const StreamConversionFactory hashClass = StreamConversions::HashSHA256() 
)

HashPasswdWithSalt creates a unique salt string and hashes the password together with the string hash(salt + password). To verify a password you need to store the salt and call "String hashedPasswd = GetPasswordHash(passwordSalt + passwd, StreamConversions::HashSHA256())" to get the hashed passwd.

Parameters
[in]passwordPassword to hash.
[in]hashClassHashClass to use.
Returns
Tuple<salt, passwordhash> if no error occurred.

◆ AddConversionTestSetting()

Result<void> maxon::AddConversionTestSetting ( MAXON_SOURCE_LOCATION_DECLARATION  ,
BaseArray< DataDictionary > &  resultArray,
const Id encoderId,
const Id decoderId,
Int  blockSizeBits,
const void *  key1,
Int  key1BitSize,
const void *  key2 = nullptr,
Int  key2BitSize = 0,
UInt64  flags = 0,
BLOCK_CIPHER_CTR_CALLBACK &&  callback = BLOCK_CIPHER_CTR_CALLBACK(),
const Char srcData = nullptr,
const Char compareData = nullptr 
)

Helper function to add crypto tests.