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.
19 20 21 22 |
# File 'lib/sandal/enc/alg/direct.rb', line 19 def initialize(cmk) @name = 'dir' @cmk = cmk end |
Instance Attribute Details
#cmk ⇒ String (readonly)
Returns The pre-shared content master key key.
14 15 16 |
# File 'lib/sandal/enc/alg/direct.rb', line 14 def cmk @cmk end |
#name ⇒ String (readonly)
Returns The JWA name of the algorithm.
11 12 13 |
# File 'lib/sandal/enc/alg/direct.rb', line 11 def name @name end |
Instance Method Details
#decrypt_cmk(encrypted_cmk) ⇒ String
Returns the pre-shared content master key.
37 38 39 40 41 42 |
# File 'lib/sandal/enc/alg/direct.rb', line 37 def decrypt_cmk(encrypted_cmk) unless encrypted_cmk.nil? || encrypted_cmk.empty? raise Sandal::TokenError, 'The token should not include an encrypted content master key.' end @cmk end |
#encrypt_cmk(cmk) ⇒ String
Returns an empty string as the content master key is not included in the JWE token.
28 29 30 |
# File 'lib/sandal/enc/alg/direct.rb', line 28 def encrypt_cmk(cmk) '' end |