Changes in zcrypt.c [36486be:a6ac9fe]
Legend:
- Unmodified
- Added
- Removed
-
zcrypt.c
r36486be ra6ac9fe 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; 126 int use_buffer = FALSE;127 132 int num_blocks=0, last_block_size=0; 128 133 … … 131 136 fkey=fopen(fname, "r"); 132 137 if (!fkey) return(-1); 133 fgets(keystring, MAX_KEY-1, fkey); 138 if (!fgets(keystring, MAX_KEY-1, fkey)) { 139 fclose(fkey); 140 return -1; 141 } 134 142 fclose(fkey); 135 143 136 des_string_to_key(keystring, key); 137 des_key_sched(key, schedule); 144 owl_zcrypt_string_to_schedule(keystring, schedule); 138 145 139 146 inbuff=in; … … 141 148 num_blocks=(length+7)/8; 142 149 last_block_size=((length+7)%8)+1; 143 use_buffer=TRUE;144 150 145 151 strcpy(out, ""); … … 167 173 168 174 /* Encrypt and output the block */ 169 des_ecb_encrypt( input,output, schedule, TRUE);175 des_ecb_encrypt(&input, &output, schedule, TRUE); 170 176 171 177 for (i = 0; i < 8; i++) { … … 216 222 /* Scan file for a match */ 217 223 while (!feof(fsearch)) { 218 fgets(buffer, MAX_BUFF - 3, fsearch);224 if (!fgets(buffer, MAX_BUFF - 3, fsearch)) break; 219 225 for (i = 0; i < numsearch; i++) { 220 226 if (strncasecmp(varname[i], buffer, length[i]) == 0) { … … 262 268 } 263 269 264 static pid_t zephyrpipe_pid = 0; 265 266 #endif 270 #endif
Note: See TracChangeset
for help on using the changeset viewer.