shithub: mc

ref: 41046c6382017e0297f8e07a7493c2cd779b8f0b
dir: /lib/crypto/clear.myr/

View raw version
use std

pkg crypto =
	/* designed to facilitating freeing sensitive data */
	generic	clear	: (p : @a# -> void)
	generic	slclear	: (sl : @a[:] -> void)
	generic free	: (p : @a# -> void)
	generic slfree	: (sl : @a[:] -> void)
;;

generic clear = {p : @a#
	std.memfill((p : byte#), 0, sizeof(@a))
}

generic slclear = {sl : @a[:]
	std.memfill((sl : byte#), 0, sizeof(@a)*sl.len)
}

generic free = {p : @a#
	clear(p)
	std.free(p)
}

generic slfree = {sl : @a[:]
	slclear(sl)
	std.slfree(sl)
}