Class: R2D2::AndroidPayToken
- Inherits:
-
Object
- Object
- R2D2::AndroidPayToken
- Includes:
- Util
- Defined in:
- lib/r2d2/android_pay_token.rb
Instance Attribute Summary collapse
-
#encrypted_message ⇒ Object
Returns the value of attribute encrypted_message.
-
#ephemeral_public_key ⇒ Object
Returns the value of attribute ephemeral_public_key.
-
#tag ⇒ Object
Returns the value of attribute tag.
Instance Method Summary collapse
- #decrypt(private_key_pem) ⇒ Object
-
#initialize(token_attrs) ⇒ AndroidPayToken
constructor
A new instance of AndroidPayToken.
Methods included from Util
#decrypt_message, #derive_hkdf_keys, #generate_shared_secret, #to_length_value, #verify_mac
Constructor Details
#initialize(token_attrs) ⇒ AndroidPayToken
Returns a new instance of AndroidPayToken.
7 8 9 10 11 |
# File 'lib/r2d2/android_pay_token.rb', line 7 def initialize(token_attrs) self.ephemeral_public_key = token_attrs["ephemeralPublicKey"] self.tag = token_attrs["tag"] self. = token_attrs["encryptedMessage"] end |
Instance Attribute Details
#encrypted_message ⇒ Object
Returns the value of attribute encrypted_message.
5 6 7 |
# File 'lib/r2d2/android_pay_token.rb', line 5 def @encrypted_message end |
#ephemeral_public_key ⇒ Object
Returns the value of attribute ephemeral_public_key.
5 6 7 |
# File 'lib/r2d2/android_pay_token.rb', line 5 def ephemeral_public_key @ephemeral_public_key end |
#tag ⇒ Object
Returns the value of attribute tag.
5 6 7 |
# File 'lib/r2d2/android_pay_token.rb', line 5 def tag @tag end |
Instance Method Details
#decrypt(private_key_pem) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/r2d2/android_pay_token.rb', line 13 def decrypt(private_key_pem) private_key = OpenSSL::PKey::EC.new(private_key_pem) shared_secret = generate_shared_secret(private_key, ephemeral_public_key) # derive the symmetric_encryption_key and mac_key hkdf_keys = derive_hkdf_keys(ephemeral_public_key, shared_secret, 'Android') # verify the tag is a valid value verify_mac(hkdf_keys[:mac_key], , tag) JSON.parse((, hkdf_keys[:symmetric_encryption_key])) end |