libsle4442  0.2-5
sle.h
Go to the documentation of this file.
1 /* This file is part of libsle4442.
2  * Copyright (C) 2010, 2011 Enrico Rossi
3  *
4  * Libsle4442 is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as
6  * published by the Free Software Foundation, either version 3 of the
7  * License, or (at your option) any later version.
8  *
9  * Libsle4442 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 Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this program.
16  * If not, see <http://www.gnu.org/licenses/>.
17  */
18 
26 #ifndef SLE_H_
27 #define SLE_H_
28 
29 #ifdef MAKE_LIB
30 
31 /* Include the low level interface only if the library
32  * needs to be compiled.
33  */
34 #include "sle_bbg.h"
35 
47 #define SLE_CMD_DUMP_MEMORY 0x30
48 #define SLE_CMD_DUMP_SECMEM 0x31
49 #define SLE_CMD_DUMP_PRT_MEMORY 0x34
50 #define SLE_CMD_COMPARE_VERIFICATION_DATA 0x33
51 #define SLE_CMD_UPDATE_SECMEM 0x39
52 #define SLE_CMD_UPDATE_MEMORY 0x38
53 
54 #endif /* Make lib */
55 
56 /* Uncomment to enable internal pullup resistor,
57  it will drain a lot of power in sleep modes */
58 #define SLE_MICRO_PULLUP
59 
92 struct sle_t {
93  uint8_t *atr;
94  uint8_t *main_memory;
95  uint8_t *protected_memory;
96  uint8_t *security_memory;
97  uint8_t *ck_proc;
98  uint8_t card_present;
99  uint8_t auth;
100 };
101 
102 void sle_enable_port(void);
103 void sle_disable_port(void);
104 struct sle_t* sle_init(void);
105 void sle_free(struct sle_t *sle);
106 void sle_reset(uint8_t *atr);
107 uint8_t sle_present(struct sle_t *sle);
108 void sle_dump_memory(uint8_t *mm);
109 void sle_dump_prt_memory(uint8_t *mm);
110 void sle_dump_secmem(uint8_t *mm);
111 void sle_dump_allmem(struct sle_t *sle);
112 void sle_auth(struct sle_t *sle, const uint8_t pin1, const uint8_t pin2, const uint8_t pin3);
113 void sle_write_memory(struct sle_t *sle, const uint8_t addr, const uint8_t len);
114 void sle_write_secmem(struct sle_t *sle);
115 
116 #endif
void sle_reset(uint8_t *atr)
reset the card.
Definition: sle.c:116
Bit banging driver to SLE4442.
void sle_write_memory(struct sle_t *sle, const uint8_t addr, const uint8_t len)
Definition: sle.c:262
uint8_t * protected_memory
ptr to a 32 bytes copy of the SLE 4442 memory.
Definition: sle.h:95
uint8_t * atr
ptr to a 4 bytes ATR header returned by the ATZ command.
Definition: sle.h:93
void sle_dump_prt_memory(uint8_t *mm)
Definition: sle.c:165
void sle_free(struct sle_t *sle)
Definition: sle.c:100
uint8_t * main_memory
ptr to a 256 bytes copy of the SLE 4442 memory.
Definition: sle.h:94
void sle_write_secmem(struct sle_t *sle)
Definition: sle.c:284
uint8_t * security_memory
4 bytes
Definition: sle.h:96
uint8_t * ck_proc
processing clock counts
Definition: sle.h:97
void sle_dump_memory(uint8_t *mm)
Definition: sle.c:147
void sle_disable_port(void)
Definition: sle.c:63
void sle_auth(struct sle_t *sle, const uint8_t pin1, const uint8_t pin2, const uint8_t pin3)
Definition: sle.c:218
uint8_t sle_present(struct sle_t *sle)
Definition: sle.c:129
struct sle_t * sle_init(void)
Definition: sle.c:75
The main struct which represent the status of the card.
Definition: sle.h:92
void sle_dump_secmem(uint8_t *mm)
Definition: sle.c:183
void sle_enable_port(void)
Definition: sle.c:46
uint8_t auth
card auth 1 - ok, 0 - writing forbidden
Definition: sle.h:99
void sle_dump_allmem(struct sle_t *sle)
Definition: sle.c:201
uint8_t card_present
card present 0=no; 1=yes
Definition: sle.h:98