fix one too small
[RRG-proxmark3.git] / client / src / cipurse / cipursecore.h
blobf7bdd9be01db8064e2fa2191e1cc36571de059af
1 //-----------------------------------------------------------------------------
2 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // See LICENSE.txt for the text of the license.
15 //-----------------------------------------------------------------------------
16 // CIPURSE transport cards data and commands
17 //-----------------------------------------------------------------------------
19 #ifndef __CIPURSECORE_H__
20 #define __CIPURSECORE_H__
22 #include <jansson.h>
23 #include <stdbool.h>
24 #include "common.h"
25 #include "../iso7816/apduinfo.h" // sAPDU_t
26 #include "cipurse/cipursecrypto.h"
29 #define CIPURSE_DEFAULT_KEY {0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73}
30 #define CIPURSE_DEFAULT_AID {0x41, 0x44, 0x20, 0x46, 0x31}
32 void CIPURSEPrintInfoFile(uint8_t *data, size_t len);
34 int CIPURSESelect(bool activate_field, bool leave_field_on, uint8_t *result, size_t max_result_len, size_t *result_len, uint16_t *sw);
35 int CIPURSESelectAID(bool activate_field, bool leave_field_on, uint8_t *aid, size_t aidlen, uint8_t *result, size_t max_result_len, size_t *result_len, uint16_t *sw);
37 int CIPURSEChallenge(uint8_t *result, size_t max_result_len, size_t *result_len, uint16_t *sw);
38 int CIPURSEMutualAuthenticate(uint8_t keyindex, uint8_t *params, uint8_t paramslen, uint8_t *result, size_t max_result_len, size_t *result_len, uint16_t *sw);
40 int CIPURSECreateFile(uint8_t *attr, uint16_t attrlen, uint8_t *result, size_t max_result_len, size_t *result_len, uint16_t *sw);
41 int CIPURSEDeleteFile(uint16_t fileid, uint8_t *result, size_t max_result_len, size_t *result_len, uint16_t *sw);
42 int CIPURSEDeleteFileAID(uint8_t *aid, size_t aidLen, uint8_t *result, size_t max_result_len, size_t *result_len, uint16_t *sw);
44 int CIPURSEFormatAll(uint16_t *sw);
46 int CIPURSESelectFileEx(bool activate_field, bool leave_field_on, uint16_t fileid, uint8_t *result, size_t max_result_len, size_t *result_len, uint16_t *sw);
47 int CIPURSESelectFile(uint16_t fileid, uint8_t *result, size_t max_result_len, size_t *result_len, uint16_t *sw);
48 int CIPURSESelectMFDefaultFileEx(bool activate_field, bool leave_field_on, uint8_t *result, size_t max_result_len, size_t *result_len, uint16_t *sw);
49 int CIPURSESelectMFDefaultFile(uint8_t *result, size_t max_result_len, size_t *result_len, uint16_t *sw);
50 int CIPURSESelectMFEx(bool activate_field, bool leave_field_on, uint8_t *result, size_t max_result_len, size_t *result_len, uint16_t *sw);
51 int CIPURSESelectMF(uint8_t *result, size_t max_result_len, size_t *result_len, uint16_t *sw);
53 int CIPURSEReadFileAttributes(uint8_t *result, size_t max_result_len, size_t *result_len, uint16_t *sw);
54 int CIPURSEUpdateFileAttributes(uint8_t *data, uint16_t datalen, uint8_t *result, size_t max_result_len, size_t *result_len, uint16_t *sw);
55 int CIPURSEReadBinary(uint16_t offset, uint8_t *result, size_t max_result_len, size_t *result_len, uint16_t *sw);
56 int CIPURSEUpdateBinary(uint16_t offset, uint8_t *data, uint16_t datalen, uint8_t *result, size_t max_result_len, size_t *result_len, uint16_t *sw);
58 int CIPURSEUpdateKey(uint8_t encrypt_key_num, uint8_t key_num, uint8_t *key, uint16_t key_len, uint8_t *result, size_t max_result_len, size_t *result_len, uint16_t *sw);
59 int CIPURSEUpdateKeyAttrib(uint8_t key_num, uint8_t key_attrib, uint8_t *result, size_t max_result_len, size_t *result_len, uint16_t *sw);
61 int CIPURSECommitTransaction(uint16_t *sw);
62 int CIPURSECancelTransaction(uint16_t *sw);
64 bool CIPURSEChannelAuthenticate(uint8_t keyindex, uint8_t *key, bool verbose);
65 void CIPURSECSetActChannelSecurityLevels(CipurseChannelSecurityLevel req, CipurseChannelSecurityLevel resp);
67 const char *CIPURSEGetSMR(uint8_t smr);
68 void CIPURSEPrintSMR(const uint8_t *smrrec);
69 void CIPURSEPrintART(const uint8_t *artrec, size_t artlen);
70 void CIPURSEPrintEFFileAttr(uint8_t *attr, size_t len);
71 void CIPURSEPrintFileAttrEx(uint8_t *attr, size_t len, bool isDGI);
72 void CIPURSEPrintFileAttr(uint8_t *attr, size_t len);
73 void CIPURSEPrintFileUpdateAttr(uint8_t *attr, size_t len);
74 void CIPURSEPrintFileDescriptor(uint8_t desc);
75 void CIPURSEPrintDGIArray(uint8_t *dgi, size_t dgilen);
76 void CIPURSEPrintDGI(uint8_t *dgi, size_t dgilen);
77 void CIPURSEPrintKeySecurityAttributes(uint8_t attr);
79 #endif /* __CIPURSECORE_H__ */