started to implement clientApp (Go + Electron(with Angularjs))

This commit is contained in:
arnaucode
2017-12-27 20:25:03 +01:00
parent 92462dc3db
commit 91dc63ed96
36 changed files with 1102 additions and 6 deletions

View File

@@ -15,7 +15,7 @@ import (
var userCollection *mgo.Collection
var serverRsa ownrsa.RSA
var serverRSA ownrsa.RSA
func main() {
color.Blue("Starting serverIDsigner")
@@ -26,11 +26,11 @@ func main() {
initializeToken()
//initialize RSA
serverRsa = ownrsa.GenerateKeyPair()
serverRSA = ownrsa.GenerateKeyPair()
color.Blue("Public Key:")
fmt.Println(serverRsa.PubK)
fmt.Println(serverRSA.PubK)
color.Green("Private Key:")
fmt.Println(serverRsa.PrivK)
fmt.Println(serverRSA.PrivK)
//mongodb
session, err := getSession()

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"math/big"
"math/rand"
"strings"
"time"
)
@@ -181,3 +182,28 @@ func PubKStringToBigInt(kS RSAPublicKeyString) (RSAPublicKey, error) {
}
return k, nil
}
type PackRSA struct {
PubK string `json:"pubK"`
PrivK string `json:"privK"`
}
func PackKey(k RSA) PackRSA {
var p PackRSA
p.PubK = k.PubK.E.String() + "," + k.PubK.N.String()
p.PrivK = k.PrivK.D.String() + "," + k.PrivK.N.String()
return p
}
func UnpackKey(p PackRSA) RSA {
var k RSA
var ok bool
k.PubK.E, ok = new(big.Int).SetString(strings.Split(p.PubK, ",")[0], 10)
k.PubK.N, ok = new(big.Int).SetString(strings.Split(p.PubK, ",")[1], 10)
k.PrivK.D, ok = new(big.Int).SetString(strings.Split(p.PrivK, ",")[0], 10)
k.PrivK.N, ok = new(big.Int).SetString(strings.Split(p.PrivK, ",")[1], 10)
if !ok {
fmt.Println("error on Unpacking Keys")
}
return k
}

View File

@@ -125,7 +125,7 @@ func BlindSign(w http.ResponseWriter, r *http.Request) {
m = append(m, int(byte))
}
sigma := ownrsa.BlindSign(m, askBlindSign.PubK, serverRsa.PrivK) //here the privK will be the CA privK, not the m emmiter's one. The pubK is the user's one
sigma := ownrsa.BlindSign(m, askBlindSign.PubK, serverRSA.PrivK) //here the privK will be the CA privK, not the m emmiter's one. The pubK is the user's one
fmt.Print("Sigma': ")
fmt.Println(sigma)
@@ -164,7 +164,7 @@ func VerifySign(w http.ResponseWriter, r *http.Request) {
mSignedInts = append(mSignedInts, i)
}
verified := ownrsa.Verify(mOriginal, mSignedInts, serverRsa.PubK)
verified := ownrsa.Verify(mOriginal, mSignedInts, serverRSA.PubK)
fmt.Fprintln(w, verified)
}