From 94299a36a6ec2fe2155d94a75c9d4a1c191fe4e2 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Fri, 30 May 2008 17:07:18 +0000 Subject: [PATCH] Update error codes. --- engines/e_capi.c | 13 +++++++------ engines/e_capi_err.c | 2 ++ engines/e_capi_err.h | 2 ++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/engines/e_capi.c b/engines/e_capi.c index a30a12b2a6..445ec91af0 100644 --- a/engines/e_capi.c +++ b/engines/e_capi.c @@ -827,35 +827,36 @@ static DSA_SIG *capi_dsa_do_sign(const unsigned char *digest, int dlen, if (!capi_key) { - CAPIerr(CAPI_F_CAPI_RSA_SIGN, CAPI_R_CANT_GET_KEY); + CAPIerr(CAPI_F_CAPI_DSA_DO_SIGN, CAPI_R_CANT_GET_KEY); return NULL; } if (dlen != 20) { - /* Invalid signature length */ + CAPIerr(CAPI_F_CAPI_DSA_DO_SIGN, CAPI_R_INVALID_DIGEST_LENGTH); + return NULL; } /* Create the hash object */ if(!CryptCreateHash(capi_key->hprov, CALG_SHA1, 0, 0, &hash)) { - CAPIerr(CAPI_F_CAPI_RSA_SIGN, CAPI_R_CANT_CREATE_HASH_OBJECT); + CAPIerr(CAPI_F_CAPI_DSA_DO_SIGN, CAPI_R_CANT_CREATE_HASH_OBJECT); capi_addlasterror(); return NULL; } /* Set the hash value to the value passed */ if(!CryptSetHashParam(hash, HP_HASHVAL, (unsigned char *)digest, 0)) { - CAPIerr(CAPI_F_CAPI_RSA_SIGN, CAPI_R_CANT_SET_HASH_VALUE); + CAPIerr(CAPI_F_CAPI_DSA_DO_SIGN, CAPI_R_CANT_SET_HASH_VALUE); capi_addlasterror(); goto err; } /* Finally sign it */ - slen = 40; + slen = sizeof(csigbuf); if(!CryptSignHash(hash, AT_SIGNATURE, NULL, 0, csigbuf, &slen)) { - CAPIerr(CAPI_F_CAPI_RSA_SIGN, CAPI_R_ERROR_SIGNING_HASH); + CAPIerr(CAPI_F_CAPI_DSA_DO_SIGN, CAPI_R_ERROR_SIGNING_HASH); capi_addlasterror(); goto err; } diff --git a/engines/e_capi_err.c b/engines/e_capi_err.c index 0dfab056d3..6ffd5bf574 100644 --- a/engines/e_capi_err.c +++ b/engines/e_capi_err.c @@ -74,6 +74,7 @@ static ERR_STRING_DATA CAPI_str_functs[]= {ERR_FUNC(CAPI_F_CAPI_CTRL), "CAPI_CTRL"}, {ERR_FUNC(CAPI_F_CAPI_CTX_NEW), "CAPI_CTX_NEW"}, {ERR_FUNC(CAPI_F_CAPI_CTX_SET_PROVNAME), "CAPI_CTX_SET_PROVNAME"}, +{ERR_FUNC(CAPI_F_CAPI_DSA_DO_SIGN), "CAPI_DSA_DO_SIGN"}, {ERR_FUNC(CAPI_F_CAPI_GET_KEY), "CAPI_GET_KEY"}, {ERR_FUNC(CAPI_F_CAPI_GET_PROVNAME), "CAPI_GET_PROVNAME"}, {ERR_FUNC(CAPI_F_CAPI_GET_PROV_INFO), "CAPI_GET_PROV_INFO"}, @@ -105,6 +106,7 @@ static ERR_STRING_DATA CAPI_str_reasons[]= {ERR_REASON(CAPI_R_ERROR_SIGNING_HASH) ,"error signing hash"}, {ERR_REASON(CAPI_R_FUNCTION_NOT_SUPPORTED),"function not supported"}, {ERR_REASON(CAPI_R_GETUSERKEY_ERROR) ,"getuserkey error"}, +{ERR_REASON(CAPI_R_INVALID_DIGEST_LENGTH),"invalid digest length"}, {ERR_REASON(CAPI_R_INVALID_DSA_PUBLIC_KEY_BLOB_MAGIC_NUMBER),"invalid dsa public key blob magic number"}, {ERR_REASON(CAPI_R_INVALID_LOOKUP_METHOD),"invalid lookup method"}, {ERR_REASON(CAPI_R_INVALID_PUBLIC_KEY_BLOB),"invalid public key blob"}, diff --git a/engines/e_capi_err.h b/engines/e_capi_err.h index 8f929f267f..cb801140b9 100644 --- a/engines/e_capi_err.h +++ b/engines/e_capi_err.h @@ -71,6 +71,7 @@ static void ERR_CAPI_error(int function, int reason, char *file, int line); #define CAPI_F_CAPI_CTRL 100 #define CAPI_F_CAPI_CTX_NEW 101 #define CAPI_F_CAPI_CTX_SET_PROVNAME 102 +#define CAPI_F_CAPI_DSA_DO_SIGN 114 #define CAPI_F_CAPI_GET_KEY 103 #define CAPI_F_CAPI_GET_PROVNAME 104 #define CAPI_F_CAPI_GET_PROV_INFO 105 @@ -99,6 +100,7 @@ static void ERR_CAPI_error(int function, int reason, char *file, int line); #define CAPI_R_ERROR_SIGNING_HASH 111 #define CAPI_R_FUNCTION_NOT_SUPPORTED 112 #define CAPI_R_GETUSERKEY_ERROR 113 +#define CAPI_R_INVALID_DIGEST_LENGTH 124 #define CAPI_R_INVALID_DSA_PUBLIC_KEY_BLOB_MAGIC_NUMBER 122 #define CAPI_R_INVALID_LOOKUP_METHOD 114 #define CAPI_R_INVALID_PUBLIC_KEY_BLOB 115 -- 2.25.1