GithubHelp home page GithubHelp logo

kdihalas / sks Goto Github PK

View Code? Open in Web Editor NEW

This project forked from facebookincubator/sks

0.0 1.0 0.0 94 KB

Secure Key Storage (SKS) is a library for Go that abstracts Security Hardware on laptops.

License: Apache License 2.0

Go 100.00%

sks's Introduction

Secure Key Store

go.dev reference

Secure Key Store (SKS) is a Go library that abstracts the APIs provided by hardware security modules present on most modern day user devices such as TPM and Secure Enclave, allowing users to leverage their features through a single and simple API.

Overview

In today's world, most user devices (such as laptops) are shipped with an embedded hardware security device. Namely Macs come with a SoC called Secure Enclave (SE) while most other manufacturers choose to use an implementation of the Trusted Platform Module (TPM).

These devices share common functionality such as key creation, signing and encryption, however they differ significantly on how they operate and how their APIs are implemented. SKS abstracts these discrepancies and provides users with a simple unified API that allows them to create keys and use them to sign data.

Hardware Support

We currently support the following hardware and platforms:

  • TPM 2.0 on Linux
  • TPM 2.0 on Windows
  • Secure Enclave (T1 and T2 Chipsets) on macOS 10.14 and above

Features and Status

The status of the library is stable beta - it can be used to interact with the hardware but certain features might be missing or the API may change in future releases without prior notice.

The library currently supports the following features:

  • ECDSA P256 key creation.
  • Searching for a key within the hardware.
  • Signing of arbitrary data.
  • Removal of keys from within the hardware.

The following will be implemented at later releases:

  • AWS KMS support as a key store.

Some features do not work due to limitations of the platforms:

  • Use of biometrics is not available on Linux and Windows.
  • Use of key accessibility only when unlocked is not available on Linux and Windows.
  • Key hierarchies are not exposed for TPM although they are used internally.

The API

The library exposes a number of functions for creating and identifying a public/private key pair:

  1. NewKey(label, tag string, useBiometrics, accessibleWhenUnlockedOnly bool) (Key, error) This function generates a public/private key pair in the underlying hardware and returns a structure implementing the Key interface or an error if it occurred. The key is identified by two arbitrary strings the label and the tag. useBiometrics and accessibleWhenUnlockedOnly have no effect on Linux. Currently this produces only ECSDA P256 keys.

  2. FromLabelTag(labelTag string) Key This function constructs a Key identified by label and tag without looking up the key in SKS. The public key of the structure implementing the Key interface is not populated.

The Key interface implements the crypto.Signer interface with some additional functions specific to SKS.

  1. Sign(_ io.Reader, digest []byte, _ crypto.SignerOpts) ([]byte, error) This function searches for the key identified by label and tag and instructs the underlying hardware to sign the arbitrary data - typically the digest of the some larger data set.

  2. Remove() error Try to remove the key from the hardware store. It returns nil or an error if it could not remove the key.

  3. Hash() []byte Returns the SHA1 hash of the public portion of the key.

  4. Label() string Returns the label of the key.

  5. Tag() string Returns the tag of the key.

Example Usage

key := sks.FromLabelTag("label:tag")
signer, _ := sks.NewKey(key.Label(), key.Tag(), false, true)

digest := make([]byte, 32)
rand.Read(digest)

signer.Sign(nil, digest, nil)

signer.Remove()

Note

To use Secure Enclave on Mac, your app must have a registered App ID (com.apple.application-identifier entitlement). For more information, see this thread.

License

SKS is published under the Apache v2.0 License.

sks's People

Contributors

n-canter avatar shapzka avatar slasher- avatar venkyg-sec avatar facebook-github-bot avatar andygeorge avatar u1f35c avatar joaopenteado avatar trynity avatar

Watchers

 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.