* maperror.c (map_gcry_err): Add some mappings.
authorWerner Koch <wk@gnupg.org>
Thu, 20 Dec 2001 16:49:48 +0000 (16:49 +0000)
committerWerner Koch <wk@gnupg.org>
Thu, 20 Dec 2001 16:49:48 +0000 (16:49 +0000)
common/ChangeLog
common/errors.h
common/maperror.c

index 1d0cec6..8323104 100644 (file)
@@ -1,3 +1,7 @@
+2001-12-20  Werner Koch  <wk@gnupg.org>
+
+       * maperror.c (map_gcry_err): Add some mappings.
+
 2001-12-18  Werner Koch  <wk@gnupg.org>
 
        * Makefile.am (AM_CPPFLAGS): Include flags for gcrypt and ksba
index faa39c7..cea4950 100644 (file)
@@ -64,6 +64,9 @@ enum {
   GNUPG_Bad_PIN = 35,
   GNUPG_Bad_Passphrase = 36,
   GNUPG_Invalid_Name = 37,
+  GNUPG_Bad_Public_Key = 38,
+  GNUPG_Bad_Secret_Key = 39,
+  GNUPG_Bad_Data = 40,
 };
 
 /* Status codes - fixme: should go into another file */
index e073f16..0c259dd 100644 (file)
@@ -58,10 +58,50 @@ map_gcry_err (int err)
 {
   switch (err)
     {
+    case GCRYERR_EOF:
     case -1:
+      err = -1;
+      break;
+
     case 0:
       break;
+
+    case GCRYERR_WRONG_PK_ALGO:
+    case GCRYERR_INV_PK_ALGO:
+    case GCRYERR_INV_MD_ALGO:
+    case GCRYERR_INV_CIPHER_ALGO:
+      err = GNUPG_Unsupported_Algorithm;
+      break;
+    case GCRYERR_INV_KEYLEN:
+    case GCRYERR_WEAK_KEY:
+    case GCRYERR_BAD_PUBLIC_KEY: err = GNUPG_Bad_Public_Key; break;
+    case GCRYERR_BAD_SECRET_KEY: err = GNUPG_Bad_Secret_Key; break;
+    case GCRYERR_BAD_SIGNATURE:  err = GNUPG_Bad_Signature; break;
+
+    case GCRYERR_BAD_MPI:
+      err = GNUPG_Bad_Data;
+      break;
+      
+    case GCRYERR_INV_ARG:
+    case GCRYERR_INV_OP:
+    case GCRYERR_INTERNAL:
+    case GCRYERR_INV_CIPHER_MODE:
+      err = GNUPG_Invalid_Value;
+      break;
+
+    case GCRYERR_SELFTEST: 
+      err = GNUPG_Bug;
+      break;
+
+    case GCRYERR_NO_MEM: err = GNUPG_Out_Of_Core; break;
+
+    case GCRYERR_NOT_IMPL:  err = GNUPG_Not_Implemented; break;
+    case GCRYERR_CONFLICT:  err = GNUPG_Conflict; break;
       
+    case GCRYERR_INV_OBJ:   /* an object is not valid */
+    case GCRYERR_TOO_SHORT: /* provided buffer too short */
+    case GCRYERR_TOO_LARGE: /* object is too large */
+    case GCRYERR_NO_OBJ:    /* Missing item in an object */
     default:
       err = seterr (General_Error);
       break;