- Timestamp:
- Sep 20, 2009, 8:36:01 PM (15 years ago)
- Branches:
- master, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 8073852
- Parents:
- 168f8a9 (diff), 2693b12 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
zcrypt.c
r36486be r3daca13 23 23 #include <unistd.h> 24 24 #include <sys/types.h> 25 #include <des.h> 25 26 #ifdef HAVE_KERBEROS_IV 27 #include <kerberosIV/des.h> 28 #else 29 #include <openssl/des.h> 30 #endif 26 31 27 32 #define MAX_KEY 128 … … 51 56 char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance); 52 57 53 #ifndef HAVE_DES_ECB_ENCRYPT_PROTO54 int des_ecb_encrypt(char [], char [], des_key_schedule, int);55 #endif56 57 58 #define M_NONE 0 58 59 #define M_ZEPHYR_ENCRYPT 1 … … 61 62 #define M_RANDOMIZE 4 62 63 #define M_SETKEY 5 64 65 static void owl_zcrypt_string_to_schedule(char *keystring, des_key_schedule schedule) { 66 #ifdef HAVE_KERBEROS_IV 67 des_cblock key; 68 #else 69 des_cblock _key, *key = &_key; 70 #endif 71 72 des_string_to_key(keystring, key); 73 des_key_sched(key, schedule); 74 } 63 75 64 76 /* The 'owl_zcrypt_decrypt' function was written by kretch for Owl. … … 73 85 char *fname, keystring[MAX_KEY]; 74 86 FILE *fkey; 75 des_cblock key;76 87 des_key_schedule schedule; 77 char input[8], output[9];88 unsigned char input[8], output[8]; 78 89 int i, c1, c2; 79 90 … … 82 93 fkey=fopen(fname, "r"); 83 94 if (!fkey) return(-1); 84 fgets(keystring, MAX_KEY-1, fkey); 95 if (!fgets(keystring, MAX_KEY-1, fkey)) { 96 fclose(fkey); 97 return -1; 98 } 85 99 fclose(fkey); 86 100 … … 88 102 89 103 output[0] = '\0'; /* In case no message at all */ 90 output[8] = '\0'; /* NULL at end will limit string length to 8 */ 91 92 des_string_to_key(keystring, key); 93 des_key_sched(key, schedule); 104 105 owl_zcrypt_string_to_schedule(keystring, schedule); 94 106 95 107 inptr=in; … … 102 114 inptr+=2; 103 115 } 104 des_ecb_encrypt(input, output, schedule, FALSE); 105 strcat(out, output); 106 } 107 108 if (output[0]) { 109 if (output[strlen(output)-1] != '\n') { 110 strcat(out, "\n"); 111 } 112 } else { 116 des_ecb_encrypt(&input, &output, schedule, FALSE); 117 strncat(out, (const char *)output, 8); 118 } 119 120 if (out[0] && out[strlen(out) - 1] != '\n') 113 121 strcat(out, "\n"); 114 }115 122 return(0); 116 123 } … … 119 126 char *fname, keystring[MAX_KEY]; 120 127 FILE *fkey; 121 des_cblock key;122 128 des_key_schedule schedule; 123 char input[8], output[8];129 unsigned char input[8], output[8]; 124 130 int size, length, i; 125 131 const char *inbuff = NULL, *inptr; … … 131 137 fkey=fopen(fname, "r"); 132 138 if (!fkey) return(-1); 133 fgets(keystring, MAX_KEY-1, fkey); 139 if (!fgets(keystring, MAX_KEY-1, fkey)) { 140 fclose(fkey); 141 return -1; 142 } 134 143 fclose(fkey); 135 144 136 des_string_to_key(keystring, key); 137 des_key_sched(key, schedule); 145 owl_zcrypt_string_to_schedule(keystring, schedule); 138 146 139 147 inbuff=in; … … 167 175 168 176 /* Encrypt and output the block */ 169 des_ecb_encrypt( input,output, schedule, TRUE);177 des_ecb_encrypt(&input, &output, schedule, TRUE); 170 178 171 179 for (i = 0; i < 8; i++) { … … 216 224 /* Scan file for a match */ 217 225 while (!feof(fsearch)) { 218 fgets(buffer, MAX_BUFF - 3, fsearch);226 if (!fgets(buffer, MAX_BUFF - 3, fsearch)) break; 219 227 for (i = 0; i < numsearch; i++) { 220 228 if (strncasecmp(varname[i], buffer, length[i]) == 0) { … … 262 270 } 263 271 264 static pid_t zephyrpipe_pid = 0; 265 266 #endif 272 #endif
Note: See TracChangeset
for help on using the changeset viewer.