MChip Select 4 tag values (9F7E and D5) - emv

I'm working on a profile for MasterCard EMV cards on M/Chip Select 4 version 1.1b and I need some help understanding the data elements for the 9F7E (Application Life Cycle Data) tag value and D5 (Application Control) tag value. Unfortunately, the MasterCard SSF form doesn't explain information. From our card vendor we found a document in which we found application Id number is it similar to ALCD(9F7E)? And how could could I found D5 value

9F7E is a 48 bytes long field organized into two 4 parts.
2 bytes - version number - for your case 03
7 bytes - type approval id - which is provided by MasterCard while
certifying applet.
20 bytes - Contents are issuer specific denoting application identification.
20 bytes application code identification
For options available on D5, download MChip 4 Version 1.1 Issuer Guide to Debit and Credit Parameter Management.pdf from MasterCard Connect. It has bit by bit information.

You can find this informations in:
M/Chip 4 Version 1.1 Issuer Guide to Debit and Credit Parameter Management
There, you will see next (tag D5 value related):
The Application Control activates or de-activates functions in the application.
The coding of the Application Control data element varies depending on the
version of M/Chip 4, and on whether the Lite or Select application is being
used.
You are using M/Chip Select 4 version 1.1b, so, there it is:
And, if you have M/Chip Lite 4 version 1.1b, first byte will be like:
Second byte value is same for both:
Hope this can help you.

Related

Nand2Tetris-Obtaining Register from RAM chips

I've recently completed Chapter 3 of the associated textbook for this course: The Elements of Computing, Second Edition.
While I was able to implement all of the chips described in this chapter, I am still trying to wrap my head around how exactly the RAM chips work. I think I understand them in theory (e.g. a Ram4K chip stores a set of 8 RAM512 chips, which itself is a set of 8 RAM64 chips).
What I am unsure about is actually using the chips. For example, suppose I try to output a single register from RAM16K using this code, given an address:
CHIP RAM16K {
IN in[16], load, address[14];
OUT out[16];
PARTS:
Mux4Way16(a=firstRam, b=secondRam, c=thirdRam, d=fourthRam, sel=address[12..13], out=out);
And(a=load, b=load, out=shouldLoad);
DMux4Way(in=shouldLoad, sel=address[12..13], a=setRamOne, b=setRamTwo, c=setRamThree, d=setRamFour);
RAM4K(in=in, load=setRamOne, address=address[0..11], out=firstRam);
RAM4K(in=in, load=setRamTwo, address=address[0..11], out=secondRam);
RAM4K(in=in, load=setRamThree, address=address[0..11], out=thirdRam);
RAM4K(in=in, load=setRamFour, address=address[0..11], out=fourthRam);
}
How does the above code get the underlying register? If I understand the description of the chip correctly, it is supposed to return a single register. I can see that it outputs a RAM4K based on a series of address bits -- does it also get the base register itself recursively through the chips at the bottom? Why doesn't this code have an error if it's outputting a RAM4K when we expect a register?
It's been a while since I did the course so please excuse any minor errors below.
Each RAM chip (whatever the size) consists of an array of smaller chips. If you are implementing a 16K chip with 4K subchips, then there will be 4 of them.
So you would use 2 bits of the incoming address to select what sub-chip you need to work with, and the remaining 12 bits are sent on to all the sub-chip. It doesn't matter how you divide up the bits, as long as you have a set of 2 and a set of 12.
Specifically, the 2 select bits are used to route the load signal to just one sub-chip (ie: using a DMux4Way), so loads only affect that one sub-chip, and they are also used to pick which of the sub-chips outputs are used (ie: a Mux4Way16).
When I was doing it, I found that the simplest way to do things was always use the least-significant bits as the select bits. So for example, my RAM64 chip used address[0..2] as the select bits, and passed address[3..5] to the RAM8 sub-chips.
The thing that may be confusing you is that in these kinds of circuits, all of the sub-chips are activated. It's just that you use the select bits to decide which sub-chip's output to pass on to the outputs, and also as a filter to decide which sub-chip might perform a load.
As the saying goes, "It's turtles (or ram chips) all the way down."

Determine Issuer of EMV card

What would be the best way to determine the issuer of a contactless EMV card. I am trying to determine if a card was issued by Amex, Visa or Mastercard. Is that information available via a USB EMV reader? I don't need to pull any other information from the card..
I'm assuming that it could be done by some python, or C++ code interacting with the card. I'm looking for a good jumping off point.
You should be able to get this info from the successful response of SELECT. Store the list of RIDs ( AID = RID + PIX ), and do SELECT one by one. On success, it will return status bytes 90 00, otherwise 6A 82( file not found ).
The easiest option would be through SELECT command as mentioned
before. The list of AID:
https://www.eftlab.com/knowledge-base/211-emv-aid-rid-pix/
The other option would be getting it from the PAN. You can define issuer
based on first 6 digits or 8 digits of the PAN, which represents Issuer
Identification Number (IIN)/Bank Identification Number(BIN).
34, 37 - American Express
4 - Visa
51-55, 2221-2720 - MasterCard
https://en.wikipedia.org/wiki/Payment_card_number#Issuer_identification_number_(IIN)
You would have to send commands:
SELECT
GET PROCESSING OPTIONS
READ RECORD
You would look for 5A - PAN and extract first digits.
Good tool that you can just use to read data from contactless EMV card is:
https://www.javacardos.com/tools/pyresman
You can create your own scripts or just proceed with some basic commands like a SELECT command.

bitwise comparison of large numbers

