|
|
1.1 root 1: /* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
2: This product uses components written by Paul Le Roux <[email protected]> */
3:
4: #include "TCdefs.h"
5: #include "crypto.h"
6: #include "random.h"
7:
8: PCRYPTO_INFO
9: crypto_open ()
10: {
11: /* Do the crt allocation */
12: PCRYPTO_INFO cryptoInfo = TCalloc (sizeof (CRYPTO_INFO));
13: if (cryptoInfo == NULL)
14: return NULL;
15:
16: cryptoInfo->cipher = -1;
17: return cryptoInfo;
18: }
19:
20: void
21: crypto_loadkey (PKEY_INFO keyInfo, char *lpszUserKey, int nUserKeyLen)
22: {
23: keyInfo->keyLength = nUserKeyLen;
24: burn (keyInfo->userKey, sizeof (keyInfo->userKey));
25: memcpy (keyInfo->userKey, lpszUserKey, nUserKeyLen);
26: }
27:
28: void
29: crypto_close (PCRYPTO_INFO cryptoInfo)
30: {
31: burn (cryptoInfo, sizeof (CRYPTO_INFO));
32: TCfree (cryptoInfo);
33: }
34:
35: int
36: get_block_size (int cipher)
37: {
38: if (cipher); /* remove warning */
39: return 8;
40: }
41:
42: int
43: get_key_size (int cipher)
44: {
45: if (cipher == DES56)
46: return 7;
47: else if (cipher == IDEA)
48: return 16;
49: else if (cipher == BLOWFISH)
50: return 56;
51: else if (cipher == TRIPLEDES)
52: return 21;
53: else if (cipher == CAST)
54: return 16;
55: else
56: {
57: return 0;
58: }
59: }
60:
61: char *
62: get_cipher_name (int cipher)
63: {
64: if (cipher == BLOWFISH)
65: return "Blowfish";
66: else if (cipher == IDEA)
67: return "IDEA";
68: else if (cipher == DES56)
69: return "DES";
70: else if (cipher == TRIPLEDES)
71: return "Triple-DES";
72: else if (cipher == CAST)
73: return "CAST";
74: else if (cipher == NONE)
75: return "None";
76: else
77: return "Unknown";
78: }
79:
80: char * get_hash_name (int pkcs5)
81: {
82: switch (pkcs5)
83: {
84: case SHA1: return "HMAC-SHA-1";
85: case RIPEMD160: return "HMAC-RIPEMD-160";
86: default: return "Unknown";
87: }
88: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.