Class: JOSE::JWE::ALG_dir
- Inherits:
-
Struct
- Object
- Struct
- JOSE::JWE::ALG_dir
- Defined in:
- lib/jose/jwe/alg_dir.rb
Instance Attribute Summary collapse
-
#direct ⇒ Object
Returns the value of attribute direct.
Class Method Summary collapse
-
.from_map(fields) ⇒ Object
JOSE::JWE callbacks.
Instance Method Summary collapse
-
#generate_key(fields, enc) ⇒ Object
JOSE::JWE::ALG callbacks.
- #key_decrypt(key, enc, encrypted_key) ⇒ Object
- #key_encrypt(key, enc, decrypted_key) ⇒ Object
- #next_cek(key, enc) ⇒ Object
- #to_map(fields) ⇒ Object
Instance Attribute Details
#direct ⇒ Object
Returns the value of attribute direct
1 2 3 |
# File 'lib/jose/jwe/alg_dir.rb', line 1 def direct @direct end |
Class Method Details
.from_map(fields) ⇒ Object
JOSE::JWE callbacks
5 6 7 8 9 10 11 12 |
# File 'lib/jose/jwe/alg_dir.rb', line 5 def self.from_map(fields) case fields['alg'] when 'dir' return new(true), fields.delete('alg') else raise ArgumentError, "invalid 'alg' for JWE: #{fields['alg'].inspect}" end end |
Instance Method Details
#generate_key(fields, enc) ⇒ Object
JOSE::JWE::ALG callbacks
20 21 22 |
# File 'lib/jose/jwe/alg_dir.rb', line 20 def generate_key(fields, enc) return JOSE::JWE::ALG.generate_key([:oct, enc.bits.div(8)], 'dir', enc.algorithm) end |
#key_decrypt(key, enc, encrypted_key) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/jose/jwe/alg_dir.rb', line 24 def key_decrypt(key, enc, encrypted_key) if key.is_a?(String) return key else return key.kty.derive_key end end |
#key_encrypt(key, enc, decrypted_key) ⇒ Object
32 33 34 |
# File 'lib/jose/jwe/alg_dir.rb', line 32 def key_encrypt(key, enc, decrypted_key) return '', self end |
#next_cek(key, enc) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/jose/jwe/alg_dir.rb', line 36 def next_cek(key, enc) if key.is_a?(String) return key, self else return key.kty.derive_key, self end end |
#to_map(fields) ⇒ Object
14 15 16 |
# File 'lib/jose/jwe/alg_dir.rb', line 14 def to_map(fields) return fields.put('alg', 'dir') end |