undefined4
AES_Key_Unwrap(void *param_1,int param_2,undefined4 param_3,int param_4,void *param_5,uint *param_6)
{
uint uVar1;
undefined4 uVar2;
uint uVar3;
int iVar4;
uint uVar5;
uint uVar6;
int iVar7;
uint __n;
void *local_60;
undefined4 local_5c;
undefined1 auStack_58 [7];
byte local_51;
undefined1 auStack_50 [8];
undefined1 auStack_48 [8];
undefined1 auStack_40 [8];
undefined1 auStack_38 [8];
uint local_30;
int local_2c;
local_5c = 0;
if (((param_4 == 0x10) || (param_4 == 0x18)) || (param_4 == 0x20)) {
__n = param_2 - 8;
os_alloc_mem(0,&local_60,__n);
if (local_60 == (void *)0x0) {
uVar2 = 0xfffffffe;
if (RTDebugLevel != 0) {
printk("AES_Key_Unwrap: allocate %d bytes memory failure.\n",__n);
uVar2 = 0xfffffffe;
}
}
else {
memmove(auStack_58,param_1,8) //possible issue identified - semgrep
memmove(local_60,(void *)((int)param_1 + 8),__n) //possible issue identified - semgrep
uVar3 = __n >> 3;
uVar1 = uVar3 * 6;
local_30 = -uVar3 & 0xff;
local_2c = (uVar3 + 0x1fffffff) * 8;
iVar7 = 5;
do {
iVar4 = local_2c;
uVar5 = uVar1 & 0xff;
uVar6 = uVar3;
while( true ) {
uVar6 = uVar6 - 1;
if ((int)uVar6 < 0) break;
local_51 = (byte)uVar5 ^ local_51;
memmove(auStack_40,auStack_58,8) //possible issue identified - semgrep
memmove(auStack_38,(void *)((int)local_60 + iVar4),8) //possible issue identified - semgrep
local_5c = 0x10;
RT_AES_Decrypt(auStack_40,0x10,param_3,param_4,auStack_50,&local_5c);
memmove(auStack_58,auStack_50,8) //possible issue identified - semgrep
memmove((void *)((int)local_60 + iVar4),auStack_48,8) //possible issue identified - semgrep
uVar5 = uVar5 - 1 & 0xff;
iVar4 = iVar4 + -8;
}
iVar7 = iVar7 + -1;
uVar1 = (uVar1 & 0xff) + local_30;
} while (iVar7 != -1);
*param_6 = __n;
memmove(param_5,local_60,__n) //possible issue identified - semgrep
os_free_mem(0,local_60);
uVar2 = 0;
}
}
else {
uVar2 = 0xffffffff;
if (RTDebugLevel != 0) {
printk("AES_Key_Unwrap: key length is %d bytes, it must be %d, %d, or %d bytes(128, 192, or 256 bits).\n"
,param_4,0x10,0x18,0x20);
uVar2 = 0xffffffff;
}
}
return uVar2;
}