|
|
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 == BLOWFISH)
61: return 56;
1.1.1.2 root 62: else if (cipher == AES)
63: return 32;
1.1 root 64: else if (cipher == TRIPLEDES)
65: return 21;
66: else if (cipher == CAST)
67: return 16;
68: else
69: {
70: return 0;
71: }
72: }
73:
74: char *
75: get_cipher_name (int cipher)
76: {
77: if (cipher == BLOWFISH)
78: return "Blowfish";
1.1.1.2 root 79: if (cipher == AES)
80: return "AES";
1.1 root 81: else if (cipher == DES56)
82: return "DES";
83: else if (cipher == TRIPLEDES)
84: return "Triple-DES";
85: else if (cipher == CAST)
86: return "CAST";
87: else if (cipher == NONE)
88: return "None";
89: else
90: return "Unknown";
91: }
92:
93: char * get_hash_name (int pkcs5)
94: {
95: switch (pkcs5)
96: {
97: case SHA1: return "HMAC-SHA-1";
98: case RIPEMD160: return "HMAC-RIPEMD-160";
99: default: return "Unknown";
100: }
101: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.