Git Product home page Git Product logo

iso7816-tlv's Introduction

iso7816-tlv

Tools and utilities for handling TLV data as defined in ISO7816-4.

This include BER-TLV data or SIMPLE-TLV data objects.

Features

Currently only generating and parsing BER-TLV or SIMPLE-TLV data.

More features or functions may be added depending of needs.

There is currently no real plan for needed/required features to add.

Improvements

Feel free to open issues for anything, including

  • API changes
  • remarks about code style (as i'm quite new to rust)
  • feature requests

iso7816-tlv's People

Contributors

jkowalsk avatar eliasholzmann avatar

Stargazers

 avatar  avatar ૮༼⚆︿⚆༽つ avatar

Watchers

James Cloos avatar  avatar

iso7816-tlv's Issues

Better iterator APIs

Would be nice to iterate over a Vec<u8> or array and return a vector of TLV objects (at least for Simple-TLV case.

TLV Tag 9F1E rejected

In tag.rs, impl TryFrom for Tag, fn try_from(v: u64):

//Line 273:
if len > 1 {
match bytes[3 - len] {
0x00 | 0x1E | 0x80 => return Err(TlvError::InvalidInput),
_ => (),
}
}

The 0x1E matches and rejects a valid TLV tag 9F1E which is the Interface Device Serial number on EMV cards: https://emvlab.org/emvtags/show/t9F1E/

Thanks,

Allan

getter methods for Tlv?

Hi,
for my smart card driver I'm currently testing Your iso7816-tlv code, referring to pub mod simple;

My task is to parse something like this (hex values): [84, 1, 2C, 97, 0, 84, 1, 24, 9E, 1, 42], which is a sequence of simple-tlv.
There is a small, known set of valid 1-byte tags: 0x8?, 0x97, 0x9E and a few more; L is 1 byte as well, <255.
Depending on the tag value, different processing is involved: First is splitting by 0x8? tags, i.e.
in the simple case shown here, 2 simple-tlv form a "group of information", stored as a struct and pushed to a Vec, thus vector's len() will be 2 here.

The point (UpdateEdit) issue with Your code is: There is no public access to the Tlv struct members tag: Tag, value: Value, thus I introduced getter methods. Perhaps You may find that useful as well, or am I mistaken (I'm quite new to Rust):

$ diff -u3 ../iso7816-tlv-master/src/simple.rs iso7816-tlv/src/simple.rs
--- ../iso7816-tlv-master/src/simple.rs 2019-09-30 13:02:57.000000000 +0200
+++ iso7816-tlv/src/simple.rs   2019-10-30 13:22:09.343488554 +0100
@@ -87,6 +87,21 @@
     }
   }
 
+  /// Returns tag number of TLV
+  pub fn tag(&self) -> u8 {
+    self.tag.0
+  }
+
+  /// Returns length of TLV
+  pub fn length(&self) -> usize {
+    self.value.0.len()
+  }
+
+  /// Returns value of TLV
+  pub fn value(&self) -> &[u8] {
+    self.value.0.as_slice()
+  }
+
   /// serializes self into a byte vector.
   #[allow(clippy::cast_possible_truncation)]
   pub fn to_vec(&self) -> Vec<u8> {
$

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.