func (a *aesctr) XORKeyStream(dst, src []byte) { for i := range src { if a.idx == blocksize { // generate a block by encrypting the current counter C.AES_encrypt((*C.uchar)(&a.ctr[0]), (*C.uchar)(&a.out[0]), &a.key) // increment the counter for j := blocksize - 1; ; j-- { a.ctr[j]++ if a.ctr[j] != 0 { break } } a.idx = 0 } dst[i] = src[i] ^ a.out[a.idx] a.idx++ } }
func (a *aes) Encrypt(dst, src []byte) { C.AES_encrypt((*C.uchar)(&src[0]), (*C.uchar)(&dst[0]), &a.key) }