diff --git a/CTng/gossip/gossip_object.go b/CTng/gossip/gossip_object.go index 4b34f9d..3d2e47e 100644 --- a/CTng/gossip/gossip_object.go +++ b/CTng/gossip/gossip_object.go @@ -53,57 +53,54 @@ func unpack_object(obj []byte) (depacked Gossip_object) { } //verify gossip pom takes a gossip object as input +// Note: This function is not yet working. func Verify_gossip_pom(g Gossip_object, c *crypto.CryptoConfig) error { if g.Type == GOSSIP_POM { + // Assume true for now. + return nil //gossip pom refers to Pom generated due to conflicting information //From Finn's gossiper design, gossip poms are defaulted to have 2 non empty fields for signature and paypload var err1, err2 error - if g.Signature[1] != "" && g.Payload[1] != "" { - if g.Signature[0] != g.Signature[1] { - //that means there are conflicting information - //the PoM is valid and the verification went through. + if g.Signature[0] != g.Signature[1] { + //that means there are conflicting information + //the PoM is valid and the verification went through. - // Next we need to figure out what type of signature is being used. - // First: try ThresholdSignature - thresSig1, sigerr1 := crypto.ThresholdSigFromString(g.Signature[0]) - thresSig2, sigerr2 := crypto.ThresholdSigFromString(g.Signature[1]) - // Verify the signatures were made successfully - if sigerr1 != nil || sigerr2 != nil && thresSig1.Sign != thresSig2.Sign { - err1 = c.ThresholdVerify(g.Payload[0], thresSig1) - err2 = c.ThresholdVerify(g.Payload[1], thresSig2) + // Next we need to figure out what type of signature is being used. + // First: try ThresholdSignature + thresSig1, sigerr1 := crypto.ThresholdSigFromString(g.Signature[0]) + thresSig2, sigerr2 := crypto.ThresholdSigFromString(g.Signature[1]) + // Verify the signatures were made successfully + if sigerr1 != nil || sigerr2 != nil && thresSig1.Sign != thresSig2.Sign { + err1 = c.ThresholdVerify(g.Payload[0], thresSig1) + err2 = c.ThresholdVerify(g.Payload[1], thresSig2) + } else { + // Second: try SigFragment + fragsig1, sigerr1 := crypto.SigFragmentFromString(g.Signature[0]) + fragsig2, sigerr2 := crypto.SigFragmentFromString(g.Signature[1]) + // Verify the signatures were made successfully + if sigerr1 != nil || sigerr2 != nil && !fragsig1.Sign.IsEqual(fragsig2.Sign) { + err1 = c.FragmentVerify(g.Payload[0], fragsig1) + err2 = c.FragmentVerify(g.Payload[1], fragsig2) } else { - // Second: try SigFragment - fragsig1, sigerr1 := crypto.SigFragmentFromString(g.Signature[0]) - fragsig2, sigerr2 := crypto.SigFragmentFromString(g.Signature[1]) + // Try RSASig + rsaSig1, sigerr1 := crypto.RSASigFromString(g.Signature[0]) + rsaSig2, sigerr2 := crypto.RSASigFromString(g.Signature[1]) // Verify the signatures were made successfully - if sigerr1 != nil || sigerr2 != nil && !fragsig1.Sign.IsEqual(fragsig2.Sign) { - err1 = c.FragmentVerify(g.Payload[0], fragsig1) - err2 = c.FragmentVerify(g.Payload[1], fragsig2) - } else { - // Try RSASig - rsaSig1, sigerr1 := crypto.RSASigFromString(g.Signature[0]) - rsaSig2, sigerr2 := crypto.RSASigFromString(g.Signature[1]) - // Verify the signatures were made successfully - if sigerr1 != nil || sigerr2 != nil { - err1 = c.Verify([]byte(g.Payload[0]), rsaSig1) - err2 = c.Verify([]byte(g.Payload[1]), rsaSig2) - } + if sigerr1 != nil || sigerr2 != nil { + err1 = c.Verify([]byte(g.Payload[0]), rsaSig1) + err2 = c.Verify([]byte(g.Payload[1]), rsaSig2) } } - if err1 == nil && err2 == nil { - return nil - } else { - return errors.New("Message Signature Mismatch" + fmt.Sprint(sigerr1) + fmt.Sprint(sigerr2)) - } + } + if err1 == nil && err2 == nil { + return nil } else { - //if signatures are the same, there are no conflicting information - return errors.New("This is not a valid gossip pom") + return errors.New("Message Signature Mismatch" + fmt.Sprint(sigerr1) + fmt.Sprint(sigerr2)) } } else { - //type mislabeled - return errors.New("Gossip object label Mismatch") + //if signatures are the same, there are no conflicting information + return errors.New("This is not a valid gossip pom") } - } return errors.New("the input is not an gossip pom") } diff --git a/CTng/gossip/process_object.go b/CTng/gossip/process_object.go index cfb6d04..b15d21a 100644 --- a/CTng/gossip/process_object.go +++ b/CTng/gossip/process_object.go @@ -91,7 +91,6 @@ func ProcessAccusation(c *GossiperContext, acc Gossip_object) { fmt.Println(util.RED+"Generated POM for", acc.Payload[0], util.RESET) c.StoreObject(*pom) c.HasPom[acc.Payload[0]] = true - // We do not currently gossip PoMs. SendToOwner(c, *pom) } } diff --git a/CTng/monitor/monitor.go b/CTng/monitor/monitor.go index 43fdc33..f5c1660 100644 --- a/CTng/monitor/monitor.go +++ b/CTng/monitor/monitor.go @@ -26,7 +26,7 @@ func QueryLoggers(c *MonitorContext) { sthResp, err := http.Get(PROTOCOL + logger + "/ctng/v2/get-sth/") if err != nil { log.Println(err) - // AccuseEntity(c, logger) + AccuseEntity(c, logger) continue } @@ -35,13 +35,13 @@ func QueryLoggers(c *MonitorContext) { err = json.Unmarshal(sthBody, &STH) if err != nil { log.Println(util.RED+err.Error(), util.RESET) - // AccuseEntity(c, logger) + AccuseEntity(c, logger) continue } err = STH.Verify(c.Config.Crypto) if err != nil { log.Println(util.RED+"STH signature verification failed", err.Error(), util.RESET) - // AccuseEntity(c, logger) + AccuseEntity(c, logger) } else { Process_valid_object(c, STH) } diff --git a/CTng/monitor/monitor_process.go b/CTng/monitor/monitor_process.go index a591b1a..51afe81 100644 --- a/CTng/monitor/monitor_process.go +++ b/CTng/monitor/monitor_process.go @@ -14,7 +14,6 @@ func Process_valid_object(c *MonitorContext, g gossip.Gossip_object) { if IsLogger(c, g.Signer) && g.Type == gossip.STH { Send_to_gossiper(c, g) f := func() { - fmt.Println(util.BLUE, "Signing Revocation of", g.Signer, util.RESET) sig_frag, err := c.Config.Crypto.ThresholdSign(g.Payload[0]) if err != nil { fmt.Println(err.Error()) @@ -22,14 +21,17 @@ func Process_valid_object(c *MonitorContext, g gossip.Gossip_object) { pom_err := Check_entity_pom(c, g.Signer) //if there is no conflicting information/PoM send the Threshold signed version to the gossiper if pom_err == false { + fmt.Println(util.BLUE, "Signing Revocation of", g.Signer, util.RESET) g.Type = gossip.STH_FRAG g.Signature[0] = sig_frag.String() g.Signer = c.Config.Crypto.SelfID.String() Send_to_gossiper(c, g) + } else { + fmt.Println(util.RED, "Conflicting information/PoM found, not sending STH_FRAG", util.RESET) } } - time.AfterFunc(time.Duration(c.Config.Public.Gossip_wait_time), f) + time.AfterFunc(time.Duration(c.Config.Public.Gossip_wait_time)*time.Second, f) return } //if the object is from a CA, revocation information diff --git a/CTng/server/Monitor_server.go b/CTng/server/Monitor_server.go index 1cdc256..729b102 100644 --- a/CTng/server/Monitor_server.go +++ b/CTng/server/Monitor_server.go @@ -3,6 +3,7 @@ package server import ( "CTng/gossip" "CTng/monitor" + "CTng/util" "encoding/json" "fmt" "io/ioutil" @@ -143,7 +144,7 @@ func handle_gossip(c *monitor.MonitorContext, w http.ResponseWriter, r *http.Req // Verify the object is valid. err = gossip_obj.Verify(c.Config.Crypto) if err != nil { - fmt.Println("Recieved invalid object from " + getSenderURL(r) + ".") + fmt.Println(util.RED+"Recieved invalid object from "+getSenderURL(r)+".", util.RESET) monitor.AccuseEntity(c, gossip_obj.Signer) http.Error(w, err.Error(), http.StatusOK) return diff --git a/CTng/testData/monitorNetworkTest/2/monitor_priv_config.json b/CTng/testData/monitorNetworkTest/2/monitor_priv_config.json index 4e161ba..0c9ea03 100644 --- a/CTng/testData/monitorNetworkTest/2/monitor_priv_config.json +++ b/CTng/testData/monitorNetworkTest/2/monitor_priv_config.json @@ -1,6 +1,6 @@ { "Crypto_config_path": "testData/monitorNetworkTest/2/monitorCrypto.json", - "CA_URLs": ["localhost:9101", "localhost:9102"], + "CA_URLs": ["localhost:9102"], "Logger_URLs": ["localhost:9001", "localhost:9002"], "Gossiper_URL": "localhost:8081", "Port": "8181" diff --git a/CTng/testData/monitorNetworkTest/3/monitor_priv_config.json b/CTng/testData/monitorNetworkTest/3/monitor_priv_config.json index da2b49a..3b5240f 100644 --- a/CTng/testData/monitorNetworkTest/3/monitor_priv_config.json +++ b/CTng/testData/monitorNetworkTest/3/monitor_priv_config.json @@ -1,7 +1,7 @@ { "Crypto_config_path": "testData/monitorNetworkTest/3/monitorCrypto.json", - "CA_URLs": ["localhost:9102", "localhost:9103"], - "Logger_URLs": ["localhost:9002", "localhost:9003"], + "CA_URLs": ["localhost:9100", "localhost:9102"], + "Logger_URLs": ["localhost:9000", "localhost:9002"], "Gossiper_URL": "localhost:8082", "Port": "8182" } \ No newline at end of file diff --git a/CTng/testData/monitorNetworkTest/4/monitor_priv_config.json b/CTng/testData/monitorNetworkTest/4/monitor_priv_config.json index c32826c..f4394c8 100644 --- a/CTng/testData/monitorNetworkTest/4/monitor_priv_config.json +++ b/CTng/testData/monitorNetworkTest/4/monitor_priv_config.json @@ -1,6 +1,6 @@ { "Crypto_config_path": "testData/monitorNetworkTest/4/monitorCrypto.json", - "CA_URLs": ["localhost:9100", "localhost:9101"], + "CA_URLs": ["localhost:9102", "localhost:9101"], "Logger_URLs": ["localhost:9001"], "Gossiper_URL": "localhost:8083", "Port": "8183"