Example #1
0
File: sha1.go Project: runcom/gossl
func (d *digest) Write(msg []byte) (n int, err error) {
	size := C.size_t(len(msg))
	if C.SHA1_Update(&d.ctx, unsafe.Pointer(C.CString(string(msg))), size) != 1 {
		return 0, sslerr.Error()
	}
	return len(msg), nil
}
Example #2
0
func (h *sha1) Write(p []byte) (n int, err error) {
	l := len(p)
	if C.SHA1_Update(&h.ctx, unsafe.Pointer(&p[0]), C.size_t(l)) == 0 {
		panic("SHA1_Update failed")
	}
	return l, nil
}
Example #3
0
func (self *SHA1Hash) Write(msg []byte) (n int, err error) {
	size := C.size_t(len(msg))
	if C.SHA1_Update(&self.sha, unsafe.Pointer(C.CString(string(msg))), size) != 1 {
		panic("problem updating hash")
	}
	return len(msg), nil
}
Example #4
0
func (d *digest) Write(p []byte) (nn int, err error) {
	if len(p) == 0 || C.SHA1_Update(d.context, unsafe.Pointer(&p[0]),
		C.size_t(len(p))) == 1 {
		return len(p), nil
	}

	return 0, errors.New("SHA1_Update failed")
}
Example #5
0
// TODO: Is this pointer safe from GC?
func (ctx *ShaContext) Update(data []byte) {
	C.SHA1_Update((*C.SHA_CTX)(ctx), unsafe.Pointer(&data[0]), C.size_t(len(data)))
}