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) }
func (hk *HelloPubKey) String() string { return rsa64.PubToBase64(hk.RSAPubKey()) }
func (cmpk *CipherMsgPubKey) String() string { return rsa64.PubToBase64(cmpk.rsa) }
func (sk *SigPubKey) String() string { return rsa64.PubToBase64(sk.RsaPubKey()) }