Researching the possibility of using bitwise comparison to assess what options have been selected out a possible 100 options.
now as an integer the selection of all options would require storage of an integer of 2 to the power of 99 (6E29). way beyond the limit of circa 9E18.
just as with dir permissions ( 1 = read, 2= write, 4 = execute) 1+2+4 = 7 = full access.
I would like to know which of the 100 options have been chosen by the same method.
Any advice/tips much appreciated.
NB storage will be mysql
-- EDIT --
The end goal here is to simplify a check as to what currencies a user can be paid in.
assigning values to currency like so:
Currency OptVal
GBP 1
USD 2
EUR 4
AUD 8
CAD 16
ZAR 32
and so on (there are many many currencies and more will arise through crypto currencies I'm sure)
it would then be convenient to check which currencies a user has using bitwise operators...
so if a user had currency setting of 3 only GBP and USD.
5 GBP & EUR
63 GBP,USD,EUR,AUD,CAD,ZAR
and so on - hope this clarifies the goal.
The issue is to do this in its most simplistic form of storing that integer when you have > 100 currencies. you need a value 2E(n-1) for each option and for large n this number is very large and not storable as an integer (BIGINT Max value is 18446744073709551615)
You want advice. Don't do it this way.
MySQL offers the boolean data type, which is convenient for flags. Each value does occupy one byte, so the storage will be larger than using bits.
MySQL also offers the bit() data type, where you can put together up to 64 bits. You can read about them here.
Using built-in data types is simply the right way to go. They protect your from changes of server, from upgrades on the OS, and the possibility that your application and server have different endian-ness (if you don't know what this is, then you definitely should not be thinking about bit fiddling).
The good news is that there are data types for what you want to do.

Only one node owns data in a Cassandra cluster

I am new to Cassandra and just run a cassandra cluster (version 1.2.8) with 5 nodes, and I have created several keyspaces and tables on there. However, I found all data are stored in one node (in the below output, I have replaced ip addresses by node numbers manually):
Datacenter: 105
==========
Address Rack Status State Load Owns Token
4
node-1 155 Up Normal 249.89 KB 100.00% 0
node-2 155 Up Normal 265.39 KB 0.00% 1
node-3 155 Up Normal 262.31 KB 0.00% 2
node-4 155 Up Normal 98.35 KB 0.00% 3
node-5 155 Up Normal 113.58 KB 0.00% 4
and in their cassandra.yaml files, I use all default settings except cluster_name, initial_token, endpoint_snitch, listen_address, rpc_address, seeds, and internode_compression. Below I list those non-ip address fields I modified:
endpoint_snitch: RackInferringSnitch
rpc_address: 0.0.0.0
seed_provider:
- class_name: org.apache.cassandra.locator.SimpleSeedProvider
parameters:
- seeds: "node-1, node-2"
internode_compression: none
and all nodes using the same seeds.
Can I know where I might do wrong in the config? And please feel free to let me know if any additional information is needed to figure out the problem.
Thank you!
If you are starting with Cassandra 1.2.8 you should try using the vnodes feature. Instead of setting the initial_token, uncomment # num_tokens: 256 in the cassandra.yaml, and leave initial_token blank, or comment it out. Then you don't have to calculate token positions. Each node will randomly assign itself 256 tokens, and your cluster will be mostly balanced (within a few %). Using vnodes will also mean that you don't have to "rebalance" you cluster every time you add or remove nodes.
See this blog post for a full description of vnodes and how they work:
http://www.datastax.com/dev/blog/virtual-nodes-in-cassandra-1-2
Your token assignment is the problem here. An assigned token are used determines the node's position in the ring and the range of data it stores. When you generate tokens the aim is to use up the entire range from 0 to (2^127 - 1). Tokens aren't id's like with mysql cluster where you have to increment them sequentially.
There is a tool on git that can help you calculate the tokens based on the size of your cluster.
Read this article to gain a deeper understanding of the tokens. And if you want to understand the meaning of the numbers that are generated check this article out.
You should provide a replication_factor when creating a keyspace:
CREATE KEYSPACE demodb
WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor': 3};
If you use DESCRIBE KEYSPACE x in cqlsh you'll see what replication_factor is currently set for your keyspace (I assume the answer is 1).
More details here

How to read this barcode?

How to find out which type of barcode is this in my sample ? I looked on wikipedia and there are quite many types of barcodes, most common should be Code 39 and Code 128.
Is there any lib for barcode OCR (python, java, C#, delphi) ?
On this barcode should be encoded time and date of expiration.
EDIT
I need to know how to read and decode above barcode. This barcodes were generated in legacy system and It would be nice if my app could OCR and understand them
On my barcode should be date 19.11.2010 15:43
According to this online bar code reader, it an EAN_13 code for a product with the number 5252235562500.
According to Wikipedia it's a product number for a discount coupon with manufacturer code 25223, family code 556 and coupon code 25.
If there is an expiration date encoded in the data, it's in some custom format encoded into the family code and coupon code. Otherwise you need a loopup table from the manufacturer to determine which coupon has which expiration date.
How about, http://code.google.com/p/zxing/.
There's an excellent barcode reading library named Zebra crossing (zxing) available in Java with ports/wrappers to C#, C++, Ruby, etc.
This particular one is indeed EAN-13 code, which encodes 13 decimal digits [0-9] (2..3 country digits + 9..10 product digits + 1 checksum digit).
The Wikipedia article referenced above seems to only refers to "coupon codes" only for UPC12 barcodes which are slightly different from EAN13 barcodes.
According to the offical GS1 site http://gepir.gs1.org/v31/xx/gtin.aspx?Lang=en-US this barcode is not defined as belonging to anyone (or country) so it is probably used internally by some organization for a custom application.
The GS1 site lot of information on barcode standards and formats.