SlideShare a Scribd company logo
Applications of PBKDF2
Algorithm in Android Application
Secure Data Storage
Shiv Sahni
Sr. Security Analyst
Confidential
What is PBKDF?
PBKDF2 applies a pseudorandom function, such as hash-based message authentication
code (HMAC), to the input password or passphrase along with a salt value and repeats
the process many times to produce a derived key, which can then be used as a
cryptographic key in subsequent operations.
The Process!
The PBKDF2 key derivation function has five input parameters:
DK = PBKDF2(PRF, Password, Salt, c, dkLen)
where:
● PRF is a pseudorandom function (e.g. a keyed HMAC)
● Password is the master password from which a derived key is generated
● Salt is a sequence of bits, known as a cryptographic salt
● c is the number of iterations desired
● dkLen is the desired length of the derived key
● DK is the generated derived key
Why PBKDF?
● The algorithm is designed to increase the computation cost so as to prevent
Brute-force Attacks.
Usage?
● Key Derivation Functions
● Password Hashing
Hashing -> Salted Hashes->PBKDF
Salts are added so as to increase the computation requirements for cracking the
hashes.
PBKDF makes it more complex.
Storing Sensitive Data Securely in
Local Data Storage of Android
Applications
Attacker Can Not Reach to Private Data
Directory??
The Android sandbox for application data is not enough to create a
truly secure application.
● File System Misconfiguration
● Exploitation
The Sensitive Data is Actually Required?
Think Again!
It is recommended that the application should not capture unnecessary sensitive
data. Only the required sensitive data should be captured and should be securely
handled.
Not Just Encrypt it - SECURELY ENCRYPT IT!
● Say no to custom encryption algorithm.
● Avoid usage of weak cryptographic algorithms
○ Weak Encryption Algorithms: DES, 3DES, AES (ECB Mode) etc.
○ Weak Hashing Algorithms: RC4, MD5, SHA-1 etc.
○ Insecure Random Number Generators: Usage of java.util.Random for random number
generation.
● Poor Key Management
○ Hardcoded Encryption Keys
○ Storing Keys with Ciphertext Locally
Do we have pin/password/passphrase
implementation?
If the application requires password for authentication then
● Use user supplied password should be used to derive encryption key via a key
derivation function such as PBKDF2.
● The encryption key can be derived at the time of registration/first login and
can be used to encrypt sensitive data.
● The same key can be used to decrypt sensitive data whenever correct
password is supplied.
Not Just Encryption - Secure Encryption
● The application must have Strong Password Policy to prevent decryption of
sensitive data through brute-force attacks.
● Use Key Derivation Function with 10,000 or more rounds of iteration so as to
make brute-force attacks expensive.
Code Snippet
public static SecretKey generateKey(char[] passphraseOrPin, byte[] salt) throws NoSuchAlgorithmException,
InvalidKeySpecException {
// Number of PBKDF2 hardening rounds to use. Larger values increase
// computation time. You should select a value that causes computation
// to take >100ms.
final int iterations = 1000;
// Generate a 256-bit key
final int outputKeyLength = 256;
SecretKeyFactory secretKeyFactory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
KeySpec keySpec = new PBEKeySpec(passphraseOrPin, salt, iterations, outputKeyLength);
SecretKey secretKey = secretKeyFactory.generateSecret(keySpec);
return secretKey;
}
Reference:android-developers.googleblog.com
Example: AES Encryption and Decryption
Reference: https://gist.github.com/dweymouth/11089238
References
● The Mobile Application Hacker’s Handbook
● Wikipedia (https://en.wikipedia.org/)
● Android Developers Blogs (http://android-developers.blogspot.com)
PBKDF2: Storing Sensitive Data Securely in Android Applications

More Related Content

PPT
Lezione linguaggio teorie e sviluppo
PDF
Comunicazione efficace: principi e tecniche di base
PDF
Meeting 5.2 : ssh
PPT
Public speaking
PPTX
Comunicazione efficace
PPT
bullimo lezione
PDF
Dispense lezione 21 apprendimento-4 dicembre
Lezione linguaggio teorie e sviluppo
Comunicazione efficace: principi e tecniche di base
Meeting 5.2 : ssh
Public speaking
Comunicazione efficace
bullimo lezione
Dispense lezione 21 apprendimento-4 dicembre

What's hot (12)

PPT
Diffie-hellman algorithm
PDF
Abilità sociali
PPT
Operational Risk & Basel Ii
PPT
Tecniche di comunicazione
PPT
Vygotskij
PDF
Blind Signature Scheme
PPTX
Intelligenza emotiva slideshare
PDF
Autostima nell'Islam - "Il segreto è avere fiducia in se stessi" - GMI - Roma
ODP
Emotions in Multi-Agent Based Simulation
PPTX
Salute mentale giu
PPT
7. l empatia_nell_adolescenza
PDF
Adolescenti e i segnali del disagio
Diffie-hellman algorithm
Abilità sociali
Operational Risk & Basel Ii
Tecniche di comunicazione
Vygotskij
Blind Signature Scheme
Intelligenza emotiva slideshare
Autostima nell'Islam - "Il segreto è avere fiducia in se stessi" - GMI - Roma
Emotions in Multi-Agent Based Simulation
Salute mentale giu
7. l empatia_nell_adolescenza
Adolescenti e i segnali del disagio
Ad

Similar to PBKDF2: Storing Sensitive Data Securely in Android Applications (20)

PDF
Strong cryptography in PHP
PDF
Cryptography with Zend Framework
PDF
Secure Your Encryption with HSM
PDF
Password (in)security
PDF
Cryptography in PHP: Some Use Cases
PPTX
CryptoGraphy Module in Mulesoft
PPTX
Cryptography 101
PPT
Secure Mail Application's by Ashok Panwar
PDF
Consulthink @ GDG Meets U - L'Aquila2014 - Codelab: Android Security -Il ke...
PDF
How to Use Cryptography Properly: The Common Mistakes People Make When Using ...
PPTX
Data Security Essentials - JavaOne 2013
PDF
Unit 3 RSA for cryptography and cybersecurity
PPTX
Unit-III_3R-CRYPTO_2021-22_VSM.pptx
PDF
Passwords good badugly181212-2
PDF
Encrypted Negative Password using for Authentication
PPTX
Crypto failures every developer should avoid
PPTX
Crypto failures every developer should avoid
PDF
From Java 17 to 21- A Showcase of JDK Security Enhancements
PPTX
Digitalsignature&protocol Cryptographycss
PPTX
Crypography in c#
Strong cryptography in PHP
Cryptography with Zend Framework
Secure Your Encryption with HSM
Password (in)security
Cryptography in PHP: Some Use Cases
CryptoGraphy Module in Mulesoft
Cryptography 101
Secure Mail Application's by Ashok Panwar
Consulthink @ GDG Meets U - L'Aquila2014 - Codelab: Android Security -Il ke...
How to Use Cryptography Properly: The Common Mistakes People Make When Using ...
Data Security Essentials - JavaOne 2013
Unit 3 RSA for cryptography and cybersecurity
Unit-III_3R-CRYPTO_2021-22_VSM.pptx
Passwords good badugly181212-2
Encrypted Negative Password using for Authentication
Crypto failures every developer should avoid
Crypto failures every developer should avoid
From Java 17 to 21- A Showcase of JDK Security Enhancements
Digitalsignature&protocol Cryptographycss
Crypography in c#
Ad

Recently uploaded (20)

PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Electronic commerce courselecture one. Pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
sap open course for s4hana steps from ECC to s4
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
A Presentation on Artificial Intelligence
PPTX
Cloud computing and distributed systems.
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Advanced methodologies resolving dimensionality complications for autism neur...
The AUB Centre for AI in Media Proposal.docx
Unlocking AI with Model Context Protocol (MCP)
Assigned Numbers - 2025 - Bluetooth® Document
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Big Data Technologies - Introduction.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Electronic commerce courselecture one. Pdf
Spectral efficient network and resource selection model in 5G networks
sap open course for s4hana steps from ECC to s4
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
A comparative analysis of optical character recognition models for extracting...
Review of recent advances in non-invasive hemoglobin estimation
A Presentation on Artificial Intelligence
Cloud computing and distributed systems.
Diabetes mellitus diagnosis method based random forest with bat algorithm
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
Chapter 3 Spatial Domain Image Processing.pdf

PBKDF2: Storing Sensitive Data Securely in Android Applications

  • 1. Applications of PBKDF2 Algorithm in Android Application Secure Data Storage Shiv Sahni Sr. Security Analyst Confidential
  • 2. What is PBKDF? PBKDF2 applies a pseudorandom function, such as hash-based message authentication code (HMAC), to the input password or passphrase along with a salt value and repeats the process many times to produce a derived key, which can then be used as a cryptographic key in subsequent operations.
  • 3. The Process! The PBKDF2 key derivation function has five input parameters: DK = PBKDF2(PRF, Password, Salt, c, dkLen) where: ● PRF is a pseudorandom function (e.g. a keyed HMAC) ● Password is the master password from which a derived key is generated ● Salt is a sequence of bits, known as a cryptographic salt ● c is the number of iterations desired ● dkLen is the desired length of the derived key ● DK is the generated derived key
  • 4. Why PBKDF? ● The algorithm is designed to increase the computation cost so as to prevent Brute-force Attacks.
  • 5. Usage? ● Key Derivation Functions ● Password Hashing
  • 6. Hashing -> Salted Hashes->PBKDF Salts are added so as to increase the computation requirements for cracking the hashes. PBKDF makes it more complex.
  • 7. Storing Sensitive Data Securely in Local Data Storage of Android Applications
  • 8. Attacker Can Not Reach to Private Data Directory?? The Android sandbox for application data is not enough to create a truly secure application. ● File System Misconfiguration ● Exploitation
  • 9. The Sensitive Data is Actually Required? Think Again! It is recommended that the application should not capture unnecessary sensitive data. Only the required sensitive data should be captured and should be securely handled.
  • 10. Not Just Encrypt it - SECURELY ENCRYPT IT! ● Say no to custom encryption algorithm. ● Avoid usage of weak cryptographic algorithms ○ Weak Encryption Algorithms: DES, 3DES, AES (ECB Mode) etc. ○ Weak Hashing Algorithms: RC4, MD5, SHA-1 etc. ○ Insecure Random Number Generators: Usage of java.util.Random for random number generation. ● Poor Key Management ○ Hardcoded Encryption Keys ○ Storing Keys with Ciphertext Locally
  • 11. Do we have pin/password/passphrase implementation? If the application requires password for authentication then ● Use user supplied password should be used to derive encryption key via a key derivation function such as PBKDF2. ● The encryption key can be derived at the time of registration/first login and can be used to encrypt sensitive data. ● The same key can be used to decrypt sensitive data whenever correct password is supplied.
  • 12. Not Just Encryption - Secure Encryption ● The application must have Strong Password Policy to prevent decryption of sensitive data through brute-force attacks. ● Use Key Derivation Function with 10,000 or more rounds of iteration so as to make brute-force attacks expensive.
  • 13. Code Snippet public static SecretKey generateKey(char[] passphraseOrPin, byte[] salt) throws NoSuchAlgorithmException, InvalidKeySpecException { // Number of PBKDF2 hardening rounds to use. Larger values increase // computation time. You should select a value that causes computation // to take >100ms. final int iterations = 1000; // Generate a 256-bit key final int outputKeyLength = 256; SecretKeyFactory secretKeyFactory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"); KeySpec keySpec = new PBEKeySpec(passphraseOrPin, salt, iterations, outputKeyLength); SecretKey secretKey = secretKeyFactory.generateSecret(keySpec); return secretKey; } Reference:android-developers.googleblog.com
  • 14. Example: AES Encryption and Decryption Reference: https://gist.github.com/dweymouth/11089238
  • 15. References ● The Mobile Application Hacker’s Handbook ● Wikipedia (https://en.wikipedia.org/) ● Android Developers Blogs (http://android-developers.blogspot.com)