Пример #1
0
func (h *sha384) Write(p []byte) (n int, err error) {
	l := len(p)
	if C.SHA384_Update(&h.ctx, unsafe.Pointer(&p[0]), C.size_t(l)) == 0 {
		panic("SHA384_Update failed")
	}
	return l, nil
}
Пример #2
0
func (self *SHA384Hash) Write(msg []byte) (n int, err error) {
	size := C.size_t(len(msg))
	if C.SHA384_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)
	switch d.function {
	case crypto.SHA384:
		if C.SHA384_Update(&d.ctx, unsafe.Pointer(C.CString(string(msg))), size) != 1 {
			return 0, sslerr.Error()
		}
		return mlen, nil
	default:
		if C.SHA512_Update(&d.ctx, unsafe.Pointer(C.CString(string(msg))), size) != 1 {
			return 0, sslerr.Error()
		}
		return mlen, nil
	}
}