In Files

Parent

Files

CTAPI::Card

Attributes

atr[RW]

The answer to reset (ATR) of the inserted chipcard.

Public Class Methods

new(atr) click to toggle source

(Not documented)

# File lib/ctapi.rb, line 455
    def initialize(atr)
      @atr = atr
    end

Public Instance Methods

atr_ok?() click to toggle source

Check if the ATR is correct. If false, the data of this Card object could be wrong and the calculations based on this data wrong.

# File lib/ctapi.rb, line 464
    def atr_ok?
      @atr[4, 2] == "\x90\x00" && @atr[2] == 0x10
    end
inspect() click to toggle source

Returns adescription of this card including the ATR as a string.

# File lib/ctapi.rb, line 518
    def inspect
      string = to_s
      string[-1] = " #{atr}>"
      string
    end
memory_bits() click to toggle source

The bit width of this chipcard.

# File lib/ctapi.rb, line 469
    def memory_bits
      1 << (@atr[1] & 0x07)
    end
memory_blocks() click to toggle source

Number of memory blocks on this chipcard.

# File lib/ctapi.rb, line 474
    def memory_blocks
      1 << (((@atr[1] & 0x78) >> 3) + 6)
    end
memory_size() click to toggle source

Computes the memory size of the inserted chipcard in bytes.

# File lib/ctapi.rb, line 479
    def memory_size
      (memory_blocks * memory_bits >> 3)
    end
protocol() click to toggle source

Supported protocol of this chipcard.

# File lib/ctapi.rb, line 497
    def protocol
      if (@atr[0] & 0x80) == 0x00
        'ISO'
      elsif (@atr[0] & 0xf0) == 0x80
        'I2C'
      elsif (@atr[0] & 0xf0) == 0x90
        '3W'
      elsif (@atr[0] & 0xf0) == 0xa0
        '2W'
      else
        'unknown'
      end
    end
structure() click to toggle source

The structure of this chipcard.

# File lib/ctapi.rb, line 484
    def structure
      if (@atr[0] & 0x3) == 0
        'ISO'
      elsif (@atr[0] & 0x7) == 2
        'common use'
      elsif (@atr[0] & 0x7) == 6
        'proprietary use'
      else
        'special use'
      end
    end
to_s() click to toggle source

Returns a short description of this card as a string.

# File lib/ctapi.rb, line 512
    def to_s
      "<#{self.class}:Structure #{structure} Protocol #{protocol} "  +
      "(#{memory_blocks}x#{memory_bits}=#{memory_size}B)" + '>'
    end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.