SlideShare a Scribd company logo
Dance like
nobody's watching
Encrypt like everyone is
How to do cryptography right in android
Part #1
Arash Ramez
Basic Concepts
• Cryptography is the art or science encompassing the principles and
methods of transforming an intelligible message into one that is
unintelligible, and then retransforming that message back to its
original form
• Concerned with developing algorithms which may be used to:
• conceal the context of some message from all except the sender and recipient
(privacy or secrecy), and/or (Confidentiality)
• verify the correctness of a message to the recipient (authentication)
Jefferson cylinder, developed in 1790s
Basic Concepts
Plaintext
the original intelligible message
Ciphertext
the transformed message
Cipher an algorithm for transforming an intelligible message into one that is unintelligible
by transposition and/or substitution methods
Key
some critical information used by the cipher, known only to the sender & receiver
encipher (encode)
the process of converting plaintext to ciphertext using a cipher and a key
decipher (decode)
the process of converting ciphertext back into plaintext using a cipher and a key
cryptanalysis
the study of principles and methods of transforming an unintelligible message back into
an intelligible message without knowledge of the key. Also called codebreaking
code
an algorithm for transforming an intelligible message into an unintelligible one using a code-book
Two very important truisms
1. Cryptography is harder than it looks.
2. Complexity is the worst enemy of security.
Enigma Rotor machine
Common pitfalls
• Rolling your own cryptographic algorithms or implementations.
• Misuse of libraries and algorithms.
• Poor key management.
• Randomness that is not random.
• Failure to centralize cryptography.
• Failure to allow for algorithm adaptation and evolution.
Regulations
• HIPPA Breach Notification Rule
• PCIDSS
• GDPR : Article 17
• GDPR, RIGHT OF ERASURE (RIGHT TO BE FORGOTTEN), AND ENCRYPTION KEY
MANAGEMENT (https://gdpr-info.eu/art-17-gdpr/)
• Encryption is one of the most well understood mechanisms for data privacy
• FIPS 140-2
• HTTPS://CSRC.NIST.GOV/PROJECTS/CRYPTOGRAPHIC-MODULE-VALIDATION-
PROGRAM/VALIDATED-MODULES/SEARCH
Type of Algorithms
• Hashing
• One-way, irreversible, Key-less (e.g. SHA-512,SHA1,MD5)
• HMAC
• One-way, irreversible, Keyed-Hash (e.g. HMACSHA512)
• Symmetric
• One Key encrypt and decrypt (e.g. DES,3DES,AES,RC4)
• Asymmetric
• Two mathematically related Keys; one key reverses transformations of the other.
(e.g. RSA, ECC)
• Random Number Generation
• Generate a random sequence of numbers
One-Way Hashing
- MD5(banned) / 128bit
- SHA0/SHA1 (banned 2014) /
160bit
- SHA-1 shall not be used for
digital signature
generation after December
31, 2013. (NIST)
- SHA-256
- SHA-384
- SHA-512
- SHA3
HMAC (Hash-based Message Authentication
Code)
Symmetric Cryptography
Symmetric Algorithms
• RC4 (unsafe)
• DES (unsafe) : 56-bit Key
• TwoFish
• 3DES : 64 / 112 / 168 bit
• AES (Rijndael) : 128/192/256 bit
Block Cipher vs Stream Cipher
• A block cipher encrypts data in specific-sized blocks, such as 64-bit
blocks or 128-bit blocks. The block cipher divides large files or
messages into these blocks and then encrypts each individual block
separately. (DES/3DES/AES-ECB/CBC)
• Encrypting a file or a specific-sized database field.
• Stream ciphers encrypt data as a stream of bits or bytes rather than
dividing it into blocks. (RC4/AES-GCM)
• the size of the data is unknown or sent in a continuous stream, such as when
streaming audio and video over a network
• Important Note : Encryption keys should never be reused.
Block Ciphers
• ECB ( Electronic Codebook)
• CBC (Cipher Block Chaining)
Asymmetric Cryptography
• Public Key Cryptography
• PKI
• PKE
Asymmetric Cryptography (Public Key
Cryptography)
• Rivest Shamir Adleman (RSA) /1978
• The basic RSA algorithm for confidentiality
• Ciphertext = (plaintext)^e mod n
Plaintext = (ciphertext)^d mod n
Private Key = {d, n}
Public Key = {e, n}
• The basic RSA algorithm for authentication
• ciphertext = (plaintext)^d mod n
plaintext = (ciphertext)^e mod n
private key = {d, n}
public key = {e, n}
Asymmetric Cryptography (Public Key
Cryptography)
• Diffie-Hellman key agreement (Dr. Whitfield Diffie and Dr. Martin
Hellman) / 1976
Elliptic Curve Cryptography (ECC)
• provides similar functionality to RSA. Elliptic Curve Cryptography
(ECC) is being implemented in smaller devices like cell phones. It
requires less computing power compared with RSA. ECC encryption
systems are based on the idea of using points on a curve to define the
public/private key pair.
Asymmetric Cryptography
Asymmetric Sign Algorithm
Keys
• Bits of Protection(Key length)
Key Management : The ways to do it wrong
• The hardest part of getting encryption right has to do with creating,
protecting, and deploying encryption keys. It is probably the hardest
part of getting an encryption strategy right.
• Storing the unprotected encryption key with the protected data
• Using weak protection methods to secure encryption keys
• Storing the encryption key directly in application code
• Using a weak encryption key - a password is an example of a weak key
• Not using strong, industry standard methods of generating an encryption key
• Not providing separation of duties and dual control around key management
Android Keystore
Android Keystore
• KeyStore (API 1) / JKS or BKS based keystores
• You will have to create a KeyStore file and you will also have to manage the
secret to access to it. This secret is very sensitive and difficult to hide from
attackers.
• Android KeyStore Provider (API 18)
• TEE based keystore
• check KeyInfo#isInsideSecureHardware() method to see whether the key is saved there
or not
• significantly enhanced in Android 6.0 (API level 23)
• Android 9 (API level 28)
• StrongBox (Titan M on Google Pixel 3)
Android keystore system
• The Android Keystore system lets you store cryptographic keys in a
container to make it more difficult to extract from the device. Once keys
are in the keystore, they can be used for cryptographic operations with the
key material remaining non-exportable
• introduced in Android 4.3 (API level 18)
• Firstly, Android Keystore mitigates unauthorized use of key material outside
of the Android device by preventing extraction of the key material from
application processes and from the Android device as a whole
• Secondly, Android KeyStore mitigates unauthorized use of key material on
the Android device by making apps specify authorized uses of their keys
and then enforcing these restrictions outside of the apps' processes.
Security Features: Extraction prevention
• Key material never enters the application process.
• Key material may be bound to the secure hardware.
• (e.g., Trusted Execution Environment (TEE), Secure Element (SE)) of
the Android device
Why does Hardware-Based Cryptography
matter?
• The software solution is often more accessible to an attacker
• In contrast, the IP running on an FPGA is physically fully internal.
• The second reason is performance.
• FPGAs excel at massively parallel processing, and it’s easy to get duplex
throughputs of 10 Gbps with modest clocks
• Using faster silicon, higher clock speeds and more FPGA resources can push
the throughput up to 100 Gbps or beyond.
Secure Storage of keys
• Android also now supports hardware-backed storage for your KeyChain
credentials, providing more security by making the keys unavailable for
extraction. That is, once keys are in a hardware-backed key store (Secure
Element, TPM, or TrustZone), they can be used for cryptographic operations
but the private key material cannot be exported. Even the OS kernel cannot
access this key material. While not all Android-powered devices support
storage on hardware, you can check at runtime if hardware-backed storage
is available by calling KeyChain.IsBoundKeyAlgorithm()
• Android Keystore Nasty Bug(more common before Android 5):
• if the user changes the lock screen pattern into a password or just deletes the
pattern, the KeyStore will be fully corrupted.
• https://doridori.github.io/android-security-the-forgetful-
keystore/#sthash.G3v7Ei7g.Myhj1R0a.dpbs
Keystore API
• Encryption/Decryption
• https://gist.github.com/aramezx/f69bbd897cc19f29e68008659f8ed653
• https://gist.github.com/aramezx/8cc5922a9602694a02fa905149f02a63
Keystore API(cont.)
• Sign/Verify
• https://gist.github.com/aramezx/885cc89be75a3838c26b7b3975e4f667
Keystore API(cont.)
• Key Exchange
• https://gist.github.com/aramezx/e50d90af51877e6608c981e03d371a76
Keystore redesign in Android M
• New symmetric cryptography API based on JCA
• Requiring use authentication
• Keymaster redesign
• Key blob storage
Symmetric API
• https://gist.github.com/aramezx/7a9ae46fa02dc1875b311323ef68abab
Improvements in API 23 & N
• keys can be generated within the secure hardware, and then used to
perform cryptographic operations on user data, without the keys
ever leaving the secure hardware.
• High Maturity Cipher suites support
• Android N :
• CrytpoProvider is deprecated
• Hardware-backed keystore is mandatory
How to do Cryptography right in Android Part One

More Related Content

What's hot

IPSec (Internet Protocol Security) - PART 1
IPSec (Internet Protocol Security) - PART 1IPSec (Internet Protocol Security) - PART 1
IPSec (Internet Protocol Security) - PART 1Shobhit Sharma
 
introduction to cryptography
introduction to cryptographyintroduction to cryptography
introduction to cryptographyPriyamvada Singh
 
RSA & MD5 algorithm
RSA & MD5 algorithmRSA & MD5 algorithm
RSA & MD5 algorithmSiva Rushi
 
RSA Algorithm - Public Key Cryptography
RSA Algorithm - Public Key CryptographyRSA Algorithm - Public Key Cryptography
RSA Algorithm - Public Key CryptographyMd. Shafiul Alam Sagor
 
Public Key Cryptography and RSA algorithm
Public Key Cryptography and RSA algorithmPublic Key Cryptography and RSA algorithm
Public Key Cryptography and RSA algorithmIndra97065
 
18CS2005 Cryptography and Network Security
18CS2005 Cryptography and Network Security18CS2005 Cryptography and Network Security
18CS2005 Cryptography and Network SecurityKathirvel Ayyaswamy
 
Information Security Cryptography ( L02- Types Cryptography)
Information Security Cryptography ( L02- Types Cryptography)Information Security Cryptography ( L02- Types Cryptography)
Information Security Cryptography ( L02- Types Cryptography)Anas Rock
 
History of cryptography
History of cryptographyHistory of cryptography
History of cryptographyFarah Shaikh
 
Cs8792 cns - unit iv
Cs8792   cns - unit ivCs8792   cns - unit iv
Cs8792 cns - unit ivArthyR3
 
[CB19] Cyber Threat Landscape in Japan – Revealing Threat in the Shadow by C...
[CB19] Cyber Threat Landscape in Japan – Revealing Threat in the Shadow by  C...[CB19] Cyber Threat Landscape in Japan – Revealing Threat in the Shadow by  C...
[CB19] Cyber Threat Landscape in Japan – Revealing Threat in the Shadow by C...CODE BLUE
 
Cryptographic Algorithms: DES and RSA
Cryptographic Algorithms: DES and RSACryptographic Algorithms: DES and RSA
Cryptographic Algorithms: DES and RSAaritraranjan
 

What's hot (20)

IPSec (Internet Protocol Security) - PART 1
IPSec (Internet Protocol Security) - PART 1IPSec (Internet Protocol Security) - PART 1
IPSec (Internet Protocol Security) - PART 1
 
Public key cryptography and RSA
Public key cryptography and RSAPublic key cryptography and RSA
Public key cryptography and RSA
 
introduction to cryptography
introduction to cryptographyintroduction to cryptography
introduction to cryptography
 
Encryption
EncryptionEncryption
Encryption
 
RSA & MD5 algorithm
RSA & MD5 algorithmRSA & MD5 algorithm
RSA & MD5 algorithm
 
RSA Algorithm - Public Key Cryptography
RSA Algorithm - Public Key CryptographyRSA Algorithm - Public Key Cryptography
RSA Algorithm - Public Key Cryptography
 
Ch02 classic nemo
Ch02 classic nemoCh02 classic nemo
Ch02 classic nemo
 
Cryptography and Network Security William Stallings Lawrie Brown
Cryptography and Network Security William Stallings Lawrie BrownCryptography and Network Security William Stallings Lawrie Brown
Cryptography and Network Security William Stallings Lawrie Brown
 
Public Key Cryptography and RSA algorithm
Public Key Cryptography and RSA algorithmPublic Key Cryptography and RSA algorithm
Public Key Cryptography and RSA algorithm
 
IP Sec - Basic Concepts
IP Sec - Basic ConceptsIP Sec - Basic Concepts
IP Sec - Basic Concepts
 
18CS2005 Cryptography and Network Security
18CS2005 Cryptography and Network Security18CS2005 Cryptography and Network Security
18CS2005 Cryptography and Network Security
 
Information Security Cryptography ( L02- Types Cryptography)
Information Security Cryptography ( L02- Types Cryptography)Information Security Cryptography ( L02- Types Cryptography)
Information Security Cryptography ( L02- Types Cryptography)
 
History of cryptography
History of cryptographyHistory of cryptography
History of cryptography
 
ip security
ip securityip security
ip security
 
IP Security
IP SecurityIP Security
IP Security
 
Cs8792 cns - unit iv
Cs8792   cns - unit ivCs8792   cns - unit iv
Cs8792 cns - unit iv
 
[CB19] Cyber Threat Landscape in Japan – Revealing Threat in the Shadow by C...
[CB19] Cyber Threat Landscape in Japan – Revealing Threat in the Shadow by  C...[CB19] Cyber Threat Landscape in Japan – Revealing Threat in the Shadow by  C...
[CB19] Cyber Threat Landscape in Japan – Revealing Threat in the Shadow by C...
 
Email security
Email securityEmail security
Email security
 
2014.11 asfws
2014.11 asfws2014.11 asfws
2014.11 asfws
 
Cryptographic Algorithms: DES and RSA
Cryptographic Algorithms: DES and RSACryptographic Algorithms: DES and RSA
Cryptographic Algorithms: DES and RSA
 

Similar to How to do Cryptography right in Android Part One

cryptography deepan fav subject
cryptography deepan fav subjectcryptography deepan fav subject
cryptography deepan fav subjectdeepan v
 
UNIT 4 CRYPTOGRAPHIC SYSTEMS.pptx
UNIT 4  CRYPTOGRAPHIC SYSTEMS.pptxUNIT 4  CRYPTOGRAPHIC SYSTEMS.pptx
UNIT 4 CRYPTOGRAPHIC SYSTEMS.pptxssuserd5e356
 
Encryption techniques
Encryption techniquesEncryption techniques
Encryption techniquesMohitManna
 
Ch 12: Cryptography
Ch 12: CryptographyCh 12: Cryptography
Ch 12: CryptographySam Bowne
 
Cryptographic Chronicles: Unveiling Definitions, Algorithms, Attacks, and App...
Cryptographic Chronicles: Unveiling Definitions, Algorithms, Attacks, and App...Cryptographic Chronicles: Unveiling Definitions, Algorithms, Attacks, and App...
Cryptographic Chronicles: Unveiling Definitions, Algorithms, Attacks, and App...zachdwg
 
Comparison of Various Encryption Algorithms and Techniques for improving secu...
Comparison of Various Encryption Algorithms and Techniques for improving secu...Comparison of Various Encryption Algorithms and Techniques for improving secu...
Comparison of Various Encryption Algorithms and Techniques for improving secu...IOSR Journals
 
Slide Deck – Session 6 – FRSecure CISSP Mentor Program 2017
Slide Deck – Session 6 – FRSecure CISSP Mentor Program 2017Slide Deck – Session 6 – FRSecure CISSP Mentor Program 2017
Slide Deck – Session 6 – FRSecure CISSP Mentor Program 2017FRSecure
 
Enhancing lan using cryptography and other modules
Enhancing lan using cryptography and other modulesEnhancing lan using cryptography and other modules
Enhancing lan using cryptography and other modulesMurali Krishna
 
Unit III Public Key Crypto Systems.pptx
Unit III Public Key Crypto Systems.pptxUnit III Public Key Crypto Systems.pptx
Unit III Public Key Crypto Systems.pptxSayeeKumarMadhesh
 
6. cryptography
6. cryptography6. cryptography
6. cryptography7wounders
 

Similar to How to do Cryptography right in Android Part One (20)

Security - ch3.pptx
Security - ch3.pptxSecurity - ch3.pptx
Security - ch3.pptx
 
Security - ch3.pptx
Security - ch3.pptxSecurity - ch3.pptx
Security - ch3.pptx
 
Cryptology - The practice and study of hiding information
Cryptology - The practice and study of hiding informationCryptology - The practice and study of hiding information
Cryptology - The practice and study of hiding information
 
Cryptography
CryptographyCryptography
Cryptography
 
Cryptography
CryptographyCryptography
Cryptography
 
cryptography deepan fav subject
cryptography deepan fav subjectcryptography deepan fav subject
cryptography deepan fav subject
 
UNIT 4 CRYPTOGRAPHIC SYSTEMS.pptx
UNIT 4  CRYPTOGRAPHIC SYSTEMS.pptxUNIT 4  CRYPTOGRAPHIC SYSTEMS.pptx
UNIT 4 CRYPTOGRAPHIC SYSTEMS.pptx
 
Crypto academy
Crypto academyCrypto academy
Crypto academy
 
Encryption techniques
Encryption techniquesEncryption techniques
Encryption techniques
 
Ch 12: Cryptography
Ch 12: CryptographyCh 12: Cryptography
Ch 12: Cryptography
 
groupWork.pptx
groupWork.pptxgroupWork.pptx
groupWork.pptx
 
Cryptographic Chronicles: Unveiling Definitions, Algorithms, Attacks, and App...
Cryptographic Chronicles: Unveiling Definitions, Algorithms, Attacks, and App...Cryptographic Chronicles: Unveiling Definitions, Algorithms, Attacks, and App...
Cryptographic Chronicles: Unveiling Definitions, Algorithms, Attacks, and App...
 
L017136269
L017136269L017136269
L017136269
 
Comparison of Various Encryption Algorithms and Techniques for improving secu...
Comparison of Various Encryption Algorithms and Techniques for improving secu...Comparison of Various Encryption Algorithms and Techniques for improving secu...
Comparison of Various Encryption Algorithms and Techniques for improving secu...
 
Slide Deck – Session 6 – FRSecure CISSP Mentor Program 2017
Slide Deck – Session 6 – FRSecure CISSP Mentor Program 2017Slide Deck – Session 6 – FRSecure CISSP Mentor Program 2017
Slide Deck – Session 6 – FRSecure CISSP Mentor Program 2017
 
Lesson 1
Lesson 1Lesson 1
Lesson 1
 
Enhancing lan using cryptography and other modules
Enhancing lan using cryptography and other modulesEnhancing lan using cryptography and other modules
Enhancing lan using cryptography and other modules
 
Network security
Network securityNetwork security
Network security
 
Unit III Public Key Crypto Systems.pptx
Unit III Public Key Crypto Systems.pptxUnit III Public Key Crypto Systems.pptx
Unit III Public Key Crypto Systems.pptx
 
6. cryptography
6. cryptography6. cryptography
6. cryptography
 

Recently uploaded

When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...Elena Simperl
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaCzechDreamin
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka DoktorováCzechDreamin
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Product School
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...CzechDreamin
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...Product School
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...Product School
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...Product School
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlPeter Udo Diehl
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxDavid Michel
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...Product School
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupCatarinaPereira64715
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeCzechDreamin
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor TurskyiFwdays
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Thierry Lestable
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
 

Recently uploaded (20)

When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 

How to do Cryptography right in Android Part One

  • 1. Dance like nobody's watching Encrypt like everyone is How to do cryptography right in android Part #1 Arash Ramez
  • 2. Basic Concepts • Cryptography is the art or science encompassing the principles and methods of transforming an intelligible message into one that is unintelligible, and then retransforming that message back to its original form • Concerned with developing algorithms which may be used to: • conceal the context of some message from all except the sender and recipient (privacy or secrecy), and/or (Confidentiality) • verify the correctness of a message to the recipient (authentication) Jefferson cylinder, developed in 1790s
  • 3. Basic Concepts Plaintext the original intelligible message Ciphertext the transformed message Cipher an algorithm for transforming an intelligible message into one that is unintelligible by transposition and/or substitution methods Key some critical information used by the cipher, known only to the sender & receiver encipher (encode) the process of converting plaintext to ciphertext using a cipher and a key decipher (decode) the process of converting ciphertext back into plaintext using a cipher and a key cryptanalysis the study of principles and methods of transforming an unintelligible message back into an intelligible message without knowledge of the key. Also called codebreaking code an algorithm for transforming an intelligible message into an unintelligible one using a code-book
  • 4. Two very important truisms 1. Cryptography is harder than it looks. 2. Complexity is the worst enemy of security. Enigma Rotor machine
  • 5.
  • 6. Common pitfalls • Rolling your own cryptographic algorithms or implementations. • Misuse of libraries and algorithms. • Poor key management. • Randomness that is not random. • Failure to centralize cryptography. • Failure to allow for algorithm adaptation and evolution.
  • 7. Regulations • HIPPA Breach Notification Rule • PCIDSS • GDPR : Article 17 • GDPR, RIGHT OF ERASURE (RIGHT TO BE FORGOTTEN), AND ENCRYPTION KEY MANAGEMENT (https://gdpr-info.eu/art-17-gdpr/) • Encryption is one of the most well understood mechanisms for data privacy • FIPS 140-2 • HTTPS://CSRC.NIST.GOV/PROJECTS/CRYPTOGRAPHIC-MODULE-VALIDATION- PROGRAM/VALIDATED-MODULES/SEARCH
  • 8.
  • 9. Type of Algorithms • Hashing • One-way, irreversible, Key-less (e.g. SHA-512,SHA1,MD5) • HMAC • One-way, irreversible, Keyed-Hash (e.g. HMACSHA512) • Symmetric • One Key encrypt and decrypt (e.g. DES,3DES,AES,RC4) • Asymmetric • Two mathematically related Keys; one key reverses transformations of the other. (e.g. RSA, ECC) • Random Number Generation • Generate a random sequence of numbers
  • 10. One-Way Hashing - MD5(banned) / 128bit - SHA0/SHA1 (banned 2014) / 160bit - SHA-1 shall not be used for digital signature generation after December 31, 2013. (NIST) - SHA-256 - SHA-384 - SHA-512 - SHA3
  • 11. HMAC (Hash-based Message Authentication Code)
  • 13. Symmetric Algorithms • RC4 (unsafe) • DES (unsafe) : 56-bit Key • TwoFish • 3DES : 64 / 112 / 168 bit • AES (Rijndael) : 128/192/256 bit
  • 14.
  • 15. Block Cipher vs Stream Cipher • A block cipher encrypts data in specific-sized blocks, such as 64-bit blocks or 128-bit blocks. The block cipher divides large files or messages into these blocks and then encrypts each individual block separately. (DES/3DES/AES-ECB/CBC) • Encrypting a file or a specific-sized database field. • Stream ciphers encrypt data as a stream of bits or bytes rather than dividing it into blocks. (RC4/AES-GCM) • the size of the data is unknown or sent in a continuous stream, such as when streaming audio and video over a network • Important Note : Encryption keys should never be reused.
  • 16. Block Ciphers • ECB ( Electronic Codebook) • CBC (Cipher Block Chaining)
  • 17. Asymmetric Cryptography • Public Key Cryptography • PKI • PKE
  • 18. Asymmetric Cryptography (Public Key Cryptography) • Rivest Shamir Adleman (RSA) /1978 • The basic RSA algorithm for confidentiality • Ciphertext = (plaintext)^e mod n Plaintext = (ciphertext)^d mod n Private Key = {d, n} Public Key = {e, n} • The basic RSA algorithm for authentication • ciphertext = (plaintext)^d mod n plaintext = (ciphertext)^e mod n private key = {d, n} public key = {e, n}
  • 19. Asymmetric Cryptography (Public Key Cryptography) • Diffie-Hellman key agreement (Dr. Whitfield Diffie and Dr. Martin Hellman) / 1976
  • 20. Elliptic Curve Cryptography (ECC) • provides similar functionality to RSA. Elliptic Curve Cryptography (ECC) is being implemented in smaller devices like cell phones. It requires less computing power compared with RSA. ECC encryption systems are based on the idea of using points on a curve to define the public/private key pair.
  • 23. Keys • Bits of Protection(Key length)
  • 24. Key Management : The ways to do it wrong • The hardest part of getting encryption right has to do with creating, protecting, and deploying encryption keys. It is probably the hardest part of getting an encryption strategy right. • Storing the unprotected encryption key with the protected data • Using weak protection methods to secure encryption keys • Storing the encryption key directly in application code • Using a weak encryption key - a password is an example of a weak key • Not using strong, industry standard methods of generating an encryption key • Not providing separation of duties and dual control around key management
  • 26. Android Keystore • KeyStore (API 1) / JKS or BKS based keystores • You will have to create a KeyStore file and you will also have to manage the secret to access to it. This secret is very sensitive and difficult to hide from attackers. • Android KeyStore Provider (API 18) • TEE based keystore • check KeyInfo#isInsideSecureHardware() method to see whether the key is saved there or not • significantly enhanced in Android 6.0 (API level 23) • Android 9 (API level 28) • StrongBox (Titan M on Google Pixel 3)
  • 27. Android keystore system • The Android Keystore system lets you store cryptographic keys in a container to make it more difficult to extract from the device. Once keys are in the keystore, they can be used for cryptographic operations with the key material remaining non-exportable • introduced in Android 4.3 (API level 18) • Firstly, Android Keystore mitigates unauthorized use of key material outside of the Android device by preventing extraction of the key material from application processes and from the Android device as a whole • Secondly, Android KeyStore mitigates unauthorized use of key material on the Android device by making apps specify authorized uses of their keys and then enforcing these restrictions outside of the apps' processes.
  • 28. Security Features: Extraction prevention • Key material never enters the application process. • Key material may be bound to the secure hardware. • (e.g., Trusted Execution Environment (TEE), Secure Element (SE)) of the Android device
  • 29. Why does Hardware-Based Cryptography matter? • The software solution is often more accessible to an attacker • In contrast, the IP running on an FPGA is physically fully internal. • The second reason is performance. • FPGAs excel at massively parallel processing, and it’s easy to get duplex throughputs of 10 Gbps with modest clocks • Using faster silicon, higher clock speeds and more FPGA resources can push the throughput up to 100 Gbps or beyond.
  • 30. Secure Storage of keys • Android also now supports hardware-backed storage for your KeyChain credentials, providing more security by making the keys unavailable for extraction. That is, once keys are in a hardware-backed key store (Secure Element, TPM, or TrustZone), they can be used for cryptographic operations but the private key material cannot be exported. Even the OS kernel cannot access this key material. While not all Android-powered devices support storage on hardware, you can check at runtime if hardware-backed storage is available by calling KeyChain.IsBoundKeyAlgorithm() • Android Keystore Nasty Bug(more common before Android 5): • if the user changes the lock screen pattern into a password or just deletes the pattern, the KeyStore will be fully corrupted. • https://doridori.github.io/android-security-the-forgetful- keystore/#sthash.G3v7Ei7g.Myhj1R0a.dpbs
  • 31. Keystore API • Encryption/Decryption • https://gist.github.com/aramezx/f69bbd897cc19f29e68008659f8ed653 • https://gist.github.com/aramezx/8cc5922a9602694a02fa905149f02a63
  • 32. Keystore API(cont.) • Sign/Verify • https://gist.github.com/aramezx/885cc89be75a3838c26b7b3975e4f667
  • 33. Keystore API(cont.) • Key Exchange • https://gist.github.com/aramezx/e50d90af51877e6608c981e03d371a76
  • 34. Keystore redesign in Android M • New symmetric cryptography API based on JCA • Requiring use authentication • Keymaster redesign • Key blob storage
  • 36. Improvements in API 23 & N • keys can be generated within the secure hardware, and then used to perform cryptographic operations on user data, without the keys ever leaving the secure hardware. • High Maturity Cipher suites support • Android N : • CrytpoProvider is deprecated • Hardware-backed keystore is mandatory

Editor's Notes

  1. Rolling your own cryptographic algorithms or implementations. Designing a cryptographic algorithm (including protocols and modes) requires significant and rare mathematical skills and training, and even trained mathematicians sometimes produce algorithms that have subtle problems. There are also numerous subtleties with implementing cryptographic algorithms. For example, the order of operations involved when exponentiating a number — something common in cryptographic operations — can leak secret information to attackers. Standard algorithms and libraries are preferable. Misuse of libraries and algorithms. Even when using strong libraries, do not assume that just using the libraries will be sufficient. There have been numerous instances in which standard libraries were used, but the developers using the libraries made incorrect assumptions about how to use the library routines. In other situations, developers don’t choose the right algorithm or use the algorithm incorrectly. For example, an encryption scheme may protect the confidentiality of data, but may not protect against malicious modifications to the data. As another example, if an algorithm requires an initialization vector (IV), then choosing an IV with certain properties may be required for the algorithm to work securely. Understanding the nuances of algorithm and library usage is a core skill for applied cryptographers. Poor key management. When everything else is done correctly, the security of the cryptographic system still hinges on the protection of the cryptographic keys. Key management mistakes are common, and include hard-coding keys into software (often observed in embedded devices and application software), failure to allow for the revocation and/or rotation of keys, use of cryptographic keys that are weak (e.g., keys that are too short or that are predictable), and weak key distribution mechanisms. Randomness that is not random. Confusion between statistical randomness and cryptographic randomness is common. Cryptographic operations require random numbers that have strong security properties. In addition to obtaining numbers with strong cryptographic randomness properties, care must be taken not to re-use the random numbers. Failure to centralize cryptography. Numerous situations have been observed in which different teams within an organization each implemented their own cryptographic routines. Cryptographic algorithms often don’t interact nicely. Best practices indicate getting it “right” once and reusing the component elsewhere. Failure to allow for algorithm adaptation and evolution. See Bullet “Design for changes in the security properties of components beyond your control” in “Be flexible when considering future changes to objects and actors” section.
  2. 1) Software is more vulnerable 1.2)including an operating system making it large and complex so that it offers many opportunities to an attacker and  difficult to analyse for security weaknesses. 2) Isolating the encryption code in fixed hardware and never allowing the software to come in contact with critical security parameters such as keys makes it easier to analyse the system’s overall security and many classes of threat are eliminated. 2.2) The design should have only “plaintext” (i.e., message-in-the-clear) and fully encrypted data (i.e., ciphertext) going anywhere near the device’s pins. 3)