summaryrefslogtreecommitdiff
path: root/workers/workers.go
diff options
context:
space:
mode:
authorAleksander Mistewicz <a.mistewicz@samsung.com>2018-06-12 10:42:30 +0200
committerAleksander Mistewicz <a.mistewicz@samsung.com>2018-08-03 13:36:41 +0200
commit2a8a63489b6435f0e4970176472a509170719f9c (patch)
tree68dca4bd1a4f44c4c7a4641e9e39b541c9419102 /workers/workers.go
parent5fa76614610cf135171ed329f42ed173352af1e3 (diff)
downloadboruta-2a8a63489b6435f0e4970176472a509170719f9c.tar.gz
boruta-2a8a63489b6435f0e4970176472a509170719f9c.tar.bz2
boruta-2a8a63489b6435f0e4970176472a509170719f9c.zip
Install public key on dryad
This patch changes interface and communication between boruta server and dryads. Key is generated on boruta server, public part is installed on dryad and private part is stored internally. It is a preparation for using user's public keys provided by an external service. Change-Id: Ic6fb087aba02553c6b2b8f7cc13cc6bd67eff36a Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
Diffstat (limited to 'workers/workers.go')
-rw-r--r--workers/workers.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/workers/workers.go b/workers/workers.go
index da22336..b77a01a 100644
--- a/workers/workers.go
+++ b/workers/workers.go
@@ -18,6 +18,7 @@
package workers
import (
+ "crypto/rand"
"crypto/rsa"
"fmt"
"math"
@@ -31,6 +32,10 @@ import (
// UUID denotes a key in Capabilities where WorkerUUID is stored.
const UUID string = "UUID"
+// sizeRSA is a length of the RSA key.
+// It is a variable for test purposes.
+var sizeRSA = 4096
+
// mapWorker is used by WorkerList to store all
// (public and private) structures representing Worker.
type mapWorker struct {
@@ -440,8 +445,7 @@ func (wl *WorkerList) setState(worker WorkerUUID, state WorkerState) error {
return nil
}
-// prepareKey delegates key generation to Dryad and sets up generated key in the
-// worker. In case of any failure it returns an error.
+// prepareKey generates key, installs public part on worker and stores private part in WorkerList.
func (wl *WorkerList) prepareKey(worker WorkerUUID) error {
addr, err := wl.GetWorkerAddr(worker)
if err != nil {
@@ -453,7 +457,11 @@ func (wl *WorkerList) prepareKey(worker WorkerUUID) error {
return err
}
defer client.Close()
- key, err := client.Prepare()
+ key, err := rsa.GenerateKey(rand.Reader, sizeRSA)
+ if err != nil {
+ return err
+ }
+ err = client.Prepare(&key.PublicKey)
if err != nil {
return err
}