Skip to content

Commit

Permalink
Added CA Debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
tfn18001 committed Apr 25, 2022
1 parent b40046e commit 6fdca9d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
11 changes: 11 additions & 0 deletions CTng/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@
"testData/gossiperNetworkTest/1/gossiperCrypto.json"
],
},
{
"name": "Launch CA",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceRoot}/ctng.go",
"args": [
"ca",
"testData/fakeCA/ca1.json"
],
},
{
"name": "Launch testData Gossiper 3",
"type": "go",
Expand Down
1 change: 0 additions & 1 deletion CTng/testData/fakeCA/ca1.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"N": 21807808817028069521693981025854627766849100907464628031386389529795793140445452403979568400586301388102303005688782597096478795543494617476262626637251939091457219474844544584944694111795327351162485025615396615156332890111445956553729344912738727208120229178581403780883051005207097866108991379098981205093118647139047092214048380759204440914928346690315813577955415022365974040592290311683131513649330794291316838007320668201086717296546111828165980835726696797314928836964283576233301855572522559548630195787917554335560790396850488199331707061308922415163250057868060445529850753103153976841020361249662478352377,
"E": 65537
},
"CRVs": [[1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0,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, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0]],
"MRD": 10,
"Day": 1,
"MisbehaviorInterval": 3
Expand Down
20 changes: 13 additions & 7 deletions CTng/testData/fakeCA/fakeCA.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
"github.com/gorilla/mux"
)

var CA_SIZE int

type CAConfig struct {
Signer string
Port string
Expand Down Expand Up @@ -44,13 +46,15 @@ func generateCRVs(CA CAConfig, miss int) gossip.Gossip_object {
// Generate delta CRV and then compress it
first_arr := CA.CRVs[CA.Day] //this assumes we never have CRV of len 0 (fresh CA)
CA.Day += 1
CA.CRVs[CA.Day] = make([]byte, 0, 4096)
CA.CRVs[CA.Day] = make([]byte, CA_SIZE, CA_SIZE)

var delta_crv = make([]byte, 0, len(first_arr))
var delta_crv = make([]byte, CA_SIZE, CA_SIZE)
// Make the dCRV here by randomly flipping Config.NRevoke bits
for i := 0; i < CA.NRevoke; i++ {
change := rand.Intn(len(delta_crv))
delta_crv[change] = ^delta_crv[change]
flip := byte(1)
flip = flip << uint(rand.Intn(8))
delta_crv[change] = flip
}

// creates the new CRV from the old one+dCRV
Expand Down Expand Up @@ -142,6 +146,7 @@ func getCAType() {
// Runs a fake CA server with the ability to act roguely.
func RunCA(configFile string) {
// Global Variable initialization
CA_SIZE = 1024
caType = 1
currentPeriod = 0
request_count = 0
Expand All @@ -159,10 +164,11 @@ func RunCA(configFile string) {
fmt.Println("Error reading config file: ", err)
}

config.CRVs = make([][]byte, 1, 999)
config.CRVs[0] = make([]byte, 0, 4096)
config.Day = 1
getCAType()
config.CRVs = make([][]byte, 999, 999)
config.CRVs[0] = make([]byte, CA_SIZE, CA_SIZE)
config.Day = 0
// getCAType()
caType = 1
// MUX which routes HTTP directories to functions.
gorillaRouter := mux.NewRouter().StrictSlash(true)
gorillaRouter.HandleFunc("/ctng/v2/get-revocation", requestSRH).Methods("GET")
Expand Down

0 comments on commit 6fdca9d

Please sign in to comment.