Decrypt returns the list of users used for delegation

When decrypting a chunk of data, red october will now report the users
whose keys were used in the decryption.
This commit is contained in:
Kyle Isom
2014-09-10 09:22:04 -07:00
committed by Kyle
parent 886bd0d623
commit 91cd67f267
5 changed files with 69 additions and 20 deletions

View File

@@ -8,10 +8,11 @@ import (
"encoding/json"
"errors"
"fmt"
"log"
"github.com/cloudflare/redoctober/cryptor"
"github.com/cloudflare/redoctober/keycache"
"github.com/cloudflare/redoctober/passvault"
"log"
)
// Each of these structures corresponds to the JSON expected on the
@@ -60,6 +61,11 @@ type decrypt struct {
Data []byte
}
type decryptWithDelegates struct {
Data []byte
Delegates []string
}
type modify struct {
Name string
Password string
@@ -283,13 +289,23 @@ func Decrypt(jsonIn []byte) ([]byte, error) {
return jsonStatusError(err)
}
resp, err := cryptor.Decrypt(s.Data)
data, names, err := cryptor.Decrypt(s.Data)
if err != nil {
log.Println("Error decrypting:", err)
return jsonStatusError(err)
}
return jsonResponse(resp)
resp := &decryptWithDelegates{
Data: data,
Delegates: names,
}
out, err := json.Marshal(resp)
if err != nil {
return jsonStatusError(err)
}
return jsonResponse(out)
}
// Modify processes a modify request.