| IGLib 1.7.2 The IGLib base library for development of numerical, technical and business applications.

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
Public Member Functions | Protected Member Functions | Protected Attributes | Properties | Private Attributes | List of all members
IG.Crypto.PasswordAlgorithmBase Class Referenceabstract

Base class for algorithms that generate passwords, encryption initialization vectors, and salts from the specified keys/passwords and salts. More...

Inheritance diagram for IG.Crypto.PasswordAlgorithmBase:
[legend]

## Public Member Functions
virtual void | Init (bool publicParameters=false)
| Clears all data and resets the passwords/keys/salts generation algorithm. More...
virtual void | Reset ()
| Resets the password/key generator (Clears its parameters and sets the initialization flag IsInitialized to false). More...
virtual void | Init (string password, byte[] salt, int numIterations)
virtual void | Init (byte[] password, byte[] salt, int numIterations)
string | GetPasswordString ()
| If the generator has public parameters (flag IsParametersPublic) then the password string is returned. Otherwise, an InvalidOperationException is thrown. More...
byte[] | GetPasswordBytes ()
| If the generator has public parameters (flag IsParametersPublic) then the password in form of a byte array is returned. Otherwise, an InvalidOperationException is thrown. More...
string | GetSaltString ()
| If the generator has public parameters (flag IsParametersPublic) then the salt string is returned. Otherwise, an InvalidOperationException is thrown. More...
byte[] | GetSaltBytes ()
| If the generator has public parameters (flag IsParametersPublic) then the salt in form of a byte array is returned. Otherwise, an InvalidOperationException is thrown. More...
int | GetNuIterations ()
| If the generator has public parameters (flag IsParametersPublic) then the number of iterations is returned. Otherwise, an InvalidOperationException is thrown. More...
byte[] | GetLastGeneratedBytes ()
| If the generator has public parameters (flag IsParametersPublic) then the last generated key in form of a byte array is returned. Otherwise, an InvalidOperationException is thrown. More...
int | GetNuGenerations ()
| Returns the number of keys (byte sequences) generated until now. More...
void | GetBytes (int numBytes, ref byte[] outputBytes)
| Creates and stores the next generated key of the specified length. More...
byte[] | GetBytes (int numBytes)
| Creates and returns the next generated key of the specified length by calling GetBytes(int, ref byte[]). More...

## Protected Member Functions
| PasswordAlgorithmBase (bool publicParameters=false)
abstract void | InitializeExternalAlgorithm ()
| Initializes eventual external algorithm used as proxy object to perform operations. More...
abstract void | ClearExternalAlgorithm ()
| Clears eventual external algorithm used as proxy object to perform operations. More...
abstract void | GetBytesInternal (int numBytes, ref byte[] outputBytes)
| Returns the next generated key of the specified length. More...

## Protected Attributes
int | _numIterations = 0
int | _numGenerations = 0

## Properties
bool | IsParametersPublic`[get, protected set]`
| Flag that specifies whether initialization parameters of the algorithm can be queried or not. More...
bool | IsInitialized`[get, set]`
| Flag that specifies whether the algorithm has been initialized. More...
string | PasswordString`[get, set]`
| Password, in form of string, to be used in generation of keys, initialization vectors, etc. More...
byte[] | PasswordBytes`[get, set]`
| Password, in form of byte array, to be used in generation of keys, initialization vectors, etc. More...
string | SaltString`[get, set]`
| Salt, in form of byte array, to be used in generation of keys, initialization vectors, etc. More...
byte[] | SaltBytes`[get, set]`
| Salt, in form of byte array, to be used in generation of keys, initialization vectors, etc. More...
int | NumIterations`[get, set]`
| Number of iteration used when generating keys. More...
byte[] | LastGeneratedBytes`[get, set]`
| Last value of the generated bytes. More...
int | NumGenerations`[get, set]`
| Number of generated keys (byte sequences) up to now. More...

## Private Attributes
bool | _isPublicParameters = false
bool | _isInitialized = false
string | _passwordString = null
byte[] | _passwordBytes = null
string | _saltString = null
byte[] | _saltBytes = null
byte[] | _lastGeneratedBytes = null

## Detailed Description

Base class for algorithms that generate passwords, encryption initialization vectors, and salts from the specified keys/passwords and salts.

