From e90713a370ddd5669a453fd519f89ca69767d857 Mon Sep 17 00:00:00 2001 From: Brendan Mc Date: Sat, 11 Apr 2015 01:25:50 -0700 Subject: [PATCH] Cleaned up; Patched identity point & invalid curve attacks.. - Update README.md - Set read-only and write-only channels. - Reorganized code. - Set Content-Type and HSTS on index - House keeping in ecdh.go and symcrypt.go - Fixed bug; user changes weren't being saved. --- README.md | 15 +++++++------ ecdh/ecdh.go | 12 +++------- index.html | 18 +++++++-------- passvault/passvault.go | 6 ++--- redoctober.go | 51 ++++++++++++++++++++++++++++-------------- symcrypt/symcrypt.go | 3 +-- 6 files changed, 58 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index 9575b0b..da0e27d 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ secure) way is to skip the [Certificate Authority](https://en.wikipedia.org/wiki/Certificate_authority#Issuing_a_certificate) verification and generate a self-signed TLS certificate. Read this [detailed guide](http://www.akadia.com/services/ssh_test_certificate.html) -or, alternatively, follow these unsecure commands: +or, alternatively, follow these insecure commands: $ mkdir cert $ chmod 700 cert @@ -152,11 +152,11 @@ server. Example query: - $ echo "Why is a raven like a writing desk?"|python -c "print raw_input().encode('base64')" - V2h5IGlzIGEgcmF2ZW4gbGlrZSBhIHdyaXRpbmcgZGVzaz8= + $ echo "Why is a raven like a writing desk?" | openssl base64 + V2h5IGlzIGEgcmF2ZW4gbGlrZSBhIHdyaXRpbmcgZGVzaz8K $ curl --cacert cert/server.crt https://localhost:8080/encrypt \ - -d '{"Name":"Alice","Password":"Lewis","Minimum":2, "Owners":["Alice","Bill","Cat","Dodo"],"Data":"V2h5IGlzIGEgcmF2ZW4gbGlrZSBhIHdyaXRpbmcgZGVzaz8="}' + -d '{"Name":"Alice","Password":"Lewis","Minimum":2, "Owners":["Alice","Bill","Cat","Dodo"],"Data":"V2h5IGlzIGEgcmF2ZW4gbGlrZSBhIHdyaXRpbmcgZGVzaz8K"}' {"Status":"ok","Response":"eyJWZXJzaW9uIj...NSSllzPSJ9"} The data expansion is not tied to the size of the input. @@ -165,13 +165,14 @@ The data expansion is not tied to the size of the input. Decrypt allows an admin to decrypt a piece of data. As long as "Minimum" number users from the set of "Owners" have delegated their -keys to the server, the clear data will be returned. +keys to the server, a base64 encoded object with the clear data and the +set of "Owners" whose private keys were used is returned. Example query: $ curl --cacert cert/server.crt https://localhost:8080/decrypt \ - -d {"Name":"Alice","Password":"Lewis","Data":"eyJWZXJzaW9uIj...NSSllzPSJ9"} - {"Status":"ok","Response":"V2h5IGlzIGEgcmF2ZW4gbGlrZSBhIHdyaXRpbmcgZGVzaz8="} + -d '{"Name":"Alice","Password":"Lewis","Data":"eyJWZXJzaW9uIj...NSSllzPSJ9"}' + {"Status":"ok","Response":"eyJEYXRhI...FuMiJdfQ=="} If there aren't enough keys delegated you'll see: diff --git a/ecdh/ecdh.go b/ecdh/ecdh.go index 0b2f15f..77b09a2 100644 --- a/ecdh/ecdh.go +++ b/ecdh/ecdh.go @@ -19,13 +19,6 @@ import ( var Curve = elliptic.P256 -func zero(in []byte) { - inLen := len(in) - for i := 0; i < inLen; i++ { - in[i] ^= in[i] - } -} - // Encrypt secures and authenticates its input using the public key // using ECDHE with AES-128-CBC-HMAC-SHA1. func Encrypt(pub *ecdsa.PublicKey, in []byte) (out []byte, err error) { @@ -63,7 +56,7 @@ func Encrypt(pub *ecdsa.PublicKey, in []byte) (out []byte, err error) { return } -// Decrypt authentications and recovers the original message from +// Decrypt authenticates and recovers the original message from // its input using the private key and the ephemeral key included in // the message. func Decrypt(priv *ecdsa.PrivateKey, in []byte) (out []byte, err error) { @@ -75,7 +68,8 @@ func Decrypt(priv *ecdsa.PrivateKey, in []byte) (out []byte, err error) { } x, y := elliptic.Unmarshal(Curve(), ephPub) - if x == nil { + ok := Curve().IsOnCurve(x, y) // Rejects the identity point too. + if x == nil || !ok { return nil, errors.New("Invalid public key") } diff --git a/index.html b/index.html index 9360cc4..c3812be 100644 --- a/index.html +++ b/index.html @@ -9,12 +9,11 @@ -