]> cvs.zerfleddert.de Git - proxmark3-svn/blob - client/lualibs/7816_error.lua
FIX: forgot a LEN in print message.
[proxmark3-svn] / client / lualibs / 7816_error.lua
1 --[[
2 local _errorcodes = {
3 SW_NO_ERROR = 0x9000,
4 SW_BYTES_REMAINING_00 = 0x6100, -- Response bytes remaining
5 SW_WARNING_STATE_UNCHANGED = 0x6200, -- Warning, card state unchanged =
6 SW_WRONG_LENGTH = 0x6700, -- : Wrong length
7 SW_WRONG_P1P2 = 0x6B00, -- : Incorrect parameters (P1,P2)
8 SW_CORRECT_LENGTH_00 = 0x6C00, -- : Correct Expected Length (Le)
9 SW_INS_NOT_SUPPORTED = 0x6D00, -- : INS value not supported
10 SW_CLA_NOT_SUPPORTED = 0x6E00, -- : CLA value not supported
11 SW_UNKNOWN = 0x6F00, -- : No precise diagnosis
12
13 SW_LOGICAL_CHANNEL_NOT_SUPPORTED = 0x6881, -- : Card does not support the operation on the specified logical channel
14 SW_SECURE_MESSAGING_NOT_SUPPORTED = 0x6882, -- : Card does not support secure messaging
15 SW_LAST_COMMAND_EXPECTED = 0x6883, -- : Last command in chain expected
16 SW_COMMAND_CHAINING_NOT_SUPPORTED = 0x6884, -- : Command chaining not supported
17
18 SW_SECURITY_STATUS_NOT_SATISFIED = 0x6982, -- : Security condition not satisfied
19 SW_FILE_INVALID = 0x6983, -- : File invalid
20 SW_DATA_INVALID = 0x6984, -- : Data invalid
21 SW_CONDITIONS_NOT_SATISFIED = 0x6985, -- : Conditions of use not satisfied
22 SW_COMMAND_NOT_ALLOWED = 0x6986, -- : Command not allowed (no current EF)
23 SW_APPLET_SELECT_FAILED = 0x6999, -- : Applet selection failed
24
25 SW_WRONG_DATA = 0x6A80, -- : Wrong data
26 SW_FUNC_NOT_SUPPORTED = 0x6A81, -- : Function not supported
27 SW_FILE_NOT_FOUND = 0x6A82, -- : File not found
28 SW_RECORD_NOT_FOUND = 0x6A83, -- : Record not found
29 SW_FILE_FULL = 0x6A84, -- : Not enough memory space in the file
30 SW_INCORRECT_P1P2 = 0x6A86, -- : Incorrect parameters (P1,P2)
31 }
32 --]]
33 local _errorcodes = {
34 SW_NO_ERROR = '9000',
35 SW_BYTES_REMAINING_00 = '6100', -- Response bytes remaining
36 SW_WARNING_STATE_UNCHANGED = '6200', -- Warning', card state unchanged =
37 SW_WRONG_LENGTH = '6700', -- : Wrong length
38 SW_WRONG_P1P2 = '6B00', -- : Incorrect parameters (P1,P2)
39 SW_CORRECT_LENGTH_00 = '6C00', -- : Correct Expected Length (Le)
40 SW_INS_NOT_SUPPORTED = '6D00', -- : INS value not supported
41 SW_CLA_NOT_SUPPORTED = '6E00', -- : CLA value not supported
42 SW_UNKNOWN = '6F00', -- : No precise diagnosis
43
44 SW_LOGICAL_CHANNEL_NOT_SUPPORTED = '6881', -- : Card does not support the operation on the specified logical channel
45 SW_SECURE_MESSAGING_NOT_SUPPORTED = '6882', -- : Card does not support secure messaging
46 SW_LAST_COMMAND_EXPECTED = '6883', -- : Last command in chain expected
47 SW_COMMAND_CHAINING_NOT_SUPPORTED = '6884', -- : Command chaining not supported
48
49 SW_SECURITY_STATUS_NOT_SATISFIED = '6982', -- : Security condition not satisfied
50 SW_FILE_INVALID = '6983', -- : File invalid
51 SW_DATA_INVALID = '6984', -- : Data invalid
52 SW_CONDITIONS_NOT_SATISFIED = '6985', -- : Conditions of use not satisfied
53 SW_COMMAND_NOT_ALLOWED = '6986', -- : Command not allowed (no current EF)
54 SW_APPLET_SELECT_FAILED = '6999', -- : Applet selection failed
55
56 SW_WRONG_DATA = '6A80', -- : Wrong data
57 SW_FUNC_NOT_SUPPORTED = '6A81', -- : Function not supported
58 SW_FILE_NOT_FOUND = '6A82', -- : File not found
59 SW_RECORD_NOT_FOUND = '6A83', -- : Record not found
60 SW_FILE_FULL = '6A84', -- : Not enough memory space in the file
61 SW_INCORRECT_P1P2 = '6A86', -- : Incorrect parameters (P1,P2)
62 }
63
64 local _reverse_lookup,k,v = {}
65 for k, v in pairs(_errorcodes) do
66 _reverse_lookup[v] = k
67 end
68
69 _errorcodes.tostring = function(command)
70 if(type(command) == 'string') then
71 return ("%s (%d)"):format(_reverse_lookup[command] or "ERROR UNDEFINED!", command)
72 end
73 if(type(command) == 'number') then
74 return ("%s (%d)"):format(_reverse_lookup[ tostring(command)] or "ERROR UNDEFINED!", command)
75 end
76 return ("Error, numeric or string argument expected, got : %s"):format(tostring(command))
77 end
78 return _errorcodes
Impressum, Datenschutz