Add error codes for blob sanity checks, rebuild error table.
This commit is contained in:
parent
2f2f032497
commit
00f716bbe6
@ -494,8 +494,7 @@ static EVP_PKEY *capi_load_privkey(ENGINE *eng, const char *key_id,
|
|||||||
bh = (BLOBHEADER *)pubkey;
|
bh = (BLOBHEADER *)pubkey;
|
||||||
if (bh->bType != PUBLICKEYBLOB)
|
if (bh->bType != PUBLICKEYBLOB)
|
||||||
{
|
{
|
||||||
/* FIXME */
|
CAPIerr(CAPI_F_CAPI_LOAD_PRIVKEY, CAPI_R_INVALID_PUBLIC_KEY_BLOB);
|
||||||
fprintf(stderr, "Invalid public key blob\n");
|
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
if (bh->aiKeyAlg == CALG_RSA_SIGN || bh->aiKeyAlg == CALG_RSA_KEYX)
|
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
|
else
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Unsupported Key Algorithm %x\n",
|
CAPIerr(CAPI_F_CAPI_LOAD_PRIVKEY, CAPI_R_UNSUPPORTED_PUBLIC_KEY_ALGORITHM);
|
||||||
bh->aiKeyAlg);
|
|
||||||
goto err;
|
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);
|
capi_key = RSA_get_ex_data(rsa, rsa_capi_idx);
|
||||||
if (!capi_key)
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -683,7 +681,7 @@ int capi_rsa_priv_dec(int flen, const unsigned char *from,
|
|||||||
{
|
{
|
||||||
char errstr[10];
|
char errstr[10];
|
||||||
sprintf(errstr, "%d", padding);
|
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);
|
ERR_add_error_data(2, "padding=", errstr);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -691,7 +689,7 @@ int capi_rsa_priv_dec(int flen, const unsigned char *from,
|
|||||||
/* Create temp reverse order version of input */
|
/* Create temp reverse order version of input */
|
||||||
if(!(tmpbuf = OPENSSL_malloc(flen)) )
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
for(i = 0; i < flen; i++) tmpbuf[flen - i - 1] = from[i];
|
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 */
|
/* Finally decrypt it */
|
||||||
if(!CryptDecrypt(capi_key->key, 0, TRUE, 0, tmpbuf, &flen))
|
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();
|
capi_addlasterror();
|
||||||
OPENSSL_free(tmpbuf);
|
OPENSSL_free(tmpbuf);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -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_LIST_CONTAINERS), "CAPI_LIST_CONTAINERS"},
|
||||||
{ERR_FUNC(CAPI_F_CAPI_LOAD_PRIVKEY), "CAPI_LOAD_PRIVKEY"},
|
{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_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_PRIV_ENC), "CAPI_RSA_PRIV_ENC"},
|
||||||
{ERR_FUNC(CAPI_F_CAPI_RSA_SIGN), "CAPI_RSA_SIGN"},
|
{ERR_FUNC(CAPI_F_CAPI_RSA_SIGN), "CAPI_RSA_SIGN"},
|
||||||
{ERR_FUNC(CAPI_F_WIDE_TO_ASC), "WIDE_TO_ASC"},
|
{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_FUNCTION_NOT_SUPPORTED),"function not supported"},
|
||||||
{ERR_REASON(CAPI_R_GETUSERKEY_ERROR) ,"getuserkey error"},
|
{ERR_REASON(CAPI_R_GETUSERKEY_ERROR) ,"getuserkey error"},
|
||||||
{ERR_REASON(CAPI_R_INVALID_LOOKUP_METHOD),"invalid lookup method"},
|
{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_ERROR) ,"pubkey export error"},
|
||||||
{ERR_REASON(CAPI_R_PUBKEY_EXPORT_LENGTH_ERROR),"pubkey export length 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_UNKNOWN_COMMAND) ,"unknown command"},
|
||||||
{ERR_REASON(CAPI_R_UNSUPPORTED_ALGORITHM_NID),"unsupported algorithm nid"},
|
{ERR_REASON(CAPI_R_UNSUPPORTED_ALGORITHM_NID),"unsupported algorithm nid"},
|
||||||
{ERR_REASON(CAPI_R_UNSUPPORTED_PADDING) ,"unsupported padding"},
|
{ERR_REASON(CAPI_R_UNSUPPORTED_PADDING) ,"unsupported padding"},
|
||||||
|
{ERR_REASON(CAPI_R_UNSUPPORTED_PUBLIC_KEY_ALGORITHM),"unsupported public key algorithm"},
|
||||||
{0,NULL}
|
{0,NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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_LIST_CONTAINERS 107
|
||||||
#define CAPI_F_CAPI_LOAD_PRIVKEY 108
|
#define CAPI_F_CAPI_LOAD_PRIVKEY 108
|
||||||
#define CAPI_F_CAPI_OPEN_STORE 109
|
#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_PRIV_ENC 111
|
||||||
#define CAPI_F_CAPI_RSA_SIGN 112
|
#define CAPI_F_CAPI_RSA_SIGN 112
|
||||||
#define CAPI_F_WIDE_TO_ASC 113
|
#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_FUNCTION_NOT_SUPPORTED 112
|
||||||
#define CAPI_R_GETUSERKEY_ERROR 113
|
#define CAPI_R_GETUSERKEY_ERROR 113
|
||||||
#define CAPI_R_INVALID_LOOKUP_METHOD 114
|
#define CAPI_R_INVALID_LOOKUP_METHOD 114
|
||||||
#define CAPI_R_PUBKEY_EXPORT_ERROR 115
|
#define CAPI_R_INVALID_PUBLIC_KEY_BLOB 115
|
||||||
#define CAPI_R_PUBKEY_EXPORT_LENGTH_ERROR 116
|
#define CAPI_R_PUBKEY_EXPORT_ERROR 116
|
||||||
#define CAPI_R_UNKNOWN_COMMAND 117
|
#define CAPI_R_PUBKEY_EXPORT_LENGTH_ERROR 117
|
||||||
#define CAPI_R_UNSUPPORTED_ALGORITHM_NID 118
|
#define CAPI_R_UNKNOWN_COMMAND 118
|
||||||
#define CAPI_R_UNSUPPORTED_PADDING 119
|
#define CAPI_R_UNSUPPORTED_ALGORITHM_NID 119
|
||||||
|
#define CAPI_R_UNSUPPORTED_PADDING 120
|
||||||
|
#define CAPI_R_UNSUPPORTED_PUBLIC_KEY_ALGORITHM 121
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user