Module: JOSE::JWA::XChaCha20Poly1305
- Extended by:
- XChaCha20Poly1305
- Included in:
- XChaCha20Poly1305
- Defined in:
- lib/jose/jwa/xchacha20poly1305.rb
Constant Summary collapse
- MUTEX =
Mutex.new
Instance Method Summary collapse
- #__config_change__(lock = true) ⇒ Object
- #__implementation__ ⇒ Object
- #__implementation__=(implementation) ⇒ Object
- #__register__(implementation, ruby = false) ⇒ Object
- #xchacha20poly1305_aead_decrypt(key, nonce, aad, ciphertext, tag) ⇒ Object
- #xchacha20poly1305_aead_encrypt(key, nonce, aad, plaintext) ⇒ Object
Instance Method Details
#__config_change__(lock = true) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/jose/jwa/xchacha20poly1305.rb', line 30 def __config_change__(lock = true) MUTEX.lock if lock @__implementation__ ||= nil @__implementation__ = __pick_best_implementation__ if @__implementation__.nil? or @__implementation__.__ruby__? or not @__implementation__.__supported__? MUTEX.unlock if lock end |
#__implementation__ ⇒ Object
10 11 12 |
# File 'lib/jose/jwa/xchacha20poly1305.rb', line 10 def __implementation__ return MUTEX.synchronize { @__implementation__ ||= __pick_best_implementation__ } end |
#__implementation__=(implementation) ⇒ Object
14 15 16 |
# File 'lib/jose/jwa/xchacha20poly1305.rb', line 14 def __implementation__=(implementation) return MUTEX.synchronize { @__implementation__ = implementation } end |
#__register__(implementation, ruby = false) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/jose/jwa/xchacha20poly1305.rb', line 18 def __register__(implementation, ruby = false) MUTEX.synchronize { if ruby @__ruby_implementations__.unshift(implementation) else @__implementations__.unshift(implementation) end __config_change__(false) implementation } end |
#xchacha20poly1305_aead_decrypt(key, nonce, aad, ciphertext, tag) ⇒ Object
41 42 43 |
# File 'lib/jose/jwa/xchacha20poly1305.rb', line 41 def xchacha20poly1305_aead_decrypt(key, nonce, aad, ciphertext, tag) return (@__implementation__ || __implementation__).xchacha20poly1305_aead_decrypt(key, nonce, aad, ciphertext, tag) end |
#xchacha20poly1305_aead_encrypt(key, nonce, aad, plaintext) ⇒ Object
37 38 39 |
# File 'lib/jose/jwa/xchacha20poly1305.rb', line 37 def xchacha20poly1305_aead_encrypt(key, nonce, aad, plaintext) return (@__implementation__ || __implementation__).xchacha20poly1305_aead_encrypt(key, nonce, aad, plaintext) end |