summaryrefslogtreecommitdiffstats
path: root/engines
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2008-05-30 11:58:50 +0000
committerDr. Stephen Henson <steve@openssl.org>2008-05-30 11:58:50 +0000
commit00f716bbe6f533f852ee12d56b9bc68c65f17d65 (patch)
treee1834bf5cba7d19fa5d2c22dde0fe492780dce1d /engines
parent2f2f032497b00e4cb976ead5f5a536c1a68055c8 (diff)
Add error codes for blob sanity checks, rebuild error table.
Diffstat (limited to 'engines')
-rw-r--r--engines/e_capi.c14
-rw-r--r--engines/e_capi_err.c4
-rw-r--r--engines/e_capi_err.h14
3 files changed, 17 insertions, 15 deletions
diff --git a/engines/e_capi.c b/engines/e_capi.c
index 86fa204990..10f15da138 100644
--- a/engines/e_capi.c
+++ b/engines/e_capi.c
@@ -494,8 +494,7 @@ static EVP_PKEY *capi_load_privkey(ENGINE *eng, const char *key_id,
bh = (BLOBHEADER *)pubkey;
if (bh->bType != PUBLICKEYBLOB)
{
- /* FIXME */
- fprintf(stderr, "Invalid public key blob\n");
+ CAPIerr(CAPI_F_CAPI_LOAD_PRIVKEY, CAPI_R_INVALID_PUBLIC_KEY_BLOB);
goto err;
}
if (bh->aiKeyAlg == CALG_RSA_SIGN || bh->aiKeyAlg == CALG_RSA_KEYX)
@@ -539,8 +538,7 @@ static EVP_PKEY *capi_load_privkey(ENGINE *eng, const char *key_id,
}
else
{
- fprintf(stderr, "Unsupported Key Algorithm %x\n",
- bh->aiKeyAlg);
+ CAPIerr(CAPI_F_CAPI_LOAD_PRIVKEY, CAPI_R_UNSUPPORTED_PUBLIC_KEY_ALGORITHM);
goto err;
}
@@ -675,7 +673,7 @@ int capi_rsa_priv_dec(int flen, const unsigned char *from,
capi_key = RSA_get_ex_data(rsa, rsa_capi_idx);
if (!capi_key)
{
- CAPIerr(CAPI_F_CAPI_RSA_DECRYPT, CAPI_R_CANT_GET_KEY);
+ CAPIerr(CAPI_F_CAPI_RSA_PRIV_DEC, CAPI_R_CANT_GET_KEY);
return -1;
}
@@ -683,7 +681,7 @@ int capi_rsa_priv_dec(int flen, const unsigned char *from,
{
char errstr[10];
sprintf(errstr, "%d", padding);
- CAPIerr(CAPI_F_CAPI_RSA_DECRYPT, CAPI_R_UNSUPPORTED_PADDING);
+ CAPIerr(CAPI_F_CAPI_RSA_PRIV_DEC, CAPI_R_UNSUPPORTED_PADDING);
ERR_add_error_data(2, "padding=", errstr);
return -1;
}
@@ -691,7 +689,7 @@ int capi_rsa_priv_dec(int flen, const unsigned char *from,
/* Create temp reverse order version of input */
if(!(tmpbuf = OPENSSL_malloc(flen)) )
{
- CAPIerr(CAPI_F_CAPI_RSA_DECRYPT, ERR_R_MALLOC_FAILURE);
+ CAPIerr(CAPI_F_CAPI_RSA_PRIV_DEC, ERR_R_MALLOC_FAILURE);
return -1;
}
for(i = 0; i < flen; i++) tmpbuf[flen - i - 1] = from[i];
@@ -699,7 +697,7 @@ int capi_rsa_priv_dec(int flen, const unsigned char *from,
/* Finally decrypt it */
if(!CryptDecrypt(capi_key->key, 0, TRUE, 0, tmpbuf, &flen))
{
- CAPIerr(CAPI_F_CAPI_RSA_DECRYPT, CAPI_R_DECRYPT_ERROR);
+ CAPIerr(CAPI_F_CAPI_RSA_PRIV_DEC, CAPI_R_DECRYPT_ERROR);
capi_addlasterror();
OPENSSL_free(tmpbuf);
return -1;
diff --git a/engines/e_capi_err.c b/engines/e_capi_err.c
index 64e10e929d..bfead58c59 100644
--- a/engines/e_capi_err.c
+++ b/engines/e_capi_err.c
@@ -81,7 +81,7 @@ static ERR_STRING_DATA CAPI_str_functs[]=
{ERR_FUNC(CAPI_F_CAPI_LIST_CONTAINERS), "CAPI_LIST_CONTAINERS"},
{ERR_FUNC(CAPI_F_CAPI_LOAD_PRIVKEY), "CAPI_LOAD_PRIVKEY"},
{ERR_FUNC(CAPI_F_CAPI_OPEN_STORE), "CAPI_OPEN_STORE"},
-{ERR_FUNC(CAPI_F_CAPI_RSA_DECRYPT), "CAPI_RSA_DECRYPT"},
+{ERR_FUNC(CAPI_F_CAPI_RSA_PRIV_DEC), "CAPI_RSA_PRIV_DEC"},
{ERR_FUNC(CAPI_F_CAPI_RSA_PRIV_ENC), "CAPI_RSA_PRIV_ENC"},
{ERR_FUNC(CAPI_F_CAPI_RSA_SIGN), "CAPI_RSA_SIGN"},
{ERR_FUNC(CAPI_F_WIDE_TO_ASC), "WIDE_TO_ASC"},
@@ -106,11 +106,13 @@ static ERR_STRING_DATA CAPI_str_reasons[]=
{ERR_REASON(CAPI_R_FUNCTION_NOT_SUPPORTED),"function not supported"},
{ERR_REASON(CAPI_R_GETUSERKEY_ERROR) ,"getuserkey error"},
{ERR_REASON(CAPI_R_INVALID_LOOKUP_METHOD),"invalid lookup method"},
+{ERR_REASON(CAPI_R_INVALID_PUBLIC_KEY_BLOB),"invalid public key blob"},
{ERR_REASON(CAPI_R_PUBKEY_EXPORT_ERROR) ,"pubkey export error"},
{ERR_REASON(CAPI_R_PUBKEY_EXPORT_LENGTH_ERROR),"pubkey export length error"},
{ERR_REASON(CAPI_R_UNKNOWN_COMMAND) ,"unknown command"},
{ERR_REASON(CAPI_R_UNSUPPORTED_ALGORITHM_NID),"unsupported algorithm nid"},
{ERR_REASON(CAPI_R_UNSUPPORTED_PADDING) ,"unsupported padding"},
+{ERR_REASON(CAPI_R_UNSUPPORTED_PUBLIC_KEY_ALGORITHM),"unsupported public key algorithm"},
{0,NULL}
};
diff --git a/engines/e_capi_err.h b/engines/e_capi_err.h
index 50ad51d9c4..f0e1ff1f95 100644
--- a/engines/e_capi_err.h
+++ b/engines/e_capi_err.h
@@ -78,7 +78,7 @@ static void ERR_CAPI_error(int function, int reason, char *file, int line);
#define CAPI_F_CAPI_LIST_CONTAINERS 107
#define CAPI_F_CAPI_LOAD_PRIVKEY 108
#define CAPI_F_CAPI_OPEN_STORE 109
-#define CAPI_F_CAPI_RSA_DECRYPT 110
+#define CAPI_F_CAPI_RSA_PRIV_DEC 110
#define CAPI_F_CAPI_RSA_PRIV_ENC 111
#define CAPI_F_CAPI_RSA_SIGN 112
#define CAPI_F_WIDE_TO_ASC 113
@@ -100,11 +100,13 @@ static void ERR_CAPI_error(int function, int reason, char *file, int line);
#define CAPI_R_FUNCTION_NOT_SUPPORTED 112
#define CAPI_R_GETUSERKEY_ERROR 113
#define CAPI_R_INVALID_LOOKUP_METHOD 114
-#define CAPI_R_PUBKEY_EXPORT_ERROR 115
-#define CAPI_R_PUBKEY_EXPORT_LENGTH_ERROR 116
-#define CAPI_R_UNKNOWN_COMMAND 117
-#define CAPI_R_UNSUPPORTED_ALGORITHM_NID 118
-#define CAPI_R_UNSUPPORTED_PADDING 119
+#define CAPI_R_INVALID_PUBLIC_KEY_BLOB 115
+#define CAPI_R_PUBKEY_EXPORT_ERROR 116
+#define CAPI_R_PUBKEY_EXPORT_LENGTH_ERROR 117
+#define CAPI_R_UNKNOWN_COMMAND 118
+#define CAPI_R_UNSUPPORTED_ALGORITHM_NID 119
+#define CAPI_R_UNSUPPORTED_PADDING 120
+#define CAPI_R_UNSUPPORTED_PUBLIC_KEY_ALGORITHM 121
#ifdef __cplusplus
}