Added -e option to print out encryption types
authorChris Provenzano <proven@mit.edu>
Thu, 9 Feb 1995 22:45:35 +0000 (22:45 +0000)
committerChris Provenzano <proven@mit.edu>
Thu, 9 Feb 1995 22:45:35 +0000 (22:45 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@4932 dc483132-0cff-0310-8789-dd5450dbe970

src/clients/klist/ChangeLog
src/clients/klist/klist.c

index 36cd01447a8e8e744ab755be2f001718c4e13b35..14135d24fe887c4795b6a138970b0630461333fe 100644 (file)
@@ -1,3 +1,6 @@
+Thu Feb 09 17:43:47 1995  Chris Provenzano (proven@mit.edu)
+
+       * klist.c Added -e option to print out encryption types.
 
 Fri Feb 03 22:14:26 1995  Chris Provenzano (proven@mit.edu)
 
index 9c9b3802f82a4660f2b52c587d99f5dd5840a598..bfc8df7a9ef12e7885cc205654c72ad18eea42f4 100644 (file)
@@ -33,6 +33,7 @@
 
 extern int optind;
 extern char *optarg;
+int show_etype = 0;
 int show_flags = 0;
 char *progname;
 char *defname;
@@ -69,8 +70,11 @@ main(argc, argv)
     else
        progname = argv[0];
 
-    while ((c = getopt(argc, argv, "fc:")) != EOF) {
+    while ((c = getopt(argc, argv, "efc:")) != EOF) {
        switch (c) {
+       case 'e':
+            show_etype = 1;
+            break;
        case 'f':
             show_flags = 1;
             break;
@@ -209,6 +213,16 @@ printtime(tv)
            stime->tm_sec);
 }
 
+/* Make sure this list matches the ETYPE order in encryption.h */
+#define ETYPE_MAX 6
+char * etype_string[ETYPE_MAX] = {
+    "ETYPE_NULL", 
+    "ETYPE_DES_CBC_CRC", 
+    "ETYPE_DES_CBC_MD4", 
+    "ETYPE_DES_CBC_MD5", 
+    "ETYPE_RAW_DES_CBC", 
+    NULL };
+
 void
 show_credential(kcontext, cred)
     krb5_context kcontext;
@@ -252,6 +266,25 @@ show_credential(kcontext, cred)
        fputs("renew until ", stdout);
         printtime(cred->times.renew_till);
     }
+
+    if (show_etype) {
+       krb5_enctype etype = cred->keyblock.etype;
+
+       if (!first) 
+           putchar('\n');
+
+       printf("\tEncryption type: ");
+       if (etype != ETYPE_UNKNOWN) {
+           if ((etype < ETYPE_MAX) && etype_string[etype]) {
+               printf("%s", etype_string[etype]);
+           } else {
+               printf("UNRECOGNIZED");
+           }
+       } else {
+           printf("ETYPE_UNKNOWN");
+       }
+    }
+
     if (show_flags) {
        flags = flags_string(cred);
        if (flags && *flags) {
@@ -263,6 +296,7 @@ show_credential(kcontext, cred)
            first = 0;
         }
     }
+
     putchar('\n');
     free(name);
     free(sname);