Class: JOSE::JWE::ALG_dir
- Inherits:
-
Object
- Object
- JOSE::JWE::ALG_dir
- Defined in:
- lib/jose/jwe/alg_dir.rb
Class Method Summary collapse
-
.from_map(fields) ⇒ Object
JOSE::JWE callbacks.
Instance Method Summary collapse
-
#key_decrypt(key, enc, encrypted_key) ⇒ Object
JOSE::JWE::ALG callbacks.
- #key_encrypt(key, enc, decrypted_key) ⇒ Object
- #next_cek(key, enc) ⇒ Object
- #to_map(fields) ⇒ Object
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(), fields.delete('alg') else raise ArgumentError, "invalid 'alg' for JWE: #{fields['alg'].inspect}" end end |
Instance Method Details
#key_decrypt(key, enc, encrypted_key) ⇒ Object
JOSE::JWE::ALG callbacks
20 21 22 23 24 25 26 |
# File 'lib/jose/jwe/alg_dir.rb', line 20 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
28 29 30 |
# File 'lib/jose/jwe/alg_dir.rb', line 28 def key_encrypt(key, enc, decrypted_key) return '', self end |
#next_cek(key, enc) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/jose/jwe/alg_dir.rb', line 32 def next_cek(key, enc) if key.is_a?(String) return key else return key.kty.derive_key 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 |