242 lines
8.5 KiB
C#
242 lines
8.5 KiB
C#
#if USE_UNI_LUA
|
|
using LuaAPI = UniLua.Lua;
|
|
using RealStatePtr = UniLua.ILuaState;
|
|
using LuaCSFunction = UniLua.CSharpFunctionDelegate;
|
|
#else
|
|
using LuaAPI = XLua.LuaDLL.Lua;
|
|
using RealStatePtr = System.IntPtr;
|
|
using LuaCSFunction = XLua.LuaDLL.lua_CSFunction;
|
|
#endif
|
|
|
|
using XLua;
|
|
using System.Collections.Generic;
|
|
|
|
|
|
namespace XLua.CSObjectWrap
|
|
{
|
|
using Utils = XLua.Utils;
|
|
public class BFCounterModeCryptoTransformWrap
|
|
{
|
|
public static void __Register(RealStatePtr L)
|
|
{
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
System.Type type = typeof(BF.CounterModeCryptoTransform);
|
|
Utils.BeginObjectRegister(type, L, translator, 0, 3, 4, 0);
|
|
|
|
Utils.RegisterFunc(L, Utils.METHOD_IDX, "TransformFinalBlock", _m_TransformFinalBlock);
|
|
Utils.RegisterFunc(L, Utils.METHOD_IDX, "TransformBlock", _m_TransformBlock);
|
|
Utils.RegisterFunc(L, Utils.METHOD_IDX, "Dispose", _m_Dispose);
|
|
|
|
|
|
Utils.RegisterFunc(L, Utils.GETTER_IDX, "InputBlockSize", _g_get_InputBlockSize);
|
|
Utils.RegisterFunc(L, Utils.GETTER_IDX, "OutputBlockSize", _g_get_OutputBlockSize);
|
|
Utils.RegisterFunc(L, Utils.GETTER_IDX, "CanTransformMultipleBlocks", _g_get_CanTransformMultipleBlocks);
|
|
Utils.RegisterFunc(L, Utils.GETTER_IDX, "CanReuseTransform", _g_get_CanReuseTransform);
|
|
|
|
|
|
|
|
Utils.EndObjectRegister(type, L, translator, null, null,
|
|
null, null, null);
|
|
|
|
Utils.BeginClassRegister(type, L, __CreateInstance, 1, 0, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Utils.EndClassRegister(type, L, translator);
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int __CreateInstance(RealStatePtr L)
|
|
{
|
|
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
if(LuaAPI.lua_gettop(L) == 4 && translator.Assignable<System.Security.Cryptography.SymmetricAlgorithm>(L, 2) && (LuaAPI.lua_isnil(L, 3) || LuaAPI.lua_type(L, 3) == LuaTypes.LUA_TSTRING) && (LuaAPI.lua_isnil(L, 4) || LuaAPI.lua_type(L, 4) == LuaTypes.LUA_TSTRING))
|
|
{
|
|
System.Security.Cryptography.SymmetricAlgorithm _symmetricAlgorithm = (System.Security.Cryptography.SymmetricAlgorithm)translator.GetObject(L, 2, typeof(System.Security.Cryptography.SymmetricAlgorithm));
|
|
byte[] _key = LuaAPI.lua_tobytes(L, 3);
|
|
byte[] _counter = LuaAPI.lua_tobytes(L, 4);
|
|
|
|
var gen_ret = new BF.CounterModeCryptoTransform(_symmetricAlgorithm, _key, _counter);
|
|
translator.Push(L, gen_ret);
|
|
|
|
return 1;
|
|
}
|
|
|
|
}
|
|
catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return LuaAPI.luaL_error(L, "invalid arguments to BF.CounterModeCryptoTransform constructor!");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_TransformFinalBlock(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
|
|
BF.CounterModeCryptoTransform gen_to_be_invoked = (BF.CounterModeCryptoTransform)translator.FastGetCSObj(L, 1);
|
|
|
|
|
|
|
|
{
|
|
byte[] _inputBuffer = LuaAPI.lua_tobytes(L, 2);
|
|
int _inputOffset = LuaAPI.xlua_tointeger(L, 3);
|
|
int _inputCount = LuaAPI.xlua_tointeger(L, 4);
|
|
|
|
var gen_ret = gen_to_be_invoked.TransformFinalBlock( _inputBuffer, _inputOffset, _inputCount );
|
|
LuaAPI.lua_pushstring(L, gen_ret);
|
|
|
|
|
|
|
|
return 1;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_TransformBlock(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
|
|
BF.CounterModeCryptoTransform gen_to_be_invoked = (BF.CounterModeCryptoTransform)translator.FastGetCSObj(L, 1);
|
|
|
|
|
|
|
|
{
|
|
byte[] _inputBuffer = LuaAPI.lua_tobytes(L, 2);
|
|
int _inputOffset = LuaAPI.xlua_tointeger(L, 3);
|
|
int _inputCount = LuaAPI.xlua_tointeger(L, 4);
|
|
byte[] _outputBuffer = LuaAPI.lua_tobytes(L, 5);
|
|
int _outputOffset = LuaAPI.xlua_tointeger(L, 6);
|
|
|
|
var gen_ret = gen_to_be_invoked.TransformBlock( _inputBuffer, _inputOffset, _inputCount, _outputBuffer, _outputOffset );
|
|
LuaAPI.xlua_pushinteger(L, gen_ret);
|
|
|
|
|
|
|
|
return 1;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_Dispose(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
|
|
BF.CounterModeCryptoTransform gen_to_be_invoked = (BF.CounterModeCryptoTransform)translator.FastGetCSObj(L, 1);
|
|
|
|
|
|
|
|
{
|
|
|
|
gen_to_be_invoked.Dispose( );
|
|
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _g_get_InputBlockSize(RealStatePtr L)
|
|
{
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
BF.CounterModeCryptoTransform gen_to_be_invoked = (BF.CounterModeCryptoTransform)translator.FastGetCSObj(L, 1);
|
|
LuaAPI.xlua_pushinteger(L, gen_to_be_invoked.InputBlockSize);
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _g_get_OutputBlockSize(RealStatePtr L)
|
|
{
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
BF.CounterModeCryptoTransform gen_to_be_invoked = (BF.CounterModeCryptoTransform)translator.FastGetCSObj(L, 1);
|
|
LuaAPI.xlua_pushinteger(L, gen_to_be_invoked.OutputBlockSize);
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _g_get_CanTransformMultipleBlocks(RealStatePtr L)
|
|
{
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
BF.CounterModeCryptoTransform gen_to_be_invoked = (BF.CounterModeCryptoTransform)translator.FastGetCSObj(L, 1);
|
|
LuaAPI.lua_pushboolean(L, gen_to_be_invoked.CanTransformMultipleBlocks);
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _g_get_CanReuseTransform(RealStatePtr L)
|
|
{
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
BF.CounterModeCryptoTransform gen_to_be_invoked = (BF.CounterModeCryptoTransform)translator.FastGetCSObj(L, 1);
|
|
LuaAPI.lua_pushboolean(L, gen_to_be_invoked.CanReuseTransform);
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|