IGLib
1.7.2
The IGLib base library for development of numerical, technical and business applications.
|
Base class for algorithms that generate passwords, encryption initialization vectors, and salts from the specified keys/passwords and salts. More...
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 |
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).
|
inlineprotected |
|
inlinevirtual |
Clears all data and resets the passwords/keys/salts generation algorithm.
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().
|
inlinevirtual |
Resets the password/key generator (Clears its parameters and sets the initialization flag IsInitialized to false).
|
inlinevirtual |
|
inlinevirtual |
|
inline |
If the generator has public parameters (flag IsParametersPublic) then the password string is returned. Otherwise, an InvalidOperationException is thrown.
|
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.
|
inline |
If the generator has public parameters (flag IsParametersPublic) then the salt string is returned. Otherwise, an InvalidOperationException is thrown.
|
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.
|
inline |
If the generator has public parameters (flag IsParametersPublic) then the number of iterations is returned. Otherwise, an InvalidOperationException is thrown.
|
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.
|
inline |
Returns the number of keys (byte sequences) generated until now.
|
protectedpure virtual |
Initializes eventual external algorithm used as proxy object to perform operations.
Implemented in IG.Crypto.PasswordAlgorithmNone, IG.Crypto.PasswordAlgorithmDeriveBytes, and IG.Crypto.PasswordAlgorithmRfc2898.
|
protectedpure virtual |
Clears eventual external algorithm used as proxy object to perform operations.
Implemented in IG.Crypto.PasswordAlgorithmNone, IG.Crypto.PasswordAlgorithmDeriveBytes, and IG.Crypto.PasswordAlgorithmRfc2898.
|
protectedpure virtual |
Returns the next generated key of the specified length.
In principle, the successive calls will return different and uncorrelated byte sequences.
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.
|
inline |
Creates and stores the next generated key of the specified length.
In principle, the successive calls will return different and uncorrelated byte sequences.
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().
|
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.
numBytes | Number of bytes in the returned array. |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
protected |
|
private |
|
protected |
|
getprotected 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.
|
getset |
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).
|
getsetprotected |
Password, in form of string, to be used in generation of keys, initialization vectors, etc.
|
getsetprotected |
Password, in form of byte array, to be used in generation of keys, initialization vectors, etc.
|
getsetprotected |
Salt, in form of byte array, to be used in generation of keys, initialization vectors, etc.
|
getsetprotected |
Salt, in form of byte array, to be used in generation of keys, initialization vectors, etc.
|
getsetprotected |
Number of iteration used when generating keys.
Must be at least 1.
|
getsetprotected |
Last value of the generated bytes.
|
getsetprotected |
Number of generated keys (byte sequences) up to now.