Beispiel #1
0
func aes_cleanup(ctx evp_ctx_ptr, c *aesCipher) {
	if ctx != nil {
		C.EVP_CIPHER_CTX_cleanup(ctx)
	}
	if c != nil && c.key != nil {
		Memset(c.key, 0)
	}
}
Beispiel #2
0
func New(key, iv []byte) Cipher {
	c := &cipher{}
	cgolock.Lock()
	defer cgolock.Unlock()

	C.EVP_CIPHER_CTX_init(&c.evp)
	runtime.SetFinalizer(c, func(c *cipher) {
		C.EVP_CIPHER_CTX_cleanup(&c.evp)
	})

	C.EVP_EncryptInit_ex(&c.evp, C.EVP_aes_128_ctr(), nil, (*C.uchar)(&key[0]), (*C.uchar)(&iv[0]))

	return c
}
Beispiel #3
0
func CleanUpCipherCtx(self *CipherCtx) {
	//ignore return value. Do we want to
	//panic in a finalizer?
	C.EVP_CIPHER_CTX_cleanup(self.evp_cipher_ctx)
}