mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-17 05:38:33 +03:00
add library providing ISO 7816-3 utilities
this will become part of libosmocore since it it common to smart card related projects (such as osmo-ccid-firmware) Change-Id: I3d4c65d137fc4555fcb256443feadd1c695de73d
This commit is contained in:
committed by
Harald Welte
parent
debbf3c6fa
commit
4a29f64cbe
70
firmware/libcommon/include/iso7816_3.h
Normal file
70
firmware/libcommon/include/iso7816_3.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (C) 2019 sysmocom -s.f.m.c. GmbH, Author: Kevin Redon <kredon@sysmocom.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/* this library provides utilities to handle the ISO-7816 part 3 communication aspects (e.g. related
|
||||
* to F and D) */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/*! default clock rate conversion integer Fd.
|
||||
* ISO/IEC 7816-3:2006(E) section 8.1 */
|
||||
#define ISO7816_3_DEFAULT_FD 372
|
||||
|
||||
/*! default baud rate adjustment factor Dd.
|
||||
* ISO/IEC 7816-3:2006(E) section 8.1 */
|
||||
#define ISO7816_3_DEFAULT_DD 1
|
||||
|
||||
/*! default clock rate conversion integer Fi.
|
||||
* ISO/IEC 7816-3:2006(E) section 8.3
|
||||
* \note non-default value is optionally specified in TA1 */
|
||||
#define ISO7816_3_DEFAULT_FI 372
|
||||
|
||||
/*! default baud rate adjustment factor Di.
|
||||
* ISO/IEC 7816-3:2006(E) section 8.3
|
||||
* \note non-default value is optionally specified in TA1 */
|
||||
#define ISO7816_3_DEFAULT_DI 1
|
||||
|
||||
/*! default maximum clock frequency, in Hz.
|
||||
* ISO/IEC 7816-3:2006(E) section 8.3
|
||||
* \note non-default value is optionally specified in TA1 */
|
||||
#define ISO7816_3_DEFAULT_FMAX 5000000UL
|
||||
|
||||
/*! default Waiting Integer (WI) value for T=0.
|
||||
* ISO/IEC 7816-3:2006(E) section 10.2
|
||||
* \note non-default value is optionally specified in TC2 */
|
||||
#define ISO7816_3_DEFAULT_WI 10
|
||||
|
||||
/*! default Waiting Time (WT) value, in ETU.
|
||||
* ISO/IEC 7816-3:2006(E) section 8.1
|
||||
* \note depends on Fi, Di, and WI if protocol T=0 is selected */
|
||||
#define ISO7816_3_DEFAULT_WT 9600
|
||||
|
||||
extern const uint16_t iso7816_3_fi_table[];
|
||||
|
||||
extern const uint32_t iso7816_3_fmax_table[];
|
||||
|
||||
extern const uint8_t iso7816_3_di_table[];
|
||||
|
||||
bool iso7816_3_valid_f(uint16_t f);
|
||||
|
||||
bool iso7816_3_valid_d(uint8_t d);
|
||||
|
||||
int32_t iso7816_3_calculate_wt(uint8_t wi, uint16_t fi, uint8_t di, uint16_t f, uint8_t d);
|
||||
Reference in New Issue
Block a user