diff --git a/src/libopensc/errors.c b/src/libopensc/errors.c index e8bff61b..31ac4f13 100644 --- a/src/libopensc/errors.c +++ b/src/libopensc/errors.c @@ -119,6 +119,21 @@ const char *sc_strerror(int error) }; const int p15i_base = -SC_ERROR_PKCS15INIT; + const int sm_base = -SC_ERROR_SM; + const char *sm_errors[] = { + "Generic Secure Messaging error", + "Data enciphering error", + "Invalid secure messaging level", + "No session keys", + "Invalid session keys", + "Secure Messaging not initialized", + "Cannot authenticate card", + "Random generation error", + "Secure messaging keyset not found", + "IFD data missing" + }; + + const char *misc_errors[] = { "Unknown error", "PKCS#15 compatible smart card not found", @@ -138,6 +153,10 @@ const char *sc_strerror(int error) errors = misc_errors; count = DIM(misc_errors); err_base = misc_base; + } else if (error >= sm_base) { + errors = sm_errors; + count = DIM(sm_errors); + err_base = sm_base; } else if (error >= p15i_base) { errors = p15i_errors; count = DIM(p15i_errors); diff --git a/src/libopensc/errors.h b/src/libopensc/errors.h index f9ac4f03..945a4561 100644 --- a/src/libopensc/errors.h +++ b/src/libopensc/errors.h @@ -108,6 +108,19 @@ extern "C" { #define SC_ERROR_INVALID_PIN_REFERENCE -1509 #define SC_ERROR_FILE_TOO_SMALL -1510 +/* Related to secure messaging */ +#define SC_ERROR_SM -1600 +#define SC_ERROR_SM_ENCRYPT_FAILED -1601 +#define SC_ERROR_SM_INVALID_LEVEL -1602 +#define SC_ERROR_SM_NO_SESSION_KEYS -1603 +#define SC_ERROR_SM_INVALID_SESSION_KEY -1604 +#define SC_ERROR_SM_NOT_INITIALIZED -1605 +#define SC_ERROR_SM_AUTHENTICATION_FAILED -1606 +#define SC_ERROR_SM_RAND_FAILED -1607 +#define SC_ERROR_SM_KEYSET_NOT_FOUND -1608 +#define SC_ERROR_SM_IFD_DATA_MISSING -1609 + + /* Errors that do not fit the categories above */ #define SC_ERROR_UNKNOWN -1900 #define SC_ERROR_PKCS15_APP_NOT_FOUND -1901