Changeset 633db30 for zcrypt.c


Ignore:
Timestamp:
Sep 20, 2009, 8:36:01 PM (15 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
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.
Message:
Merge branch 'build'

* build:
  owl_new_sv: Squelch a pointer sign warning.
  Makefile.am: Add zcrypt.c back to BASE_SRCS and kill off libzcrypt.a.
  zcrypt.c: Clean up warnings.
  FOO → PERL_CFLAGS in configure.ac
  Clean up AC_CHECK_FUNCS call.
  configure.ac: Use AC_SEARCH_LIBS for lib{nsl,socket,resolv}.
  configure.ac: Only use com_err if building --with-zephyr.
  configure.ac: Clean up checks for Kerberos IV.
  owl_command_zcrypt: Fix a compile warning building without zcrypt.
  Compile with warnings enabled by default.
  Compile libfaim with -Wno-pointer-sign if the compiler supports it.
  Assume des_ecb_encrypt is prototyped.
  configure.ac: Reimplement -fstack-protector check with AX_C_CHECK_FLAG.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • zcrypt.c

    r36486be r3daca13  
    2323#include <unistd.h>
    2424#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
    2631
    2732#define MAX_KEY 128
     
    5156char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance);
    5257
    53 #ifndef HAVE_DES_ECB_ENCRYPT_PROTO
    54 int des_ecb_encrypt(char [], char [], des_key_schedule, int);
    55 #endif
    56 
    5758#define M_NONE            0
    5859#define M_ZEPHYR_ENCRYPT  1
     
    6162#define M_RANDOMIZE       4
    6263#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}
    6375
    6476/* The 'owl_zcrypt_decrypt' function was written by kretch for Owl.
     
    7385  char *fname, keystring[MAX_KEY];
    7486  FILE *fkey;
    75   des_cblock key;
    7687  des_key_schedule schedule;
    77   char input[8], output[9];
     88  unsigned char input[8], output[8];
    7889  int i, c1, c2;
    7990 
     
    8293  fkey=fopen(fname, "r");
    8394  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  }
    8599  fclose(fkey);
    86100
     
    88102
    89103  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);
    94106
    95107  inptr=in;
     
    102114      inptr+=2;
    103115    }
    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')
    113121    strcat(out, "\n");
    114   }
    115122  return(0);
    116123}
     
    119126  char *fname, keystring[MAX_KEY];
    120127  FILE *fkey;
    121   des_cblock key;
    122128  des_key_schedule schedule;
    123   char input[8], output[8];
     129  unsigned char input[8], output[8];
    124130  int size, length, i;
    125131  const char *inbuff = NULL, *inptr;
     
    131137  fkey=fopen(fname, "r");
    132138  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  }
    134143  fclose(fkey);
    135144
    136   des_string_to_key(keystring, key);
    137   des_key_sched(key, schedule);
     145  owl_zcrypt_string_to_schedule(keystring, schedule);
    138146
    139147  inbuff=in;
     
    167175
    168176    /* Encrypt and output the block */
    169     des_ecb_encrypt(input, output, schedule, TRUE);
     177    des_ecb_encrypt(&input, &output, schedule, TRUE);
    170178
    171179    for (i = 0; i < 8; i++) {
     
    216224    /* Scan file for a match */
    217225    while (!feof(fsearch)) {
    218       fgets(buffer, MAX_BUFF - 3, fsearch);
     226      if (!fgets(buffer, MAX_BUFF - 3, fsearch)) break;
    219227      for (i = 0; i < numsearch; i++) {
    220228        if (strncasecmp(varname[i], buffer, length[i]) == 0) {
     
    262270}
    263271
    264 static pid_t zephyrpipe_pid = 0;
    265 
    266 #endif
     272#endif
Note: See TracChangeset for help on using the changeset viewer.