Class: Tem::Session

Inherits:
Object
  • Object
show all
Includes:
Abi, Admin::Emit, Admin::Migrate, Apdus::Buffers, Apdus::Keys, Apdus::Lifecycle, Apdus::Tag, CA, ECert, SeClosures, Toolkit
Defined in:
lib/tem/tem.rb

Constant Summary collapse

CAPPLET_AID =
[0x19, 0x83, 0x12, 0x29, 0x10, 0xBA, 0xBE]

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Toolkit

#tk_gen_key, #tk_post_key, #tk_read_key

Methods included from SeClosures

#execute, included, #sec_trace, #solve_psfault

Methods included from Tem::SeClosures::MixedMethods

#assemble

Methods included from ECert

ecert_tag, ecert_tag_key, #endorsement_cert, #manufacturer_cert, #pubek

Methods included from CA

ca_cert, ca_key, config, new_ecert, scaffold_ca, scaffold_config

Methods included from Admin::Migrate

blank_ecert_verify_seclosure, blank_migrate_seclosure, blank_skey_load_seclosure, ecert_verify_bytes_tag_key, ecert_verify_seclosure, #migrate, migrate_bytes_tag_key, migrate_seclosure, seclosures_from_tag_data, skey_load_seclosure, skey_load_tag_key, tag_data

Methods included from Admin::Emit

emit, #emit, emit_keygen, emit_keygen_seclosure

Methods included from Apdus::Tag

decode_tag, encode_tag, #get_raw_tag_data, #get_raw_tag_length, #set_raw_tag_data, #set_tag, #tag

Methods included from Apdus::Lifecycle

#activate, #fw_version, #kill

Methods included from Apdus::Keys

#devchip_decrypt, #devchip_encrypt, #devchip_encrypt_decrypt, #devchip_generate_key_pair, #devchip_save_key, #release_key, #stat_keys

Methods included from Apdus::Buffers

#alloc_buffer, #flush_buffers, #get_buffer_length, #guess_buffer_chunk_size, #guess_buffer_chunk_size!, #post_buffer, #read_buffer, #release_buffer, #stat_buffers, #write_buffer

Methods included from Abi

included

Constructor Details

#initialize(transport) ⇒ Session

Returns a new instance of Session.



29
30
31
32
33
34
35
# File 'lib/tem/tem.rb', line 29

def initialize(transport)
  @transport = transport
  @transport.extend Smartcard::Gp::GpCardMixin
  @transport.select_application CAPPLET_AID
  
  @icache = {}
end

Instance Attribute Details

#icacheObject (readonly)

The TEM instance cache.

This cache stores information about the TEM connected to this session. The cache can be safely cleared without losing correctness.

The cache should not be modified directly by client code.



27
28
29
# File 'lib/tem/tem.rb', line 27

def icache
  @icache
end

#transportObject (readonly)

The transport used for this TEM.



19
20
21
# File 'lib/tem/tem.rb', line 19

def transport
  @transport
end

Instance Method Details

#clear_icacheObject

Clears the TEM instance cache.

This should be called when connecting to a different TEM.



47
48
49
# File 'lib/tem/tem.rb', line 47

def clear_icache
  @icache.clear
end

#disconnectObject



37
38
39
40
41
42
# File 'lib/tem/tem.rb', line 37

def disconnect
  return unless @transport
  @transport.disconnect
  @transport = nil
  clear_icache
end

#tem_secpack_error(response) ⇒ Object



51
52
53
# File 'lib/tem/tem.rb', line 51

def tem_secpack_error(response)
  raise "TEM refused the SECpack"
end