updates.
authorPekka Riikonen <priikone@silcnet.org>
Wed, 19 Sep 2001 20:13:53 +0000 (20:13 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Wed, 19 Sep 2001 20:13:53 +0000 (20:13 +0000)
CHANGES
apps/silcd/protocol.c
lib/silcske/silcske.c
lib/silcske/silcske.h
lib/silcske/silcske_status.h

diff --git a/CHANGES b/CHANGES
index c02b602f37189d23ffff842895e8b07ca756bfbd..8f3b05b4a3ff8303e2a2a4cf13f41a62403386ac 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,9 @@
+Wed Sep 19 22:58:32 EEST 2001  Pekka Riikonen <priikone@silcnet.org>
+
+       * 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 <priikone@silcnet.org>
 
        * Do not show the private channels on the WHOIS channel list
index 4d306195f71e09c7a3b6569f2e8da5cf865b4ef6..07f3233d037378628bc5f7bd25f922734ec5c9de 100644 (file)
@@ -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);
index e69fc0f9df52914c69fc0bff33ff2023944d40ed..cacdb3d66d1b43be2f9d5e82cbe54210b425a3a2 100644 (file)
@@ -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 "";
+}
index 55a0e0bfdc7072cc4be0e24cd6fe4e4a91c882c6..62c221c0becbc02e3281942a284dc84cb3c2b5b8 100644 (file)
@@ -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
index 3dc0ad6160f60be2872d634fbe488359e1cf7544..f223354bc50f7ef87cac7d3d6c9d3ce28f71b0bc 100644 (file)
@@ -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