Update error codes.

This commit is contained in:
Dr. Stephen Henson 2008-05-30 17:07:18 +00:00
parent 3aaeb5c1e5
commit 94299a36a6
3 changed files with 11 additions and 6 deletions

View file

@ -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;
}

View file

@ -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"},

View file

@ -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