示例#1
0
文件: sha.go 项目: eftychis/crypto-1
func (h *sha224) Write(p []byte) (n int, err error) {
	l := len(p)
	if C.SHA224_Update(&h.ctx, unsafe.Pointer(&p[0]), C.size_t(l)) == 0 {
		panic("SHA224_Update failed")
	}
	return l, nil
}
示例#2
0
文件: sha224.go 项目: postfix/go-ssl
func (self *SHA224Hash) Write(msg []byte) (n int, err error) {
	size := C.size_t(len(msg))
	if C.SHA224_Update(&self.sha, unsafe.Pointer(C.CString(string(msg))), size) != 1 {
		panic("problem updating hash")
	}
	return len(msg), nil
}
示例#3
0
文件: sha256.go 项目: runcom/gossl
func (d *digest) Write(msg []byte) (n int, err error) {
	mlen := len(msg)
	size := C.size_t(mlen)
	if d.is224 {
		if C.SHA224_Update(&d.ctx, unsafe.Pointer(C.CString(string(msg))), size) != 1 {
			return 0, sslerr.Error()
		}
		return mlen, nil
	}
	if C.SHA256_Update(&d.ctx, unsafe.Pointer(C.CString(string(msg))), size) != 1 {
		return 0, sslerr.Error()
	}
	return mlen, nil
}