예제 #1
0
func fastAES_GCM(rwkey []byte) fastGCMState {
	key := hash_invar(rwkey)[:16]
	state := make([]byte, 65536*20)
	sched := (*_Ctype_gcm_state)(unsafe.Pointer(&state[0]))
	idx := C.find_cipher(C.CString("aes"))
	FASSERT(C.gcm_init(sched, idx, unsafe_bytes(key), C.int(len(key))) == C.CRYPT_OK)
	//LOG(LOG_DEBUG, "%X", state)
	return fastGCMState(state)
}
예제 #2
0
func fastTF_NewOFB(key []byte) fastTF_State {
	idx := C.find_cipher(C.CString("aes"))
	iv := make([]byte, 16)
	state := make([]byte, 65536)
	FASSERT(C.ofb_start(idx,
		unsafe_bytes(iv),
		unsafe_bytes(key),
		C.int(len(key)),
		C.int(0), (*_Ctype_symmetric_OFB)((unsafe.Pointer)(&state[0]))) == C.CRYPT_OK)
	return state
}