From 3ce69d8387925d444d529ce0bb5beed9e880aad7 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 23 Feb 2021 12:56:42 +0100 Subject: [PATCH] scd: Add new status codes. * scd/apdu.h (SW_SM_NOT_SUP, SW_CC_NOT_SUP, SW_FILE_STRUCT) (SW_NO_CURRENT_EF): New. * scd/apdu.c (apdu_strerror): Map them to strings. * scd/iso7816.c (map_sw): ... and to gpg-error. --- scd/apdu.c | 4 ++++ scd/apdu.h | 2 ++ scd/iso7816.c | 2 ++ 3 files changed, 8 insertions(+) diff --git a/scd/apdu.c b/scd/apdu.c index f53194b35..3bdb509b3 100644 --- a/scd/apdu.c +++ b/scd/apdu.c @@ -522,10 +522,14 @@ apdu_strerror (int rc) case SW_EOF_REACHED : return "eof reached"; case SW_EEPROM_FAILURE : return "eeprom failure"; case SW_WRONG_LENGTH : return "wrong length"; + case SW_SM_NOT_SUP : return "secure messaging not supported"; + case SW_CC_NOT_SUP : return "command chaining not supported"; + case SW_FILE_STRUCT : return "command can't be used for file structure."; case SW_CHV_WRONG : return "CHV wrong"; case SW_CHV_BLOCKED : return "CHV blocked"; case SW_REF_DATA_INV : return "referenced data invalidated"; case SW_USE_CONDITIONS : return "use conditions not satisfied"; + case SW_NO_CURRENT_EF : return "no current EF selected"; case SW_BAD_PARAMETER : return "bad parameter"; case SW_NOT_SUPPORTED : return "not supported"; case SW_FILE_NOT_FOUND : return "file not found"; diff --git a/scd/apdu.h b/scd/apdu.h index 1cd04c2ee..a7f2b145f 100644 --- a/scd/apdu.h +++ b/scd/apdu.h @@ -34,10 +34,12 @@ enum { SW_WRONG_LENGTH = 0x6700, SW_SM_NOT_SUP = 0x6882, /* Secure Messaging is not supported. */ SW_CC_NOT_SUP = 0x6884, /* Command Chaining is not supported. */ + SW_FILE_STRUCT = 0x6981, /* Command can't be used for file structure. */ SW_CHV_WRONG = 0x6982, SW_CHV_BLOCKED = 0x6983, SW_REF_DATA_INV = 0x6984, /* Referenced data invalidated. */ SW_USE_CONDITIONS = 0x6985, + SW_NO_CURRENT_EF = 0x6986, /* No current EF selected. */ SW_BAD_PARAMETER = 0x6a80, /* (in the data field) */ SW_NOT_SUPPORTED = 0x6a81, SW_FILE_NOT_FOUND = 0x6a82, diff --git a/scd/iso7816.c b/scd/iso7816.c index d996eef39..450590175 100644 --- a/scd/iso7816.c +++ b/scd/iso7816.c @@ -69,9 +69,11 @@ map_sw (int sw) case SW_WRONG_LENGTH: ec = GPG_ERR_INV_VALUE; break; case SW_SM_NOT_SUP: ec = GPG_ERR_NOT_SUPPORTED; break; case SW_CC_NOT_SUP: ec = GPG_ERR_NOT_SUPPORTED; break; + case SW_FILE_STRUCT: ec = GPG_ERR_CARD; break; case SW_CHV_WRONG: ec = GPG_ERR_BAD_PIN; break; case SW_CHV_BLOCKED: ec = GPG_ERR_PIN_BLOCKED; break; case SW_USE_CONDITIONS: ec = GPG_ERR_USE_CONDITIONS; break; + case SW_NO_CURRENT_EF: ec = GPG_ERR_ENOENT; break; case SW_NOT_SUPPORTED: ec = GPG_ERR_NOT_SUPPORTED; break; case SW_BAD_PARAMETER: ec = GPG_ERR_INV_VALUE; break; case SW_FILE_NOT_FOUND: ec = GPG_ERR_ENOENT; break;