forked from AlterCodex/nxppy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMifare.h
137 lines (121 loc) · 3.45 KB
/
Mifare.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#pragma once
/*******************************************************************************
* Copyright (c), NXP Semiconductors Gratkorn / Austria
*
* (C)NXP Semiconductors
* All rights are reserved. Reproduction in whole or in part is
* prohibited without the written consent of the copyright owner.
* NXP reserves the right to make changes without notice at any time.
* NXP makes no warranty, expressed, implied or statutory, including but
* not limited to any implied warranty of merchantability or fitness for any
* particular purpose, or that the use will not infringe any third party patent,
* copyright or trademark. NXP must not be liable for any loss or damage
* arising from its use.
********************************************************************************
*
* Filename: main.c
* Processor family: ARM11
*
* Description: This file contains main entry.
*
*******************************************************************************/
#include <Python.h>
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdint.h>
/**
* Header for hardware configuration: bus interface, reset of attached reader ID, onboard LED handling etc.
* */
#include <phhwConfig.h>
/**
* Reader Library Headers
*/
#include <ph_Status.h>
/*
* BAL Headers
*/
#include <phbalReg.h>
/*
* PAL Headers
*/
#include <phpalI14443p3a.h>
#include <phpalI14443p4.h>
#include <phpalI14443p3b.h>
#include <phpalI14443p4a.h>
#include <phpalMifare.h>
/*
* AL Headers
*/
#include <phalMfc.h>
#include <phacDiscLoop.h>
/*
* Printf macro
*/
/*
* Configuration Headers
*/
/*
* Controls build behavior of components
*/
#include <ph_NxpBuild.h>
/*
* Status code definitions
*/
#include <ph_Status.h>
/*
* Reader Library Headers
*/
/*
* Generic ISO14443-3A Component of Reader Library Framework
*/
#include <phpalI14443p3a.h>
/*
* Generic ISO14443-4 Component of Reader Library Framework
*/
#include <phpalI14443p4.h>
/*
* Generic ISO14443-4A Component of Reader Library Framework
*/
#include <phpalI14443p4a.h>
/*
* Generic MIFARE(R) Ultralight Application Component of Reader Library Framework
*/
#include <phalMful.h>
#include <phalMfc.h>
#include <phpalI14443p3b.h>
#define UID_BUFFER_SIZE 20
#define UID_ASCII_BUFFER_SIZE ((UID_BUFFER_SIZE * 2) + 1)
#define MIFARECLASSIC_BUFFER_SIZE 16
typedef struct {
phbalReg_Stub_DataParams_t balReader;
phhalHw_Nfc_Ic_DataParams_t hal;
phpalI14443p4_Sw_DataParams_t I14443p4;
phpalMifare_Sw_DataParams_t palMifare;
phpalI14443p3a_Sw_DataParams_t I14443p3a;
phalMful_Sw_DataParams_t alMful;
uint8_t bHalBufferReader[0x40];
//phKeyStore_Sw_DataParams_t KeyStore;
phalMfc_Sw_DataParams_t palMifareClassic;
uint8_t Sak;
uint8_t *uid;
uint8_t uidSize;
} nfc_data;
typedef struct {
PyObject_HEAD nfc_data data;
} Mifare;
//Pyobject *Mifare_init(Mifare *self, PyObject *args, PyObject *kwds);
PyObject *Mifare_select(Mifare *self);
PyObject *Mifare_read_block(Mifare *self, PyObject *args);
PyObject *Mifare_read_sign(Mifare *self);
PyObject *Mifare_write_block(Mifare *self, PyObject *args);
PyObject *MifareClassic_Authenticate(Mifare *self, PyObject *args);
PyObject *MifareClassic_read_block(Mifare *self, PyObject *args);
PyObject *Mifare_get_type(Mifare * self);
PyObject *MifareClassic_Write(Mifare *self, PyObject *args);
extern PyObject *InitError;
extern PyObject *SelectError;
extern PyObject *ReadError;
extern PyObject *WriteError;
extern PyMethodDef Mifare_methods[];
extern PyTypeObject MifareType;