示例#1
0
文件: idkey.go 项目: fedgrant/tonika
func IdForKey(pk rsa.PublicKey) Id {

	// Write the Rsa64 representation of public key into Sha256
	pk64 := []byte(rsa64.PubToBase64(&pk))
	sha256 := sha256.New()
	for {
		n, err := sha256.Write(pk64)
		if err != nil {
			panic("sha256 malfunction")
		}
		if n == len(pk64) {
			break
		}
		pk64 = pk64[n:]
	}

	// Compute and fold the Sha256 hash
	h := sha256.Sum()
	if len(h) != 32 {
		panic("expecting 32 bytes")
	}

	for i := 1; i < 4; i++ {
		for j := 0; j < 8; j++ {
			h[j] ^= h[8*i+j]
		}
	}
	id64, err := bytes.BytesToInt64(h[0:8])
	if err != nil {
		panic("logic")
	}

	return Id(id64)
}
示例#2
0
func (hk *HelloPubKey) String() string { return rsa64.PubToBase64(hk.RSAPubKey()) }
示例#3
0
文件: msg.go 项目: fedgrant/tonika
func (cmpk *CipherMsgPubKey) String() string {
	return rsa64.PubToBase64(cmpk.rsa)
}
示例#4
0
文件: sigkey.go 项目: fedgrant/tonika
func (sk *SigPubKey) String() string {
	return rsa64.PubToBase64(sk.RsaPubKey())
}