Module iso7816

Utilities for parsing and generating ISO7816 APDUs.

Behaviours: pcsc_apdu_transform.

Description

Utilities for parsing and generating ISO7816 APDUs. Also a pcsc_apdu_transform implementation which does the same.

Data Types

apdu_cmd()

apdu_cmd() = #apdu_cmd{proto = default | pcsc:protocol(), cla = iso7816:cls(), ins = iso7816:ins(), p1 = iso7816:p1(), p2 = iso7816:p2(), data = none | binary(), le = none | iso7816:le()}

The type of a standard APDU command. See ISO7816 for the definitions of these fields.

apdu_reply()

apdu_reply() = #apdu_reply{proto = pcsc:protocol(), sw = iso7816:sw(), data = none | binary()}

The type of a reply to an APDU command.

atr_info()

atr_info() = #{t0 => #{wi => integer()}, t1 => #{ifsc => integer(), cwi => integer(), bwi => integer(), checksum => lrc | crc}, status => {iso_sw(), LCS::integer()}, fi => integer(), fmax => integer(), di => integer(), guardn => integer(), historical_bytes => {proprietary, binary()} | standard, country_code => binary(), issuer => binary(), aid => binary(), initial_data_cmd => apdu_cmd(), initial_data => binary(), service_data => binary(), isseru_data => binary(), preissuing_data => binary(), df_selection => [full_name | part_name | path | file_id], implicit_df => boolean(), short_ef => boolean(), record_num => boolean(), record_id => boolean(), ef_ber_tlv => boolean(), write_functions => one_time | proprietary | write_or | write_and, long_private_tags => boolean(), data_unit_size => integer(), chain_support => boolean(), extended_length => boolean(), extended_length_atr => boolean(), logical_chan_assign => [card | host], logical_chans => integer(), application_family => binary(), leftovers => binary()}

Information decoded from an ATR value.

ber_tlv_tag()

ber_tlv_tag() = {Tag::integer(), Data::binary() | [ber_tlv_tag()]}

channel()

channel() = integer()

cls()

cls() = iso | {iso, chain} | {iso, channel()} | {iso, chain, channel()} | integer()

The ISO7816 "class" field for a command APDU.

ins()

ins() = iso_ins() | integer()

The ISO7816 "instruction" field for a command APDU.

iso_error_ch()

iso_error_ch() = changed | memory_failure | {changed, integer()}

iso_error_cla()

iso_error_cla() = no_info | bad_chain | not_supported | {not_supported, channel | secure_msg | chain}

iso_error_cmd()

iso_error_cmd() = no_info | incompat_file | security_status | auth_method | conditions | no_ef | requires_secure_msg | bad_secure_msg | integer()

iso_error_format()

iso_error_format() = length | apdu | lc | lc_tlv_mismatch

iso_error_sec()

iso_error_sec() = integer()

iso_error_unch()

iso_error_unch() = unchanged | immediate_response | channel_share_denied | channel_denied | {unchanged, integer()}

iso_ins()

iso_ins() = change_ref_data | external_auth | general_auth | generate_asym_key | get_response | get_data | put_data | select | verify | reset_retry_counter

iso_sw()

iso_sw() = ok | {continue, integer()} | {requires_le, integer()} | {counter, integer()} | {warning, iso_warning_unch()} | {warning, iso_warning_ch()} | {error, {system, iso_error_unch()}} | {error, {system, iso_error_ch()}} | {error, {security, iso_error_sec()}} | {error, {denied, iso_error_cmd()}} | {error, {format, iso_error_format()}} | {error, {cla, iso_error_cla()}} | {error, {ins, not_supported}} | {error, {file, not_found}} | {error, {file, invalid}} | {error, {file, out_of_memory}} | {error, {file, exists}} | {error, {record, not_found}} | {error, {ref_data, not_found | unusable}} | {error, data_required} | {error, func_not_supported} | {error, p1p2} | {error, wrong_data} | {error, general_failure} | {error, integer()}

iso_warning_ch()

iso_warning_ch() = changed | bad_compare | file_full | {changed, integer()}

iso_warning_unch()

iso_warning_unch() = unchanged | part_corrupted | eof | deactivated | bad_format | terminated | no_input | {unchanged, integer()}

le()

le() = none | integer()

Expected length of reply field (optional).

p1()

p1() = integer()

First parameter byte in a command APDU.

p2()

p2() = integer()

Second parameter byte in a command APDU.

sw()

sw() = iso_sw() | integer()

Status word in a reply APDU.

Function Index

decode_apdu_cmd/1
decode_apdu_reply/1
decode_atr/1Decodes an ATR into the different encoded fields and information.
decode_ber_tlv/1
decode_ber_tlvs/1
encode_apdu_cmd/1
encode_apdu_reply/1
encode_ber_tlv/2
encode_ber_tlvs/1

Function Details

decode_apdu_cmd/1

decode_apdu_cmd(X1::binary()) -> apdu_cmd()

decode_apdu_reply/1

decode_apdu_reply(Bin::binary()) -> apdu_reply()

decode_atr/1

decode_atr(X1::binary()) -> atr_info()

Decodes an ATR into the different encoded fields and information.

decode_ber_tlv/1

decode_ber_tlv(X1::binary()) -> {ok, integer(), binary(), binary()} | {error, term()}

decode_ber_tlvs/1

decode_ber_tlvs(Bin::binary()) -> {ok, [ber_tlv_tag()]} | {error, term()}

encode_apdu_cmd/1

encode_apdu_cmd(Apdu_cmd::apdu_cmd()) -> binary()

encode_apdu_reply/1

encode_apdu_reply(Apdu_reply::apdu_reply()) -> binary()

encode_ber_tlv/2

encode_ber_tlv(Tag::integer(), Data::binary()) -> binary()

encode_ber_tlvs/1

encode_ber_tlvs(Tlvs::[ber_tlv_tag()]) -> binary()


Generated by EDoc