Normalize SC_ERROR_* API and clean up ISO7816-4 errors.

* iso7816_check_sw() emits a "informational message" (from ISO7816-4 table 6)
 * SW-s which are not known or not meaningful for internal API get translated
   to SC_ERROR_CARD_CMD_FAILED by default, so use it also in the SW table
 * Remove undefined SW-s and move generic SW-s to their sequential location.

This commit improves 8fc679bf40
This commit is contained in:
Martin Paljak 2013-03-15 12:14:54 +02:00
parent 6f1ae23b1e
commit 9901682288
3 changed files with 7 additions and 23 deletions

View File

@ -137,12 +137,6 @@ const char *sc_strerror(int error)
};
const int sm_base = -SC_ERROR_SM;
const char *warnings[] = {
"Warning: no information given",
"Warning: file filled up by last write",
};
const int warn_base = -SC_WARNING;
const char *misc_errors[] = {
"Unknown error",
"PKCS#15 compatible smart card not found",
@ -162,10 +156,6 @@ const char *sc_strerror(int error)
errors = misc_errors;
count = DIM(misc_errors);
err_base = misc_base;
} else if (error >= warn_base) {
errors = warnings;
count = DIM(warnings);
err_base = warn_base;
} else if (error >= sm_base) {
errors = sm_errors;
count = DIM(sm_errors);

View File

@ -124,10 +124,6 @@ extern "C" {
#define SC_ERROR_SM_SESSION_ALREADY_ACTIVE -1611
#define SC_ERROR_SM_INVALID_CHECKSUM -1612
/* Warnings */
#define SC_WARNING -1700
#define SC_WARNING_FILE_FILLED -1701
/* Errors that do not fit the categories above */
#define SC_ERROR_UNKNOWN -1900
#define SC_ERROR_PKCS15_APP_NOT_FOUND -1901

View File

@ -30,14 +30,14 @@
#include "iso7816.h"
static const struct sc_card_error iso7816_errors[] = {
{ 0x6200, SC_WARNING, "warning: no information given, non-volatile memory is unchanged" },
{ 0x6200, SC_ERROR_CARD_CMD_FAILED, "Warning: no information given, non-volatile memory is unchanged" },
{ 0x6281, SC_ERROR_CORRUPTED_DATA, "Part of returned data may be corrupted" },
{ 0x6282, SC_ERROR_FILE_END_REACHED, "End of file/record reached before reading Le bytes" },
{ 0x6283, SC_ERROR_CARD_CMD_FAILED, "Selected file invalidated" },
{ 0x6284, SC_ERROR_CARD_CMD_FAILED, "FCI not formatted according to ISO 7816-4" },
{ 0x6300, SC_WARNING, "warning: no information given, non-volatile memory has changed" },
{ 0x6381, SC_WARNING_FILE_FILLED, "warning: file filled up by last write" },
{ 0x6300, SC_ERROR_CARD_CMD_FAILED, "Warning: no information given, non-volatile memory has changed" },
{ 0x6381, SC_ERROR_CARD_CMD_FAILED, "Warning: file filled up by last write" },
{ 0x6581, SC_ERROR_MEMORY_FAILURE, "Memory failure" },
@ -67,18 +67,16 @@ static const struct sc_card_error iso7816_errors[] = {
{ 0x6A86, SC_ERROR_INCORRECT_PARAMETERS,"Incorrect parameters P1-P2" },
{ 0x6A87, SC_ERROR_INCORRECT_PARAMETERS,"Lc inconsistent with P1-P2" },
{ 0x6A88, SC_ERROR_DATA_OBJECT_NOT_FOUND,"Referenced data not found" },
{ 0x6A89, SC_ERROR_FILE_ALREADY_EXISTS, "File already exists"},
{ 0x6A8A, SC_ERROR_FILE_ALREADY_EXISTS, "DF name already exists"},
{ 0x6B00, SC_ERROR_INCORRECT_PARAMETERS,"Wrong parameter(s) P1-P2" },
{ 0x6D00, SC_ERROR_INS_NOT_SUPPORTED, "Instruction code not supported or invalid" },
{ 0x6E00, SC_ERROR_CLASS_NOT_SUPPORTED, "Class not supported" },
{ 0x6F00, SC_ERROR_CARD_CMD_FAILED, "No precise diagnosis" },
/* Possibly TCOS / Micardo specific errors */
{ 0x6600, SC_ERROR_INCORRECT_PARAMETERS, "Error setting the security env"},
{ 0x66F0, SC_ERROR_INCORRECT_PARAMETERS, "No space left for padding"},
{ 0x69F0, SC_ERROR_NOT_ALLOWED, "Command not allowed"},
{ 0x6A89, SC_ERROR_FILE_ALREADY_EXISTS, "Files exists"},
{ 0x6A8A, SC_ERROR_FILE_ALREADY_EXISTS, "Application exists"},
};