Class: Tem::Key
- Inherits:
-
Object
- Object
- Tem::Key
- Defined in:
- lib/tem/keys/key.rb
Overview
Base class for the TEM keys.
This class consists of stubs describing the interface implemented by subclasses.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#ssl_key ⇒ Object
readonly
The OpenSSL key wrapped by this TEM key.
Class Method Summary collapse
-
.new_from_ssl_key(ssl_key) ⇒ Object
Creates a new TEM key wrapper from a SSL key.
Instance Method Summary collapse
- #decrypt(data) ⇒ Object
-
#encrypt(data) ⇒ Object
Encrypts a block of data into a TEM-friendly format.
-
#initialize(ssl_key) ⇒ Key
constructor
Creates a new key based on an OpenSSL key.
- #sign(data) ⇒ Object
-
#to_tem_key ⇒ Object
Serializes this key to the TEM ABI format.
- #verify(data) ⇒ Object
Constructor Details
#initialize(ssl_key) ⇒ Key
Creates a new key based on an OpenSSL key.
17 18 19 |
# File 'lib/tem/keys/key.rb', line 17 def initialize(ssl_key) @ssl_key = ssl_key end |
Instance Attribute Details
#ssl_key ⇒ Object (readonly)
The OpenSSL key wrapped by this TEM key.
14 15 16 |
# File 'lib/tem/keys/key.rb', line 14 def ssl_key @ssl_key end |
Class Method Details
.new_from_ssl_key(ssl_key) ⇒ Object
Creates a new TEM key wrapper from a SSL key
46 47 48 49 50 51 52 53 54 |
# File 'lib/tem/keys/key.rb', line 46 def self.new_from_ssl_key(ssl_key) if ssl_key.kind_of? OpenSSL::PKey::PKey Tem::Keys::Asymmetric.new ssl_key elsif ssl_key.kind_of? OpenSSL::Cipher or ssl_key.kind_of? String Tem::Keys::Symmetric.new ssl_key else raise "Can't handle keys of class #{ssl_key.class}" end end |
Instance Method Details
#decrypt(data) ⇒ Object
33 34 35 |
# File 'lib/tem/keys/key.rb', line 33 def decrypt(data) raise "TEM Key class #{self.class.name} didn't implement decrypt" end |
#encrypt(data) ⇒ Object
Encrypts a block of data into a TEM-friendly format.
29 30 31 |
# File 'lib/tem/keys/key.rb', line 29 def encrypt(data) raise "TEM Key class #{self.class.name} didn't implement encrypt" end |
#sign(data) ⇒ Object
37 38 39 |
# File 'lib/tem/keys/key.rb', line 37 def sign(data) raise "TEM Key class #{self.class.name} didn't implement sign" end |
#to_tem_key ⇒ Object
Serializes this key to the TEM ABI format.
24 25 26 |
# File 'lib/tem/keys/key.rb', line 24 def to_tem_key Tem::Abi.to_tem_key self end |
#verify(data) ⇒ Object
41 42 43 |
# File 'lib/tem/keys/key.rb', line 41 def verify(data) raise "TEM Key class #{self.class.name} didn't implement verify" end |