Example #1
0
func main() {
	if GenKey {
		_, priv, err := tarcrypto.GenerateKeyPair()
		if err != nil {
			log.Fatal(err)
		}
		data := tarcrypto.MarshalKey(priv)

		if err := keyfile.Write(KeyFile, data); err != nil {
			log.Fatal(err)
		}
		return
	}

	if GenSource {
		b, err := keyfile.Read(KeyFile)
		if err != nil {
			log.Fatal(err)
		}

		if err := keyfile.GenerateSource(b); err != nil {
			log.Fatal(err)
		}
		return
	}
}
Example #2
0
func (s *Server) AddRootKey(f string) {

	data, err := keyfile.Read(f)
	if err != nil {

		panic(err)
	}

	pub, priv, err := tarcrypto.ParseKey(data)
	if err != nil {

		panic(err)
	}

	s.ServerKeyChain = new(ServerKeyChain)
	s.ServerKeyChain.PublicKey = pub
	s.ServerKeyChain.PrivateKey = priv
}