func TestPK(t *testing.T) { // init the Log acutl.InitDebugLog(os.Stderr) // init the key map for our tests.. ackp.ACmap = ackp.NewPSKMap() // TEST PKGEN : myself & eau stored fmt.Printf("\n== PKGEN TESTs ==\n") makeTests(PKGENTests, PKGEN_Handler, t) // TEST PKADD : nick1 & nick2 stored too fmt.Printf("\n== PKADD TESTs ==\n") makeTests(PKADDTests, PKADD_Handler, t) // TEST PKLIST fmt.Printf("\n== PKLIST TESTs ==\n") makeTests(PKLISTTests, PKLIST_Handler, t) // TEST PKDEL }
func main() { Version := acVersion /* f, err := os.Create("toto.pprof") if err != nil { panic(err) } pprof.StartCPUProfile(f) defer pprof.StopCPUProfile() */ // parsing the RSA code... rsaFlag := flag.Bool("rsagen", false, "generate RSA identity keys") ecFlag := flag.Bool("ecgen", false, "generate ECDSA identity keys (these are using NIST curve SecP384") saecFlag := flag.Bool("ec25gen", false, "generate EC 25519 identify keys") dbgFlag := flag.Bool("debug", false, "activate debug log") // we cannot use more than 2048K anyway why bother with a flag then //bitOpt := flag.Int("client", 2048, "generate Client SSL Certificate") flag.Parse() if len(flag.Args()) != 0 { usage(os.Args[0]) flag.PrintDefaults() os.Exit(1) } if *dbgFlag == true { //log.SetOutput(os.Stderr) acutl.InitDebugLog(os.Stderr) } else { //log.SetOutput(ioutil.Discard) acutl.InitDebugLog(ioutil.Discard) } if *rsaFlag == true || *ecFlag == true || *saecFlag == true { // generate a set of identity RSA keys and save them to file encrypted //accp.GenRSAKeys() var i *ackp.IdentityKey var err error switch { case *rsaFlag == true: i, err = ackp.NewIdentityKey(ackp.KEYRSA) //ackp.GenKeysRSA(rand.Reader) case *ecFlag == true: fmt.Printf("LET'S SWITCH!!: %v\n", *ecFlag) i, err = ackp.NewIdentityKey(ackp.KEYECDSA) //ackp.GenKeysECDSA(rand.Reader) case *saecFlag == true: i, err = ackp.NewIdentityKey(ackp.KEYEC25519) //ackp.GenKeysED25519(rand.Reader) } acutl.DebugLog.Printf("bleh i: %p err: %p", i, err) } else { // find and load the keys in memory to sign our requests // private key will need to be unlocked using PB request //accp.LoadRSAKeys() // memory storage maps init.. //ackp.ACmap = make(ackp.PSKMap) ackp.ACrun = true //fmt.Fprintf(os.Stderr, "[+] ac-%s\nstart\n", Version) acutl.DebugLog.Printf("ac-%s", Version) // XXX TODO: this is not stable enough but should do the trick for now.. // it is not clear what happens if the ACrun = false is done first // but i close the socket on both sides.. and it should clean the // socket file running... let's test with the script now :) // XXX deactivated sig := make(chan os.Signal, 2) signal.Notify(sig, os.Interrupt, os.Kill, syscall.SIGTERM, syscall.SIGKILL, syscall.SIGQUIT, syscall.SIGSEGV, syscall.SIGINT) // signal.Notify(sig, nil) go func() { <-sig ackp.ACrun = false //fmt.Fprintf(os.Stderr, "[+] exiting...!\n") acutl.DebugLog.Fatalf("exiting.\n") //os.Exit(3) }() for ackp.ACrun == true { handleStdin() } } os.Exit(0) }