/[shishi]/inetutils/libinetutils/shishi.c
ViewVC logotype

Diff of /inetutils/libinetutils/shishi.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by npo, Wed Sep 17 13:16:52 2003 UTC revision 1.3 by npo, Wed Sep 17 20:35:40 2003 UTC
# Line 101  shishi_auth (Shishi ** handle, int verbo Line 101  shishi_auth (Shishi ** handle, int verbo
101    
102    memset (&hint, 0, sizeof (hint));    memset (&hint, 0, sizeof (hint));
103    
104    tmpserver = xmalloc (strlen(SERVICE) + strlen(sname) + 2);    tmpserver = (char *)xmalloc (strlen(SERVICE) + strlen(sname) + 2);
105    strcpy (tmpserver, SERVICE);    strcpy (tmpserver, SERVICE);
106    strcat (tmpserver, "/");    strcat (tmpserver, "/");
107    strcat (tmpserver, sname);    strcat (tmpserver, sname);
# Line 236  get_auth (int infd, Shishi ** handle, Sh Line 236  get_auth (int infd, Shishi ** handle, Sh
236    int rc;    int rc;
237    int i;    int i;
238    int error;    int error;
   char result;  
239    /* KERBEROS 5 SENDAUTH MESSAGE */    /* KERBEROS 5 SENDAUTH MESSAGE */
240    char krb5sendauth[] = "KRB5_SENDAUTH_V1.0";    char krb5sendauth[] = "KRB5_SENDAUTH_V1.0";
241    /* PROTOCOL VERSION */    /* PROTOCOL VERSION */
# Line 334  get_auth (int infd, Shishi ** handle, Sh Line 333  get_auth (int infd, Shishi ** handle, Sh
333        
334    /* Authentication type is ok */    /* Authentication type is ok */
335    
336    result = '\0';    write (infd, "\0", 1);
   write (infd, &result, 1);  
337    
338    /* Read Authentication request from client */    /* Read Authentication request from client */
339    
# Line 467  int Line 465  int
465  readenc (Shishi * h, int sock, char *buf, int *len, shishi_ivector *iv,  readenc (Shishi * h, int sock, char *buf, int *len, shishi_ivector *iv,
466           Shishi_key * enckey, int proto)           Shishi_key * enckey, int proto)
467  {  {
468    char *out;    char * out;
469    char *outbis;    char * outbis;
470    char *iv2;    char * iv2;
471    
472    int rc;    int rc;
473    int val;    int val;
# Line 497  readenc (Shishi * h, int sock, char *buf Line 495  readenc (Shishi * h, int sock, char *buf
495    dlen += blocksize - 1;    dlen += blocksize - 1;
496    if (proto == 2)    if (proto == 2)
497      dlen += 4;      dlen += 4;
498    if (shishi_key_type (enckey) != SHISHI_DES3_CBC_HMAC_SHA1_KD)    if (enctype != SHISHI_DES3_CBC_HMAC_SHA1_KD)
499      dlen += hashsize;      dlen += hashsize;
500    else    else
501      dlen += blocksize;      dlen += blocksize;
# Line 505  readenc (Shishi * h, int sock, char *buf Line 503  readenc (Shishi * h, int sock, char *buf
503    dlen /= blocksize;    dlen /= blocksize;
504    dlen *= blocksize;    dlen *= blocksize;
505    
506    if (shishi_key_type (enckey) == SHISHI_DES3_CBC_HMAC_SHA1_KD)    if (enctype == SHISHI_DES3_CBC_HMAC_SHA1_KD)
507      dlen += hashsize;      dlen += hashsize;
508    
509    /* read encrypted data */    /* read encrypted data */
510    outbis = malloc (dlen);    outbis = (char *)xmalloc (dlen);
511    if (outbis == NULL)    if (outbis == NULL)
512      {      {
513        printf ("Malloc error!\n");        printf ("Malloc error!\n");
# Line 520  readenc (Shishi * h, int sock, char *buf Line 518  readenc (Shishi * h, int sock, char *buf
518    if (rc != dlen)    if (rc != dlen)
519      {      {
520        printf ("Error during read socket\n");        printf ("Error during read socket\n");
521          free (outbis);
522        return 1;        return 1;
523      }      }
524        
# Line 527  readenc (Shishi * h, int sock, char *buf Line 526  readenc (Shishi * h, int sock, char *buf
526      {      {
527        rc =        rc =
528          shishi_decrypt (h, enckey, iv->keyusage, outbis, dlen, &out, &outlen);          shishi_decrypt (h, enckey, iv->keyusage, outbis, dlen, &out, &outlen);
529          if (rc != SHISHI_OK)
530            {
531              printf ("decryption error\n");
532              free (outbis);
533              return 1;
534            }
535    
536          *len = outlen;
537          val = 0;
538      }      }
539    else    else
540      {      {
541        rc =        rc =
542          shishi_decrypt_ivupdate (h, enckey, iv->keyusage, iv->iv, iv->ivlen, &iv2, &iv->ivlen, outbis,          shishi_decrypt_ivupdate (h, enckey, iv->keyusage, iv->iv, iv->ivlen, &iv2, &iv->ivlen, outbis,
543                               dlen, &out, &outlen);                               dlen, &out, &outlen);
544      }        if (rc != SHISHI_OK)
545    if (rc != SHISHI_OK)          {
546      {            printf ("decryption error\n");
547        printf ("decryption error\n");            free (outbis);
548        return 1;            return 1;
549      }          }
550    
   /* len = first 4 bytes of decrypted data */  
   if (proto == 2)  
     {  
551        /* in KCMDV0.2 first 4 bytes of decrypted data = len of data */        /* in KCMDV0.2 first 4 bytes of decrypted data = len of data */
552        *len = ntohl (*((int *) out));        *len = ntohl (*((int *) out));
553        val = sizeof (int);        val = sizeof (int);
     }  
   else  
     {  
       *len = outlen;  
       val = 0;  
     }  
554    
   if (proto == 2)  
     {  
555        /* update iv */        /* update iv */
556        memcpy (iv->iv, iv2, iv->ivlen);        memcpy (iv->iv, iv2, iv->ivlen);
557      }      }
# Line 591  writeenc (Shishi * h, int sock, char *bu Line 588  writeenc (Shishi * h, int sock, char *bu
588    /* data to encrypt = size + data */    /* data to encrypt = size + data */
589    if (proto == 2)    if (proto == 2)
590      {      {
591        bufbis = malloc (wlen + sizeof (int));        bufbis = (char *)xmalloc (wlen + sizeof (int));
       memset (bufbis, 0, wlen + sizeof (int));  
592        memcpy (bufbis, (char *) &dlen, sizeof (int));        memcpy (bufbis, (char *) &dlen, sizeof (int));
593        memcpy (bufbis + sizeof (int), buf, wlen);        memcpy (bufbis + sizeof (int), buf, wlen);
594                
# Line 603  writeenc (Shishi * h, int sock, char *bu Line 599  writeenc (Shishi * h, int sock, char *bu
599      }      }
600    else    else
601      {      {
602        bufbis = malloc (wlen);        bufbis = (char *)xmalloc (wlen);
       memset (bufbis, 0, wlen);  
603        memcpy (bufbis, buf, wlen);        memcpy (bufbis, buf, wlen);
604            
605        /* data to encrypt = size + data */        /* data to encrypt = size + data */

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

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26