Class: Yasst::Provider::OpenSSL
- Inherits:
-
Yasst::Provider
- Object
- Yasst::Provider
- Yasst::Provider::OpenSSL
- Includes:
- Yasst::Primatives::OpenSSL
- Defined in:
- lib/yasst/provider/openssl.rb
Overview
OpenSSL provider
Parameters
-
profile
Required Parameters
-
passphrase
Constant Summary
Constants inherited from Yasst::Provider
Instance Attribute Summary collapse
-
#profile ⇒ Object
readonly
Returns the value of attribute profile.
Attributes inherited from Yasst::Provider
Instance Method Summary collapse
-
#decrypt(string) ⇒ Object
De-encode, unpack and decrypt a string.
-
#encrypt(string) ⇒ Object
Encrypt a string using a unique salt + key for every encrypt action, and then package it up in a usable base64’d string with iv + salt prepended.
-
#passphrase_required? ⇒ Boolean
Whether or not a passphrase is required for this provider.
-
#post_initialize(**args) ⇒ Object
initialize hook for superclass.
Methods inherited from Yasst::Provider
#initialize, #passphrase_valid?, #validate_passphrase
Constructor Details
This class inherits a constructor from Yasst::Provider
Instance Attribute Details
#profile ⇒ Object (readonly)
Returns the value of attribute profile.
14 15 16 |
# File 'lib/yasst/provider/openssl.rb', line 14 def profile @profile end |
Instance Method Details
#decrypt(string) ⇒ Object
De-encode, unpack and decrypt a string
Parameters
-
string
A base64-encoded string to decrypt. Must be in the same format as the encrypt method produces
Returns
55 56 57 58 59 60 61 62 63 |
# File 'lib/yasst/provider/openssl.rb', line 55 def decrypt(string) d_salt, d_iv, ciphertext = p_unpack_string( string, profile.key_len, profile.iv_len, profile.salt_bytes ) p_decrypt_string(ciphertext, key(d_salt), d_iv, profile.algorithm) end |
#encrypt(string) ⇒ Object
Encrypt a string using a unique salt + key for every encrypt action, and then package it up in a usable base64’d string with iv + salt prepended
Parameters
-
string
A string to encrypt
Returns
-
String
40 41 42 43 44 45 |
# File 'lib/yasst/provider/openssl.rb', line 40 def encrypt(string) e_salt = salt e_key = key(e_salt) e_iv, ciphertext = p_encrypt_string(string, e_key, profile.algorithm) p_pack_string(e_iv, e_salt, ciphertext) end |
#passphrase_required? ⇒ Boolean
Whether or not a passphrase is required for this provider
26 27 28 |
# File 'lib/yasst/provider/openssl.rb', line 26 def passphrase_required? true end |