From a35f90bf9ed2c7147188597f2e75f30cedde1076 Mon Sep 17 00:00:00 2001 From: Endi Sukma Dewata Date: Fri, 30 Nov 2012 00:23:23 -0500 Subject: WIP --- base/native-tools/src/tkstool/tkstool.c | 64 ++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 21 deletions(-) (limited to 'base/native-tools/src/tkstool/tkstool.c') diff --git a/base/native-tools/src/tkstool/tkstool.c b/base/native-tools/src/tkstool/tkstool.c index 5368b2e7b..c11151e1c 100644 --- a/base/native-tools/src/tkstool/tkstool.c +++ b/base/native-tools/src/tkstool/tkstool.c @@ -356,7 +356,7 @@ main( int argc, char **argv ) /* the "-U" command */ if( tkstool.options[opt_InFile].activated && !tkstool.commands[cmd_UnWrapMasterKey].activated ) { - PR_fprintf( PR_STDERR, + PR_fprintf( PR_STDERR, "%s -%c: the \"-i infile\" option may only be " "specified with one of the following command(s):\n\n", progName, @@ -392,10 +392,11 @@ main( int argc, char **argv ) } /* the "-o outfile" command option may ONLY be used with */ - /* the "-W" command */ - if( tkstool.options[opt_OutFile].activated && - !tkstool.commands[cmd_WrapMasterKey].activated ) { - PR_fprintf( PR_STDERR, + /* the "-T" and "-W" command */ + if( tkstool.options[opt_OutFile].activated && + ! ( tkstool.commands[cmd_WrapMasterKey].activated || + tkstool.commands[cmd_GenTransportKey].activated ) ) { + PR_fprintf( PR_STDERR, "%s -%c: the \"-o outfile\" option may only be " "specified with one of the following command(s):\n\n", progName, @@ -1019,25 +1020,26 @@ main( int argc, char **argv ) } - /***********************************/ - /* Clear screen and wait for user. */ - /***********************************/ + if( ! tkstool.options[opt_OutFile].activated ) { + /***********************************/ + /* Clear screen and wait for user. */ + /***********************************/ - TKS_ClearScreen(); + TKS_ClearScreen(); - if( tkstool.commands[cmd_GenTransportKey].activated ) { - PR_fprintf( PR_STDOUT, - "\nThe next screen generates the " - "first session key share . . .\n" ); - } else { - /* ( tkstool.commands[cmd_InputGenTransportKey].activated ) */ - PR_fprintf( PR_STDOUT, - "\nUse the next screen to input the " - "first session key share . . .\n" ); - } - - TKS_TypeProceedToContinue(); + if( tkstool.commands[cmd_GenTransportKey].activated ) { + PR_fprintf( PR_STDOUT, + "\nThe next screen generates the " + "first session key share . . .\n" ); + } else { + /* ( tkstool.commands[cmd_InputGenTransportKey].activated ) */ + PR_fprintf( PR_STDOUT, + "\nUse the next screen to input the " + "first session key share . . .\n" ); + } + TKS_TypeProceedToContinue(); + } /******************************************************************/ /* Input ("-I"), or Generate ("-T"), the first session key share. */ @@ -1097,6 +1099,26 @@ main( int argc, char **argv ) DES_LENGTH ); #endif + if( tkstool.options[opt_OutFile].activated ) { + /**************************************************************/ + /* Write the wrapped master key to the specified output file. */ + /**************************************************************/ + + PR_fprintf( PR_STDOUT, + "Writing shared keys into the file called\n\"%s\" . . .\n\n", + output ); + rv = TKS_WriteSharedKeyIntoOutputFile( output ); + if( rv != SECSuccess ) { + PR_fprintf( PR_STDERR, + "%s -%c: %s: %d\n", + progName, + commandToRun, + "unable to save the shared keys", + PR_GetError() ); + goto shutdown; + } + goto shutdown; + } /***********************************/ /* Clear screen and wait for user. */ -- cgit