lib/yoti/protobuf/main.rb in yoti-1.6.0 vs lib/yoti/protobuf/main.rb in yoti-1.6.1

- old
+ new

@@ -42,13 +42,13 @@ decipher_profile(receipt['profile_content'], receipt['wrapped_receipt_key']) end def extra_data(receipt) - return nil unless valid_receipt?(receipt) + return nil if receipt['extra_data_content'].nil? || receipt['extra_data_content'] == '' - decipher_profile(receipt['extra_data'], receipt['wrapped_receipt_key']) if receipt['extra_data'] + decipher_extra_data(receipt['extra_data_content'], receipt['wrapped_receipt_key']) end def attribute_list(data) Yoti::Protobuf::Attrpubapi::AttributeList.decode(data) end @@ -109,13 +109,23 @@ decoded_profile_content = Base64.decode64(profile_content) Yoti::Protobuf::Compubapi::EncryptedData.decode(decoded_profile_content) end def decipher_profile(profile_content, wrapped_key) - encrypted_data = decode_profile(profile_content) - unwrapped_key = Yoti::SSL.decrypt_token(wrapped_key) - decrypted_data = Yoti::SSL.decipher(unwrapped_key, encrypted_data.iv, encrypted_data.cipher_text) + decrypted_data = decipher_data(profile_content, wrapped_key) Protobuf.attribute_list(decrypted_data) + end + + def decipher_extra_data(extra_data_content, wrapped_key) + decrypted_data = decipher_data(extra_data_content, wrapped_key) + proto = Yoti::Protobuf::Sharepubapi::ExtraData.decode(decrypted_data) + Share::ExtraData.new(proto) + end + + def decipher_data(encrypted_content, wrapped_key) + encrypted_data = decode_profile(encrypted_content) + unwrapped_key = Yoti::SSL.decrypt_token(wrapped_key) + Yoti::SSL.decipher(unwrapped_key, encrypted_data.iv, encrypted_data.cipher_text) end end end end