Exemplo n.º 1
0
/* runs through the process of setting up the server as specified in the args */
func main() {

	kingpin.MustParse(app.Parse(os.Args[1:]))

	var port int = *appPort
	var kfilepath string = *appPrivatekeyfile
	var kinfopath string = *appInfo

	fmt.Printf("Sigserv3 - listening on port %d.\n", port)

	suite := ed25519.NewAES128SHA256Ed25519(true)
	kv, err := crypto.SchnorrLoadKeypair(kfilepath, suite)
	if err != nil {
		fmt.Println("Error " + err.Error())
		return
	}

	info, err := LoadInfo(kinfopath)
	if err != nil {
		fmt.Println("Error " + err.Error())
		return
	}

	// I don't know if there's a way to
	// do std::bind-like behaviour in GO.
	// for C++ what I'd do is pretty simple:
	// newfunc := std::bind(&func, args to bind)
	var signBlindImpl connectionhandler = func(conn net.Conn) {
		signBlindlySchnorr(conn, suite, kv, info)
	}
	serve(port, signBlindImpl)
}
Exemplo n.º 2
0
func main() {
	app.Version(buildVersion)
	kp.MustParse(app.Parse(os.Args[1:]))
	pwd, err := os.Getwd()
	app.FatalIfError(err, "pwd")
	fatalIfError(app, gc.VersionCheck(pwd, buildVersion), "version")
	showComments(pwd)
}
Exemplo n.º 3
0
func main() {
	app.Version(buildVersion)
	pwd, err := os.Getwd()
	app.FatalIfError(err, "pwd")
	fatalIfError(app, gc.VersionCheck(pwd, buildVersion), "version")
	switch kp.MustParse(app.Parse(os.Args[1:])) {
	case "find":
		findText(pwd, *text)
	case "index":
		indexComments(pwd)
	}
}
Exemplo n.º 4
0
func Run(args []string) {
	kingpin.CommandLine.HelpFlag.Short('h')
	kingpin.Version(VERSION)

	opFmt := &OuputFormat{JSON: *json, TSV: *tsv}

	switch kingpin.MustParse(cli.Parse(args[1:])) {
	case "servers":
		listServers(opFmt)
	case "api":
		apiRequest(*apiMethod, *apiPath, opFmt)
	}
}
Exemplo n.º 5
0
func main() {
	app.Version(buildVersion)
	pwd, err := os.Getwd()
	app.FatalIfError(err, "pwd")
	fatalIfError(app, gc.VersionCheck(pwd, buildVersion), "version")
	switch kp.MustParse(app.Parse(os.Args[1:])) {
	case "config":
		app.FatalIfError(gc.ConfigureRemoteForComments(pwd, *configRemote).Failure, "git")
		fmt.Printf("Remote '%v' updated\n", *configRemote)
	case "delete":
		app.FatalIfError(gc.DeleteRemoteComment(pwd, *deleteRemote, *deleteComment).Failure, "git")
		fmt.Printf("Remote comment reference deleted\n")
	}
}
Exemplo n.º 6
0
func main() {
	switch kingpin.MustParse(app.Parse(os.Args[1:])) {
	case master.FullCommand():
		println("listening on", (*masterIp)+":"+strconv.Itoa(*masterPort))
		m.RunMaster((*masterIp) + ":" + strconv.Itoa(*masterPort))
	case sender.FullCommand():
		var wg sync.WaitGroup
		sendChan, err := s.NewSendChannel(*sendToChanName, *senderAgentPort, &wg)
		if err != nil {
			panic(err)
		}

		file := os.Stdin
		if *sendFile != "" {
			file, err = os.Open(*sendFile)
			if err != nil {
				log.Fatal(err)
			}
			defer file.Close()
		}

		counter := 0
		scanner := bufio.NewScanner(file)
		for scanner.Scan() {
			sendChan <- scanner.Bytes()
			counter++
		}
		if err := scanner.Err(); err != nil {
			log.Fatal(err)
		}
		close(sendChan)
		wg.Wait()

	case receiver.FullCommand():
		target := r.FindTarget(*receiveFromChanName, *receiverMaster)
		rc := r.NewReceiveChannel(*receiveFromChanName, 0)
		recvChan, err := rc.GetDirectChannel(target, 128)
		if err != nil {
			panic(err)
		}
		for m := range recvChan {
			println(string(m))
		}

	case agent.FullCommand():
		agentServer := a.NewAgentServer(agentOption)
		agentServer.Run()
	}
}
Exemplo n.º 7
0
func Start() {
	app.Version(fmt.Sprintf("Version: %s Build: %s", Version, Build))
	args, perr := app.Parse(os.Args[1:])

	initLogger()

	config, err := NewConfig(*appConfigPath)

	if err != nil {
		Log.Fatal(err)
	} else {
		GlobalConfig = *config
	}

	if !config.TestConfig() {
		Log.Fatal("Invalid configuration detected.")
	}

	switch kingpin.MustParse(args, perr) {

	case server.FullCommand():
		StartServer()

	case registerCommand.FullCommand():
		RegisterCodetainerImage(*registerImageId, *registerCommandArg)

	case codetainerCreate.FullCommand():
		CreateCodetainer(*codetainerCreateImageId, *codetainerCreateName)

	case codetainerList.FullCommand():
		CodetainerList()

	case codetainerRemove.FullCommand():
		CodetainerRemove(*codetainerRemoveId)

	case listImagesCommand.FullCommand():
		ListCodetainerImages()

	case profileListCommand.FullCommand():
		ListCodetainerProfiles()

	case profileRegisterCommand.FullCommand():
		RegisterCodetainerProfile(*profileRegisterPath, *profileRegisterName)

	default:
		app.Usage([]string{})
	}

}
Exemplo n.º 8
0
func main() {
	app.Version(buildVersion)
	kp.MustParse(app.Parse(os.Args[1:]))
	pwd, err := os.Getwd()
	app.FatalIfError(err, "pwd")
	if *update {
		gc.VersionUpdate(pwd, buildVersion)
		return
	}
	fatalIfError(app, gc.VersionCheck(pwd, buildVersion), "version")
	if len(*deleteID) > 0 {
		app.FatalIfError(gc.DeleteComment(pwd, *deleteID).Failure, "git")
		fmt.Println("Comment deleted")
	} else {
		editComment(pwd)
	}
}
Exemplo n.º 9
0
Arquivo: main.go Projeto: dz0ny/gobu
func main() {
	app.Author("dz0ny")
	app.Version(build)
	cmd := kingpin.MustParse(app.Parse(os.Args[1:]))

	if *showVerbose {
		log.SetLevel(log.DebugLevel)
		log.Debug("Debug mode enabled")
	}

	r := remote.Remote{}

	switch cmd {
	case "versions":
		r.Update()
		fmt.Println("List of supported Golang releases for this platform:")
		for _, v := range r.Versions {
			fmt.Println(v.String())
		}
		break
	case "shell":

		if *shellVersion != "" {
			r.Update()
			selected, err := r.GetVersion(*shellVersion)
			if err != nil {
				log.Fatalln(err)
			}
			if err := selected.Setup(envPath); err != nil {
				log.Fatalln(err)
			}
			runShell(selected.Release)
		} else {
			r.Update()
			latest := r.LatestVersion()
			if err := latest.Setup(envPath); err != nil {
				log.Fatalln(err)
			}
			runShell(latest.Release)
		}

	}
}
Exemplo n.º 10
0
/* Entry point to the keytool utility. Switches based on the command line argument structure
   given above.
   Parses all  arguments except os.Args[0], the program name.
*/
func main() {

	switch kingpin.MustParse(app.Parse(os.Args[1:])) {
	case genCmd.FullCommand():
		runKeyGen(*genCmdOutput)
	case groupCmd.FullCommand():

		var outputfile string = *groupCmdOutput
		var parties []SchnorrMSHostSpec

		for _, item := range *groupCmdHost {
			parts := strings.Split(item, ",")
			hostspec := parts[0]
			pubkeyfile := parts[1]

			hsparts := strings.Split(hostspec, ":")
			host := hsparts[0]
			port, err := strconv.Atoi(hsparts[1])
			if err != nil {
				fmt.Println("Error invalid argument")
				fmt.Println(err.Error())
				os.Exit(1)
			}

			party := SchnorrMSHostSpec{host, port, pubkeyfile}
			parties = append(parties, party)
		}

		runMultiSignatureGen(parties, outputfile)
	case randomInfCmd.FullCommand():
		var outputfile string = *randomInfCmdOutput
		err := createRandomSharedInfoInFile(outputfile)
		if err != nil {
			fmt.Println("Error", err.Error())
		} else {
			fmt.Println("Random bytes written to", outputfile)
		}
	}
}
Exemplo n.º 11
0
/* Runs through the "user" side of the protocol i.e. the party
   requesting a partially blind signature */
