Class: Sandal::Enc::Alg::Direct
- Inherits:
-
Object
- Object
- Sandal::Enc::Alg::Direct
- Defined in:
- lib/sandal/enc/alg/direct.rb
Overview
The direct (“dir”) key encryption mechanism, which uses a pre-shared content master key.
Instance Attribute Summary collapse
-
#cmk ⇒ String
readonly
The pre-shared content master key key.
-
#name ⇒ String
readonly
The JWA name of the algorithm.
Instance Method Summary collapse
-
#decrypt_cmk(encrypted_cmk) ⇒ String
Returns the pre-shared content master key.
-
#encrypt_cmk(cmk) ⇒ String
Returns an empty string as the content master key is not included in the JWE token.
-
#initialize(cmk) ⇒ Direct
constructor
Creates a new instance.
Constructor Details
#initialize(cmk) ⇒ Direct
Creates a new instance.
20 21 22 23 |
# File 'lib/sandal/enc/alg/direct.rb', line 20 def initialize(cmk) @name = 'dir' @cmk = cmk end |
Instance Attribute Details
#cmk ⇒ String (readonly)
15 16 17 |
# File 'lib/sandal/enc/alg/direct.rb', line 15 def cmk @cmk end |
#name ⇒ String (readonly)
12 13 14 |
# File 'lib/sandal/enc/alg/direct.rb', line 12 def name @name end |
Instance Method Details
#decrypt_cmk(encrypted_cmk) ⇒ String
Returns the pre-shared content master key.
39 40 41 42 43 44 |
# File 'lib/sandal/enc/alg/direct.rb', line 39 def decrypt_cmk(encrypted_cmk) unless encrypted_cmk.nil? || encrypted_cmk.empty? raise Sandal::TokenError, 'Token must not include encrypted CMK.' end @cmk end |
#encrypt_cmk(cmk) ⇒ String
Returns an empty string as the content master key is not included in the JWE token.
30 31 32 |
# File 'lib/sandal/enc/alg/direct.rb', line 30 def encrypt_cmk(cmk) '' end |