Class: Themis::Scell

Inherits:
Object
  • Object
show all
Includes:
ThemisCommon, ThemisImport
Defined in:
lib/rbthemis.rb

Overview

Scell base class is retained for compatibility. New code should use ScellSeal, ScellTokenProtect, or ScellContextImprint.

Direct Known Subclasses

ScellContextImprint, ScellSeal, ScellTokenProtect

Constant Summary collapse

SEAL_MODE =
0
TOKEN_PROTECT_MODE =
1
CONTEXT_IMPRINT_MODE =
2

Constants included from ThemisImport

ThemisImport::THEMIS_KEY_EC_PRIVATE, ThemisImport::THEMIS_KEY_EC_PUBLIC, ThemisImport::THEMIS_KEY_INVALID, ThemisImport::THEMIS_KEY_RSA_PRIVATE, ThemisImport::THEMIS_KEY_RSA_PUBLIC

Instance Method Summary collapse

Methods included from ThemisImport

canonical_themis_paths, load_themis

Methods included from ThemisCommon

empty?, string_to_pointer_size

Constructor Details

#initialize(key, mode) ⇒ Scell

Returns a new instance of Scell.



573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
# File 'lib/rbthemis.rb', line 573

def initialize(key, mode)
  # We could have replaced this with "self.new" but it's not possible
  # to override new *and* keep Scell as superclass of ScellSeal et al.
  # So we keep an instance of appropriate class here and never call
  # superclass initialize in subclasses.
  case mode
  when SEAL_MODE
    @cell = ScellSeal.new(key)
  when TOKEN_PROTECT_MODE
    @cell = ScellTokenProtect.new(key)
  when CONTEXT_IMPRINT_MODE
    @cell = ScellContextImprint.new(key)
  else
    raise ThemisError, "unknown Secure Cell mode: #{mode}"
  end
  warn "NOTE: #{self.class.name} is deprecated; use #{@cell.class.name} instead."
end

Instance Method Details

#decrypt(message, context = nil) ⇒ Object



595
596
597
# File 'lib/rbthemis.rb', line 595

def decrypt(message, context = nil)
  @cell.decrypt(message, context)
end

#encrypt(message, context = nil) ⇒ Object



591
592
593
# File 'lib/rbthemis.rb', line 591

def encrypt(message, context = nil)
  @cell.encrypt(message, context)
end