Back to index

glibc  2.9
Functions | Variables
cert.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include "crypt.h"

Go to the source code of this file.

Functions

void get8 ()
void put8 ()
void good_bye ()
int main (int argc, argv)
void get8 (char *cp)
void put8 (char *cp)

Variables

int totfails = 0

Function Documentation

void get8 ( )

Here is the caller graph for this function:

void get8 ( char *  cp)

Definition at line 87 of file cert.c.

{
       int i,j,t;

       for(i=0;i<8;i++){
              scanf("%2x",&t);
              if(feof(stdin))
                good_bye();
              for(j=0; j<8 ; j++) {
                *cp++ = (t & (0x01 << (7-j))) != 0;
              }
       }
}

Here is the call graph for this function:

void good_bye ( )

Definition at line 24 of file cert.c.

{
  if(totfails == 0) {
    printf("Passed DES validation suite\n");
    exit(0);
  } else {
    printf("%d failures during DES validation suite!!!\n", totfails);
    exit(1);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int  argc,
argv   
)

Definition at line 36 of file cert.c.

{
       char key[64],plain[64],cipher[64],answer[64];
       int i;
       int test;
       int fail;

       for(test=0;!feof(stdin);test++){

              get8(key);
              printf(" K: "); put8(key);
              setkey(key);

              get8(plain);
              printf(" P: "); put8(plain);

              get8(answer);
              printf(" C: "); put8(answer);

              for(i=0;i<64;i++)
                     cipher[i] = plain[i];
              encrypt(cipher, 0);

              for(i=0;i<64;i++)
                     if(cipher[i] != answer[i])
                            break;
              fail = 0;
              if(i != 64){
                     printf(" Encrypt FAIL");
                     fail++; totfails++;
              }

              encrypt(cipher, 1);

              for(i=0;i<64;i++)
                     if(cipher[i] != plain[i])
                            break;
              if(i != 64){
                     printf(" Decrypt FAIL");
                     fail++; totfails++;
              }

              if(fail == 0)
                     printf(" OK");
              printf("\n");
       }
       good_bye();
}

Here is the call graph for this function:

void put8 ( )

Here is the caller graph for this function:

void put8 ( char *  cp)

Definition at line 102 of file cert.c.

{
       int i,j,t;

       for(i=0;i<8;i++){
         t = 0;
         for(j = 0; j<8; j++)
           t = (t<<1) | *cp++;
         printf("%02x", t);
       }
}

Here is the call graph for this function:


Variable Documentation

Definition at line 13 of file cert.c.