示例#1
0
文件: respond.go 项目: wbl/ringauth
func main() {
	var challenge = os.Args[1]
	var err error
	var parthandle *os.File
	parthandle, err = os.Open(os.Args[2])
	if err != nil {
		log.Fatal(err)
	}
	var partreader = bufio.NewReader(parthandle)
	var randreader *os.File
	randreader, err = os.Open("/dev/random")
	if err != nil {
		log.Fatal(err)
	}
	var group *bbssig.Group = new(bbssig.Group)
	var mem *bbssig.MemberKey = new(bbssig.MemberKey)
	var hash = sha256.New()
	var cb []byte
	var response []byte
	objpack.UnPackPart(partreader, group, mem)
	cb, err = base64.StdEncoding.DecodeString(challenge)
	if err != nil {
		log.Fatal("Invalid Challenge")
	}
	response, err = mem.Sign(randreader, cb, hash)
	if err != nil {
		log.Fatal(err)
	}
	basepack.Packout(os.Stdout, response)
}
示例#2
0
func answerChallenge(message string, memberKey *bbssig.MemberKey) string {
	out, err := memberKey.Sign(rand.Reader, []byte(message), sha1.New())
	if err != nil {
		log.Printf("Challenge failed. Error was: %s\n", err)
	}

	return string(out)
}
示例#3
0
文件: addpart.go 项目: wbl/ringauth
func main() {
	var err error
	var ofhandle *os.File
	ofhandle, err = os.Create(os.Args[1])
	if err != nil {
		log.Fatal(err)
	}
	var privhandle *os.File
	privhandle, err = os.Open(os.Args[2])
	if err != nil {
		log.Fatal(err)
	}
	var privreader *bufio.Reader
	privreader = bufio.NewReader(privhandle)
	var group *bbssig.Group = new(bbssig.Group)
	var privkey *bbssig.PrivateKey = new(bbssig.PrivateKey)
	var part *bbssig.MemberKey = new(bbssig.MemberKey)
	var randreader *os.File
	randreader, err = os.Open("/dev/random")
	if err != nil {
		log.Fatal(err)
	}
	var gb []byte
	{
		gb = basepack.Unpack(privreader)
		var success bool
		_, success = group.Unmarshal(gb)
		if !success {
			log.Fatal("Unable to unpack group data")
		}
		var pb = basepack.Unpack(privreader)
		_, success = privkey.Unmarshal(group, pb)
		if !success {
			log.Fatal("Unable to unpack private key")
		}
	}
	part, err = privkey.NewMember(randreader)
	if err != nil {
		log.Fatal(err)
	}
	{
		var partbyte = part.Marshal()
		objpack.PackGroup(ofhandle, part.Group)
		basepack.Packout(ofhandle, partbyte)
		fmt.Printf("Tag for part is ")
		basepack.Packout(os.Stdout, part.Tag())
	}
	ofhandle.Close()
	privhandle.Close()
	randreader.Close()
}
示例#4
0
文件: tag.go 项目: wbl/ringauth
func main() {
	var err error
	var parthandle *os.File
	parthandle, err = os.Open(os.Args[1])
	if err != nil {
		log.Fatal(err)
	}
	var partreader = bufio.NewReader(parthandle)
	var group *bbssig.Group = new(bbssig.Group)
	var part *bbssig.MemberKey = new(bbssig.MemberKey)
	objpack.UnPackPart(partreader, group, part)
	var tagbytes = part.Tag()
	fmt.Printf("Tag is %s\n", base64.StdEncoding.EncodeToString(tagbytes))
}
示例#5
0
文件: obj.go 项目: wbl/ringauth
func UnPackPart(partreader *bufio.Reader, group *bbssig.Group,
	part *bbssig.MemberKey) {
	var gb = basepack.Unpack(partreader)
	var success bool
	_, success = group.Unmarshal(gb)
	if !success {
		log.Fatal("Unable to unpack group")
	}
	var mb = basepack.Unpack(partreader)
	_, success = part.Unmarshal(group, mb)
	if !success {
		log.Fatal("Unable to unpack part")
	}
}
示例#6
0
文件: revoke.go 项目: wbl/ringauth
func main() {
	var err error
	var group = new(bbssig.Group)
	var sk = new(bbssig.PrivateKey)
	var part = new(bbssig.MemberKey)
	var rev *bbssig.Revocation
	var revbyte []byte
	var partfile *os.File
	partfile, err = os.Open(os.Args[1])
	if err != nil {
		log.Fatal(err)
	}
	var privfile *os.File
	privfile, err = os.Open(os.Args[2])
	if err != nil {
		log.Fatal(err)
	}
	var partreader = bufio.NewReader(partfile)
	var privreader = bufio.NewReader(privfile)
	/* Now we have a detail, namely need to skip some stuff from
	the part file before we can use it. But first load the
	private key*/
	{
		var gb = basepack.Unpack(privreader)
		var success bool
		_, success = group.Unmarshal(gb)
		if !success {
			log.Fatal("Could not load key")
		}
		var sb = basepack.Unpack(privreader)
		_, success = sk.Unmarshal(group, sb)
		if !success {
			log.Fatal("Could not load private key")
		}
	}
	{
		var success bool
		basepack.Unpack(partreader) /*Skip first entry*/
		var memb = basepack.Unpack(partreader)
		_, success = part.Unmarshal(group, memb)
		if !success {
			log.Fatal("Part could not be upacked")
		}
	}
	rev = sk.GenerateRevocation(part)
	revbyte = rev.Marshal()
	fmt.Printf("The revokation string is %s\n",
		base64.StdEncoding.EncodeToString(revbyte))
}