@@ -716,20 +716,23 @@ int sam3GenerateKeys(Sam3Session *ses, const char *hostname, int port,
716716 return -1 ;
717717 }
718718 //
719- if (sam3tcpPrintf (fd , "DEST GENERATE %s\n" , sigtypes [sigType ]) >= 0 ) {
720- if ((rep = sam3ReadReply (fd )) != NULL &&
721- sam3IsGoodReply (rep , "DEST" , "REPLY" , NULL , NULL )) {
722- const char * pub = sam3FindField (rep , "PUB" ),
723- * priv = sam3FindField (rep , "PRIV" );
724- //
725- if (pub != NULL && sam3CheckValidKeyLength (pub ) && priv != NULL &&
726- strlen (priv ) >= SAM3_PRIVKEY_MIN_SIZE ) {
727- strcpy (ses -> pubkey , pub );
728- strcpy (ses -> privkey , priv );
729- res = 0 ;
730- }
731- }
719+ if (sam3tcpPrintf (fd , "DEST GENERATE\n" ) < 0 ) {
720+ strcpyerr (ses , "DEST_ERROR" );
721+ }
722+
723+ rep = sam3ReadReply (fd );
724+ // sam3DumpFieldList(rep);
725+ if (!sam3IsGoodReply (rep , "DEST" , "REPLY" , "PUB" , NULL )) {
726+ strcpyerr (ses , "PUBKEY_ERROR" );
727+ }
728+ if (!sam3IsGoodReply (rep , "DEST" , "REPLY" , "PRIV" , NULL )) {
729+ strcpyerr (ses , "PRIVKEY_ERROR" );
732730 }
731+ const char * pub = sam3FindField (rep , "PUB" );
732+ strcpy (ses -> pubkey , pub );
733+ const char * priv = sam3FindField (rep , "PRIV" );
734+ strcpy (ses -> privkey , priv );
735+ res = 0 ;
733736 //
734737 sam3FreeFieldList (rep );
735738 sam3tcpDisconnect (fd );
0 commit comments