28
Mobile Data Encryption Enhanced Application Security with SQLCipher Stephen Lombardo | Zetetic LLC | @sjlombardo

Protecting data on device with SQLCipher, Stephen Lombardo

  • Upload
    xamarin

  • View
    1.586

  • Download
    2

Embed Size (px)

Citation preview

Page 1: Protecting data on device with SQLCipher, Stephen Lombardo

Mobile Data EncryptionEnhanced Application Security with SQLCipher

Stephen Lombardo | Zetetic LLC | @sjlombardo

Page 2: Protecting data on device with SQLCipher, Stephen Lombardo

Unique Challenges

Page 3: Protecting data on device with SQLCipher, Stephen Lombardo

Pin CodesShortLow EntropyPredictable

Source: DataGenetics, http://www.datagenetics.com/blog/september32012/

26.83% could be guessed by attempting 20 combinations

Page 4: Protecting data on device with SQLCipher, Stephen Lombardo

Face RecognitionPhoto BypassPoor PerformanceInconvenient

Page 5: Protecting data on device with SQLCipher, Stephen Lombardo

Pattern LockLow EntropySmudge Attacks

See Also: Smudge Attacks on Smartphone Touch Screens ,static.usenix.org/event/woot10/tech/full_papers/Aviv.pdfA

Page 6: Protecting data on device with SQLCipher, Stephen Lombardo

PasswordsInconvenientDictionary BasedFrequently Reused

Source: 10,000 Top Passwords, Mark Burnetthttp://xato.net/passwords/more-top-worst-passwords/

Page 7: Protecting data on device with SQLCipher, Stephen Lombardo

Device EncryptionInconvenientUses Lock Key

Page 8: Protecting data on device with SQLCipher, Stephen Lombardo

Default Insecure

Original photo by Jean-Etienne Poirrier (jepoirrier) on Flickrhttps://secure.flickr.com/photos/30077353@N05/7107568421/

Page 9: Protecting data on device with SQLCipher, Stephen Lombardo

Threat Landscape

•Forensic Analysis•Rooting / Jail breaking•OS Issues• Infrequent Updates•Removable Storage•Cloud Services•Targeted Attacks•Device Sharing

Page 10: Protecting data on device with SQLCipher, Stephen Lombardo

ResponsibilityComplianceCorporateLiabilityGovernment ThreatsRespect

Page 11: Protecting data on device with SQLCipher, Stephen Lombardo

Defense in DepthMake attacks difficult with

multiple layers of security

Page 12: Protecting data on device with SQLCipher, Stephen Lombardo

Principle ofLeast Privilege

Access to device should not allow

access to all apps and data

Page 13: Protecting data on device with SQLCipher, Stephen Lombardo

Data Security

Minimize impact of unauthorized access, on and

off device

Page 14: Protecting data on device with SQLCipher, Stephen Lombardo

Strategies

1. Authentication2. Encryption3. Authenticity

Page 15: Protecting data on device with SQLCipher, Stephen Lombardo

SQLite Extension Full Database EncryptionGood PerformancePortableOpen Source Core

SQLite by D. Richard Hipp, Hwaci, SQLite.org

Page 16: Protecting data on device with SQLCipher, Stephen Lombardo

Features

• AES 256 CBC• Random IVs• Random salt• Key Derivation• MAC• OpenSSL• Fast startup• No size limit

Page 17: Protecting data on device with SQLCipher, Stephen Lombardo

How it WorksPager CodecKey DerivationEncryptionMAC

Database Salt

Encrypted Data

Encrypted Data IVMAC

Encrypted Data

Encrypted Data IVMAC

Encrypted Data

Encrypted Data IVMAC

Page1

Page2

Page3

Page 18: Protecting data on device with SQLCipher, Stephen Lombardo

XamarinDrop-in ReplacementiOS & AndroidComponent StoreFree for EnterpriseTrial Available

Page 19: Protecting data on device with SQLCipher, Stephen Lombardo

Installation

Page 20: Protecting data on device with SQLCipher, Stephen Lombardo

Mono.Data.Sqlcipher

using Mono.Data.Sqlcipher;using(var conn = new SqliteConnection(ConnectionString)){ conn.SetPassword(secret); conn.Open(); using (var cmd = conn.CreateCommand()) { cmd.CommandText = “CREATE TABLE Model(“ + “Id INTEGER PRIMARY KEY AUTOINCREMENT, Content TEXT)"; cmd.ExecuteNonQuery();

cmd.CommandText = "INSERT INTO Model (Content) VALUES (@content)"; var p = cmd.CreateParameter(); p.ParameterName = "@content"; p.Value = content; cmd.Parameters.Add(p);

cmd.CommandText = “SELECT * FROM Model Where Id = 0"; var reader = command.ExecuteReader (); while (reader.Read()) {} }}© The Mono Project

Robert Simpson & SQLite.org

Page 21: Protecting data on device with SQLCipher, Stephen Lombardo

sqlite-net

using SQLite;

public class Model{ [PrimaryKey,AutoIncrement] public int Id { get; set; } public string Content { get; set; }}…using(var conn = new SQLiteConnection (file, secret)){ conn.CreateTable<Model>();

conn.InsertOrReplace( new Model() {Id = 0, Content = content});

var models = conn.Table<Model>().Where(x => x.Id == 0);

models = conn.Query<Model> ( "SELECT * FROM Model WHERE Id = ?", 0);}

© Frank Krueger, Krueger Systemshttps://github.com/praeclarum/sqlite-net

Page 22: Protecting data on device with SQLCipher, Stephen Lombardo

Results

Page 23: Protecting data on device with SQLCipher, Stephen Lombardo

Performance

Page 24: Protecting data on device with SQLCipher, Stephen Lombardo

Advanced

• PRAGMA rekey• PRAGMA cipher• PRAGMA kdf_iter• PRAGMA cipher_page_size• PRAGMA cipher_use_hmac• ATTACH• sqlcipher_export()

Page 25: Protecting data on device with SQLCipher, Stephen Lombardo

FAQ

• Key Management• Lost Credentials• Existing Databases• Compression• Portability• Export

Page 26: Protecting data on device with SQLCipher, Stephen Lombardo

Resources

http://components.xamarin.com/view/sqlcipher-for-android

http://github.com/zeteticllc/sqlcipherapp-xamarin

http://github.com/zeteticllc/sqlcipherspeed-xamarin

http://bis.doc.gov/encryption

http://sqlcipher.net

http://zetetic.net

Page 27: Protecting data on device with SQLCipher, Stephen Lombardo

Q & A

Page 28: Protecting data on device with SQLCipher, Stephen Lombardo

Thank you!Stephen Lombardo | Zetetic LLC | @sjlombardo