Пример #1
0
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
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
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
}