[BACK]Return to tcfs_keymaint.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tcfs

Diff for /src/usr.bin/tcfs/Attic/tcfs_keymaint.c between version 1.2 and 1.3

version 1.2, 2000/06/19 03:23:03 version 1.3, 2000/06/19 14:01:54
Line 17 
Line 17 
 #include <sys/param.h>  #include <sys/param.h>
 #include <sys/mount.h>  #include <sys/mount.h>
 #include <sys/ucred.h>  #include <sys/ucred.h>
 #include <des.h>  #include <blf.h>
   
 #include <miscfs/tcfs/tcfs.h>  #include <miscfs/tcfs/tcfs.h>
 #include <miscfs/tcfs/tcfs_cmd.h>  #include <miscfs/tcfs/tcfs_cmd.h>
   
Line 59 
Line 60 
 {  {
         int i = 0;          int i = 0;
         char pass[_PASSWORD_LEN], *cypher;          char pass[_PASSWORD_LEN], *cypher;
         char tcfskey[2*KEYSIZE];          char tcfskey[2*KEYSIZE], iv[8];
         des_key_schedule ks;          blf_ctx ctx;
         int keysize = (flag == GROUPKEY) ? KEYSIZE + KEYSIZE/8 : KEYSIZE;          int keysize = (flag == GROUPKEY) ? GKEYSIZE : KEYSIZE;
   
         if (!tk)          if (!tk)
                 return 0;                  return 0;
Line 80 
Line 81 
                 strcat (pass, tmp);                  strcat (pass, tmp);
         }          }
   
         while ((i*8) < keysize) {          blf_key(&ctx, pass, strlen(pass));
                 des_set_key ((des_cblock *) pass, ks);          memset(iv, 0, sizeof(iv));
           blf_cbc_decrypt(&ctx, iv, tcfskey, keysize);
   
                 des_ecb_encrypt ((des_cblock *) (tcfskey+i*8),  
                                  (des_cblock *) (tcfskey+i*8), ks, DES_DECRYPT);  
                 i++;  
         }  
         memset (pass, 0, strlen (pass));          memset (pass, 0, strlen (pass));
           memset (&ctx, 0, sizeof(ctx));
   
         memcpy (tk, tcfskey, keysize);          memcpy (tk, tcfskey, keysize);
         return 1;          return 1;
Line 98 
Line 97 
                   unsigned int flag)                    unsigned int flag)
 {  {
         int i = 0;          int i = 0;
         char pass[_PASSWORD_LEN];          char pass[_PASSWORD_LEN], iv[8];
         des_key_schedule ks;          blf_ctx ctx;
         int keysize = (flag == GROUPKEY) ? KEYSIZE + KEYSIZE/8 : KEYSIZE;          int keysize = (flag == GROUPKEY) ? GKEYSIZE : KEYSIZE;
         int uulen = (flag == GROUPKEY) ? UUGKEYSIZE : UUKEYSIZE;          int uulen = (flag == GROUPKEY) ? UUGKEYSIZE : UUKEYSIZE;
         int res;          int res;
   
Line 116 
Line 115 
                 strcat (tmp, pass);                  strcat (tmp, pass);
                 strcat (pass, tmp);                  strcat (pass, tmp);
         }          }
   
           blf_key(&ctx, pass, strlen(pass));
           blf_cbc_encrypt(&ctx, iv, key, keysize);
   
         while ((i*8) < keysize) {          memset(&ctx, 0, sizeof(ctx));
                 des_set_key((des_cblock *) pass, ks);  
                 des_ecb_encrypt((des_cblock *) (key + i * 8),  
                                 (des_cblock *) (key + i * 8), ks, DES_ENCRYPT);  
                 i++;  
         }  
   
         res = uuencode (key, keysize, ek, uulen + 1);          res = uuencode (key, keysize, ek, uulen + 1);
         if (res != uulen) {          if (res != uulen) {

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3