[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r3818 - in GNUnet/src: applications/pingpong applications/s
From: |
grothoff |
Subject: |
[GNUnet-SVN] r3818 - in GNUnet/src: applications/pingpong applications/session include |
Date: |
Fri, 24 Nov 2006 14:50:12 -0800 (PST) |
Author: grothoff
Date: 2006-11-24 14:50:10 -0800 (Fri, 24 Nov 2006)
New Revision: 3818
Modified:
GNUnet/src/applications/pingpong/pingpong.c
GNUnet/src/applications/session/connect.c
GNUnet/src/include/gnunet_pingpong_service.h
Log:
fix
Modified: GNUnet/src/applications/pingpong/pingpong.c
===================================================================
--- GNUnet/src/applications/pingpong/pingpong.c 2006-11-24 22:34:27 UTC (rev
3817)
+++ GNUnet/src/applications/pingpong/pingpong.c 2006-11-24 22:50:10 UTC (rev
3818)
@@ -511,6 +511,7 @@
&plaintextPongReceived);
ret.ping = &initiatePing;
ret.pingUser = &createPing;
+ ret.ping_size = sizeof(P2P_pingpong_MESSAGE);
return &ret;
}
Modified: GNUnet/src/applications/session/connect.c
===================================================================
--- GNUnet/src/applications/session/connect.c 2006-11-24 22:34:27 UTC (rev
3817)
+++ GNUnet/src/applications/session/connect.c 2006-11-24 22:50:10 UTC (rev
3818)
@@ -187,6 +187,7 @@
const Signature * signature) {
char * limited;
EncName enc;
+ unsigned int rsize;
if ( (sks == NULL) ||
(hostId == NULL) ) {
@@ -240,10 +241,27 @@
}
FREE(limited);
+ rsize = ntohs(sks->header.size);
+ while (rsize > sizeof(P2P_new_setkey_MESSAGE))
+ rsize -= pingpong->ping_size;
+ if (rsize < sizeof(P2P_setkey_MESSAGE)) {
+ EncName enc;
+
+ GE_BREAK(ectx, 0);
+ IF_GELOG(ectx,
+ GE_INFO | GE_USER | GE_REQUEST,
+ hash2enc(&hostId->hashPubKey,
+ &enc));
+ GE_LOG(ectx,
+ GE_INFO | GE_USER | GE_REQUEST,
+ _("Session key from peer `%s' could not be verified.\n"),
+ &enc);
+ return SYSERR;
+ }
if (OK != identity->verifyPeerSignature
(hostId,
sks,
- ntohs(sks->header.size) - sizeof(Signature),
+ rsize - sizeof(Signature),
signature)) {
EncName enc;
@@ -543,6 +561,8 @@
EncName enc;
int ret;
Signature * sig;
+ P2P_new_setkey_MESSAGE * newMsg;
+ const void * end;
hash2enc(&sender->hashPubKey,
&enc);
@@ -577,8 +597,11 @@
}
sessionkeySigned = (P2P_setkey_MESSAGE *) msg;
- if (ntohs(msg->size) == sizeof(P2P_new_setkey_MESSAGE)) {
- P2P_new_setkey_MESSAGE * newMsg = (P2P_new_setkey_MESSAGE *) msg;
+ if ( (ntohs(msg->size) == sizeof(P2P_new_setkey_MESSAGE)) ||
+ (ntohs(msg->size) == sizeof(P2P_new_setkey_MESSAGE) +
pingpong->ping_size) ||
+ (ntohs(msg->size) == sizeof(P2P_new_setkey_MESSAGE) +
pingpong->ping_size * 2) ) {
+ newMsg = (P2P_new_setkey_MESSAGE *) msg;
+
if (!equalsHashCode512(&coreAPI->myIdentity->hashPubKey,
&newMsg->target.hashPubKey)) {
EncName ta;
@@ -594,6 +617,7 @@
sig = &newMsg->signature;
} else {
sig = &sessionkeySigned->signature;
+ newMsg = NULL;
}
ret = verifySKS(sender,
sessionkeySigned,
@@ -660,8 +684,17 @@
pong = NULL;
plaintext = NULL;
size = ntohs(sessionkeySigned->header.size);
- if (sizeof(P2P_setkey_MESSAGE) < size) {
- size -= sizeof(P2P_setkey_MESSAGE);
+ if ( ( (newMsg == NULL) &&
+ (sizeof(P2P_setkey_MESSAGE) < size) ) ||
+ ( (newMsg != NULL) &&
+ (sizeof(P2P_new_setkey_MESSAGE) < size) ) ) {
+ if (newMsg == NULL) {
+ size -= sizeof(P2P_setkey_MESSAGE);
+ end = &sessionkeySigned[1];
+ } else {
+ size -= sizeof(P2P_new_setkey_MESSAGE);
+ end = &newMsg[1];
+ }
plaintext = MALLOC(size);
#if DEBUG_SESSION
GE_LOG(ectx,
@@ -670,13 +703,13 @@
size,
&enc,
printSKEY(&key),
- *(int*)&sessionkeySigned->signature);
+ *(int*)sig);
#endif
GE_ASSERT(ectx,
-1 != decryptBlock(&key,
-
&((char*)sessionkeySigned)[sizeof(P2P_setkey_MESSAGE)],
+ end,
size,
- (const INITVECTOR*)
&sessionkeySigned->signature,
+ (const INITVECTOR*) sig,
plaintext));
pos = 0;
/* find pings & pongs! */
Modified: GNUnet/src/include/gnunet_pingpong_service.h
===================================================================
--- GNUnet/src/include/gnunet_pingpong_service.h 2006-11-24 22:34:27 UTC
(rev 3817)
+++ GNUnet/src/include/gnunet_pingpong_service.h 2006-11-24 22:50:10 UTC
(rev 3818)
@@ -74,6 +74,8 @@
void * data,
int plaintext);
+ unsigned int ping_size;
+
} Pingpong_ServiceAPI;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r3818 - in GNUnet/src: applications/pingpong applications/session include,
grothoff <=