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)
}
else
{
- fprintf(stderr, "Unsupported Key Algorithm %x\n",
- bh->aiKeyAlg);
+ CAPIerr(CAPI_F_CAPI_LOAD_PRIVKEY, CAPI_R_UNSUPPORTED_PUBLIC_KEY_ALGORITHM);
goto err;
}
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;
}
{
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;
}
/* 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];
/* 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;
{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"},
{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}
};
#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
#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
}