IGLib
1.7.2
The IGLib base library for development of numerical, technical and business applications.
|
Basic Cryptographic utilities. More...
Static Public Member Functions | |
static PasswordAlgorithmType[] | GetPasswordAlgorithmTypes () |
Returns all password algorithm types contained in the enumeration PasswordAlgorithmType More... | |
static PasswordAlgorithmType | GetPasswordAlgorithmType (string typeString) |
Returns a PasswordAlgorithmType value corresponding to the specified string representation. More... | |
static PasswordAlgorithmType | GetPasswordAlgorithmType (PasswordAlgorithmBase algorithmObject) |
Returns the password generation algorithm type, i.e. an enumeration of type PasswordAlgorithmType, for the specified password generation algorithm object. More... | |
static string | PasswordAlgorithmTypeToString (PasswordAlgorithmType passwordAlgorithmType) |
Returns standard string representation of the specified password generation algoithm. More... | |
static IG.Crypto.PasswordAlgorithmBase | GetPasswordAlgorithm (PasswordAlgorithmType algorithmType) |
Returns the appropriate password generation algorithm according to the specified algorithm type, or null if the type is not recognized or the method is not implemented for that type. More... | |
static bool | IsCorrectPasswordAlgorithm (DeriveBytes algorithm, PasswordAlgorithmType algorithmType) |
Returns true if the specified password generation algorithm corresponds the type specification, false otherwise. More... | |
static string | CreateRandomPassword (int PasswordLength, string allowedChars=null) |
Creates and returns a random password consisting of only allowed characters from the specified string. More... | |
static void | GetRandomBytes (byte[] byteArray) |
Fills the specified byte array with a cryptographically strong sequence of random bytes. More... | |
static void | GetRandomBytes (ref byte[] byteArray, int numBytes) |
Fills the specified byte array with a specified number of cryptographically strong random bytes. More... | |
static byte[] | GetRandomBytes (int numBytes) |
Creates and returns an array of cryptographically strong random bytes of the specified size. More... | |
static int | GetHashLengthBytes (HashType hashType) |
Returns length of the hashRet value, in bytes, for the specified hashRet algorithm. More... | |
static int | GetHashLengthHex (HashType hashType) |
Returns length of the HEXADECIMAL hashRet string for the specified hashRet algorithm. More... | |
static HashType[] | GetHashTypes () |
Returns all hashing algorithm types contained in the enumeration HashType More... | |
static HashType | GetHashType (string typeString) |
Returns a HashType value corresponding to the specified string representation. More... | |
static HashType | GetHashType (HashAlgorithm algorithmObject) |
Returns the hashing algorithm type, i.e. an enumeration of type HashType, for the specified hashing algorithm object. More... | |
static string | HashTypeToString (HashType hashType) |
Returns standard string representation of the specified hashRet type. More... | |
static HashAlgorithm | GetHashAlgorithm (HashType hashType) |
Returns the appropriate hashRet algorithm according to the specified hashRet type, or null if the type is not recognized or the method is not implemented for that type. More... | |
static bool | IsCorrectHashAlgorithm (HashAlgorithm algorithm, HashType algorithmType) |
Returns true if the specified cryptographic hashRet algorithm corresponds the type specification, false otherwise. More... | |
static void | ParseHashFile (string filePath, ref List< string[]> hashList) |
Parses the file containing hashRet values of one or more files, and adds the parsed pairs {hashRet, inputFilePath} to the specified list. More... | |
static void | ParseHashFileString (string str, ref List< string[]> hashList) |
Parses the string containing hashRet values of one or more files, and adds the parsed pairs {hashRet, inputFilePath} to the specified list. More... | |
static byte[] | GetHashBytes (byte[] bytesToHash, HashType hashType, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the hashRet (in form of byte array) of the specified kind of the specified byte array. More... | |
static string | GetHashHex (byte[] bytesToHash, HashType hashType, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the hashRet string of the specified kind of the specified byte array. More... | |
static string | GetHashMd5Hex (byte[] bytesToHash) |
Computes and returns the MD5 hashRet string of the specified array of bytes. More... | |
static string | GetHashSha1Hex (byte[] bytesToHash) |
Computes and returns the SHA1 hashRet string of the specified array of bytes. More... | |
static string | GetHashSha256Hex (byte[] bytesToHash) |
Computes and returns the SHA256 hashRet string of the specified array of bytes. More... | |
static string | GetHashSha512Hex (byte[] bytesToHash) |
Computes and returns the SHA512 hashRet string of the specified array of bytes. More... | |
static bool | CheckHashHex (byte[] bytesToCheck, string hashValue, HashType hashAlgorithmType) |
Chechs the specified type of hashRet value of a byte array. More... | |
static HashType | CheckHashSupportedTypesHex (byte[] bytesToCheck, string hashValue) |
Chechs all supported types of hashRet value of a string. More... | |
static byte[] | GetStringHashBytes (string stringToHash, HashType hashType=HashType.Default, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the hashRet string of the specified kind of the specified string. More... | |
static string | GetStringHashHex (string stringToHash, HashType hashType=HashType.Default, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the hashRet string of the specified kind of the specified string. More... | |
static string | GetStringHashMd5Hex (string stringToHash) |
Computes and returns the MD5 hashRet string of the specified string. More... | |
static string | GetStringHashSha1Hex (string stringToHash) |
Computes and returns the SHA1 hashRet string of the specified string. More... | |
static string | GetStringHashSha256Hex (string stringToHash) |
Computes and returns the SHA256 hashRet string of the specified string. More... | |
static string | GetStringHashSha512Hex (string stringToHash) |
Computes and returns the SHA512 hashRet string of the specified string. More... | |
static byte[] | GetStringSaltedHashBytes (string stringToHash, HashType hashType, string salt, int numIterations=0, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the salted hashRet (in form of byte array) of the specified kind of the specified string, with the specified number of repetitions of the salted hashing algoriithm. More... | |
static string | GetStringSaltedHash (string stringToHash, HashType hashType, string salt, int numIterations=0, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the salted hashRet of the specified kind of the specified string, with the specified number of repetitions of the salted hashing algoriithm. More... | |
static string | GetStringSaltedHashMd5Hex (string stringToHash, string salt, int numIterations=0) |
Computes and returns the MD5 salted hashRet of the specified string, with the specified number of repetitions of the salted hashing algoriithm. More... | |
static string | GetStringSaltedHashSha1Hex (string stringToHash, string salt, int numIterations=0) |
Computes and returns the SHA1 salted hashRet of the specified string, with the specified number of repetitions of the salted hashing algoriithm. More... | |
static string | GetStringSaltedHashSha256Hex (string stringToHash, string salt, int numIterations=0) |
Computes and returns the SHA-256 salted hashRet of the specified string, with the specified number of repetitions of the salted hashing algoriithm. More... | |
static string | GetStringSaltedHashSha512Hex (string stringToHash, string salt, int numIterations=0) |
Computes and returns the SHA-512 salted hashRet of the specified string, with the specified number of repetitions of the salted hashing algoriithm. More... | |
static bool | CheckStringHashHex (string stringToCheck, string hashValue, HashType hashAlgorithmType) |
Chechs the specified type of hashRet value of a string. More... | |
static HashType | CheckStringHashSupportedTypesHex (string stringToCheck, string hashValue) |
Chechs all supported types of hashRet value of a string. More... | |
static bool | CheckStringHashMd5Hex (string stringToCheck, string hashValue) |
Checks whether the specified MD5 hashRet value matches the actual hashRet value of the specified string. More... | |
static bool | CheckStringHashSha1Hex (string stringToCheck, string hashValue) |
Checks whether the specified SHA-1 hashRet value matches the actual hashRet value of the specified string. More... | |
static bool | CheckStringHashSha256Hex (string stringToCheck, string hashValue) |
Checks whether the specified SHA-256 hashRet value matches the actual hashRet value of the specified string. More... | |
static bool | CheckStringHashSha512Hex (string stringToCheck, string hashValue) |
Checks whether the specified SHA-512 hashRet value matches the actual hashRet value of the specified string. More... | |
static byte[] | GetFileHashBytes (string filePath, HashType hashType, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the hashRet (in form of byte array) of specified type of the specified stream. More... | |
static string | GetFileHashHex (string filePath, HashType hashType, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the hashRet string of specified type of the specified stream. More... | |
static string | GetFileHashMd5Hex (string filePath, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the MD5 hashRet string of the specified stream. More... | |
static string | GetFileHashSha1Hex (string filePath, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the SHA1 hashRet string of the specified stream. More... | |
static string | GetFileHashSha256Hex (string filePath, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the SHA256 hashRet string of the specified stream. More... | |
static string | GetFileHashSha512Hex (string filePath, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the SHA512 hashRet string of the specified stream. More... | |
static byte[] | GetHashBytes (Stream stream, HashType hashType, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the hashRet (in form of byte array) of specified type of the specified stream. More... | |
static string | GetHashHex (Stream stream, HashType hashType, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the hexadecimal hashRet string of specified type of the specified stream. More... | |
static string | GetHashMd5Hex (Stream stream, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the MD5 hashRet string of the specified stream. More... | |
static string | GetHashSha1Hex (Stream stream, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the SHA1 hashRet string of the specified stream. More... | |
static string | GetHashSha256Hex (Stream stream, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the SHA256 hashRet string of the specified stream. More... | |
static string | GetHashSha512Hex (Stream stream, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the SHA512 hashRet string of the specified stream. More... | |
static bool | CheckFileHashHex (string filePath, string hashValue, HashType hashType, HashAlgorithm cryptoAlgorithm=null) |
Chechs the specified type of hashRet value of a file. More... | |
static HashType | CheckFileHashSupportedTypesHex (string filePath, string hashValue) |
Chechs all supported types of hashRet value of a file. More... | |
static bool | CheckFileHashMd5Hex (string filePath, string hashValue) |
Checks whether the specified MD5 hashRet value matches the actual hashRet value of the specified file. More... | |
static bool | CheckFileHashSha1Hex (string filePath, string hashValue) |
Checks whether the specified SHA-1 hashRet value matches the actual hashRet value of the specified file. More... | |
static bool | CheckFileHashSha256Hex (string filePath, string hashValue) |
Checks whether the specified SHA-256 hashRet value matches the actual hashRet value of the specified file. More... | |
static bool | CheckFileHashSha512Hex (string filePath, string hashValue) |
Checks whether the specified SHA-512 hashRet value matches the actual hashRet value of the specified file. More... | |
static SymmetricAlgorithmType[] | GetSymmetricAlgorithmTypes () |
Returns all symmetric encryption algorithm types contained in the enumeration SymmetricAlgorithmType More... | |
static SymmetricAlgorithmType | GetSymmetricAlgorithmType (string typeString) |
Returns the SymmetricAlgorithmType value corresponding to the specified string. More... | |
static SymmetricAlgorithmType | GetSymmetricAlgorithmType (SymmetricAlgorithm algorithmObject) |
Returns the symmetric encryption algorithm type, i.e. an enumeration of type SymmetricAlgorithmType, for the specified symmetric encryption algorithm object. More... | |
static string | SymmetricAlgorithmTypeToString (SymmetricAlgorithmType algorithmType) |
Returns standard string representation of the specified symmetric encryption algorithm type. More... | |
static SymmetricAlgorithm | GetSymmetricEncryptionAlgorithm (SymmetricAlgorithmType algorithmType) |
Returns the appropriate symmetric encryption algorithm according to the specified hashRet type, or null if the type is not recognized or the method is not implemented for that type. More... | |
static bool | IsCorrectSymmetricEncryptionAlgorithm (SymmetricAlgorithm algorithm, SymmetricAlgorithmType algorithmType) |
Returns true if the specified symmetric encryption algorithm corresponds the type specification, false otherwise. More... | |
static byte[] | PadToAlgorithmBlocksizeCyclic (byte[] byteArray, int blockSize, bool truncateIfLarger=false) |
For the specified symmetric encryption algorithm, this function takes the specified byte array and checks if the array is of valid size. If yes then the unmodified initialization array is returned, otherwise the modified array that fits the required block size is returned (i.e. has integer number of blocks). More... | |
static byte[] | PadToAlgorithmBlocksizeZero (byte[] byteArray, int blockSize, bool truncateIfLarger=false) |
For the specified symmetric encryption algorithm, this function takes the specified byte array and checks if the array is of valid size. If yes then the unmodified initialization array is returned, otherwise the modified array that fits the required block size is returned (i.e. has integer number of blocks). More... | |
static byte[] | PadToSymmetricAlgorithmBlocksizeCyclic (byte[] byteArray, SymmetricAlgorithm algorithm, bool truncateIfLarger=false) |
For the specified symmetric encryption algorithm, this function takes the specified byte array and checks if the array is of valid size. If yes then the unmodified array is returned, otherwise the modified array that fits the required block size is returned. The array size must be mltiple of the block size. More... | |
static byte[] | PadToSymmetricAlgorithmBlocksizeZero (byte[] byteArray, SymmetricAlgorithm algorithm, bool truncateIfLarger=false) |
For the specified symmetric encryption algorithm, this function takes the specified byte array and checks if the array is of valid size. If yes then the unmodified array is returned, otherwise the modified array that fits the required block size is returned. The array size must be mltiple of the block size. More... | |
static byte[] | GetValidSymmetricAlgorithmKey (byte[] key, SymmetricAlgorithm algorithm) |
For the specified symmetric encryption algorithm, this function takes the specified key and checks if the key is of valid size. If yes then the unmodified key is returned, otherwise the modified key that fits the required size is returned. More... | |
static byte[] | GetValidSymmetricAlgorithmIV (byte[] IV, SymmetricAlgorithm algorithm) |
For the specified symmetric encryption algorithm, this function takes the specified initialization vector and checks if the vector is of valid size. If yes then the unmodified IV is returned, otherwise the modified IV that fits the required size is returned. More... | |
static int | GetLargestSymmetricAlgorithmKeySize (SymmetricAlgorithm algorithm) |
Returns the largest possible key siye, in bits, for the spcified symmetric encryption algorithm. More... | |
static int | GetLargestSymmetricAlgorithmBlockSize (SymmetricAlgorithm algorithm) |
Returns the largest possible block siye, in bits, for the spcified symmetric encryption algorithm. More... | |
static void | PrepareSymmetricAllgorithmBasic (byte[] passwordBytes, byte[] passwordSalt, ref byte[] key, ref byte[] IV, SymmetricAlgorithmType algorithmType, ref SymmetricAlgorithm algorithm, PasswordAlgorithmType pwdType=PasswordAlgorithmType.Default, int pwdNumIterations=1000, bool useLargestKey=false, bool useLargestBlock=false) |
Prepares the symmetric algorithm, initialization vector, and key before encryption or decryption takes place. More... | |
static byte[] | EncryptBasic (byte[] data, byte[] passwordBytes, byte[] passwordSalt, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.None, SymmetricAlgorithm algorithm=null, byte[] saltBytes=null, PasswordAlgorithmType pwdType=PasswordAlgorithmType.Default, int pwdNumIterations=1000, bool useLargestKey=false, bool useLargestBlock=false) |
Encrypts the specified byte array by a symmetric encryption algorithm and returns encrypted bytes. More... | |
static byte[] | DecryptBasic (byte[] data, byte[] passwordBytes, byte[] passwordSalt, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.None, SymmetricAlgorithm algorithm=null, int numSaltBytes=0, PasswordAlgorithmType pwdType=PasswordAlgorithmType.Default, int pwdNumIterations=1000, bool useLargestKey=false, bool useLargestBlock=false) |
Decrypts the specified byte array by a symmetric algorithm and returns decrypted data. More... | |
static string | EncryptStringBasic (string stringToEncrypt, byte[] passwordBytes, byte[] passwordSalt, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.Default, SymmetricAlgorithm algorithm=null, byte[] saltBytes=null, PasswordAlgorithmType pwdType=PasswordAlgorithmType.Default, int pwdNumIterations=1000, bool useLargestKey=false, bool useLargestBlock=false) |
Encrypts the specified string, using the specified symmetric algorithm, key, and initialization vector, and returns the ToBase64 string representation of the encrypted bytes. More... | |
static string | DecryptStringBasic (string cipherText, byte[] passwordBytes, byte[] passwordSalt, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.Default, SymmetricAlgorithm algorithm=null, int numSaltBytes=0, PasswordAlgorithmType pwdType=PasswordAlgorithmType.Default, int pwdNumIterations=1000, bool useLargestKey=false, bool useLargestBlock=false) |
Derypts the specified string from encryted byte array, using the specified symmetric algorithm, key, and initialization vector. More... | |
static void | EncryptFileBasic (string inputFilePath, string outputFilePath, byte[] passwordBytes, byte[] passwordSalt, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.Default, SymmetricAlgorithm algorithm=null, byte[] saltBytes=null, int bufferSize=ConstCrypto.FileBufferSize, PasswordAlgorithmType pwdType=PasswordAlgorithmType.Default, int pwdNumIterations=1000, bool useLargestKey=false, bool useLargestBlock=false) |
Encrypts the data from the specified input file by a symmetric encryption algorithm and writes encrypted data to the specified output file. More... | |
static void | DecryptFileBasic (string inputFilePath, string outputFilePath, byte[] passwordBytes, byte[] passwordSalt, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.Default, SymmetricAlgorithm algorithm=null, int numSaltBytes=0, int bufferSize=ConstCrypto.FileBufferSize, PasswordAlgorithmType pwdType=PasswordAlgorithmType.Default, int pwdNumIterations=1000, bool useLargestKey=false, bool useLargestBlock=false) |
Decrypts the data from the specified input file by a symmetric encryption algorithm and writes decrypted data to the specified output file. More... | |
static void | PrepareSymmetricAllgorithmPlain (ref byte[] key, ref byte[] IV, SymmetricAlgorithmType algorithmType, ref SymmetricAlgorithm algorithm, bool useLargestKey=false, bool useLargestBlock=false) |
Prepares the symmetric algorithm, initialization vector, and key before encryption or decryption takes place. More... | |
static void | EncryptPlain (byte[] data, Stream outputStream, byte[] key, byte[] IV, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.None, SymmetricAlgorithm algorithm=null, byte[] saltBytes=null, bool useLargestKey=false, bool useLargestBlock=false) |
Encrypts the specified byte array by a symmetric encryption algorithm and writes encrypted data to the specified output stream that must be open for writing. More... | |
static void | DecryptPlain (byte[] data, Stream outputStream, byte[] key, byte[] IV, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.None, SymmetricAlgorithm algorithm=null, int numSaltBytes=0, bool useLargestKey=false, bool useLargestBlock=false) |
Decrypts the specified byte array by a symmetric algorithm and writes decrypted data to the specified output stream. More... | |
static byte[] | EncryptPlain (byte[] data, byte[] key, byte[] IV, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.None, SymmetricAlgorithm algorithm=null, byte[] saltBytes=null, bool useLargestKey=false, bool useLargestBlock=false) |
Encrypts the specified byte array by a symmetric encryption algorithm and returns encrypted bytes. More... | |
static byte[] | DecryptPlain (byte[] data, byte[] key, byte[] IV, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.None, SymmetricAlgorithm algorithm=null, int numSaltBytes=0, bool useLargestKey=false, bool useLargestBlock=false) |
Decrypts the specified byte array by a symmetric algorithm and returns decrypted data. More... | |
static string | EncryptStringPlain (string stringToEncrypt, byte[] key, byte[] initializationVector, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.Default, SymmetricAlgorithm algorithm=null, byte[] saltBytes=null, bool useLargestKey=false, bool useLargestBlock=false) |
Encrypts the specified string, using the specified symmetric algorithm, key, and initialization vector, and returns the Base64 string representation of the encrypted bytes. More... | |
static string | DecryptStringPlain (string cipherText, byte[] key, byte[] initializationVector, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.Default, SymmetricAlgorithm algorithm=null, int numSaltBytes=0, bool useLargestKey=false, bool useLargestBlock=false) |
Derypts the specified string from encryted byte array, using the specified symmetric algorithm, key, and initialization vector. More... | |
static byte[] | EncryptStringToBytesPlain (string stringToEncrypt, byte[] key, byte[] initializationVector, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.Default, SymmetricAlgorithm algorithm=null, byte[] saltBytes=null, bool useLargestKey=false, bool useLargestBlock=false) |
Encrypts the specified string to a byte array, using the specified symmetric algorithm, key, and initialization vector. More... | |
static string | DecryptStringFromBytesPlain (byte[] cipherText, byte[] key, byte[] initializationVector, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.Default, SymmetricAlgorithm algorithm=null, int numSaltBytes=0, bool useLargestKey=false, bool useLargestBlock=false) |
Derypts the specified string from encryted byte array, using the specified symmetric algorithm, key, and initialization vector. More... | |
static void | EncryptPlain (Stream inputStream, Stream outputStream, byte[] key, byte[] IV, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.None, SymmetricAlgorithm algorithm=null, byte[] saltBytes=null, int bufferSize=ConstCrypto.FileBufferSize, bool useLargestKey=false, bool useLargestBlock=false) |
Encrypts the data from the specified input stream by a symmetric encryption algorithm and writes encrypted data to the specified output stream. More... | |
static void | DecryptPlain (Stream inputStream, Stream outputStream, byte[] key, byte[] IV, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.None, SymmetricAlgorithm algorithm=null, int numSaltBytes=0, int bufferSize=ConstCrypto.FileBufferSize, bool useLargestKey=false, bool useLargestBlock=false) |
Decrypts the data from the specified input stream by a symmetric encryption algorithm and writes decrypted data to the specified output stream. More... | |
static void | EncryptFilePlain (string inputFilePath, string outputFilePath, byte[] key, byte[] IV, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.None, SymmetricAlgorithm algorithm=null, byte[] saltBytes=null, int bufferSize=ConstCrypto.FileBufferSize, bool useLargestKey=false, bool useLargestBlock=false) |
Encrypts the data from the specified input file by a symmetric encryption algorithm and writes encrypted data to the specified output file. More... | |
static void | DecryptFilePlain (string inputFilePath, string outputFilePath, byte[] key, byte[] IV, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.None, SymmetricAlgorithm algorithm=null, int numSaltBytes=0, int bufferSize=ConstCrypto.FileBufferSize, bool useLargestKey=false, bool useLargestBlock=false) |
Decrypts the data from the specified input file by a symmetric encryption algorithm and writes decrypted data to the specified output file. More... | |
static AsymmetricAlgorithmType[] | GetAsymmetricAlgorithmTypes () |
Returns all asymmetric encryption algorithm types contained in the enumeration AsymmetricAlgorithmType More... | |
static AsymmetricAlgorithmType | GetAsymmetricAlgorithmType (string typeString) |
Returns the AsymmetricAlgorithmType value corresponding to the specified string. More... | |
static AsymmetricAlgorithmType | GetAsymmetricAlgorithmType (AsymmetricAlgorithm algorithmObject) |
Returns the asymmetric encryption algorithm type, i.e. an enumeration of type SymmetricAlgorithmType, for the specified asymmetric encryption algorithm object. More... | |
static string | AsymmetricAlgorithmTypeToString (AsymmetricAlgorithmType algorithmType) |
Returns standard string representation of the specified asymmetric encryption algorithm type. More... | |
static AsymmetricAlgorithm | GetAsymmetricEncryptionAlgorithm (AsymmetricAlgorithmType algorithmType) |
Returns the appropriate asymmetric algorithm according to the specified hashRet type, or null if the type is not recognized or the method is not implemented for that type. More... | |
static bool | IsCorrectAsymmetricEncryptionAlgorithm (AsymmetricAlgorithm algorithm, AsymmetricAlgorithmType algorithmType) |
Returns true if the specified asymmetric encryption algorithm corresponds the type specification, false otherwise. More... | |
static int | GetLargestAsymmetricAlgorithmKeySize (AsymmetricAlgorithm algorithm) |
Returns the largest possible key size, in bits, for the spcified symmetric encryption algorithm. More... | |
static byte[] | GetValidAsymmetricAlgorithmKey (byte[] key, AsymmetricAlgorithm algorithm, bool useLargestKey=false) |
For the specified asymmetric encryption algorithm, this function takes the specified key and checks if the key is of valid size. If yes then the unmodified key is returned, otherwise the modified key that fits the required size is returned. More... | |
static CspProviderFlags | GetCspProviderFlags (string flagString) |
Returns the value of the CspProviderFlags enum corresponding to the specified string. More... | |
static string | CspProviderFlagsToString (CspProviderFlags flags) |
Returns standard string representation of the CspProviderFlags enumeration. More... | |
static string | ToString (CspKeyContainerInfo keyInfo, int numIndent=0) |
Creates and returns a string that presents the key information contained in the argument keyInfo . More... | |
static string | ToString (RSACryptoServiceProvider alg) |
Creates and returns a string containing information about the specified RSA algorithm. More... | |
static string | ToString (DSACryptoServiceProvider alg) |
Creates and returns a string containing information about the specified DSA algorithm. More... | |
static string | ToString (AsymmetricAlgorithm alg) |
Creates and returns a string containing information about the specified RSA algorithm. More... | |
static string | ToString (X509Certificate certificate) |
Returns a readable string representation of the specified certificate. More... | |
static string | GetSimpleName (X509Certificate2 cert) |
Returns simple name of the specified cerrtificate. More... | |
static string | ToString (X509Certificate2 cert) |
Returns a readable string representation of the specified certificate. More... | |
static string | GetCertificateStoreDescription (int outputLevel=0, string storeName=null, int storeLocation=(int) StoreLocation.CurrentUser|(int) StoreLocation.LocalMachine) |
Returns a string that contains human readable description of certificate stores. More... | |
static void | GetCertificateStores (ref IList< X509Store > stores, bool clearAtBeginning=true, string storeName=null, int storeLocation=(int) StoreLocation.CurrentUser|(int) StoreLocation.LocalMachine) |
Adds to the specified list all persistent certificate stores that match the criteria specified by parameters. More... | |
static void | CloseCertificateStores (IList< X509Store > stores) |
Closes all certificate stores on the list. More... | |
static X509Certificate2 | GetCertificate (string privateKeyPassword=null, string certificateFilePath=null, string certificateName=null, string storeName=null, int storeLocation=(int) StoreLocation.CurrentUser|(int) StoreLocation.LocalMachine) |
Obtains and returns the certificate specifid by parameters. More... | |
static string | AddCertificateToStore (X509Certificate2 certificate, out bool skipped, out bool overwritten, string certificateStoreName, int storeLocation=(int) StoreLocation.CurrentUser, bool isForceOverwrites=false, bool isSkipOverwrites=false) |
Adds a certificate to the specified certificate store. More... | |
static string | DeleteCertificateFromStore (out bool skipped, out bool deleted, string certificateName, string storeName, int storeLocation=(int) StoreLocation.CurrentUser, bool isForceDeletes=false, bool isSkipDeletes=false) |
Deletes the specified certificate to the specified certificate store. More... | |
static string | GetAsymmetricalgorithmHash (AsymmetricAlgorithm algorithm, bool includePrivate=false, bool skipPrivateIfNotExportable=false, HashType hashType=HashType.SHA1) |
Returns a hash value for the specified Asymmetric algorithm, which depends on algorithm keys. More... | |
static int | GetMaximalAsymmetricTextLength (AsymmetricAlgorithm alg) |
Returns the maximal size of a byte array that can be encrypted by using the specified asymmetric algoritm. More... | |
static bool | AsymEncryptionDecryptionTest (string testString, AsymmetricAlgorithm algEnc, AsymmetricAlgorithm algDec=null) |
Tests whether the specified asymmetric algorithm(s) correctly encrypts/decrypts the specified string. More... | |
static bool | AsymEncryptionDecryptionTest (string testString, out string errorString, AsymmetricAlgorithm algEnc, AsymmetricAlgorithm algDec=null) |
Tests whether the specified asymmetric algorithm(s) correctly encrypts/decrypts the specified string. More... | |
static bool | AsymEncryptionDecryptionTest (int length, AsymmetricAlgorithm algEnc, AsymmetricAlgorithm algDec=null) |
Tests whether the specified asymmetric algorithm(s) correctly encrypts/decrypts a random byte array of the specified size. More... | |
static bool | AsymEncryptionDecryptionTest (int length, out string errorString, AsymmetricAlgorithm algEnc, AsymmetricAlgorithm algDec=null) |
Tests whether the specified asymmetric algorithm(s) correctly encrypts/decrypts a random byte array of the specified size. More... | |
static AsymmetricAlgorithm | GetAsymmetricAlgorithm (AsymmetricAlgorithmType algorithmType, string containerName=null, string xmlString=null, CspProviderFlags flags=CspProviderFlags.NoFlags, string certificateFilePath=null, string certificateName=null, string certStore=null) |
Creates (if necessary) and returns a new asymmetric algorithm whose keys are either created or obtained through arguments. More... | |
static void | DeleteKeyInCsp (AsymmetricAlgorithmType algorithmType, string containerName) |
Deletes the asymmetric algorithm keys from the specified key container. More... | |
static void | PrepareAymmetricAllgorithmBasic (AsymmetricAlgorithmType algorithmType, ref AsymmetricAlgorithm algorithm, string containerName=null, string xmlString=null, CspProviderFlags flags=CspProviderFlags.NoFlags, bool useLargestKey=false) |
static string | EncryptStringAsymShort (string stringToEncrypt, AsymmetricAlgorithm algorithm, AsymmetricAlgorithmType algorithmType=AsymmetricAlgorithmType.None) |
static string | DecryptStringAsymShort (string cipherText, AsymmetricAlgorithm algorithm, AsymmetricAlgorithmType algorithmType=AsymmetricAlgorithmType.None) |
static byte[] | EncryptAsymShort (byte[] originalBytes, AsymmetricAlgorithm algorithm, AsymmetricAlgorithmType algorithmType=AsymmetricAlgorithmType.None) |
static byte[] | DecryptAsymShort (byte[] originalBytes, AsymmetricAlgorithm algorithm, AsymmetricAlgorithmType algorithmType=AsymmetricAlgorithmType.None) |
static byte[] | EncryptAsymShort (byte[] originalBytes, AsymmetricAlgorithmType algorithmType=AsymmetricAlgorithmType.None, AsymmetricAlgorithm algorithm=null, string containerName=null, string xmlString=null, CspProviderFlags flags=CspProviderFlags.NoFlags, bool useLargestKey=false) |
static byte[] | DecryptAsymShort (byte[] originalBytes, AsymmetricAlgorithmType algorithmType=AsymmetricAlgorithmType.None, AsymmetricAlgorithm algorithm=null, string containerName=null, string xmlString=null, CspProviderFlags flags=CspProviderFlags.NoFlags, bool useLargestKey=false) |
static string | IgGetSaltSuffix (int whichSalt) |
Returns the specified standard IGLib salt string. More... | |
static int | IgGetNumSaltSuffices () |
Returns the number of standard IGLib salt strings. More... | |
Properties | |
static int | OutputLevel [get] |
Output level for static methods of the current utility class. More... | |
static object | LockStatic [get] |
Locking object for static methods and properties of this class. More... | |
static Encoding | StringEncoding [get] |
Gets the character encoding that is used for calculating hashes of strings. More... | |
static RNGCryptoServiceProvider | Rng [get] |
Object used to generate random bytes. More... | |
static bool | IsUsed_fOAEP [get] |
Whether to perform direct RSA encryption using OAEP (optimal asymmetric encryption padding - only available on computers running MS Windows XP or later). More... | |
Static Private Member Functions | |
static PasswordAlgorithmBase | GetPasswordAlgorithmNoneSingleton () |
Returns password algorithm that does not change the password provided as initialization parameters. More... | |
static int | SetLargestSymmetricAlgorithmKeySize (SymmetricAlgorithm algorithm) |
On the specified symmetric encryption algorythm, sets the largest possible key size, in bits, for the spcified symmetric encryption algorithm. More... | |
static int | SetLargestSymmetricAlgorithmBlockSize (SymmetricAlgorithm algorithm) |
On the specified symmetric encryption algorithm, sets the largest possible block size, in bits, for the spcified symmetric encryption algorithm. More... | |
static int | SetLargestAsymmetricAlgorithmKeySize (AsymmetricAlgorithm algorithm) |
On the specified asymmetric encryption algorithm, sets the largest possible key size, in bits, for the corresponding asymmetric encryption algorithm. More... | |
Static Private Attributes | |
static int | _outputLevel = 1 |
static object | _lockStatic = null |
static PasswordAlgorithmType[] | _passwordAlgorithmTypes = null |
static PasswordAlgorithmBase | _passwordAlgorithmNone = null |
static RNGCryptoServiceProvider | _rng = null |
static HashType[] | _hashTypes = null |
static SymmetricAlgorithmType[] | _symmetricTypes = null |
static AsymmetricAlgorithmType[] | _asymmetricTypes = null |
static bool | _isUsed_fOAEP1 = false |
static string[] | _igLibLongSaltSuffices |
An array of standard IGLib salt suffices. More... | |
Basic Cryptographic utilities.
Warnings:
- Functions of this class must be fixed (may not change over time) in order not to break any security instruments.
- Functions can only be renamd (always by refactoring tools that change all calls to functions).
- For IGLib functions (IGLib specific supplements of standards), these should only be used through standard shell applications. In such a way security tools can not be broken, as shell functions are more guaranteed to behave constantly over time.
See also:
- Cryptographic hashRet function: http://en.wikipedia.org/wiki/Cryptographic_hash_function
- Password verification: http://en.wikipedia.org/wiki/Cryptographic_hash_function#Password_verification
- Storing passwords: http://www.aspheute.com/english/20040105.asp
- How to encrypt user passwords: http://www.jasypt.org/howtoencryptuserpasswords.html
- Salt: https://en.wikipedia.org/wiki/Salt_(cryptography)
- Key stretching: http://en.wikipedia.org/wiki/Key_stretching
$A Igor Apr10 Jun15;
|
inlinestatic |
Returns all password algorithm types contained in the enumeration PasswordAlgorithmType
References IG.Lib.Util.LockGlobal.
|
inlinestatic |
Returns a PasswordAlgorithmType value corresponding to the specified string representation.
typeString | String that represents the PasswordAlgorithmType value. |
Referenced by IG.Crypto.CryptoManager.AppKeyGenerationAll(), IG.Script.ScriptAppBase.CryptoFunctionTimeKeyGeneration_OLD_TO_DELETE_LATER(), and IG.Crypto.CryptoManager.ParseCommandlineParameters().
|
inlinestatic |
Returns the password generation algorithm type, i.e. an enumeration of type PasswordAlgorithmType, for the specified password generation algorithm object.
algorithmObject | Password generaton algorithm object for which type enumeration is returned. |
|
inlinestatic |
Returns standard string representation of the specified password generation algoithm.
passwordAlgorithmType | Password algorithm type whose string representation is returned. |
Referenced by IG.Crypto.UtilCrypto.PrepareSymmetricAllgorithmBasic().
|
inlinestaticprivate |
Returns password algorithm that does not change the password provided as initialization parameters.
The same object is returned by each call.
References IG.Lib.Util.LockGlobal.
|
inlinestatic |
Returns the appropriate password generation algorithm according to the specified algorithm type, or null if the type is not recognized or the method is not implemented for that type.
algorithmType | Specification of the password generaion algorithm type. |
Referenced by IG.Crypto.CryptoManager.AppKeyGenerationAll(), IG.Script.ScriptAppBase.CryptoFunctionTimeKeyGeneration_OLD_TO_DELETE_LATER(), and IG.Crypto.UtilCrypto.PrepareSymmetricAllgorithmBasic().
|
inlinestatic |
Returns true if the specified password generation algorithm corresponds the type specification, false otherwise.
If the specified algorithm is null or the specified type is unknown then false is returned.
algorithm | Algorithm that is checked for type correctness. |
algorithmType | Specification of the password derivation nalgorithm type. |
|
inlinestatic |
Creates and returns a random password consisting of only allowed characters from the specified string.
Cryptographically secure random numbers are used to select characters for the password from the array of allowed characters.
PasswordLength | Length of the generated password. |
allowedChars | String containing allowed characters of the password. |
By default (if parameter is a null or empty string), these are digits and lower- and upper- case English letters.
|
inlinestatic |
Fills the specified byte array with a cryptographically strong sequence of random bytes.
byteArray | Byte array that is filled with random bytes. |
Referenced by IG.Script.ScriptAppBase.CryptoFunctionTimeKeyGeneration_OLD_TO_DELETE_LATER(), and IG.Crypto.CryptoManager.ResolvePasswordParameters().
|
inlinestatic |
Fills the specified byte array with a specified number of cryptographically strong random bytes.
Byte array is created anew if its size does not equal the specified number of bytes.
byteArray | Byte array that is filled with random bytes. Reallocated if necessary. |
numBytes | Number of bytes to be filled into the array. |
|
inlinestatic |
Creates and returns an array of cryptographically strong random bytes of the specified size.
numBytes | Number of bytes to be filled into the array. |
|
inlinestatic |
Returns length of the hashRet value, in bytes, for the specified hashRet algorithm.
-1 is returned if the length is not known.
hashType | Type of the hashing algorithm. |
|
inlinestatic |
Returns length of the HEXADECIMAL hashRet string for the specified hashRet algorithm.
-1 is returned if the length is not known.
hashType | Type of the hashing algorithm. |
|
inlinestatic |
Returns all hashing algorithm types contained in the enumeration HashType
References IG.Lib.Util.LockGlobal.
|
inlinestatic |
Returns a HashType value corresponding to the specified string representation.
typeString | String that represents the hashRet type. |
Referenced by IG.Script.ScriptAppBase.CryptoFunctionCheckSum_OLD_TO_DELETE_LATER(), and IG.Crypto.CryptoManager.ParseCommandlineParameters().
|
inlinestatic |
Returns the hashing algorithm type, i.e. an enumeration of type HashType, for the specified hashing algorithm object.
algorithmObject | Hashing algorithm object for which type enumeration is returned. |
|
inlinestatic |
Returns standard string representation of the specified hashRet type.
hashType | Hash type whose string representation is returned. |
|
inlinestatic |
Returns the appropriate hashRet algorithm according to the specified hashRet type, or null if the type is not recognized or the method is not implemented for that type.
hashType | Specification of the hashRet algorithm type. |
|
inlinestatic |
Returns true if the specified cryptographic hashRet algorithm corresponds the type specification, false otherwise.
If the specified algorithm is null or the specified type is unknown then false is returned.
algorithmType | Specification of the cryptographic hashRet algorithm type. |
algorithm | Algorithm that is checked for type correctness. |
|
inlinestatic |
Parses the file containing hashRet values of one or more files, and adds the parsed pairs {hashRet, inputFilePath} to the specified list.
File must be in the standard format where each line contains a hashRet value and the path to the corresponding file separated from hashRet value by one or more spaces.
List is allocated if necessary. Eventual existent pairs on the list are not affected.
filePath | Path to the file that is parsed. |
hashList | List to which which parsed pairs {hashRet, inputFilePath} are added in form of arrays of 2 strings. |
Example contents of the file:
595f44fec1e92a71d3e9e77456ba80d1 filetohashA.txt
71f920fa275127a7b60fa4d4d41432a3 filetohashB.txt
43c191bf6d6c3f263a8cd0efd4a058ab filetohashC.txt
/remarks>
Referenced by IG.Crypto.CryptoManager.AppCheckSum(), and IG.Script.ScriptAppBase.CryptoFunctionCheckSum_OLD_TO_DELETE_LATER().
|
inlinestatic |
Parses the string containing hashRet values of one or more files, and adds the parsed pairs {hashRet, inputFilePath} to the specified list.
String must be in the standard format where each line contains a hashRet value and the path to the corresponding file separated from hashRet value by one or more spaces.
List is allocated if necessary. Eventual existent pairs on the list are not affected.
str | String that is parsed. |
hashList | List to which which parsed pairs {hashRet, inputFilePath} are added in form of arrays of 2 strings. |
Example contents of the string:
595f44fec1e92a71d3e9e77456ba80d1 filetohashA.txt
71f920fa275127a7b60fa4d4d41432a3 filetohashB.txt
43c191bf6d6c3f263a8cd0efd4a058ab filetohashC.txt
/remarks>
|
inlinestatic |
Computes and returns the hashRet (in form of byte array) of the specified kind of the specified byte array.
Exception (InvalidOperationException) is thrown if the specified hashRet type is not known or implemented.
bytesToHash | Byte array whose hashRet string is calculated. |
hashType | Specifies the type of the hashing algorithm to be used. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by teh method. Its type must correspond the specified type. |
|
inlinestatic |
Computes and returns the hashRet string of the specified kind of the specified byte array.
Exception (InvalidOperationException) is thrown if the specified hashRet type is not known or implemented.
bytesToHash | Byte array whose hashRet string is calculated. |
hashType | Specifies the type of the hashing algorithm to be used. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by teh method. Its type must correspond the specified type. |
References IG.Lib.Util.ToHexString().
Referenced by IG.Crypto.CryptoManager.AppCheckSum().
|
inlinestatic |
Computes and returns the MD5 hashRet string of the specified array of bytes.
bytesToHash | Byte array whose hashRet string is calculated. |
|
inlinestatic |
Computes and returns the SHA1 hashRet string of the specified array of bytes.
bytesToHash | Byte array whose hashRet string is calculated. |
|
inlinestatic |
Computes and returns the SHA256 hashRet string of the specified array of bytes.
bytesToHash | Byte array whose hashRet string is calculated. |
|
inlinestatic |
Computes and returns the SHA512 hashRet string of the specified array of bytes.
bytesToHash | Byte array whose hashRet string is calculated. |
|
inlinestatic |
Chechs the specified type of hashRet value of a byte array.
Returns true if the hashRet value matches the hashRet value of the byte array, and false otherwise.
bytesToCheck | String whose hashRet value is checked. |
hashValue | Supposed hashRet value whose correctness is checked. |
hashAlgorithmType | Type of the hashRet value that is checked. |
References IG.Lib.Util.AreHexStringsEqual().
Referenced by IG.Crypto.CryptoManager.AppCheckSum().
|
inlinestatic |
Chechs all supported types of hashRet value of a string.
Returns the hashRet type if the hashRet value matches the hashRet value of that type of the specified string, or HashType.None if the specified hashRet value doesn't match the hashRet value of any supported type of the string.
bytesToCheck | String whose hashRet value is checked. |
hashValue | Supposed hashRet value whose match with the specified string is checked. |
References IG.Lib.Util.AreHexStringsEqual().
|
inlinestatic |
Computes and returns the hashRet string of the specified kind of the specified string.
Exception (InvalidOperationException) is thrown if the specified hashRet type is not known or implemented.
stringToHash | String whose hashRet string is calculated. |
hashType | Specifies the type of the hashing algorithm to be used. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by the method. Its type must correspond the specified type. |
|
inlinestatic |
Computes and returns the hashRet string of the specified kind of the specified string.
Exception (InvalidOperationException) is thrown if the specified hashRet type is not known or implemented.
stringToHash | String whose hashRet string is calculated. |
hashType | Specifies the type of the hashing algorithm to be used. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by the method. Its type must correspond the specified type. |
References IG.Lib.Util.ToHexString().
Referenced by IG.Crypto.CryptoManager.AppCheckSum(), IG.Script.ScriptAppBase.CryptoFunctionCheckSum_OLD_TO_DELETE_LATER(), and IG.Crypto.UtilCrypto.GetAsymmetricalgorithmHash().
|
inlinestatic |
Computes and returns the MD5 hashRet string of the specified string.
stringToHash | String whose cryptographic hashRet is calculated. |
Referenced by IG.Forms.HashControl.CalculateHashes().
|
inlinestatic |
Computes and returns the SHA1 hashRet string of the specified string.
stringToHash | String whose cryptographic hashRet is calculated. |
Referenced by IG.Forms.HashControl.CalculateHashes().
|
inlinestatic |
Computes and returns the SHA256 hashRet string of the specified string.
stringToHash | String whose cryptographic hashRet is calculated. |
Referenced by IG.Forms.HashControl.CalculateHashes().
|
inlinestatic |
Computes and returns the SHA512 hashRet string of the specified string.
stringToHash | String whose cryptographic hashRet is calculated. |
Referenced by IG.Forms.HashControl.CalculateHashes().
|
inlinestatic |
Computes and returns the salted hashRet (in form of byte array) of the specified kind of the specified string, with the specified number of repetitions of the salted hashing algoriithm.
Exception (InvalidOperationException) is thrown if the specified hashRet type is not known or implemented.
stringToHash | String whose salted hashRet is to be computed. |
hashType | Type of hashing algorithm used. |
salt | Salt string. |
numIterations | Optional number of iterations. If hreater than 0 then hashing algorithm is reapplied to the salted result of the previous computation for the specified number of time. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by the method. Its type must correspond the specified type. |
|
inlinestatic |
Computes and returns the salted hashRet of the specified kind of the specified string, with the specified number of repetitions of the salted hashing algoriithm.
Exception (InvalidOperationException) is thrown if the specified hashRet type is not known or implemented.
stringToHash | String whose salted hashRet is to be computed. |
hashType | Type of hashing algorithm used. |
salt | Salt string. |
numIterations | Optional number of iterations. If hreater than 0 then hashing algorithm is reapplied to the salted result of the previous computation for the specified number of time. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by the method. Its type must correspond the specified type. |
References IG.Lib.Util.ToHexString().
|
inlinestatic |
Computes and returns the MD5 salted hashRet of the specified string, with the specified number of repetitions of the salted hashing algoriithm.
Exception (InvalidOperationException) is thrown if the specified hashRet type is not known or implemented.
stringToHash | String whose salted hashRet is to be computed. |
salt | Salt string. |
numIterations | Optional number of iterations. If hreater than 0 then hashing algorithm is reapplied to the salted result of the previous computation for the specified number of time. |
|
inlinestatic |
Computes and returns the SHA1 salted hashRet of the specified string, with the specified number of repetitions of the salted hashing algoriithm.
Exception (InvalidOperationException) is thrown if the specified hashRet type is not known or implemented.
stringToHash | String whose salted hashRet is to be computed. |
salt | Salt string. |
numIterations | Optional number of iterations. If hreater than 0 then hashing algorithm is reapplied to the salted result of the previous computation for the specified number of time. |
|
inlinestatic |
Computes and returns the SHA-256 salted hashRet of the specified string, with the specified number of repetitions of the salted hashing algoriithm.
Exception (InvalidOperationException) is thrown if the specified hashRet type is not known or implemented.
stringToHash | String whose salted hashRet is to be computed. |
salt | Salt string. |
numIterations | Optional number of iterations. If hreater than 0 then hashing algorithm is reapplied to the salted result of the previous computation for the specified number of time. |
|
inlinestatic |
Computes and returns the SHA-512 salted hashRet of the specified string, with the specified number of repetitions of the salted hashing algoriithm.
Exception (InvalidOperationException) is thrown if the specified hashRet type is not known or implemented.
stringToHash | String whose salted hashRet is to be computed. |
salt | Salt string. |
numIterations | Optional number of iterations. If hreater than 0 then hashing algorithm is reapplied to the salted result of the previous computation for the specified number of time. |
|
inlinestatic |
Chechs the specified type of hashRet value of a string.
Returns true if the hashRet value matches the hashRet value of the string, and false otherwise.
stringToCheck | String whose hashRet value is checked. |
hashValue | Supposed hashRet value whose correctness is checked. |
hashAlgorithmType | Type of the hashRet value that is checked. |
References IG.Lib.Util.AreHexStringsEqual().
Referenced by IG.Crypto.CryptoManager.AppCheckSum(), and IG.Script.ScriptAppBase.CryptoFunctionCheckSum_OLD_TO_DELETE_LATER().
|
inlinestatic |
Chechs all supported types of hashRet value of a string.
Returns the hashRet type if the hashRet value matches the hashRet value of that type of the specified string, or HashType.None if the specified hashRet value doesn't match the hashRet value of any supported type of the string.
stringToCheck | String whose hashRet value is checked. |
hashValue | Supposed hashRet value whose match with the specified string is checked. |
References IG.Lib.Util.AreHexStringsEqual().
Referenced by IG.Forms.HashControl.VerifyHash().
|
inlinestatic |
Checks whether the specified MD5 hashRet value matches the actual hashRet value of the specified string.
Returns true if the specified hashRet value matches the actual hashRet value of the string, and false otherwise.
stringToCheck | String whose hashRet value is checked. |
hashValue | Supposed hashRet value whose validity is checked for the specified string. |
|
inlinestatic |
Checks whether the specified SHA-1 hashRet value matches the actual hashRet value of the specified string.
Returns true if the specified hashRet value matches the actual hashRet value of the string, and false otherwise.
stringToCheck | String whose hashRet value is checked. |
hashValue | Supposed hashRet value whose validity is checked for the specified string. |
|
inlinestatic |
Checks whether the specified SHA-256 hashRet value matches the actual hashRet value of the specified string.
Returns true if the specified hashRet value matches the actual hashRet value of the string, and false otherwise.
stringToCheck | String whose hashRet value is checked. |
hashValue | Supposed hashRet value whose validity is checked for the specified string. |
|
inlinestatic |
Checks whether the specified SHA-512 hashRet value matches the actual hashRet value of the specified string.
Returns true if the specified hashRet value matches the actual hashRet value of the string, and false otherwise.
stringToCheck | String whose hashRet value is checked. |
hashValue | Supposed hashRet value whose validity is checked for the specified string. |
|
inlinestatic |
Computes and returns the hashRet (in form of byte array) of specified type of the specified stream.
filePath | Path to the file whose contents' cryptographic hashRet is calculated. |
hashType | Specifies the type of the hashing algorithm to be used. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by teh method. Its type must correspond the specified type. |
|
inlinestatic |
Computes and returns the hashRet string of specified type of the specified stream.
filePath | Path to the file whose contents' cryptographic hashRet is calculated. |
hashType | Specifies the type of the hashing algorithm to be used. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by teh method. Its type must correspond the specified type. |
Referenced by IG.Crypto.CryptoManager.AppCheckSum(), and IG.Script.ScriptAppBase.CryptoFunctionCheckSum_OLD_TO_DELETE_LATER().
|
inlinestatic |
Computes and returns the MD5 hashRet string of the specified stream.
filePath | Path to the file whose contents' cryptographic hashRet is calculated. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by teh method. Its type must correspond the specified type. |
Referenced by IG.Crypto.CryptoManager.AppGetFileHash(), IG.Forms.HashControl.CalculateHashes(), and IG.Script.ScriptAppBase.CryptoFunctionGetFileHash_OLD_TO_DELETE().
|
inlinestatic |
Computes and returns the SHA1 hashRet string of the specified stream.
filePath | Path to the file whose contents' cryptographic hashRet is calculated. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by teh method. Its type must correspond the specified type. |
Referenced by IG.Crypto.CryptoManager.AppGetFileHash(), IG.Forms.HashControl.CalculateHashes(), and IG.Script.ScriptAppBase.CryptoFunctionGetFileHash_OLD_TO_DELETE().
|
inlinestatic |
Computes and returns the SHA256 hashRet string of the specified stream.
filePath | Path to the file whose contents' cryptographic hashRet is calculated. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by teh method. Its type must correspond the specified type. |
Referenced by IG.Crypto.CryptoManager.AppGetFileHash(), IG.Forms.HashControl.CalculateHashes(), and IG.Script.ScriptAppBase.CryptoFunctionGetFileHash_OLD_TO_DELETE().
|
inlinestatic |
Computes and returns the SHA512 hashRet string of the specified stream.
filePath | Path to the file whose contents' cryptographic hashRet is calculated. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by teh method. Its type must correspond the specified type. |
Referenced by IG.Crypto.CryptoManager.AppGetFileHash(), IG.Forms.HashControl.CalculateHashes(), and IG.Script.ScriptAppBase.CryptoFunctionGetFileHash_OLD_TO_DELETE().
|
inlinestatic |
Computes and returns the hashRet (in form of byte array) of specified type of the specified stream.
stream | Stream whose contents' cryptographic hashRet is calculated. |
hashType | Type of the hashRet algorithm used. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by the method. Its type must correspond the specified type. |
|
inlinestatic |
Computes and returns the hexadecimal hashRet string of specified type of the specified stream.
stream | Stream whose contents' cryptographic hashRet is calculated. |
hashType | Type of the hashRet algorithm used. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by the method. Its type must correspond the specified type. |
References IG.Lib.Util.ToHexString().
|
inlinestatic |
Computes and returns the MD5 hashRet string of the specified stream.
stream | Stream whose contents' cryptographic hashRet is calculated. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by the method. Its type must correspond the specified type. |
|
inlinestatic |
Computes and returns the SHA1 hashRet string of the specified stream.
stream | Stream whose contents' cryptographic hashRet is calculated. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by the method. Its type must correspond the specified type. |
|
inlinestatic |
Computes and returns the SHA256 hashRet string of the specified stream.
stream | Stream whose contents' cryptographic hashRet is calculated. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by the method. Its type must correspond the specified type. |
|
inlinestatic |
Computes and returns the SHA512 hashRet string of the specified stream.
stream | Stream whose contents' cryptographic hashRet is calculated. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by the method. Its type must correspond the specified type. |
|
inlinestatic |
Chechs the specified type of hashRet value of a file.
Returns true if the specified hashRet value matches the hashRet value of the file, and false otherwise.
filePath | Path to the file whose hashRet value is checked. |
hashValue | Supposed hashRet value whose correctness is checked. |
hashType | Type of the hashRet value that is checked. |
cryptoAlgorithm | Hasihing algoriithm to be used. |
References IG.Lib.Util.AreHexStringsEqual().
Referenced by IG.Crypto.CryptoManager.AppCheckSum(), and IG.Script.ScriptAppBase.CryptoFunctionCheckSum_OLD_TO_DELETE_LATER().
|
inlinestatic |
Chechs all supported types of hashRet value of a file.
Returns the hashRet type if the hashRet value matches the hashRet value of that type of the specified file, or HashType.None if the specified hashRet value doesn't match the hashRet value of any supported type of the specified file.
filePath | Path to the file whose hashRet value is checked. |
hashValue | Supposed hashRet value whose match with the specified file is checked. |
References IG.Lib.Util.AreHexStringsEqual().
Referenced by IG.Forms.HashControl.VerifyHash().
|
inlinestatic |
Checks whether the specified MD5 hashRet value matches the actual hashRet value of the specified file.
Returns true if the specified hashRet value matches the actual hashRet value of the file, and false otherwise.
filePath | Path to the file whose hashRet value is checked. |
hashValue | Supposed hashRet value whose validity is checked for the specified file. |
|
inlinestatic |
Checks whether the specified SHA-1 hashRet value matches the actual hashRet value of the specified file.
Returns true if the specified hashRet value matches the actual hashRet value of the file, and false otherwise.
filePath | Path to the file whose hashRet value is checked. |
hashValue | Supposed hashRet value whose validity is checked for the specified file. |
|
inlinestatic |
Checks whether the specified SHA-256 hashRet value matches the actual hashRet value of the specified file.
Returns true if the specified hashRet value matches the actual hashRet value of the file, and false otherwise.
filePath | Path to the file whose hashRet value is checked. |
hashValue | Supposed hashRet value whose validity is checked for the specified file. |
|
inlinestatic |
Checks whether the specified SHA-512 hashRet value matches the actual hashRet value of the specified file.
Returns true if the specified hashRet value matches the actual hashRet value of the file, and false otherwise.
filePath | Path to the file whose hashRet value is checked. |
hashValue | Supposed hashRet value whose validity is checked for the specified file. |
|
inlinestatic |
Returns all symmetric encryption algorithm types contained in the enumeration SymmetricAlgorithmType
References IG.Lib.Util.LockGlobal.
|
inlinestatic |
Returns the SymmetricAlgorithmType value corresponding to the specified string.
This function enables selection of algorithms with strings that can have arbitrary capitalization of their letters, and are thus friendly for user insertion.
typeString | String that represents the symmetric encryption algorithm type. |
Referenced by IG.Crypto.CryptoManager.ParseCommandlineParameters().
|
inlinestatic |
Returns the symmetric encryption algorithm type, i.e. an enumeration of type SymmetricAlgorithmType, for the specified symmetric encryption algorithm object.
algorithmObject | Symmetric algorithm object for which type enumeration is returned. |
|
inlinestatic |
Returns standard string representation of the specified symmetric encryption algorithm type.
algorithmType | Symmetric encryption algorithm type whose string representation is returned. |
Referenced by IG.Crypto.CryptoManager.AppEncryptSymmetricAll().
|
inlinestatic |
Returns the appropriate symmetric encryption algorithm according to the specified hashRet type, or null if the type is not recognized or the method is not implemented for that type.
algorithmType | Specification of the symmetric encryption algorithm type. |
|
inlinestatic |
Returns true if the specified symmetric encryption algorithm corresponds the type specification, false otherwise.
If the specified algorithm is null or the specified type is unknown then false is returned.
algorithmType | Specification of the symmetric encryption algorithm type. |
algorithm | Algorithm that is checked for type correctness. |
|
inlinestatic |
For the specified symmetric encryption algorithm, this function takes the specified byte array and checks if the array is of valid size. If yes then the unmodified initialization array is returned, otherwise the modified array that fits the required block size is returned (i.e. has integer number of blocks).
Bytes that are missing to the last full block are filled cyclically with the original bytes from teh beginning.
byteArray | Original array provided for the algorithm with specified block size. |
blockSize | Block size of the algorithm for which array is repaired, in bytes. |
Warning: Algorithms specify block size in bits, not in bytes.
truncateIfLarger | If true then the byte array is truncated to the block size if it is larger than it. |
Warning: this can only be done with the key and initialization vector, but not with data!!
An array that is of valid size for the algorithm.
If the original initialization vector size matches the required one, the vector is unmodified.
If the original vector is not a multiple of block size, it is padded by its initial bytes until the desired length.
Referenced by IG.Crypto.PasswordAlgorithmNone.GetBytesInternal().
|
inlinestatic |
For the specified symmetric encryption algorithm, this function takes the specified byte array and checks if the array is of valid size. If yes then the unmodified initialization array is returned, otherwise the modified array that fits the required block size is returned (i.e. has integer number of blocks).
Bytes that are missing to the last full block are filled cyclically with the original bytes from teh beginning.
byteArray | Original array provided for the algorithm with specified block size. |
blockSize | Block size of the algorithm for which array is repaired. |
truncateIfLarger | If true then the byte array is truncated to the block size if it is larger than it. |
Warning: this can only be done with the key and initialization vector, but not with data!!
An array that is of valid size for the algorithm.
If the original initialization vector size matches the required one, the vector is unmodified.
If the original vector is not a multiple of block size, it is padded by its initial bytes until the desired length.
|
inlinestatic |
For the specified symmetric encryption algorithm, this function takes the specified byte array and checks if the array is of valid size. If yes then the unmodified array is returned, otherwise the modified array that fits the required block size is returned. The array size must be mltiple of the block size.
Bytes that are missing to the last full block are filled cyclically with the original bytes from teh beginning.
byteArray | Original byte array provided for the algorithm. |
algorithm | Symmetric algorithm that is used for encryption/decryption. Object is used to query and eventually set the block sizes. |
truncateIfLarger | If true then the byte array is truncated to the block size if it is larger than it. |
Warning: this can only be done with the key and initialization vector, but not with data!!
An array of bytes that is of valid size for the algorithm.
If the original initialization vector size matches the required one, the array is unmodified.
If the original array is not a multiple of block size, it is padded by its initial bytes until the desired length.
|
inlinestatic |
For the specified symmetric encryption algorithm, this function takes the specified byte array and checks if the array is of valid size. If yes then the unmodified array is returned, otherwise the modified array that fits the required block size is returned. The array size must be mltiple of the block size.
Bytes that are missing to the last full block are filled cyclically with the original bytes from teh beginning.
byteArray | Original byte array provided for the algorithm. |
algorithm | Symmetric algorithm that is used for encryption/decryption. Object is used to query and eventually set the block sizes. |
truncateIfLarger | If true then the byte array is truncated to the block size if it is larger than it. |
Warning: this can only be done with the key and initialization vector, but not with data!!
An array of bytes that is of valid size for the algorithm.
If the original initialization vector size matches the required one, the array is unmodified.
If the original array is not a multiple of block size, it is padded by its initial bytes until the desired length.
|
inlinestatic |
For the specified symmetric encryption algorithm, this function takes the specified key and checks if the key is of valid size. If yes then the unmodified key is returned, otherwise the modified key that fits the required size is returned.
key | Original key provided for the algorithm. |
algorithm | Symmetric algorithm that is used for encryption/decryption. Object is used to query and eventually set the key sizes. |
A key that is of valid size for the algorithm.
If the original key size matches the required one, the key is unmodified.
If the original key is larger than the required one, the first bytes of the provided key are used in the returned key.
If the provided key is smaller than the erquired key size then bytes in the returned key are cyclically repeated bytes from the original key.
|
inlinestatic |
For the specified symmetric encryption algorithm, this function takes the specified initialization vector and checks if the vector is of valid size. If yes then the unmodified IV is returned, otherwise the modified IV that fits the required size is returned.
IV | Original initialization vector provided for the algorithm. |
algorithm | Symmetric algorithm that is used for encryption/decryption. Object is used to query and eventually set the initialization vector sizes (i.e., the block sizes). |
An initialization vector that is of valid size for the algorithm (i.e. is of the same size as block size).
If the original key size matches the required one, the IV is unmodified.
If the original IV is larger than the required one, the first bytes of the provided IV are used in the returned IV.
If the provided key is smaller than the erquired IV size (i.e. block size) then bytes in the returned IV are cyclically repeated bytes from the original IV.
|
inlinestatic |
Returns the largest possible key siye, in bits, for the spcified symmetric encryption algorithm.
algorithm | Algorithm whose largest possible key size is returned. |
|
inlinestaticprivate |
On the specified symmetric encryption algorythm, sets the largest possible key size, in bits, for the spcified symmetric encryption algorithm.
algorithm | Algorithm whose largest possible key size is returned. |
|
inlinestatic |
Returns the largest possible block siye, in bits, for the spcified symmetric encryption algorithm.
algorithm | Algorithm whose largest possible block size is returned. |
|
inlinestaticprivate |
On the specified symmetric encryption algorithm, sets the largest possible block size, in bits, for the spcified symmetric encryption algorithm.
algorithm | Algorithm whose largest possible block size is set. |
|
inlinestatic |
Prepares the symmetric algorithm, initialization vector, and key before encryption or decryption takes place.
Creates the algorithm if necessary, changes algorithm parameters (such as key size) when applicable, and checks and corrects the key and initialization vector, if necessary.
passwordBytes | Password used. |
passwordSalt | Password salt used. |
key | Key used. Method checks that the key is of correct size and corrects it when necessary. |
IV | Initialization vector used. Method checks that it is consistent with the algorithm's block size and corrects it if it is not. |
algorithmType | Algorithm type. If the algorithm is not specified then it is created anew according to this parameter. |
algorithm | Algorithm used for encryption. If null it is created. If specified then it is checked that it corresponds to the type specified by algorithmType . |
pwdType | Type of the password algorrithm. |
pwdNumIterations | Number of iterations for the password transformation algortgm. |
useLargestKey | If true then algorithm parameters are set (if necessary) in such a way that the largest hey length supported by the algorithm is used. |
useLargestBlock | If true then algorithm parameters are set (if necessary) in such a way that the largest hey length supported by the algorithm is used. |
References IG.Crypto.PasswordAlgorithmBase.GetBytes(), IG.Crypto.UtilCrypto.GetPasswordAlgorithm(), IG.Crypto.PasswordAlgorithmBase.Init(), IG.Crypto.ConstCrypto.MinPasswordLength, IG.Crypto.ConstCrypto.MinPasswordSaltLength, and IG.Crypto.UtilCrypto.PasswordAlgorithmTypeToString().
|
inlinestatic |
Encrypts the specified byte array by a symmetric encryption algorithm and returns encrypted bytes.
If the algorithm is not specified then it is provided by the system, but in this case both the key and the initialization vector must be specified.
If algorithm is specified then the key and initialization vector can be generated by the algorithm and retrieved from the algorithm after the call.
data | Data to be encrypted. |
passwordBytes | Password used to generate a secred key used to encrypt the data. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
passwordSalt | Password salt, added to the password when transformed. |
algorithmType | Type of the algorithm used. |
algorithm | Algoritgm used. |
If specified then key and IV can be generated and stored by the algorithm. Algorithm type must correspond to the specified type.
If not specified then it is generated anew.
saltBytes | Salt that is prepended the data before encryption. |
pwdType | Type of the algorithm used to transform the password. |
pwdNumIterations | Number of iteration of the password algoriithm. |
useLargestKey | If true then algorithm is eventually modified in such a way that it uses the largest possible key size. |
useLargestBlock | If true then algorithm is eventually modified in such a way that it uses the largest possible block size. |
References IG.Crypto.ConstCrypto.MinPasswordSaltLength.
|
inlinestatic |
Decrypts the specified byte array by a symmetric algorithm and returns decrypted data.
If the algorithm is not specified then it is provided by the system, but in this case both the key and the initialization vector must be specified.
If algorithm is specified then the key and initialization vector can be generated by the algorithm and retrieved from the algorithm after the call.
data | Data to be decrypted. |
passwordBytes | Password used to generate a secred key used to encrypt the data. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
passwordSalt | Password salt, added to the password when transformed. |
algorithmType | Type of the algorithm used. |
algorithm | Algoritgm used. |
If specified then key and IV can be generated and stored by the algorithm. Algorithm type must correspond to the specified type.
If not specified then it is generated anew.
numSaltBytes | Length of salt, which must be accounted for when decrypting. |
pwdType | Password algorithm type. |
pwdNumIterations | Number of iterations performed by the password algorithm. |
useLargestKey | If true then algorithm is eventually modified in such a way that it uses the largest possible key size. |
useLargestBlock | If true then algorithm is eventually modified in such a way that it uses the largest possible block size. |
|
inlinestatic |
Encrypts the specified string, using the specified symmetric algorithm, key, and initialization vector, and returns the ToBase64 string representation of the encrypted bytes.
stringToEncrypt | String that is encrypted. |
passwordBytes | Password used to generate a secred key used to encrypt the data. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
passwordSalt | Password salt, added to the password when transformed. |
algorithmType | Type of the algorithm used for enxryption. |
algorithm | Agorithm used for encryption. Must be consistend with algorithmType , or null. |
saltBytes | Salt that is prepended the data before encryption. |
pwdType | Password algorithm type. |
pwdNumIterations | Number of iterations performed by the password algorithm. |
useLargestKey | If true then the algorithm will be modified in such a way that it uses the largest possible key for this kind of algorithm. |
useLargestBlock | If true then the algorithm will be modified in such a way that it uses the largest possible block for this kind of algorithm. |
References IG.Crypto.ConstCrypto.MinPasswordSaltLength.
|
inlinestatic |
Derypts the specified string from encryted byte array, using the specified symmetric algorithm, key, and initialization vector.
cipherText | Base64 string representation of the byte array containing the encrypted original string. |
passwordBytes | Password used to generate a secred key used to encrypt the data. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
passwordSalt | Password salt, added to the password when transformed. |
algorithmType | Type of the algorithm used. |
algorithm | Agorithm used for encryption. Must be consistend with algorithmType , or null. |
numSaltBytes | Length of salt, which must be accounted for when decrypting. |
useLargestKey | If true then the algorithm will be modified in such a way that it uses the largest possible key for this kind of algorithm. |
pwdType | Password algorithm that henerated key from the password. |
pwdNumIterations | Number fo iteration of the password algorithm. |
useLargestBlock | If true then the algorithm will be modified in such a way that it uses the largest possible block for this kind of algorithm. |
|
inlinestatic |
Encrypts the data from the specified input file by a symmetric encryption algorithm and writes encrypted data to the specified output file.
If the algorithm is not specified then it is provided by the system, but in this case both the key and the initialization vector must be specified.
If algorithm is specified then the key and initialization vector can be generated by the algorithm and retrieved from the algorithm after the call.
inputFilePath | Path to the input file from which data is encrypted. The file must be exist and be readable. |
outputFilePath | Path to the output file to which encrypted data is written. The file must be writable and will be wasOverwritten if it already exists. |
passwordBytes | Password, as byte array. |
passwordSalt | Password salt, as byte array. |
algorithmType | Type of the algorithm used. |
algorithm | Algoritgm used. |
If specified then key and IV can be generated and stored by the algorithm. Algorithm type must correspond to the specified type.
If not specified then it is generated anew.
saltBytes | Salt, as byte array. |
bufferSize | Size of the intermediate buffer through which we read from input and write to output stream. Buffer makes possible to work on very large streams efficiently. |
pwdType | Password algorithm type. |
pwdNumIterations | Number of iterations performed by the password algorithm. |
useLargestKey | If true then algorithm is eventually modified in such a way that it uses the largest possible key size. |
useLargestBlock | If true then algorithm is eventually modified in such a way that it uses the largest possible block size. |
References IG.Crypto.ConstCrypto.MinPasswordSaltLength.
|
inlinestatic |
Decrypts the data from the specified input file by a symmetric encryption algorithm and writes decrypted data to the specified output file.
If the algorithm is not specified then it is provided by the system, but in this case both the key and the initialization vector must be specified.
If algorithm is specified then the key and initialization vector can be generated by the algorithm and retrieved from the algorithm after the call.
inputFilePath | Path to the input file from which data is encrypted. The file must be exist and be readable. |
outputFilePath | Path to the output file to which encrypted data is written. The file must be writable and will be wasOverwritten if it already exists. |
passwordBytes | Password, as byte array. |
passwordSalt | Password salt, as byte array. |
algorithmType | Type of the algorithm used. |
algorithm | Algoritgm used. |
If specified then key and IV can be generated and stored by the algorithm. Algorithm type must correspond to the specified type.
If not specified then it is generated anew.
numSaltBytes | Length of salt, which must be accounted for when decrypting. | ||||
bufferSize | Size of the intermediate buffer through which we read from input and write to output stream.
| ||||
useLargestKey | If true then algorithm is eventually modified in such a way that it uses the largest possible key size. | ||||
useLargestBlock | If true then algorithm is eventually modified in such a way that it uses the largest possible block size. |
|
inlinestatic |
Prepares the symmetric algorithm, initialization vector, and key before encryption or decryption takes place.
Creates the algorithm if necessary, changes algorithm parameters (such as key size) when applicable, and checks and corrects the key and initialization vector, if necessary.
key | Key used. Method checks that the key is of correct size and corrects it when necessary. |
IV | Initialization vector used. Method checks that it is consistent with the algorithm's block size and corrects it if it is not. |
algorithmType | Algorithm type. If the algorithm is not specified then it is created anew according to this parameter. |
algorithm | Algorithm used for encryption. If null it is created. If specified then it is checked that it corresponds to the type specified by algorithmType . |
useLargestKey | If true then algorithm parameters are set (if necessary) in such a way that the largest hey length supported by the algorithm is used. |
useLargestBlock | If true then algorithm parameters are set (if necessary) in such a way that the largest hey length supported by the algorithm is used. |
Referenced by IG.Crypto.UtilCrypto.DecryptPlain(), and IG.Crypto.UtilCrypto.EncryptPlain().
|
inlinestatic |
Encrypts the specified byte array by a symmetric encryption algorithm and writes encrypted data to the specified output stream that must be open for writing.
If the algorithm is not specified then it is provided by the system, but in this case both the key and the initialization vector must be specified.
If algorithm is specified then the key and initialization vector can be generated by the algorithm and retrieved from the algorithm after the call.
data | Data to be encrypted. |
outputStream | Stream to which decrypted data is written. The stream must be open for writing and should be closed by the caller of this method. |
key | Secret key used to encrypt the data. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
IV | Initialization vector. It can be public and stored together with encrypted data, but it is advised that the vecor is randomly generated for each session or each encryption. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
algorithmType | Type of the algorithm used. |
algorithm | Algoritgm used. |
If specified then key and IV can be generated and stored by the algorithm. Algorithm type must correspond to the specified type.
If not specified then it is generated anew.
saltBytes | Salt that is prepended the data before encryption. |
useLargestKey | If true then algorithm is eventually modified in such a way that it uses the largest possible key size. |
useLargestBlock | If true then algorithm is eventually modified in such a way that it uses the largest possible block size. |
References IG.Crypto.UtilCrypto.PrepareSymmetricAllgorithmPlain().
Referenced by IG.Crypto.CryptoManager.AppEncryptSymmetricAll().
|
inlinestatic |
Decrypts the specified byte array by a symmetric algorithm and writes decrypted data to the specified output stream.
If the algorithm is not specified then it is provided by the system, but in this case both the key and the initialization vector must be specified.
If algorithm is specified then the key and initialization vector can be generated by the algorithm and retrieved from the algorithm after the call.
data | Data to be decrypted. |
outputStream | Stream to which decrypted data is written. The stream must be open for writing and should be closed by the caller of this method. |
key | Secret key used to decrypt the data. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
IV | Initialization vector. It can be public and stored together with encrypted data, but it is advised that the vecor is randomly generated for each session or each encryption. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
algorithmType | Type of the algorithm used. |
algorithm | Algoritgm used. |
If specified then key and IV can be generated and stored by the algorithm. Algorithm type must correspond to the specified type.
If not specified then it is generated anew.
numSaltBytes | Length of salt, which must be accounted for when decrypting. |
useLargestKey | If true then algorithm is eventually modified in such a way that it uses the largest possible key size. |
useLargestBlock | If true then algorithm is eventually modified in such a way that it uses the largest possible block size. |
References IG.Crypto.UtilCrypto.PrepareSymmetricAllgorithmPlain().
Referenced by IG.Crypto.CryptoManager.AppEncryptSymmetricAll().
|
inlinestatic |
Encrypts the specified byte array by a symmetric encryption algorithm and returns encrypted bytes.
If the algorithm is not specified then it is provided by the system, but in this case both the key and the initialization vector must be specified.
If algorithm is specified then the key and initialization vector can be generated by the algorithm and retrieved from the algorithm after the call.
data | Data to be encrypted. |
key | Secret key used to encrypt the data. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
IV | Initialization vector. It can be public and stored together with encrypted data, but it is advised that the vecor is randomly generated for each session or each encryption. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
algorithmType | Type of the algorithm used. |
algorithm | Algoritgm used. |
If specified then key and IV can be generated and stored by the algorithm. Algorithm type must correspond to the specified type.
If not specified then it is generated anew.
saltBytes | Salt that is prepended the data before encryption. |
useLargestKey | If true then algorithm is eventually modified in such a way that it uses the largest possible key size. |
useLargestBlock | If true then algorithm is eventually modified in such a way that it uses the largest possible block size. |
|
inlinestatic |
Decrypts the specified byte array by a symmetric algorithm and returns decrypted data.
If the algorithm is not specified then it is provided by the system, but in this case both the key and the initialization vector must be specified.
If algorithm is specified then the key and initialization vector can be generated by the algorithm and retrieved from the algorithm after the call.
data | Data to be decrypted. |
key | Secret key used to decrypt the data. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
IV | Initialization vector. It can be public and stored together with encrypted data, but it is advised that the vecor is randomly generated for each session or each encryption. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
algorithmType | Type of the algorithm used. |
algorithm | Algoritgm used. |
If specified then key and IV can be generated and stored by the algorithm. Algorithm type must correspond to the specified type.
If not specified then it is generated anew.
useLargestKey | If true then algorithm is eventually modified in such a way that it uses the largest possible key size. |
numSaltBytes | Length of salt, which must be accounted for when decrypting. |
useLargestBlock | If true then algorithm is eventually modified in such a way that it uses the largest possible block size. |
|
inlinestatic |
Encrypts the specified string, using the specified symmetric algorithm, key, and initialization vector, and returns the Base64 string representation of the encrypted bytes.
stringToEncrypt | String that is encrypted. |
key | Secret key used in encryption. |
initializationVector | Initialization vector used in encryption. Necessary for stronger encryption (othervise repeating input blocks would cause repeating output blocks). |
algorithmType | Type of the algorithm used. |
algorithm | Agorithm used for encryption. Must be consistend with algorithmType , or null. |
saltBytes | Salt that is prepended the data before encryption. |
useLargestKey | If true then the algorithm will be modified in such a way that it uses the largest possible key for this kind of algorithm. |
useLargestBlock | If true then the algorithm will be modified in such a way that it uses the largest possible block for this kind of algorithm. |
Referenced by IG.Crypto.CryptoManager.AppEncryptSymmetricAll().
|
inlinestatic |
Derypts the specified string from encryted byte array, using the specified symmetric algorithm, key, and initialization vector.
cipherText | Base64 string representation of the byte array containing the encrypted original string. |
key | Secret key used in encryption. |
initializationVector | Initialization vector used in encryption. Necessary for stronger encryption (othervise repeating input blocks would cause repeating output blocks). |
algorithmType | Type of the algorithm used. |
algorithm | Agorithm used for encryption. Must be consistend with algorithmType , or null. |
numSaltBytes | Length of salt, which must be accounted for when decrypting. |
useLargestKey | If true then the algorithm will be modified in such a way that it uses the largest possible key for this kind of algorithm. |
useLargestBlock | If true then the algorithm will be modified in such a way that it uses the largest possible block for this kind of algorithm. |
Referenced by IG.Crypto.CryptoManager.AppEncryptSymmetricAll().
|
inlinestatic |
Encrypts the specified string to a byte array, using the specified symmetric algorithm, key, and initialization vector.
stringToEncrypt | String that is encrypted. |
key | Secret key used in encryption. |
initializationVector | Initialization vector used in encryption. Necessary for stronger encryption (othervise repeating input blocks would cause repeating output blocks). |
algorithmType | Type of the algorithm used. |
algorithm | Agorithm used for encryption. Must be consistend with algorithmType , or null. |
saltBytes | Salt that is prepended the data before encryption. |
useLargestKey | If true then the algorithm will be modified in such a way that it uses the largest possible key for this kind of algorithm. |
useLargestBlock | If true then the algorithm will be modified in such a way that it uses the largest possible block for this kind of algorithm. |
|
inlinestatic |
Derypts the specified string from encryted byte array, using the specified symmetric algorithm, key, and initialization vector.
cipherText | Byte array containing the encrypted original string. |
key | Secret key used in encryption. |
initializationVector | Initialization vector used in encryption. Necessary for stronger encryption (othervise repeating input blocks would cause repeating output blocks). |
algorithmType | Type of the algorithm used. |
algorithm | Agorithm used for encryption. Must be consistend with algorithmType , or null. |
numSaltBytes | Length of salt, which must be accounted for when decrypting. |
useLargestKey | If true then the algorithm is modified (if necessary) in such a way that the largest possible key size is used. |
useLargestBlock | If true then the algorithm is modified in such a way that the largest possible block size is used. |
|
inlinestatic |
Encrypts the data from the specified input stream by a symmetric encryption algorithm and writes encrypted data to the specified output stream.
If the algorithm is not specified then it is provided by the system, but in this case both the key and the initialization vector must be specified.
If algorithm is specified then the key and initialization vector can be generated by the algorithm and retrieved from the algorithm after the call.
inputStream | Input stream from which data is encrypted. The stream must be open for reading and should be closed by the caller of this method. |
outputStream | Stream to which encrypted data is written. The stream must be open for writing and should be closed by the caller of this method. |
key | Secret key used to encrypt the data. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
IV | Initialization vector. It can be public and stored together with encrypted data, but it is advised that the vecor is randomly generated for each session or each encryption. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
algorithmType | Type of the algorithm used. |
algorithm | Algoritgm used. |
If specified then key and IV can be generated and stored by the algorithm. Algorithm type must correspond to the specified type.
If not specified then it is generated anew.
saltBytes | Salt added to encrypted data. |
bufferSize | Size of the intermediate buffer through which we read from input and write to output stream. Buffer makes possible to work on very large streams efficiently. |
useLargestKey | If true then algorithm is eventually modified in such a way that it uses the largest possible key size. |
useLargestBlock | If true then algorithm is eventually modified in such a way that it uses the largest possible block size. |
References IG.Crypto.UtilCrypto.PrepareSymmetricAllgorithmPlain().
|
inlinestatic |
Decrypts the data from the specified input stream by a symmetric encryption algorithm and writes decrypted data to the specified output stream.
If the algorithm is not specified then it is provided by the system, but in this case both the key and the initialization vector must be specified.
If algorithm is specified then the key and initialization vector can be generated by the algorithm and retrieved from the algorithm after the call.
inputStream | Input stream from which data is decrypted. The stream must be open for reading and should be closed by the caller of this method. |
outputStream | Stream to which decrypted data is written. The stream must be open for writing and should be closed by the caller of this method. |
key | Secret key used to encrypt the data. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
IV | Initialization vector. It can be public and stored together with encrypted data, but it is advised that the vecor is randomly generated for each session or each encryption. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
algorithmType | Type of the algorithm used. |
algorithm | Algorithm used. |
If specified then key and IV can be generated and stored by the algorithm. Algorithm type must correspond to the specified type.
If not specified then it is generated anew.
numSaltBytes | Length of the salt that is added to the encrypted data. |
bufferSize | Size of the intermediate buffer through which we read from input and write to output stream. Buffer makes possible to work on very large streams efficiently. |
useLargestKey | If true then algorithm is eventually modified in such a way that it uses the largest possible key size. |
useLargestBlock | If true then algorithm is eventually modified in such a way that it uses the largest possible block size. |
References IG.Crypto.UtilCrypto.PrepareSymmetricAllgorithmPlain().
|
inlinestatic |
Encrypts the data from the specified input file by a symmetric encryption algorithm and writes encrypted data to the specified output file.
If the algorithm is not specified then it is provided by the system, but in this case both the key and the initialization vector must be specified.
If algorithm is specified then the key and initialization vector can be generated by the algorithm and retrieved from the algorithm after the call.
inputFilePath | Path to the input file from which data is encrypted. The file must be exist and be readable. |
outputFilePath | Path to the output file to which encrypted data is written. The file must be writable and will be wasOverwritten if it already exists. |
key | Secret key used to encrypt the data. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
IV | Initialization vector. It can be public and stored together with encrypted data, but it is advised that the vecor is randomly generated for each session or each encryption. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
algorithmType | Type of the algorithm used. |
algorithm | Algoritgm used. |
If specified then key and IV can be generated and stored by the algorithm. Algorithm type must correspond to the specified type.
If not specified then it is generated anew.
saltBytes | Salt that is added to data before encryption. |
bufferSize | Size of the intermediate buffer through which we read from input and write to output stream. Buffer makes possible to work on very large streams efficiently. |
useLargestKey | If true then algorithm is eventually modified in such a way that it uses the largest possible key size. |
useLargestBlock | If true then algorithm is eventually modified in such a way that it uses the largest possible block size. |
Referenced by IG.Crypto.CryptoManager.AppEncryptSymmetricAll().
|
inlinestatic |
Decrypts the data from the specified input file by a symmetric encryption algorithm and writes decrypted data to the specified output file.
If the algorithm is not specified then it is provided by the system, but in this case both the key and the initialization vector must be specified.
If algorithm is specified then the key and initialization vector can be generated by the algorithm and retrieved from the algorithm after the call.
inputFilePath | Path to the input file from which data is encrypted. The file must be exist and be readable. |
outputFilePath | Path to the output file to which encrypted data is written. The file must be writable and will be wasOverwritten if it already exists. |
key | Secret key used to encrypt the data. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
IV | Initialization vector. It can be public and stored together with encrypted data, but it is advised that the vecor is randomly generated for each session or each encryption. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
algorithmType | Type of the algorithm used. |
algorithm | Algoritgm used. |
If specified then key and IV can be generated and stored by the algorithm. Algorithm type must correspond to the specified type.
If not specified then it is generated anew.
numSaltBytes | Length of the salt that is added to the data befoe encryption. |
bufferSize | Size of the intermediate buffer through which we read from input and write to output stream. Buffer makes possible to work on very large streams efficiently. |
useLargestKey | If true then algorithm is eventually modified in such a way that it uses the largest possible key size. |
useLargestBlock | If true then algorithm is eventually modified in such a way that it uses the largest possible block size. |
Referenced by IG.Crypto.CryptoManager.AppEncryptSymmetricAll().
|
inlinestatic |
Returns all asymmetric encryption algorithm types contained in the enumeration AsymmetricAlgorithmType
References IG.Lib.Util.LockGlobal.
|
inlinestatic |
Returns the AsymmetricAlgorithmType value corresponding to the specified string.
typeString | String that represents the asymmetric encryption algorithm type. |
Referenced by IG.Crypto.CryptoManager.ParseCommandlineParameters(), and IG.Crypto.CryptoManager.ResolveAsymParameters().
|
inlinestatic |
Returns the asymmetric encryption algorithm type, i.e. an enumeration of type SymmetricAlgorithmType, for the specified asymmetric encryption algorithm object.
algorithmObject | Asymmetric algorithm object for which type enumeration is returned. |
|
inlinestatic |
Returns standard string representation of the specified asymmetric encryption algorithm type.
algorithmType | Asymmetric encryption algorithm type whose string representation is returned. |
Referenced by IG.Crypto.UtilCrypto.DeleteKeyInCsp(), IG.Crypto.UtilCrypto.GetAsymmetricAlgorithm(), and IG.Crypto.UtilCrypto.PrepareAymmetricAllgorithmBasic().
|
inlinestatic |
Returns the appropriate asymmetric algorithm according to the specified hashRet type, or null if the type is not recognized or the method is not implemented for that type.
algorithmType | Specification of the asymmetric encryption algorithm type. |
|
inlinestatic |
Returns true if the specified asymmetric encryption algorithm corresponds the type specification, false otherwise.
If the specified algorithm is null or the specified type is unknown then false is returned.
algorithmType | Specification of the asymmetric encryption algorithm type. |
algorithm | Algorithm that is checked for type correctness. |
|
inlinestatic |
Returns the largest possible key size, in bits, for the spcified symmetric encryption algorithm.
algorithm | Algorithm whose largest possible key size is returned. |
|
inlinestaticprivate |
On the specified asymmetric encryption algorithm, sets the largest possible key size, in bits, for the corresponding asymmetric encryption algorithm.
algorithm | Algorithm whose largest possible key size is returned. |
|
inlinestatic |
For the specified asymmetric encryption algorithm, this function takes the specified key and checks if the key is of valid size. If yes then the unmodified key is returned, otherwise the modified key that fits the required size is returned.
key | Original key provided for the algorithm. |
algorithm | Asymmetric algorithm that is used for encryption/decryption. Object is used to query and eventually set the key sizes. |
useLargestKey | If true then the specified algorithm is first modified in such a way that it uses the maximal possible key length for the specific kind of algorithm. |
A key that is of valid size for the algorithm.
If the original key size matches the required one, the key is unmodified.
If the original key is larger than the required one, the first bytes of the provided key are used in the returned key.
If the provided key is smaller than the erquired key size then bytes in the returned key are cyclically repeated bytes from the original key.
|
inlinestatic |
Returns the value of the CspProviderFlags enum corresponding to the specified string.
flagString | String representation of the flag value of type CspProviderFlags |
Referenced by IG.Crypto.CryptoManager.ParseCommandlineParameters().
|
inlinestatic |
Returns standard string representation of the CspProviderFlags enumeration.
flags | Asymmetric encryption algorithm type whose string representation is returned. |
|
inlinestatic |
Creates and returns a string that presents the key information contained in the argument keyInfo .
keyInfo | Information about the key pair that is returned in string form. |
numIndent | Indentation. |
Referenced by IG.Crypto.CryptoManager.AppAsymExportKey(), IG.Crypto.CryptoManager.AppAsymKeyInfo(), IG.Crypto.CryptoManager.AppAsymTest(), IG.Crypto.CryptoManager.AppCertInfo(), and IG.Crypto.UtilCrypto.ToString().
|
inlinestatic |
Creates and returns a string containing information about the specified RSA algorithm.
alg | Algorithm for which information is returned. |
References IG.Crypto.UtilCrypto.ToString().
|
inlinestatic |
Creates and returns a string containing information about the specified DSA algorithm.
alg | Algorithm for which information is returned. |
References IG.Lib.Util.CollectionToString(), and IG.Crypto.UtilCrypto.ToString().
|
inlinestatic |
Creates and returns a string containing information about the specified RSA algorithm.
alg | Algorithm for which information is returned. |
|
inlinestatic |
Returns a readable string representation of the specified certificate.
To obtain a detailed access to certificate data, the object is first used to create a more advanced X509Certificate2 type of object (which has a contructor that takes its base class) and then string representation is created from thi object, which offers better access to internal data.
certificate | Certificate whose string representaion is returned. |
|
inlinestatic |
Returns simple name of the specified cerrtificate.
cert | Certificate whose simple name should be returned. |
Referenced by IG.Crypto.UtilCrypto.AddCertificateToStore(), IG.Crypto.CryptoManager.AppAddCertificate(), IG.Crypto.UtilCrypto.DeleteCertificateFromStore(), IG.Crypto.UtilCrypto.GetCertificate(), and IG.Crypto.UtilCrypto.GetCertificateStoreDescription().
|
inlinestatic |
Returns a readable string representation of the specified certificate.
cert | Certificate whose string representaion is returned. |
|
inlinestatic |
Returns a string that contains human readable description of certificate stores.
outputLevel | Whether certificates contained in stores should also be listed (only by names). |
storeName | Name of the certificate store whose information is included in the string. |
storeLocation | Indicates the location of certificte store: 1 - current user, 2 - local machine, 0 or 3 - both. |
Enumeration StoreLocation can be conveniently used (eventually combined as flags with the OR operator) to define the location.
References IG.Crypto.UtilCrypto.GetSimpleName().
Referenced by IG.Crypto.CryptoManager.AppCertStoreInfo().
|
inlinestatic |
Adds to the specified list all persistent certificate stores that match the criteria specified by parameters.
stores | A list to which the matching certificate stores are added. |
If it references a variable that is null, the list is created.
If the clearAtBeginning parameter is true then the list is cleared before operation.
storeName | Name of the certificate store whose information is included in the string. |
storeLocation | Indicates the location of certificte store: 1 - current user, 2 - local machine, 0 or 3 - both. |
Enumeration StoreLocation can be conveniently used (eventually combined as flags with the OR operator) to define the location.
clearAtBeginning | If true (which is default value) then the list is cleared before the operation proceeds. |
Referenced by IG.Crypto.UtilCrypto.AddCertificateToStore(), and IG.Crypto.UtilCrypto.DeleteCertificateFromStore().
|
inlinestatic |
Closes all certificate stores on the list.
stores | List of certificate stores that are closed. |
Referenced by IG.Crypto.UtilCrypto.AddCertificateToStore(), and IG.Crypto.UtilCrypto.DeleteCertificateFromStore().
|
inlinestatic |
Obtains and returns the certificate specifid by parameters.
privateKeyPassword | Password to access the certificate's private key. |
certificateFilePath | Name of the file containing the certificate. |
certificateName | Name of the certificate from certificate store. |
storeName | Certificate store frrom which certificate is to be obtained. |
storeLocation | Indicates location of the certificate store: 1 for current user, 2 for local machine, 0 or 3 for any location, 4 for none. |
References IG.Crypto.UtilCrypto.GetSimpleName().
Referenced by IG.Crypto.CryptoManager.AppAddCertificate(), and IG.Crypto.CryptoManager.AppCertInfo().
|
inlinestatic |
Adds a certificate to the specified certificate store.
certificate | Certificate to be added to the store. |
skipped | Output flag informing whether addition has been wasSkipped (to prevent an overwrite). |
overwritten | Output flag informing whether existing certificate has been wasOverwritten (either due to automatic overwrites specified by parameter isForceOverwrites , or upon user confirmation). |
certificateStoreName | Name of the certificate store to which the certificate is added. |
storeLocation | Location where certificate is added: 1 - current user, 2 - local machine. |
isForceOverwrites | If true then overwrites are forcced without asking for user confirmation. In such a case, parameter overwritten is set to true. |
isSkipOverwrites | If true then addition is automatically wasSkipped if it would overwrite an existing certificate. In such a case, parameter skipped is set to true. |
References IG.Crypto.UtilCrypto.CloseCertificateStores(), IG.Crypto.UtilCrypto.GetAsymmetricalgorithmHash(), IG.Crypto.UtilCrypto.GetCertificateStores(), IG.Crypto.UtilCrypto.GetSimpleName(), and IG.Lib.UtilConsole.Read().
Referenced by IG.Crypto.CryptoManager.AppAddCertificate().
|
inlinestatic |
Deletes the specified certificate to the specified certificate store.
skipped | Output flag informing whether addition has been skipped (to prevent deletion). |
deleted | Output flag informing whether existing certificate has been deleeed (either due to automatic deletions specified by parameter isForceDeletes , or upon user confirmation). |
certificateName | Name of the certificate to be deleted from the store. |
storeName | Name of the certificate store to which the certificate is added. |
storeLocation | Location where certificate is added: 1 - current user, 2 - local machine. |
isForceDeletes | If true then deletes are forcced without asking for user confirmation. In such a case, parameter deleted is set to true. |
isSkipDeletes | If true then addition is automatically wasSkipped if it would overwrite an existing certificate. In such a case, parameter skipped is set to true. |
References IG.Crypto.UtilCrypto.CloseCertificateStores(), IG.Crypto.UtilCrypto.GetAsymmetricalgorithmHash(), IG.Crypto.UtilCrypto.GetCertificateStores(), IG.Crypto.UtilCrypto.GetSimpleName(), and IG.Lib.UtilConsole.Read().
Referenced by IG.Crypto.CryptoManager.AppRemoveCertificate().
|
inlinestatic |
Returns a hash value for the specified Asymmetric algorithm, which depends on algorithm keys.
The hash vlaue can be used to verify that two algorithm object used actually have the same keys. This is especially useful when encryption is performed on one machine and decryption is performed on another.
See also: RSAParameters", https://msdn.microsoft.com/en-us/library/system.security.cryptography.rsaparameters%28v=vs.110%29.aspx
algorithm | Algorithm for which keys' hashRet is returned. |
includePrivate | Whether private parameters of the asymmetric key contained in the algorithm are taken into account while hassing. |
Default is false and it is highly recommended to use only false for this parameter.
Usually using only public parameters should be enough, because it is very unlikely that any key pair would have the same public parameters but different private parameters.
skipPrivateIfNotExportable | If true then private parameters are not taken into account when they are not exportable to XML, even when includePrivate = true. If false then exception is thrown in the case that includePrivate is true but private parameters of the keys are not exportable to XML. |
Default is false.
hashType | Type of the hashing algorithm. Default is HashType.SHA1 and it is recommended that this is not changed. |
References IG.Crypto.UtilCrypto.GetStringHashHex(), IG.Crypto.RSA, and IG.Lib.Util.ToHexString().
Referenced by IG.Crypto.UtilCrypto.AddCertificateToStore(), IG.Crypto.CryptoManager.AppAsymExportKey(), IG.Crypto.CryptoManager.AppAsymKeyInfo(), IG.Crypto.CryptoManager.AppCertInfo(), and IG.Crypto.UtilCrypto.DeleteCertificateFromStore().
|
inlinestatic |
Returns the maximal size of a byte array that can be encrypted by using the specified asymmetric algoritm.
alg | Asymmetric algorithm that would be used for encryption. |
Referenced by IG.Crypto.CryptoManager.AppAsymExportKey(), IG.Crypto.CryptoManager.AppAsymKeyInfo(), and IG.Crypto.CryptoManager.AppCertInfo().
|
inlinestatic |
Tests whether the specified asymmetric algorithm(s) correctly encrypts/decrypts the specified string.
Returns true if the test passes and false if not.
The specified string must be short enough.
testString | String to be encrypted and decrypted. |
Must be short enough in order to be suitable for asymmetric encryption / decryption.
If null or empty string then false is returned.
algEnc | Asymmetric algorithm object used for encryption (and also for decryption if the second algorithm object is not specified). |
If null then false is returned.
algDec | Asymmetric algorithm used for decryption. |
If null then the first algorithm object is used for both encryption and decryption.
Possibility of having two algorithm objects makes possible to test situations when one object contains only the public key and a different object contains the private key.
Referenced by IG.Crypto.CryptoManager.AppAsymExportKey(), IG.Crypto.CryptoManager.AppAsymKeyInfo(), IG.Crypto.CryptoManager.AppAsymTest(), and IG.Crypto.CryptoManager.AppCertInfo().
|
inlinestatic |
Tests whether the specified asymmetric algorithm(s) correctly encrypts/decrypts the specified string.
Returns true if the test passes and false if not.
The specified string must be short enough.
testString | String to be encrypted and decrypted. |
Must be short enough in order to be suitable for asymmetric encryption / decryption.
If null or empty string then false is returned.
errorString | String variable where error message is stored, in case that exception is thrown during encryption/decryption. If no exception is thrown then the variable attains value null. |
algEnc | Asymmetric algorithm object used for encryption (and also for decryption if the second algorithm object is not specified). |
If null then false is returned.
algDec | Asymmetric algorithm used for decryption. |
If null then the first algorithm object is used for both encryption and decryption.
Possibility of having two algorithm objects makes possible to test situations when one object contains only the public key and a different object contains the private key.
|
inlinestatic |
Tests whether the specified asymmetric algorithm(s) correctly encrypts/decrypts a random byte array of the specified size.
Returns true if the test passes (encrypted and then decrypted bytes equal to original) and false if not.
The specified length must me smaller and equal to the value returned by GetMaximalAsymmetricTextLength for the test to pass (beside the encryption/decryption capability and correctness of operaton).
length | Length of the random byte array that is encrypted / decrypted. |
algEnc | Asymmetric algorithm object used for encryption (and also for decryption if the second algorithm object is not specified). |
If null then false is returned.
algDec | Asymmetric algorithm used for decryption. |
If null then the first algorithm object is used for both encryption and decryption.
Possibility of having two algorithm objects makes possible to test situations when one object contains only the public key and a different object contains the private key.
|
inlinestatic |
Tests whether the specified asymmetric algorithm(s) correctly encrypts/decrypts a random byte array of the specified size.
Returns true if the test passes (encrypted and then decrypted bytes equal to original) and false if not.
The specified length must me smaller and equal to the value returned by GetMaximalAsymmetricTextLength for the test to pass (beside the encryption/decryption capability and correctness of operaton).
length | Length of the random byte array to be encrypted and decrypted. |
Must be short enough in order to be suitable for asymmetric encryption / decryption. Maximal length can be obtained by the GetMaximalAsymmetricTextLength method.
If null or empty string then false is returned.
errorString | String variable where error message is stored, in case that exception is thrown during encryption/decryption. If no exception is thrown then the variable attains value null. |
algEnc | Asymmetric algorithm object used for encryption (and also for decryption if the second algorithm object is not specified). |
If null then false is returned.
algDec | Asymmetric algorithm used for decryption. |
If null then the first algorithm object is used for both encryption and decryption.
Possibility of having two algorithm objects makes possible to test situations when one object contains only the public key and a different object contains the private key.
|
inlinestatic |
Creates (if necessary) and returns a new asymmetric algorithm whose keys are either created or obtained through arguments.
algorithmType | Type of the asymmetric algorithm that is returned. |
containerName | Name of the key container where the keys persist. If not specified then keys are not persistent. |
xmlString | If not null, this string must contain properly formed XML form which the keys are read. |
flags | Flags of type CspProviderFlags used in crypto service parameters when algorithm object is created. If the value is CspProviderFlags.NoFlags then flags are not used. |
certificateFilePath | Name of the certificate file from which algorithm keys are obtained. |
certificateName | Name of the certificate from one of the standard certificate stores from which the algorithm keys are obtained. |
certStore | Certificate store from which certificate named certificateName is obtained. If null then all standard stores are searched for. |
References IG.Crypto.UtilCrypto.AsymmetricAlgorithmTypeToString().
Referenced by IG.Crypto.CryptoManager.AppAsymTest(), and IG.Crypto.CryptoManager.ResolveAsymParameters().
|
inlinestatic |
Deletes the asymmetric algorithm keys from the specified key container.
algorithmType | Type of the asymmetric algorithm for which the keys are deleted. |
containerName | Name of the container from which keys are deleted. |
References IG.Crypto.UtilCrypto.AsymmetricAlgorithmTypeToString().
Referenced by IG.Crypto.CryptoManager.AppAsymTest().
|
inlinestatic |
|
inlinestatic |
Referenced by IG.Crypto.CryptoManager.AppAsymTest().
|
inlinestatic |
Referenced by IG.Crypto.CryptoManager.AppAsymTest().
|
inlinestatic |
Referenced by IG.Crypto.CryptoManager.AppAsymTest().
|
inlinestatic |
Referenced by IG.Crypto.CryptoManager.AppAsymTest().
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Returns the specified standard IGLib salt string.
There are several uses of salt strings:
- they are appended or prepended to passwords before hashing.
whichSalt | Index of the standard IGLib salt string. |
|
inlinestatic |
Returns the number of standard IGLib salt strings.
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
An array of standard IGLib salt suffices.
Warnings:
- Hard coding salts is generally not OK, it is important that salts are random and salts can be stored together with enxrypted data.
- This array should not be modifiable.
- Elements of this array may not change over time. Only new elements can be added.
|
staticget |
Output level for static methods of the current utility class.
Warning: This field can be removed at any time.
|
staticget |
Locking object for static methods and properties of this class.
Read-only, safely provided on demand (using Util.LockGlobal when created).
|
staticget |
Gets the character encoding that is used for calculating hashes of strings.
About thread safety (Enncoding classes should be stateless):
http://stackoverflow.com/questions/3024384/thread-safety-and-system-text-encoding-in-c-sharp
Referenced by IG.Crypto.CryptoManager.AppAsymTest(), IG.Crypto.CryptoManager.AppEncryptSymmetricAll(), IG.Script.ScriptAppBase.CryptoFunctionTimeKeyGeneration_OLD_TO_DELETE_LATER(), and IG.Crypto.CryptoManager.ResolvePasswordParameters().
|
staticgetprivate |
Object used to generate random bytes.
Object is created on demand (layzy evaluation). Ony one object is used through appllication lifetime.
|
staticget |
Whether to perform direct RSA encryption using OAEP (optimal asymmetric encryption padding - only available on computers running MS Windows XP or later).
To do:
Check whether this works in Mono.