From: Pekka Riikonen Date: Wed, 19 Sep 2001 20:13:53 +0000 (+0000) Subject: updates. X-Git-Tag: silcertest~101 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=08091374ff1050f22c4f1d8bf89288c0f347b441 updates. --- diff --git a/CHANGES b/CHANGES index c02b602f..8f3b05b4 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,9 @@ +Wed Sep 19 22:58:32 EEST 2001 Pekka Riikonen + + * Added silc_ske_status_string to map the SKE error numbers + to readable strings. The affected files are + lib/silcske/silcske[_status].[ch]. + Tue Sep 18 22:50:41 EEST 2001 Pekka Riikonen * Do not show the private channels on the WHOIS channel list diff --git a/apps/silcd/protocol.c b/apps/silcd/protocol.c index 4d306195..07f3233d 100644 --- a/apps/silcd/protocol.c +++ b/apps/silcd/protocol.c @@ -365,10 +365,10 @@ static void silc_server_protocol_ke_continue(SilcSKE ske, void *context) SILC_LOG_DEBUG(("Start")); if (ske->status != SILC_SKE_STATUS_OK) { - SILC_LOG_WARNING(("Error (type %d) during Key Exchange protocol", - ske->status)); - SILC_LOG_DEBUG(("Error (type %d) during Key Exchange protocol", - ske->status)); + SILC_LOG_WARNING(("Error (%s) during Key Exchange protocol", + silc_ske_map_status(ske->status))); + SILC_LOG_DEBUG(("Error (%s) during Key Exchange protocol", + silc_ske_map_status(ske->status))); protocol->state = SILC_PROTOCOL_STATE_ERROR; silc_protocol_execute(protocol, server->schedule, 0, 300000); @@ -455,10 +455,10 @@ SILC_TASK_CALLBACK(silc_server_protocol_key_exchange) return; if (status != SILC_SKE_STATUS_OK) { - SILC_LOG_WARNING(("Error (type %d) during Key Exchange protocol", - status)); - SILC_LOG_DEBUG(("Error (type %d) during Key Exchange protocol", - status)); + SILC_LOG_WARNING(("Error (%s) during Key Exchange protocol", + silc_ske_map_status(status))); + SILC_LOG_DEBUG(("Error (%s) during Key Exchange protocol", + silc_ske_map_status(status))); protocol->state = SILC_PROTOCOL_STATE_ERROR; silc_protocol_execute(protocol, server->schedule, 0, 300000); @@ -493,10 +493,10 @@ SILC_TASK_CALLBACK(silc_server_protocol_key_exchange) return; if (status != SILC_SKE_STATUS_OK) { - SILC_LOG_WARNING(("Error (type %d) during Key Exchange protocol", - status)); - SILC_LOG_DEBUG(("Error (type %d) during Key Exchange protocol", - status)); + SILC_LOG_WARNING(("Error (%s) during Key Exchange protocol", + silc_ske_map_status(status))); + SILC_LOG_DEBUG(("Error (%s) during Key Exchange protocol", + silc_ske_map_status(status))); protocol->state = SILC_PROTOCOL_STATE_ERROR; silc_protocol_execute(protocol, server->schedule, 0, 300000); @@ -535,10 +535,10 @@ SILC_TASK_CALLBACK(silc_server_protocol_key_exchange) return; if (status != SILC_SKE_STATUS_OK) { - SILC_LOG_WARNING(("Error (type %d) during Key Exchange protocol", - status)); - SILC_LOG_DEBUG(("Error (type %d) during Key Exchange protocol", - status)); + SILC_LOG_WARNING(("Error (%s) during Key Exchange protocol", + silc_ske_map_status(status))); + SILC_LOG_DEBUG(("Error (%s) during Key Exchange protocol", + silc_ske_map_status(status))); protocol->state = SILC_PROTOCOL_STATE_ERROR; silc_protocol_execute(protocol, server->schedule, 0, 300000); @@ -573,10 +573,10 @@ SILC_TASK_CALLBACK(silc_server_protocol_key_exchange) return; if (status != SILC_SKE_STATUS_OK) { - SILC_LOG_WARNING(("Error (type %d) during Key Exchange protocol", - status)); - SILC_LOG_DEBUG(("Error (type %d) during Key Exchange protocol", - status)); + SILC_LOG_WARNING(("Error (%s) during Key Exchange protocol", + silc_ske_map_status(status))); + SILC_LOG_DEBUG(("Error (%s) during Key Exchange protocol", + silc_ske_map_status(status))); protocol->state = SILC_PROTOCOL_STATE_ERROR; silc_protocol_execute(protocol, server->schedule, 0, 300000); @@ -1386,8 +1386,8 @@ SILC_TASK_CALLBACK(silc_server_protocol_rekey) status = silc_ske_responder_phase_2(ctx->ske, ctx->packet->buffer); if (status != SILC_SKE_STATUS_OK) { - SILC_LOG_WARNING(("Error (type %d) during Re-key (PFS)", - status)); + SILC_LOG_WARNING(("Error (%s) during Re-key (PFS)", + silc_ske_map_status(status))); protocol->state = SILC_PROTOCOL_STATE_ERROR; silc_protocol_execute(protocol, server->schedule, 0, 300000); @@ -1442,8 +1442,8 @@ SILC_TASK_CALLBACK(silc_server_protocol_rekey) status = silc_ske_initiator_phase_2(ctx->ske, NULL, NULL); if (status != SILC_SKE_STATUS_OK) { - SILC_LOG_WARNING(("Error (type %d) during Re-key (PFS)", - status)); + SILC_LOG_WARNING(("Error (%s) during Re-key (PFS)", + silc_ske_map_status(status))); protocol->state = SILC_PROTOCOL_STATE_ERROR; silc_protocol_execute(protocol, server->schedule, 0, 300000); @@ -1487,8 +1487,8 @@ SILC_TASK_CALLBACK(silc_server_protocol_rekey) status = silc_ske_responder_finish(ctx->ske, NULL, NULL, SILC_SKE_PK_TYPE_SILC); if (status != SILC_SKE_STATUS_OK) { - SILC_LOG_WARNING(("Error (type %d) during Re-key (PFS)", - status)); + SILC_LOG_WARNING(("Error (%s) during Re-key (PFS)", + silc_ske_map_status(status))); protocol->state = SILC_PROTOCOL_STATE_ERROR; silc_protocol_execute(protocol, server->schedule, 0, 300000); @@ -1510,8 +1510,8 @@ SILC_TASK_CALLBACK(silc_server_protocol_rekey) status = silc_ske_initiator_finish(ctx->ske, ctx->packet->buffer); if (status != SILC_SKE_STATUS_OK) { - SILC_LOG_WARNING(("Error (type %d) during Re-key (PFS)", - status)); + SILC_LOG_WARNING(("Error (%s) during Re-key (PFS)", + silc_ske_map_status(status))); protocol->state = SILC_PROTOCOL_STATE_ERROR; silc_protocol_execute(protocol, server->schedule, 0, 300000); diff --git a/lib/silcske/silcske.c b/lib/silcske/silcske.c index e69fc0f9..cacdb3d6 100644 --- a/lib/silcske/silcske.c +++ b/lib/silcske/silcske.c @@ -1888,3 +1888,44 @@ void silc_ske_free_key_material(SilcSKEKeyMaterial *key) } silc_free(key); } + +const char *silc_ske_status_string[] = +{ + /* Official */ + "Ok", + "Unkown error occurred", + "Bad payload in packet", + "Unsupported group", + "Unsupported cipher", + "Unsupported PKCS", + "Unsupported hash function", + "Unsupported HMAC", + "Unsupported public key (or certificate)", + "Incorrect signature", + "Bad or unsupported version", + "Invalid cookie", + + /* Other errors */ + "Pending", + "Remote did not provide public key", + "Key exchange protocol is not active", + "Bad reserved field in packet", + "Bad payload length in packet", + "Incorrect hash", + + NULL +}; + +/* Maps status to readable string and returns the string. If string is not + found and empty character string ("") is returned. */ + +const char *silc_ske_map_status(SilcSKEStatus status) +{ + int i; + + for (i = 0; silc_ske_status_string[i]; i++) + if (status == i) + return silc_ske_status_string[i]; + + return ""; +} diff --git a/lib/silcske/silcske.h b/lib/silcske/silcske.h index 55a0e0bf..62c221c0 100644 --- a/lib/silcske/silcske.h +++ b/lib/silcske/silcske.h @@ -246,5 +246,6 @@ SilcSKEStatus silc_ske_process_key_material(SilcSKE ske, uint32 req_hmac_key_len, SilcSKEKeyMaterial *key); void silc_ske_free_key_material(SilcSKEKeyMaterial *key); +const char *silc_ske_map_status(SilcSKEStatus status); #endif diff --git a/lib/silcske/silcske_status.h b/lib/silcske/silcske_status.h index 3dc0ad61..f223354b 100644 --- a/lib/silcske/silcske_status.h +++ b/lib/silcske/silcske_status.h @@ -43,8 +43,9 @@ typedef enum { SILC_SKE_STATUS_BAD_RESERVED_FIELD, SILC_SKE_STATUS_BAD_PAYLOAD_LENGTH, SILC_SKE_STATUS_INCORRECT_HASH, - SILC_SKE_STATUS_INCORRECT_PUBLIC_KEY, SILC_SKE_STATUS_FREED, } SilcSKEStatus; +extern const char *silc_ske_status_string[]; + #endif