func main() {

	kingpin.MustParse(app.Parse(os.Args[1:]))

	var kfilepath string = *appPrivatekeyfile
	var kinfopath string = *appInfo
	var hostspec string = *appHostspec

	suite := ed25519.NewAES128SHA256Ed25519(true)

	fmt.Println("CLIENT", "Connecting to", hostspec)

	pubKey, err := crypto.SchnorrLoadPubkey(kfilepath, suite)
	if err != nil {
		fmt.Println("CLIENT", "Error loading public key"+err.Error())
		return
	}

	info, err := LoadInfo(kinfopath)
	if err != nil {
		fmt.Println("CLIENT", "Error loading info"+err.Error())
		return
	}

	message := make([]byte, 1024)
	_, err = rand.Read(message)
	if err != nil {
		fmt.Println(err.Error())
		return
	}

	conn, err := net.Dial("tcp", hostspec)
	if err != nil {
		fmt.Println("CLIENT", "Error connecting to server", err.Error())
		return
	}
	defer conn.Close()

	// first up, let's receive the signer's parameter set

	buffer := make([]byte, 1026)
	_, err = conn.Read(buffer)
	if err != nil {
		fmt.Println("CLIENT", "Error reading from server", err.Error())
		return
	}

	var userPublicParams crypto.WISchnorrPublicParams
	decodeBuffer := bytes.NewBuffer(buffer)
	err = abstract.Read(decodeBuffer, &userPublicParams, suite)

	// now we've got that, complete the challenge phase (i.e. let's generate E)
	challenge, userPrivateParams, err := crypto.ClientGenerateChallenge(suite, userPublicParams, pubKey, info, message)
	if err != nil {
		fmt.Println("CLIENT", "Error generating challenge", err.Error())
		return
	}

	// encode and send to server.
	challengebuffer := bytes.Buffer{}
	abstract.Write(&challengebuffer, &challenge, suite)
	conn.Write(challengebuffer.Bytes())

	// and now we wait for the server to respond to this:
	secondread := make([]byte, 1024)
	_, err = conn.Read(secondread)
	if err != nil {
		fmt.Println("CLIENT", "Error reading from server", err.Error())
		return
	}

	var responseMessage crypto.WISchnorrResponseMessage
	decodeBuffer = bytes.NewBuffer(secondread)
	err = abstract.Read(decodeBuffer, &responseMessage, suite)
	if err != nil {
		fmt.Println("CLIENT", "Error reading response", err.Error())
		return
	}

	// we've got the response message, time to sign and check.

	// finally, we can sign the message and check it verifies.
	sig, worked := crypto.ClientSignBlindly(suite, userPrivateParams, responseMessage, pubKey, message)

	//fmt.Println(blindSignature)

	if worked != true {
		fmt.Println("CLIENT", "Error preforming blind signature")
		return
	}

	// now verify this worked fine.
	result, err := crypto.VerifyBlindSignature(suite, pubKey, sig, info, message)

	if err != nil {
		fmt.Println("CLIENT", "Error handling signature verification", err.Error())
		return
	}
	if result != true {
		fmt.Println("CLIENT", "Signature did not correctly verify.")
		return
	}

	fmt.Println("CLIENT", "Signature OK -", sig)

	return
}
Exemplo n.º 12
0
func main() {

	master.Flag("cert.file", "A PEM eoncoded certificate file").Default("").StringVar(&masterCerts.CertFile)
	master.Flag("key.file", "A PEM encoded private key file.").Default("").StringVar(&masterCerts.KeyFile)
	master.Flag("ca.file", "A PEM eoncoded CA's certificate file.").Default("").StringVar(&masterCerts.CaFile)

	agent.Flag("cert.file", "A PEM eoncoded certificate file").Default("").StringVar(&agentOption.CertFiles.CertFile)
	agent.Flag("key.file", "A PEM encoded private key file.").Default("").StringVar(&agentOption.CertFiles.KeyFile)
	agent.Flag("ca.file", "A PEM eoncoded CA's certificate file.").Default("").StringVar(&agentOption.CertFiles.CaFile)

	sender.Flag("cert.file", "A PEM eoncoded certificate file").Default("").StringVar(&senderCerts.CertFile)
	sender.Flag("key.file", "A PEM encoded private key file.").Default("").StringVar(&senderCerts.KeyFile)
	sender.Flag("ca.file", "A PEM eoncoded CA's certificate file.").Default("").StringVar(&senderCerts.CaFile)

	receiver.Flag("cert.file", "A PEM eoncoded certificate file").Default("").StringVar(&receiverCerts.CertFile)
	receiver.Flag("key.file", "A PEM encoded private key file.").Default("").StringVar(&receiverCerts.KeyFile)
	receiver.Flag("ca.file", "A PEM eoncoded CA's certificate file.").Default("").StringVar(&receiverCerts.CaFile)

	switch kingpin.MustParse(app.Parse(os.Args[1:])) {
	case master.FullCommand():
		println("listening on", *masterAddress)
		m.RunMaster(masterCerts.MakeTLSConfig(), *masterAddress)
	case sender.FullCommand():
		tlsConfig := senderCerts.MakeTLSConfig()
		util.SetupHttpClient(tlsConfig)

		var wg sync.WaitGroup
		sendChan, err := s.NewDirectSendChannel(tlsConfig, *sendToChanName, *senderAgentAddress, &wg)
		if err != nil {
			panic(err)
		}

		file := os.Stdin
		if *sendFile != "" {
			file, err = os.Open(*sendFile)
			if err != nil {
				log.Fatal(err)
			}
			defer file.Close()
		}

		counter := 0
		scanner := bufio.NewScanner(file)
		for scanner.Scan() {
			sendChan <- scanner.Bytes()
			counter++
		}
		if err := scanner.Err(); err != nil {
			log.Fatal(err)
		}
		close(sendChan)
		wg.Wait()

	case receiver.FullCommand():
		tlsConfig := receiverCerts.MakeTLSConfig()
		util.SetupHttpClient(tlsConfig)

		target := r.FindTarget(*receiveFromChanName, *receiverMaster)
		rc := r.NewReceiveChannel(tlsConfig, *receiveFromChanName, 0)
		recvChan, err := rc.GetDirectChannel(target, 128)
		if err != nil {
			panic(err)
		}
		for m := range recvChan {
			println(string(m))
		}

	case agent.FullCommand():
		if agentOption.CertFiles.IsEnabled() {
			if *agentOption.Host == "" {
				log.Fatalf("Usage Note: --host option is needed in 2-way SSL mode and must match CN in the certificate.")
			}
		}
		agentServer := a.NewAgentServer(agentOption)
		agentServer.Run()
	}
}
Exemplo n.º 13
0
func main() {
	kingpin.MustParse(app.Parse(os.Args[1:]))

	runClientProtocol(*configFile)
}