-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b820f9
commit d188548
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Android supports password lock with PIN number or alphanumeric password. The limit of both passphrases are required to be between 4 and 16 digits or characters. The password of a smartphone is stored in the Android system in a special file called password.key in /data/system. | ||
Android stores a salted SHA1-hashsum and MD5-hashsum of the password. | ||
|
||
It is not feasible to crack the password with the help of dictionary attack as the hashed password is stored in a salt file. This salt is a string of hexadecimal representation of a random integer of 64 bit. It is easy to access the salt by using Rooted Smartphone or JTAG Adapter. | ||
|
||
A special hardware known as JTAG (Joint Test Action Group) adapter can be used to access the salt. Similarly, a Riff-Box or a JIG-Adapter can also be used for the same functionality. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
public byte[] passwordToHash(String password) { | ||
|
||
if (password == null) { | ||
return null; | ||
} | ||
|
||
String algo = null; | ||
byte[] hashed = null; | ||
|
||
try { | ||
byte[] saltedPassword = (password + getSalt()).getBytes(); | ||
byte[] sha1 = MessageDigest.getInstance(algo = "SHA-1").digest(saltedPassword); | ||
byte[] md5 = MessageDigest.getInstance(algo = "MD5").digest(saltedPassword); | ||
hashed = (toHex(sha1) + toHex(md5)).getBytes(); | ||
} catch (NoSuchAlgorithmException e) { | ||
Log.w(TAG, "Failed to encode string because of missing algorithm: " + algo); | ||
} | ||
|
||
return hashed; | ||
} |