Add functions to set ECDSA_METHOD structure.
[openssl.git] / crypto / ecdsa / ecs_err.c
index c9bed9dd8ed1f46d3e3d4db944680ce6c3d1d7e2..919cced040dd862cf80f4a6ab8057ddcb2d441a0 100644 (file)
@@ -1,6 +1,6 @@
 /* crypto/ecdsa/ecs_err.c */
 /* ====================================================================
- * Copyright (c) 1999-2002 The OpenSSL Project.  All rights reserved.
+ * Copyright (c) 1999-2013 The OpenSSL Project.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include <stdio.h>
 #include <openssl/err.h>
 #include <openssl/ecdsa.h>
-#include <openssl/opensslconf.h> /* To see if OPENSSL_NO_ERR is defined */
 
 /* BEGIN ERROR CODES */
 #ifndef OPENSSL_NO_ERR
+
+#define ERR_FUNC(func) ERR_PACK(ERR_LIB_ECDSA,func,0)
+#define ERR_REASON(reason) ERR_PACK(ERR_LIB_ECDSA,0,reason)
+
 static ERR_STRING_DATA ECDSA_str_functs[]=
        {
-{ERR_PACK(0,ECDSA_F_ECDSA_DATA_NEW,0), "ECDSA_DATA_new"},
-{ERR_PACK(0,ECDSA_F_ECDSA_DO_SIGN,0),  "ECDSA_do_sign"},
-{ERR_PACK(0,ECDSA_F_ECDSA_DO_VERIFY,0),        "ECDSA_do_verify"},
-{ERR_PACK(0,ECDSA_F_ECDSA_SIGN_SETUP,0),       "ECDSA_sign_setup"},
+{ERR_FUNC(ECDSA_F_ECDSA_DATA_NEW_METHOD),      "ECDSA_DATA_NEW_METHOD"},
+{ERR_FUNC(ECDSA_F_ECDSA_DO_SIGN),      "ECDSA_do_sign"},
+{ERR_FUNC(ECDSA_F_ECDSA_DO_VERIFY),    "ECDSA_do_verify"},
+{ERR_FUNC(ECDSA_F_ECDSA_METHOD_NEW),   "ECDSA_METHOD_new"},
+{ERR_FUNC(ECDSA_F_ECDSA_SIGN_SETUP),   "ECDSA_sign_setup"},
 {0,NULL}
        };
 
 static ERR_STRING_DATA ECDSA_str_reasons[]=
        {
-{ECDSA_R_BAD_SIGNATURE                   ,"bad signature"},
-{ECDSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE     ,"data too large for key size"},
-{ECDSA_R_ERR_EC_LIB                      ,"err ec lib"},
-{ECDSA_R_MISSING_PARAMETERS              ,"missing parameters"},
-{ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED ,"random number generation failed"},
-{ECDSA_R_SIGNATURE_MALLOC_FAILED         ,"signature malloc failed"},
+{ERR_REASON(ECDSA_R_BAD_SIGNATURE)       ,"bad signature"},
+{ERR_REASON(ECDSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE),"data too large for key size"},
+{ERR_REASON(ECDSA_R_ERR_EC_LIB)          ,"err ec lib"},
+{ERR_REASON(ECDSA_R_MISSING_PARAMETERS)  ,"missing parameters"},
+{ERR_REASON(ECDSA_R_NEED_NEW_SETUP_VALUES),"need new setup values"},
+{ERR_REASON(ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED),"random number generation failed"},
+{ERR_REASON(ECDSA_R_SIGNATURE_MALLOC_FAILED),"signature malloc failed"},
 {0,NULL}
        };
 
@@ -89,15 +94,12 @@ static ERR_STRING_DATA ECDSA_str_reasons[]=
 
 void ERR_load_ECDSA_strings(void)
        {
-       static int init=1;
-
-       if (init)
-               {
-               init=0;
 #ifndef OPENSSL_NO_ERR
-               ERR_load_strings(ERR_LIB_ECDSA,ECDSA_str_functs);
-               ERR_load_strings(ERR_LIB_ECDSA,ECDSA_str_reasons);
-#endif
 
+       if (ERR_func_error_string(ECDSA_str_functs[0].error) == NULL)
+               {
+               ERR_load_strings(0,ECDSA_str_functs);
+               ERR_load_strings(0,ECDSA_str_reasons);
                }
+#endif
        }