Example #1
0
func init() {
	aes_ciphers = []evp_cipher_ptr{
		C.EVP_aes_128_ctr(),
		C.EVP_aes_128_ofb(),
		C.EVP_aes_192_ctr(),
		C.EVP_aes_192_ctr(), // no 192-ofb
		C.EVP_aes_256_ctr(),
		C.EVP_aes_256_ofb(),
	}
}
Example #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
}