Ejemplo n.º 1
0
// Start begins the source scanner. This function will continually
// load the target list, and deliver entropy packets as appropriate.
func Start(signer *rsa.PrivateKey, targetFile string) {
	defer prng.StoreSeed()

	var delay = 6 * time.Hour
	var targetUpdate bool

	for {
		log.Println("scanning targets")
		now := time.Now().Unix()

		targets := target.Load(targetFile)
		for i, t := range targets {
			updated := targetCheck(t, signer, now)
			if updated {
				targets[i].Next = now + int64(delay.Seconds())
				targetUpdate = true
			}
		}

		if targetUpdate {
			err := target.Store(targetFile, targets)
			if err != nil {
				log.Printf("%v", err)
			}
			targetUpdate = false
		}
		<-time.After(1 * time.Minute)
	}
}
Ejemplo n.º 2
0
func main() {
	flag.StringVar(&config.signer, "k", "signer.key", "signature key")
	seedFile := flag.String("s", "source.seed", "PRNG seed file")
	flag.StringVar(&config.targets, "t", "targets.json", "test targets")
	flag.Parse()

	in, err := ioutil.ReadFile(config.signer)
	if err != nil {
		log.Fatalf("%v", err)
	}
	signer, err := x509.ParsePKCS1PrivateKey(in)
	if err != nil {
		log.Fatalf("%v", err)
	}

	prng.Start(*seedFile)

	defer prng.StoreSeed()
	source.Start(signer, config.targets)
}