Skip to content

Commit

Permalink
fakeCA helping Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tfn18001 committed Apr 25, 2022
1 parent c59b43f commit b1b6651
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CTng/GZip/Decode.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package GZIP64
package GZip

//go-gzipb64 Github Repo

Expand Down
2 changes: 1 addition & 1 deletion CTng/GZip/GZipDecomp.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package GZIP64
package GZip

import (
"bytes"
Expand Down
2 changes: 1 addition & 1 deletion CTng/GZip/GZipbyte.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"compress/gzip"
)

func compress(input []byte) []byte {
func Compress(input []byte) []byte {
var buf bytes.Buffer
compr := gzip.NewWriter(&buf)
compr.Write(input)
Expand Down
15 changes: 8 additions & 7 deletions CTng/testData/fakeCA/fakeCA.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fakeCA

import (
"CTng/GZip"
"CTng/crypto"
"CTng/gossip"
"CTng/util"
Expand Down Expand Up @@ -45,7 +46,7 @@ func generateCRVs(CA CAConfig) gossip.Gossip_object {
delta_crv[i] = e & sec_arr[i]
} //this is scuffed/slow for giant CRVs O(n), also I am assuming CRVs are same size, can modify for different sizes

delta_crv = GZip.compress(delta_crv) //should work...
delta_crv = GZip.Compress(delta_crv) //should work...

REV := Revocation{
SRH: CA.Signer,
Expand All @@ -67,6 +68,8 @@ func generateCRVs(CA CAConfig) gossip.Gossip_object {
}

func periodicTasks() {
// Queue the next tasks to occur at next MRD.
time.AfterFunc(time.Duration(config.MRD)*time.Second, periodicTasks)
// Generate CRV and SRH
fmt.Println("Running Tasks")
Rev1 := generateCRVs(config)
Expand All @@ -75,8 +78,6 @@ func periodicTasks() {
SRHs = append(SRHs, Rev1)
fakeSRHs = append(fakeSRHs, fakeRev1)
currentPeriod++
// Queue the next tasks to occur at next MRD.
time.AfterFunc(time.Duration(config.MRD)*time.Second, periodicTasks)
}

//I'm up to here right now, messaged on discord just to make sure I'm on a good path
Expand Down Expand Up @@ -104,10 +105,10 @@ func RunCA(configFile string) {

currentPeriod = 0
request_count = 0
STHS = make([]gossip.Gossip_object, 0, 20)
fakeSTHs = make([]gossip.Gossip_object, 0, 20)
SRHs = make([]gossip.Gossip_object, 0, 20)
fakeSRHs = make([]gossip.Gossip_object, 0, 20)
// Read the config file
config = LoggerConfig{}
config = CAConfig{}
configBytes, err := util.ReadByte(configFile)
if err != nil {
fmt.Println("Error reading config file: ", err)
Expand All @@ -120,7 +121,7 @@ func RunCA(configFile string) {
getLoggerType()
// MUX which routes HTTP directories to functions.
gorillaRouter := mux.NewRouter().StrictSlash(true)
gorillaRouter.HandleFunc("/ctng/v2/get-sth", requestSTH).Methods("GET")
gorillaRouter.HandleFunc("/ctng/v2/get-revocation", requestSTH).Methods("GET")
http.Handle("/", gorillaRouter)
fmt.Println("Listening on port", config.Port)
go periodicTasks()
Expand Down
4 changes: 2 additions & 2 deletions CTng/testData/fakeLogger/fakeLogger.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ func generateSTH(loggerType int) gossip.Gossip_object {
}

func periodicTasks() {
// Queue the next tasks to occur at next MMD.
time.AfterFunc(time.Duration(config.MMD)*time.Second, periodicTasks)
// Generate STH and FakeSTH
fmt.Println("Running Tasks")
sth1 := generateSTH(loggerType)
Expand All @@ -67,8 +69,6 @@ func periodicTasks() {
STHS = append(STHS, sth1)
fakeSTHs = append(fakeSTHs, fakeSTH1)
currentPeriod++
// Queue the next tasks to occur at next MMD.
time.AfterFunc(time.Duration(config.MMD)*time.Second, periodicTasks)
}

func requestSTH(w http.ResponseWriter, r *http.Request) {
Expand Down
2 changes: 1 addition & 1 deletion CTng/testData/fakeLogger/logger1.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
"E": 65537
},
"MMD": 10,
"MisbehaviorInterval": 3
"MisbehaviorInterval": 1
}

0 comments on commit b1b6651

Please sign in to comment.