Giter VIP home page Giter VIP logo

security-workshop-sample's Introduction

Secrets Keeper

Secrets Keeper is a simple secure application that uses Android Key Store API, Fingerprint API and Confirm Credentials API to keep your secrets in safe.

Note. This project is work in progress. Design, Workflow and end Goals can be changed during development.

Environment setup

To be able to build this project on your local machine, please follow the below instructions:

  • Download and install latest Android Studio 3.0
  • Download and install all dependencies that Gradle ask's you to
  • Download and install Android Virtual Device(AVD) with API 23, using build in Android Virtual Device Manager from Android Studio
  • To cover compatibility issues and support newest features, probably, you will also need to install AVD API 18 and AVD API 24+

Technologies Stack

  • Android 18+
  • Kotlin
  • AndroidKeyStore API
  • Fingerprint API
  • Confirm Credentials API
  • Safety Net API

Goals

  • Build application based on Android Fingerprint Sample
  • Use JCA to show how to use encryption in Android
  • Use encryption to protect secrets
  • Use fingerprint get access to protected secrets
  • Use confirm credentials to protect application overall
  • Keep it simple

Launch Workflow

Security Code Snippets

  • Create KeyStoreinstance and prepare it for working using AndroidKeyStore provider:
val keyStore = KeyStore.getInstance("AndroidKeyStore")
keyStore.load(null)
  • Get information about keys currently existed in keystore:
// Define data class to store key info
data class KeyData(val alias: String, val creationDate: Date)
val keyData = keyStore.aliases().toList().map { KeyData(it, keyStore.getCreationDate(it)) }
  • Prepare KeyGenerator instance for generating and saving AES symmetric keys using AndroidKeyStore provider:
val generator = KeyGenerator.getInstance(algorithm, "AndroidKeyStore")


val builder = KeyGenParameterSpec.Builder(alias, KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT)
                .setBlockModes(KeyProperties.BLOCK_MODE_CBC)
                .setUserAuthenticationRequired(userAuthenticationRequired)
                .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_PKCS7)
                .setInvalidatedByBiometricEnrollment(invalidatedByBiometricEnrollment)

generator?.init(builder.build())

// This will create and save key to KeyStore
val key = keyGenerator?.generateKey()
  • Prepare KeyPairGenerator instance for generating and saving RSA asymmetric key pairs using AndroidKeyStore provider:
val generator = KeyPairGenerator.getInstance(keyProps.mKeyType, provider);

val startDate = Calendar.getInstance()
val endDate = Calendar.getInstance()
endDate.add(Calendar.YEAR, 20)

val builder = KeyGenParameterSpec.Builder(alias, KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT)
                .setCertificateSerialNumber(BigInteger.ONE)
                .setCertificateSubject(X500Principal("CN=${alias} CA Certificate"))
                .setCertificateNotBefore(startDate.time)
                .setCertificateNotAfter(endDate.time)
                .setBlockModes(KeyProperties.BLOCK_MODE_ECB)
                .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_RSA_PKCS1)

generator.initialize(generator.build())

// This will create and save key to KeyStore
val keyPair = generator?.generateKeyPair()

Resources

Kotlin

Cryptography

Fingerprint & Credentials API

Key Attestation

security-workshop-sample's People

Contributors

yakivmospan avatar latemic avatar

Watchers

James Cloos avatar Denys Mokhrin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.