diff options
Diffstat (limited to 'src/Common/Crypto.c')
-rw-r--r-- | src/Common/Crypto.c | 68 |
1 files changed, 24 insertions, 44 deletions
diff --git a/src/Common/Crypto.c b/src/Common/Crypto.c index c0e77922..c7b0c73d 100644 --- a/src/Common/Crypto.c +++ b/src/Common/Crypto.c @@ -392,19 +392,15 @@ const wchar_t *CipherGetName (int cipherId) { Cipher* pCipher = CipherGet (cipherId); return pCipher? pCipher -> Name : L""; } -#endif int CipherGetBlockSize (int cipherId) { -#ifdef TC_WINDOWS_BOOT - return CipherGet (cipherId) -> BlockSize; -#else Cipher* pCipher = CipherGet (cipherId); return pCipher? pCipher -> BlockSize : 0; -#endif } +#endif int CipherGetKeySize (int cipherId) { #ifdef TC_WINDOWS_BOOT @@ -450,8 +446,9 @@ int EAGetFirst () { return 1; } +#ifndef TC_WINDOWS_BOOT // Returns number of EAs int EAGetCount (void) { int ea, count = 0; @@ -461,8 +458,9 @@ int EAGetCount (void) count++; } return count; } +#endif int EAGetNext (int previousEA) { int id = previousEA + 1; @@ -592,8 +590,10 @@ int EAGetKeySize (int ea) return size; } +#ifndef TC_WINDOWS_BOOT + // Returns the first mode of operation of EA int EAGetFirstMode (int ea) { return (EncryptionAlgorithms[ea].Modes[0]); @@ -611,11 +611,8 @@ int EAGetNextMode (int ea, int previousModeId) return 0; } - -#ifndef TC_WINDOWS_BOOT - // Returns the name of the mode of operation of the whole EA wchar_t *EAGetModeName (int ea, int mode, BOOL capitalLetters) { switch (mode) @@ -644,40 +641,9 @@ int EAGetKeyScheduleSize (int ea) return size; } - -// Returns the largest key size needed by an EA for the specified mode of operation -int EAGetLargestKeyForMode (int mode) -{ - int ea, key = 0; - - for (ea = EAGetFirst (); ea != 0; ea = EAGetNext (ea)) - { - if (!EAIsModeSupported (ea, mode)) - continue; - - if (EAGetKeySize (ea) >= key) - key = EAGetKeySize (ea); - } - return key; -} - - -// Returns the largest key needed by any EA for any mode -int EAGetLargestKey () -{ - int ea, key = 0; - - for (ea = EAGetFirst (); ea != 0; ea = EAGetNext (ea)) - { - if (EAGetKeySize (ea) >= key) - key = EAGetKeySize (ea); - } - - return key; -} - +#ifndef TC_WINDOWS_BOOT // Returns number of ciphers in EA int EAGetCipherCount (int ea) { @@ -686,8 +652,9 @@ int EAGetCipherCount (int ea) return i - 1; } +#endif int EAGetFirstCipher (int ea) { return EncryptionAlgorithms[ea].Ciphers[0]; @@ -731,20 +698,18 @@ int EAGetPreviousCipher (int ea, int previousCipherId) return 0; } - +#ifndef TC_WINDOWS_BOOT int EAIsFormatEnabled (int ea) { return EncryptionAlgorithms[ea].FormatEnabled; } -#ifndef TC_WINDOWS_BOOT int EAIsMbrSysEncEnabled (int ea) { return EncryptionAlgorithms[ea].MbrSysEncEnabled; } -#endif // Returns TRUE if the mode of operation is supported for the encryption algorithm BOOL EAIsModeSupported (int ea, int testedMode) { @@ -757,9 +722,8 @@ BOOL EAIsModeSupported (int ea, int testedMode) } return FALSE; } -#ifndef TC_WINDOWS_BOOT Hash *HashGet (int id) { int i; for (i = 0; Hashes[i].Id != 0; i++) @@ -809,8 +773,24 @@ BOOL HashForSystemEncryption (int hashId) return pHash? pHash -> SystemEncryption : FALSE; } +// Returns the largest key size needed by an EA for the specified mode of operation +int EAGetLargestKeyForMode (int mode) +{ + int ea, key = 0; + + for (ea = EAGetFirst (); ea != 0; ea = EAGetNext (ea)) + { + if (!EAIsModeSupported (ea, mode)) + continue; + + if (EAGetKeySize (ea) >= key) + key = EAGetKeySize (ea); + } + return key; +} + // Returns the maximum number of bytes necessary to be generated by the PBKDF2 (PKCS #5) int GetMaxPkcs5OutSize (void) { int size = 32; |