Giter Club home page Giter Club logo

kms-envelope-encryption-aws's Introduction

kms-envelope-encryption-aws

Envelope Encryption with Amazon KMS and Node

Concepts

  • Customer Master Keys (AWS term) (CMKs): Per platform keys eg. {dev|staging|prod}
  • Tenant Master Keys (TMKs): Per customer keys eg. {customer1|customer2|customer3}
  • Tenant Data Keys (TDKs): Per datasource eq. {column within database|RDS database|S3 Bucket,}

Demo

NB: Requires KMS ARN to be the specified environment var CMKID

export CMKID=arn:aws:kms:{yourregion}:{youraccount}:key/{yourkeyId}
npm run demo

Demo will show input of plain text this is a secret being enctypyred using the TMK TDK key.

The resultant encrypted envelope values of [cmkId, tmkCipherText, tdkCipherText, dataCipherText, createdAt] can all at this point be serialized and stored into your data store of choice.

  1. Create AWS credentials
  2. Create a KMS (CMK) key that you can generate the ciphertext TMK and TDK with. Add the resultant ARN of the key you’d like to use to the CMKID environment variable (either inline to the command or by exporting).
  3. Ensure AWS IAM policy will allow KMS access from laptop
  4. Define the AWSREGION environment variable (default is us-west-2)
  5. Output should look like this - kinda
Plaintext data: this is a secret

Encrypted Envelope:
cmkId:    
tmkCipherText:  
tdkCipherText:
dataCipherText:
createdAt:      

Decrypted Envelope:
cmkId:       
dataPlainText: this is a secret
decryptedAt:   

Tests

npm test

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.