|
|
1.1.1.3 ! root 1: /* The source code contained in this file has been derived from the source code ! 2: of Encryption for the Masses 2.02a by Paul Le Roux. Modifications and ! 3: additions to that source code contained in this file are Copyright (c) 2004 ! 4: TrueCrypt Team and Copyright (c) 2004 TrueCrypt Foundation. Unmodified ! 5: parts are Copyright (c) 1998-99 Paul Le Roux. This is a TrueCrypt Foundation ! 6: release. Please see the file license.txt for full license details. */ 1.1 root 7: 8: #include "TCdefs.h" 9: #include "crypto.h" 10: #include "random.h" 11: 12: PCRYPTO_INFO 13: crypto_open () 14: { 15: /* Do the crt allocation */ 16: PCRYPTO_INFO cryptoInfo = TCalloc (sizeof (CRYPTO_INFO)); 1.1.1.2 root 17: #ifndef DEVICE_DRIVER 18: VirtualLock (cryptoInfo, sizeof (CRYPTO_INFO)); 19: #endif 20: 1.1 root 21: if (cryptoInfo == NULL) 22: return NULL; 23: 24: cryptoInfo->cipher = -1; 25: return cryptoInfo; 26: } 27: 28: void 29: crypto_loadkey (PKEY_INFO keyInfo, char *lpszUserKey, int nUserKeyLen) 30: { 31: keyInfo->keyLength = nUserKeyLen; 32: burn (keyInfo->userKey, sizeof (keyInfo->userKey)); 33: memcpy (keyInfo->userKey, lpszUserKey, nUserKeyLen); 34: } 35: 36: void 37: crypto_close (PCRYPTO_INFO cryptoInfo) 38: { 39: burn (cryptoInfo, sizeof (CRYPTO_INFO)); 1.1.1.2 root 40: #ifndef DEVICE_DRIVER 41: VirtualUnlock (cryptoInfo, sizeof (CRYPTO_INFO)); 42: #endif 1.1 root 43: TCfree (cryptoInfo); 44: } 45: 46: int 47: get_block_size (int cipher) 48: { 1.1.1.2 root 49: if (cipher == AES) 50: return 16; 51: else 52: return 8; 1.1 root 53: } 54: 55: int 56: get_key_size (int cipher) 57: { 58: if (cipher == DES56) 59: return 7; 60: else if (cipher == IDEA) 61: return 16; 62: else if (cipher == BLOWFISH) 63: return 56; 1.1.1.2 root 64: else if (cipher == AES) 65: return 32; 1.1 root 66: else if (cipher == TRIPLEDES) 67: return 21; 68: else if (cipher == CAST) 69: return 16; 70: else 71: { 72: return 0; 73: } 74: } 75: 76: char * 77: get_cipher_name (int cipher) 78: { 79: if (cipher == BLOWFISH) 80: return "Blowfish"; 1.1.1.2 root 81: if (cipher == AES) 82: return "AES"; 1.1 root 83: else if (cipher == IDEA) 84: return "IDEA"; 85: else if (cipher == DES56) 86: return "DES"; 87: else if (cipher == TRIPLEDES) 88: return "Triple-DES"; 89: else if (cipher == CAST) 90: return "CAST"; 91: else if (cipher == NONE) 92: return "None"; 93: else 94: return "Unknown"; 95: } 96: 97: char * get_hash_name (int pkcs5) 98: { 99: switch (pkcs5) 100: { 101: case SHA1: return "HMAC-SHA-1"; 102: case RIPEMD160: return "HMAC-RIPEMD-160"; 103: default: return "Unknown"; 104: } 105: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.