Skip to content

Instantly share code, notes, and snippets.

@BetterProgramming
Created November 8, 2022 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BetterProgramming/12598917aeefca01a3768431063010b2 to your computer and use it in GitHub Desktop.
Save BetterProgramming/12598917aeefca01a3768431063010b2 to your computer and use it in GitHub Desktop.
func (h *boringHMAC) Reset() {
if h.needCleanup {
C._goboringcrypto_HMAC_CTX_cleanup(&h.ctx)
} else {
h.needCleanup = true
// Note: Because of the finalizer, any time h.ctx is passed to cgo,
// that call must be followed by a call to runtime.KeepAlive(h),
// to make sure h is not collected (and finalized) before the cgo
// call returns.
runtime.SetFinalizer(h, (*boringHMAC).finalize)
}
}
func (h *boringHMAC) finalize() {
C._goboringcrypto_HMAC_CTX_cleanup(&h.ctx)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment