fix public key out put in generateKeys
This commit is contained in:
@ -28,9 +28,14 @@ ssclient:
|
||||
ssserver:
|
||||
${CC} ${CFLAGS} streamss.c -o streamss ../libsam3/libsam3.o
|
||||
|
||||
keysp:
|
||||
${CXX} ${CFLAGS} keys.cc -o keysp ../libsam3/libsam3.o
|
||||
|
||||
keys:
|
||||
${CC} ${CFLAGS} keys.c -o keys ../libsam3/libsam3.o
|
||||
|
||||
clean:
|
||||
rm -f samtest lookup dgramc dgrams streamc streams streams.key test-lookup
|
||||
rm -f samtest lookup dgramc dgrams streamc streams streams.key test-lookup keys keysp
|
||||
|
||||
debug:
|
||||
sed -i 's|// libsam3_debug = 1;|libsam3_debug = 1;|g' *.c
|
||||
|
@ -716,20 +716,23 @@ int sam3GenerateKeys(Sam3Session *ses, const char *hostname, int port,
|
||||
return -1;
|
||||
}
|
||||
//
|
||||
if (sam3tcpPrintf(fd, "DEST GENERATE %s\n", sigtypes[sigType]) >= 0) {
|
||||
if ((rep = sam3ReadReply(fd)) != NULL &&
|
||||
sam3IsGoodReply(rep, "DEST", "REPLY", NULL, NULL)) {
|
||||
const char *pub = sam3FindField(rep, "PUB"),
|
||||
*priv = sam3FindField(rep, "PRIV");
|
||||
//
|
||||
if (pub != NULL && sam3CheckValidKeyLength(pub) && priv != NULL &&
|
||||
strlen(priv) >= SAM3_PRIVKEY_MIN_SIZE) {
|
||||
strcpy(ses->pubkey, pub);
|
||||
strcpy(ses->privkey, priv);
|
||||
res = 0;
|
||||
}
|
||||
}
|
||||
if (sam3tcpPrintf(fd, "DEST GENERATE\n") < 0) {
|
||||
strcpyerr(ses, "DEST_ERROR");
|
||||
}
|
||||
|
||||
rep = sam3ReadReply(fd);
|
||||
// sam3DumpFieldList(rep);
|
||||
if (!sam3IsGoodReply(rep, "DEST", "REPLY", "PUB", NULL)) {
|
||||
strcpyerr(ses, "PUBKEY_ERROR");
|
||||
}
|
||||
if (!sam3IsGoodReply(rep, "DEST", "REPLY", "PRIV", NULL)) {
|
||||
strcpyerr(ses, "PRIVKEY_ERROR");
|
||||
}
|
||||
const char *pub = sam3FindField(rep, "PUB");
|
||||
strcpy(ses->pubkey, pub);
|
||||
const char *priv = sam3FindField(rep, "PRIV");
|
||||
strcpy(ses->privkey, priv);
|
||||
res = 0;
|
||||
//
|
||||
sam3FreeFieldList(rep);
|
||||
sam3tcpDisconnect(fd);
|
||||
|
Reference in New Issue
Block a user