Differences

This shows you the differences between two versions of the page.

Link to this comparison view

smd:laboratoare:08 [2019/04/22 19:57]
adriana.draghici [Objectives]
smd:laboratoare:08 [2019/04/22 20:01] (current)
adriana.draghici [Task 3 - Generate and Verify HMAC (4p)]
Line 58: Line 58:
 Add an activity to the project. Include an **EditText** and a **Button** in the first activity. When the user types a text and presses the button, it will send the text to the second activity through an intent (**putExtra**). In the second activity, get the message from the Intent and display it in the **TextView**. ​ Add an activity to the project. Include an **EditText** and a **Button** in the first activity. When the user types a text and presses the button, it will send the text to the second activity through an intent (**putExtra**). In the second activity, get the message from the Intent and display it in the **TextView**. ​
  
-In the first activity generate a symmetric key using [[https://​developer.android.com/​reference/​javax/​crypto/​KeyGenerator|KeyGenerator]] for //​HmacSha256//​ algorithm. Save this key in a Singleton (that can be accessed from both activities). Then generate the HMAC of the text introduced by the user (using ​**Hmac** ​with HmacSha256 algorithm) and send the HMAC along with the initial message (through the Intent). In the second activity, obtain the HMAC from the Intent, obtain the Singleton, get the symmetric key and recompute the HMAC. If the HMAC is valid (equal with the recomputed one), Display the message "Data is unmodified"​. ​+In the first activity generate a symmetric key using [[https://​developer.android.com/​reference/​javax/​crypto/​KeyGenerator|KeyGenerator]] for //​HmacSha256//​ algorithm. Save this key in a Singleton (that can be accessed from both activities). Then generate the HMAC of the text introduced by the user (using ​[[https://​developer.android.com/​reference/​javax/​crypto/​Mac.html|MAC]] ​with HmacSha256 algorithm) and send the HMAC along with the initial message (through the Intent). In the second activity, obtain the HMAC from the Intent, obtain the Singleton, get the symmetric key and recompute the HMAC. If the HMAC is valid (equal with the recomputed one), Display the message "Data is unmodified"​. ​
  
 Hint: Send data and HMAC as byte arrays in the Intent.\\ Hint: Send data and HMAC as byte arrays in the Intent.\\
smd/laboratoare/08.txt ยท Last modified: 2019/04/22 20:01 by adriana.draghici
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0