- Current IDs
+ My IDs
-
+
Public Key: {{id.pubK}}
-
Private Key: {{id.privK}}
+
Date of creation: {{id.date}}
+
+
+
-
Blind & Send to serverIDsigner
+
+ Not verified
+ Verified
+
+
+ Not signed
+ Signed
+
+
Send to serverIDsigner
+
Verify
diff --git a/clientApp/GUI/views/main/main.js b/clientApp/GUI/views/main/main.js
index 7591b0d..1563896 100755
--- a/clientApp/GUI/views/main/main.js
+++ b/clientApp/GUI/views/main/main.js
@@ -33,8 +33,19 @@ angular.module('app.main', ['ngRoute'])
});
};
- $scope.blindAndVerify = function(pubK) {
- $http.get(clientapi + 'blindandverify/' + pubK)
+ $scope.blindAndSendToSign = function(pubK) {
+ $http.get(clientapi + 'blindandsendtosign/' + pubK)
+ .then(function(data) {
+ console.log('data success');
+ console.log(data);
+ $scope.ids = data.data;
+
+ }, function(data) {
+ console.log('data error');
+ });
+ };
+ $scope.verify = function(pubK) {
+ $http.get(clientapi + 'verify/' + pubK)
.then(function(data) {
console.log('data success');
console.log(data);
diff --git a/clientApp/clientAppRESTFunctions.go b/clientApp/clientAppRESTFunctions.go
index f185390..44208f2 100644
--- a/clientApp/clientAppRESTFunctions.go
+++ b/clientApp/clientAppRESTFunctions.go
@@ -50,7 +50,7 @@ type AskBlindSign struct {
M string `json:"m"`
}
-func BlindAndVerify(w http.ResponseWriter, r *http.Request) {
+func BlindAndSendToSign(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
packPubK := vars["pubK"]
color.Green(packPubK)
@@ -61,9 +61,6 @@ func BlindAndVerify(w http.ResponseWriter, r *http.Request) {
var key ownrsa.RSA
//search for complete key
for _, k := range keys {
- fmt.Println(k.PubK)
- fmt.Println(packPubK)
- fmt.Println("")
if k.PubK == packPubK {
key = ownrsa.UnpackKey(k)
}
@@ -104,10 +101,69 @@ func BlindAndVerify(w http.ResponseWriter, r *http.Request) {
sigma := ownrsa.StringToArrayInt(askBlindSign.M, "_")
fmt.Println(sigma)
+ //get the serverIDsigner pubK
+ serverPubK := getServerPubK("http://" + config.ServerIDSigner.IP + ":" + config.ServerIDSigner.Port)
+
//unblind the response
- //TODO
- //després de la blindsign response, demanar al serverIDsigner la pubK
- //unblinded := ownrsa.Unblind(sigma, rVal, )
+ mSigned := ownrsa.Unblind(sigma, rVal, serverPubK)
+ fmt.Print("mSigned: ")
+ fmt.Println(mSigned)
+
+ verified := ownrsa.Verify(m, mSigned, serverPubK)
+ fmt.Println(verified)
+
+ var iKey int
+ for i, k := range keys {
+ if k.PubK == packPubK {
+ iKey = i
+ //save to k the key updated
+ k.PubKSigned = ownrsa.ArrayIntToString(mSigned, "_")
+ k.Verified = verified
+ }
+ fmt.Println(k)
+ }
+ keys[iKey].PubKSigned = ownrsa.ArrayIntToString(mSigned, "_")
+ keys[iKey].Verified = verified
+ fmt.Println(keys)
+ saveKeys(keys, "keys.json")
+
+ jResp, err := json.Marshal(keys)
+ check(err)
+ fmt.Fprintln(w, string(jResp))
+}
+
+func Verify(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ packPubK := vars["pubK"]
+ color.Green(packPubK)
+
+ //read the keys stored in /keys directory
+ keys := readKeys("keys.json")
+
+ var key ownrsa.PackRSA
+ //search for complete key
+ for _, k := range keys {
+ if k.PubK == packPubK {
+ key = k
+ }
+ }
+
+ //get the serverIDsigner pubK
+ serverPubK := getServerPubK("http://" + config.ServerIDSigner.IP + ":" + config.ServerIDSigner.Port)
+ m := ownrsa.StringToArrayInt(key.PubK, "_")
+ mSigned := ownrsa.StringToArrayInt(key.PubKSigned, "_")
+
+ verified := ownrsa.Verify(m, mSigned, serverPubK)
+ fmt.Println(verified)
+
+ for _, k := range keys {
+ if k.PubK == packPubK {
+ //save to k the key updated
+ k.PubKSigned = ownrsa.ArrayIntToString(mSigned, "_")
+ k.Verified = verified
+ }
+ }
+ saveKeys(keys, "keys.json")
jResp, err := json.Marshal(keys)
check(err)
diff --git a/clientApp/keys.go b/clientApp/keys.go
index a5483ff..5d6b1f4 100644
--- a/clientApp/keys.go
+++ b/clientApp/keys.go
@@ -2,9 +2,12 @@ package main
import (
"encoding/json"
+ "fmt"
"io/ioutil"
+ "net/http"
ownrsa "./ownrsa"
+ "github.com/fatih/color"
)
func readKeys(path string) []ownrsa.PackRSA {
@@ -24,3 +27,21 @@ func saveKeys(keys []ownrsa.PackRSA, path string) {
err = ioutil.WriteFile(path, jsonKeys, 0644)
check(err)
}
+
+func getServerPubK(url string) ownrsa.RSAPublicKey {
+ r, err := http.Get(url + "/")
+ check(err)
+ fmt.Println(r)
+
+ decoder := json.NewDecoder(r.Body)
+ //var sigmaString string
+ var pubK ownrsa.RSAPublicKey
+ err = decoder.Decode(&pubK)
+ if err != nil {
+ panic(err)
+ }
+ defer r.Body.Close()
+ color.Blue("received server pubK:")
+ fmt.Println(pubK)
+ return pubK
+}
diff --git a/clientApp/ownrsa/rsa.go b/clientApp/ownrsa/rsa.go
index 86c28e5..1e18627 100644
--- a/clientApp/ownrsa/rsa.go
+++ b/clientApp/ownrsa/rsa.go
@@ -33,6 +33,7 @@ type PackRSA struct {
PrivK string `json:"privK"`
Date time.Time `json:"date"`
PubKSigned string `json:"pubKSigned"`
+ Verified bool `json:"verified"`
}
const maxPrime = 500
diff --git a/clientApp/restRoutes.go b/clientApp/restRoutes.go
index 6cff6c7..9be9448 100755
--- a/clientApp/restRoutes.go
+++ b/clientApp/restRoutes.go
@@ -22,9 +22,15 @@ var routes = Routes{
NewID,
},
Route{
- "BlindAndVerify",
+ "BlindAndSendToSign",
"GET",
- "/blindandverify/{pubK}",
- BlindAndVerify,
+ "/blindandsendtosign/{pubK}",
+ BlindAndSendToSign,
+ },
+ Route{
+ "Verify",
+ "GET",
+ "/verify/{pubK}",
+ Verify,
},
}
diff --git a/documentation/screenshot01.png b/documentation/screenshot01.png
new file mode 100644
index 0000000..1ed6847
Binary files /dev/null and b/documentation/screenshot01.png differ
diff --git a/documentation/screenshot02.png b/documentation/screenshot02.png
new file mode 100644
index 0000000..e81b4b3
Binary files /dev/null and b/documentation/screenshot02.png differ
diff --git a/serverIDsigner/userRESTFunctions.go b/serverIDsigner/userRESTFunctions.go
index cacb803..29fea4c 100644
--- a/serverIDsigner/userRESTFunctions.go
+++ b/serverIDsigner/userRESTFunctions.go
@@ -22,7 +22,12 @@ type User struct {
func Index(w http.ResponseWriter, r *http.Request) {
//TODO return the public key, to allow others verifign signed strings by this server
- fmt.Fprintln(w, "serverIDsigner")
+
+ jResp, err := json.Marshal(serverRSA.PubK)
+ if err != nil {
+ panic(err)
+ }
+ fmt.Fprintln(w, string(jResp))
}
func Signup(w http.ResponseWriter, r *http.Request) {