diff --git a/CTng/testData/fakeCA/ca1.json b/CTng/testData/fakeCA/ca1.json index 0a7a037..d7b11fd 100644 --- a/CTng/testData/fakeCA/ca1.json +++ b/CTng/testData/fakeCA/ca1.json @@ -1,6 +1,7 @@ { "Signer": "localhost:9100", "Port": "9100", + "NRevoke": 5, "Private": { "N": 21807808817028069521693981025854627766849100907464628031386389529795793140445452403979568400586301388102303005688782597096478795543494617476262626637251939091457219474844544584944694111795327351162485025615396615156332890111445956553729344912738727208120229178581403780883051005207097866108991379098981205093118647139047092214048380759204440914928346690315813577955415022365974040592290311683131513649330794291316838007320668201086717296546111828165980835726696797314928836964283576233301855572522559548630195787917554335560790396850488199331707061308922415163250057868060445529850753103153976841020361249662478352377, "E": 65537, diff --git a/CTng/testData/fakeCA/ca2.json b/CTng/testData/fakeCA/ca2.json index 281a666..2f661cd 100644 --- a/CTng/testData/fakeCA/ca2.json +++ b/CTng/testData/fakeCA/ca2.json @@ -1,6 +1,7 @@ { "Signer": "localhost:9101", "Port": "9101", + "NRevoke": 5, "Private": { "N": 23252973551340935183125964301239394441268751011208146732992808020417063643722798116442608594279677205628615159796637042351236895510183530067421586578520622761961327937601077936607208585910560962764238731254814969375357028226260361691859503574268216691949008213953884839053600853903979504862782260745247938279459295671742467758276923319951606178695777588680957056514003518072749213888863320971271934432550756175972781344678001820332694558433506149685765145751895391937311845198206021246778714450986559172352984358941313079975500433800828535054555138262203102926122738137575483960219776073243032678302367325287435201381, "E": 65537, diff --git a/CTng/testData/fakeCA/ca3.json b/CTng/testData/fakeCA/ca3.json index 17d9b61..74dbd06 100644 --- a/CTng/testData/fakeCA/ca3.json +++ b/CTng/testData/fakeCA/ca3.json @@ -1,6 +1,7 @@ { "Signer": "localhost:9102", "Port": "9102", + "NRevoke": 5, "Private": { "N": 20028649974874227033360914359590766678527711517531636997713603474008908788659881072754993703433185955779617335557947288171124892464864232545291605031424352674054323768598060610599281281539072954580390937994894319035538689968791373798820944766502542768153531189979514749140151783915919768722020901389133722554527607979186909863026840800319528623758670965878003072462079597023515002126915829370037330794543912057953039966473482799333260960689543682741483394536974500771002815055637466302437703527466497406576505348945381874007559705058294342241838471511807556669238624256963671945475465519079937531652829531772652319583, "E": 65537, diff --git a/CTng/testData/fakeCA/fakeCA.go b/CTng/testData/fakeCA/fakeCA.go index 82efa85..243117c 100644 --- a/CTng/testData/fakeCA/fakeCA.go +++ b/CTng/testData/fakeCA/fakeCA.go @@ -17,6 +17,7 @@ import ( type CAConfig struct { Signer string Port string + NRevoke int MRD int Private rsa.PrivateKey CRVs [][]byte //should be array of CRVs @@ -40,13 +41,18 @@ var caType int func generateCRVs(CA CAConfig, miss int) gossip.Gossip_object { // Generate delta CRV and then compress it - first_arr := CA.CRVs[CA.Day-1] //this assumes we never have CRV of len 0 (fresh CA) - sec_arr := CA.CRVs[CA.Day] + 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) + + var delta_crv = make([]byte, 0, len(first_arr)) + // Make the dCRV here by randomly flipping Config.NRevoke bits - var delta_crv = make([]byte, 0, len(sec_arr)) - for i, e := range first_arr { - delta_crv[i] = e & sec_arr[i] + // creates the new CRV from the old one+dCRV + for i, _ := range first_arr { + CA.CRVs[CA.Day][i] = first_arr[i] ^ delta_crv[i] } //this is scuffed/slow for giant CRVs O(n), also I am assuming CRVs are same size, can modify for different sizes + sec_arr := CA.CRVs[CA.Day] delta_crv = GZip.Compress(delta_crv) //should work... @@ -65,13 +71,16 @@ func generateCRVs(CA CAConfig, miss int) gossip.Gossip_object { } //Appends byte of day, hash of CRV and hash of deltaCRV (lovely looking line of code) - sign := append([]byte{byte(CA.Day - miss)}, append(hash_CRV, hash_dCRV)) - //Added (CA.Day-day) to produce incorrect SRHs when needed + //Added (CA.Day-miss) to produce incorrect SRHs when needed + var inter []byte = make([]byte, 0, 4096) + sign := append(inter, byte(CA.Day-miss)) + inter = append(inter, hash_CRV...) + inter = append(inter, hash_dCRV...) REV := Revocation{ SRH: sign, delta_CRV: delta_crv, - Timestamp: gossip.GetTimestamp(), + Timestamp: gossip.GetCurrentTimestamp(), } payload, _ := json.Marshal(REV) @@ -121,6 +130,7 @@ func getCAType() { fmt.Println("1. Normal, behaving CA (default)") fmt.Println("2. Split-World (Two different SRHs on every", config.MisbehaviorInterval, "MRD)") fmt.Println("3. Disconnecting CA (unresponsive every", config.MisbehaviorInterval, "MRD)") + fmt.Println("4. Invalid SRH on every ", config.MisbehaviorInterval, "MRD) (CURRENTLY UNIMPLEMENTED)") fmt.Scanln(&caType) } @@ -144,6 +154,9 @@ 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() // MUX which routes HTTP directories to functions. gorillaRouter := mux.NewRouter().StrictSlash(true)