Class: OoxmlDecrypt::EncryptedKey
- Inherits:
-
KeyInfoBase
- Object
- KeyInfoBase
- OoxmlDecrypt::EncryptedKey
- Defined in:
- lib/ooxml_decrypt/encrypted_key.rb
Constant Summary collapse
- ENCRYPTED_VERIFIER_HASH_INPUT_BLOCK_KEY =
Integrity-verification constants (not currently used)
"FEA7D2763B4B9E79".unhexify
- ENCRYPTED_VERIFIER_HASH_VALUE_BLOCK_KEY =
"D7AA0F6D3061344E".unhexify
- ENCRYPTED_KEY_VALUE_BLOCK_KEY =
Static key used in decrypting the key-encryption key
"146E0BE7ABACD0D6".unhexify
Class Method Summary collapse
-
.from_xml(xml_doc) ⇒ Object
Extracts key-encryption-key data parameters from the given XML document and populates a new EncryptedKey object.
Instance Method Summary collapse
-
#initialize(opts) ⇒ EncryptedKey
constructor
A new instance of EncryptedKey.
-
#key(password) ⇒ String
Decrypts the key-encryption key using the given password.
Methods inherited from KeyInfoBase
Constructor Details
#initialize(opts) ⇒ EncryptedKey
Returns a new instance of EncryptedKey.
11 12 13 14 15 |
# File 'lib/ooxml_decrypt/encrypted_key.rb', line 11 def initialize(opts) @spin_count = opts.delete(:spin_count) @encrypted_key = opts.delete(:encrypted_key) super(opts) end |
Class Method Details
.from_xml(xml_doc) ⇒ Object
Extracts key-encryption-key data parameters from the given XML document and populates a new EncryptedKey object.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ooxml_decrypt/encrypted_key.rb', line 21 def self.from_xml(xml_doc) ke_node = xml_doc.at_css("keyEncryptor") raise "Expected only one child for keyEncryptor" unless ke_node.children.count == 1 ek_node = ke_node.child opts = KeyInfoBase.opts_from_xml_node(ek_node) opts[:spin_count] = ek_node["spinCount"].to_i opts[:encrypted_key] = ek_node["encryptedKeyValue"].base64_decode return self.new(opts) end |
Instance Method Details
#key(password) ⇒ String
Decrypts the key-encryption key using the given password
48 49 50 |
# File 'lib/ooxml_decrypt/encrypted_key.rb', line 48 def key(password) decrypt(@encrypted_key, key_encryption_key(password)) end |