Classes derived from this class also serve for unification of behavior of classes such as System.Security.Cryptography.PasswordDeriveBytes and System.Security.Cryptography.Rfc2898DeriveBytes

Derived classes must have a default constructor and a constructor with a flag specifying whether initialization parameters are public. Initialization must be performed by one of the Init(...) functions.

Any concrete password generator class must be first initialized with a key or password and a salt.

After initialization, each consecutive call to GetBytes() creates an unique key that is derived from the key and salt provided at initialization (except the PasswordAlgorithmNone class).

## Constructor & Destructor Documentation

IG.Crypto.PasswordAlgorithmBase.PasswordAlgorithmBase | ( | bool | publicParameters = `false` | ) |
| inline protected

## Member Function Documentation

virtual void IG.Crypto.PasswordAlgorithmBase.Init | ( | bool | publicParameters = `false` | ) |
| inline virtual

Clears all data and resets the passwords/keys/salts generation algorithm.

Parameters

  publicParameters | If true then parameters with which this object has been initialized can be queried.

Referenced by IG.Crypto.CryptoManager.AppKeyGenerationAll(), IG.Script.ScriptAppBase.CryptoFunctionTimeKeyGeneration_OLD_TO_DELETE_LATER(), and IG.Crypto.UtilCrypto.PrepareSymmetricAllgorithmBasic().

virtual void IG.Crypto.PasswordAlgorithmBase.Reset | ( |  | ) |
| inline virtual

Resets the password/key generator (Clears its parameters and sets the initialization flag IsInitialized to false).

virtual void IG.Crypto.PasswordAlgorithmBase.Init | ( | string | password,
|  | byte[] | salt,
|  | int | numIterations
| ) |  |
| inline virtual

virtual void IG.Crypto.PasswordAlgorithmBase.Init | ( | byte[] | password,
|  | byte[] | salt,
|  | int | numIterations
| ) |  |
| inline virtual

string IG.Crypto.PasswordAlgorithmBase.GetPasswordString | ( |  | ) |
| inline

If the generator has public parameters (flag IsParametersPublic) then the password string is returned. Otherwise, an InvalidOperationException is thrown.

Returns

byte [] IG.Crypto.PasswordAlgorithmBase.GetPasswordBytes | ( |  | ) |
| inline

If the generator has public parameters (flag IsParametersPublic) then the password in form of a byte array is returned. Otherwise, an InvalidOperationException is thrown.

string IG.Crypto.PasswordAlgorithmBase.GetSaltString | ( |  | ) |
| inline

If the generator has public parameters (flag IsParametersPublic) then the salt string is returned. Otherwise, an InvalidOperationException is thrown.

byte [] IG.Crypto.PasswordAlgorithmBase.GetSaltBytes | ( |  | ) |
| inline

If the generator has public parameters (flag IsParametersPublic) then the salt in form of a byte array is returned. Otherwise, an InvalidOperationException is thrown.

int IG.Crypto.PasswordAlgorithmBase.GetNuIterations | ( |  | ) |
| inline

If the generator has public parameters (flag IsParametersPublic) then the number of iterations is returned. Otherwise, an InvalidOperationException is thrown.

byte [] IG.Crypto.PasswordAlgorithmBase.GetLastGeneratedBytes | ( |  | ) |
| inline

If the generator has public parameters (flag IsParametersPublic) then the last generated key in form of a byte array is returned. Otherwise, an InvalidOperationException is thrown.

int IG.Crypto.PasswordAlgorithmBase.GetNuGenerations | ( |  | ) |
| inline

Returns the number of keys (byte sequences) generated until now.

abstract void IG.Crypto.PasswordAlgorithmBase.InitializeExternalAlgorithm | ( |  | ) |
| protected pure virtual

Initializes eventual external algorithm used as proxy object to perform operations.

Implemented in IG.Crypto.PasswordAlgorithmNone, IG.Crypto.PasswordAlgorithmDeriveBytes, and IG.Crypto.PasswordAlgorithmRfc2898.

abstract void IG.Crypto.PasswordAlgorithmBase.ClearExternalAlgorithm | ( |  | ) |
| protected pure virtual

Clears eventual external algorithm used as proxy object to perform operations.

