Changeset 3daca13


Ignore:
Timestamp:
Sep 15, 2009, 4:22:39 PM (11 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
191d5e7
Parents:
1c89df8
git-author:
Anders Kaseorg <andersk@mit.edu> (09/14/09 23:52:36)
git-committer:
Nelson Elhage <nelhage@mit.edu> (09/15/09 16:22:39)
Message:
zcrypt.c: Clean up warnings.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
[nelhage@mit.edu: Abstract keys into owl_zcrypt_string_to_schedule]
Signed-off-by: Nelson Elhage <nelhage@mit.edu>
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Makefile.am

    r3d9f4d3 r3daca13  
    2323
    2424libzcrypt_a_SOURCES = zcrypt.c
    25 libzcrypt_a_CFLAGS  = -w
    2625
    2726CPPFLAGS = -I$(top_srcdir)/ \
  • zcrypt.c

    r806f769 r3daca13  
    6262#define M_RANDOMIZE       4
    6363#define M_SETKEY          5
     64
     65static 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}
    6475
    6576/* The 'owl_zcrypt_decrypt' function was written by kretch for Owl.
     
    7485  char *fname, keystring[MAX_KEY];
    7586  FILE *fkey;
    76   des_cblock key;
    7787  des_key_schedule schedule;
    78   char input[8], output[9];
     88  unsigned char input[8], output[8];
    7989  int i, c1, c2;
    8090 
     
    8393  fkey=fopen(fname, "r");
    8494  if (!fkey) return(-1);
    85   fgets(keystring, MAX_KEY-1, fkey);
     95  if (!fgets(keystring, MAX_KEY-1, fkey)) {
     96    fclose(fkey);
     97    return -1;
     98  }
    8699  fclose(fkey);
    87100
     
    89102
    90103  output[0] = '\0';    /* In case no message at all                 */
    91   output[8] = '\0';    /* NULL at end will limit string length to 8 */
    92 
    93   des_string_to_key(keystring, key);
    94   des_key_sched(key, schedule);
     104
     105  owl_zcrypt_string_to_schedule(keystring, schedule);
    95106
    96107  inptr=in;
     
    103114      inptr+=2;
    104115    }
    105     des_ecb_encrypt(input, output, schedule, FALSE);
    106     strcat(out, output);
    107   }
    108 
    109   if (output[0]) {
    110     if (output[strlen(output)-1] != '\n') {
    111       strcat(out, "\n");
    112     }
    113   } 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')
    114121    strcat(out, "\n");
    115   }
    116122  return(0);
    117123}
     
    120126  char *fname, keystring[MAX_KEY];
    121127  FILE *fkey;
    122   des_cblock key;
    123128  des_key_schedule schedule;
    124   char input[8], output[8];
     129  unsigned char input[8], output[8];
    125130  int size, length, i;
    126131  const char *inbuff = NULL, *inptr;
     
    132137  fkey=fopen(fname, "r");
    133138  if (!fkey) return(-1);
    134   fgets(keystring, MAX_KEY-1, fkey);
     139  if (!fgets(keystring, MAX_KEY-1, fkey)) {
     140    fclose(fkey);
     141    return -1;
     142  }
    135143  fclose(fkey);
    136144
    137   des_string_to_key(keystring, key);
    138   des_key_sched(key, schedule);
     145  owl_zcrypt_string_to_schedule(keystring, schedule);
    139146
    140147  inbuff=in;
     
    168175
    169176    /* Encrypt and output the block */
    170     des_ecb_encrypt(input, output, schedule, TRUE);
     177    des_ecb_encrypt(&input, &output, schedule, TRUE);
    171178
    172179    for (i = 0; i < 8; i++) {
     
    217224    /* Scan file for a match */
    218225    while (!feof(fsearch)) {
    219       fgets(buffer, MAX_BUFF - 3, fsearch);
     226      if (!fgets(buffer, MAX_BUFF - 3, fsearch)) break;
    220227      for (i = 0; i < numsearch; i++) {
    221228        if (strncasecmp(varname[i], buffer, length[i]) == 0) {
     
    263270}
    264271
    265 static pid_t zephyrpipe_pid = 0;
    266 
    267 #endif
     272#endif
Note: See TracChangeset for help on using the changeset viewer.