Beispiel #1
0
// zero out memory and then free
func (self *Buffer) Free() {
	C.sodium_memzero(self.ptr, self.size)
	C.free(self.ptr)
}
Beispiel #2
0
func MemZero(b1 []byte) {
	if len(b1) > 0 {
		C.sodium_memzero(unsafe.Pointer(&b1[0]), C.size_t(len(b1)))
	}
}
Beispiel #3
0
// does not check for negatives
func malloc(size C.size_t) *Buffer {
	ptr := C.malloc(size)
	C.sodium_memzero(ptr, size)
	buffer := &Buffer{ptr: ptr, size: size, length: C.int(size)}
	return buffer
}