Implemented in IG.Crypto.PasswordAlgorithmNone, IG.Crypto.PasswordAlgorithmDeriveBytes, and IG.Crypto.PasswordAlgorithmRfc2898.

abstract void IG.Crypto.PasswordAlgorithmBase.GetBytesInternal | ( | int | numBytes,
|  | ref byte[] | outputBytes
| ) |  |
| protected pure virtual

Returns the next generated key of the specified length.

In principle, the successive calls will return different and uncorrelated byte sequences.

Parameters

  numBytes | Number of bytes in the returned array.
  outputBytes | Reference to a byte array where generated bytes will be stored.

Implemented in IG.Crypto.PasswordAlgorithmNone, IG.Crypto.PasswordAlgorithmDeriveBytes, and IG.Crypto.PasswordAlgorithmRfc2898.

void IG.Crypto.PasswordAlgorithmBase.GetBytes | ( | int | numBytes,
|  | ref byte[] | outputBytes
| ) |  |
| inline

Creates and stores the next generated key of the specified length.

In principle, the successive calls will return different and uncorrelated byte sequences.

Parameters

  numBytes | Number of bytes in the returned array.
  outputBytes | Reference to a byte array where generated bytes will be stored.

Referenced by IG.Script.ScriptAppBase.CryptoFunctionTimeKeyGeneration_OLD_TO_DELETE_LATER(), and IG.Crypto.UtilCrypto.PrepareSymmetricAllgorithmBasic().

byte [] IG.Crypto.PasswordAlgorithmBase.GetBytes | ( | int | numBytes | ) |
| inline

Creates and returns the next generated key of the specified length by calling GetBytes(int, ref byte[]).

In principle, the successive calls will return different and uncorrelated byte sequences.

Parameters

  numBytes | Number of bytes in the returned array.

## Member Data Documentation

bool IG.Crypto.PasswordAlgorithmBase._isPublicParameters = false
| private

bool IG.Crypto.PasswordAlgorithmBase._isInitialized = false
| private

string IG.Crypto.PasswordAlgorithmBase._passwordString = null
| private

byte [] IG.Crypto.PasswordAlgorithmBase._passwordBytes = null
| private

string IG.Crypto.PasswordAlgorithmBase._saltString = null
| private

byte [] IG.Crypto.PasswordAlgorithmBase._saltBytes = null
| private

int IG.Crypto.PasswordAlgorithmBase._numIterations = 0
| protected

byte [] IG.Crypto.PasswordAlgorithmBase._lastGeneratedBytes = null
| private

int IG.Crypto.PasswordAlgorithmBase._numGenerations = 0
| protected

## Property Documentation

bool IG.Crypto.PasswordAlgorithmBase.IsParametersPublic
| get protected set

Flag that specifies whether initialization parameters of the algorithm can be queried or not.

Making parameters inaccessible prevents developer's errors where they store secret parameters in places they should not be stored.

bool IG.Crypto.PasswordAlgorithmBase.IsInitialized
| get set

Flag that specifies whether the algorithm has been initialized.

This means that it has been provided with a key and a salt and is able do generate consecuttive passwords).

string IG.Crypto.PasswordAlgorithmBase.PasswordString
| get set protected

Password, in form of string, to be used in generation of keys, initialization vectors, etc.

byte [] IG.Crypto.PasswordAlgorithmBase.PasswordBytes
| get set protected

Password, in form of byte array, to be used in generation of keys, initialization vectors, etc.

string IG.Crypto.PasswordAlgorithmBase.SaltString
| get set protected

Salt, in form of byte array, to be used in generation of keys, initialization vectors, etc.

byte [] IG.Crypto.PasswordAlgorithmBase.SaltBytes
| get set protected

Salt, in form of byte array, to be used in generation of keys, initialization vectors, etc.

int IG.Crypto.PasswordAlgorithmBase.NumIterations
| get set protected

Number of iteration used when generating keys.

Must be at least 1.

byte [] IG.Crypto.PasswordAlgorithmBase.LastGeneratedBytes
| get set protected

Last value of the generated bytes.

int IG.Crypto.PasswordAlgorithmBase.NumGenerations
| get set protected

Number of generated keys (byte sequences) up to now.

The documentation for this class was generated from the following file:

- igbase/utilities/UtilCryptoAux.cs