undefined4
AES_Key_Wrap(void *param_1,uint param_2,undefined4 param_3,int param_4,void *param_5,int *param_6)
{
bool bVar1;
undefined4 uVar2;
uint uVar3;
uint uVar4;
uint uVar5;
int iVar6;
int iVar7;
void *local_60;
undefined4 local_5c;
undefined1 auStack_58 [7];
byte local_51;
undefined1 auStack_50 [7];
byte local_49;
undefined1 auStack_48 [8];
undefined1 auStack_40 [8];
undefined1 auStack_38 [8];
uint local_30;
local_5c = 0;
if (((param_4 == 0x10) || (param_4 == 0x18)) || (param_4 == 0x20)) {
os_alloc_mem(0,&local_60,param_2);
if (local_60 == (void *)0x0) {
uVar2 = 0xfffffffe;
if (RTDebugLevel != 0) {
printk("AES_Key_Wrap: allocate %d bytes memory failure.\n",param_2);
uVar2 = 0xfffffffe;
}
}
else {
memmove(auStack_58,&Default_IV,8) //possible issue identified - semgrep
memmove(local_60,param_1,param_2) //possible issue identified - semgrep
local_30 = param_2 >> 3 & 0xff;
iVar6 = 0;
uVar5 = 1;
do {
uVar3 = 0;
uVar4 = uVar5;
while( true ) {
bVar1 = param_2 >> 3 <= uVar3;
iVar7 = uVar3 * 8;
uVar3 = uVar3 + 1;
if (bVar1) break;
memmove(auStack_40,auStack_58,8) //possible issue identified - semgrep
memmove(auStack_38,(void *)((int)local_60 + iVar7),8) //possible issue identified - semgrep
local_5c = 0x10;
RT_AES_Encrypt(auStack_40,0x10,param_3,param_4,auStack_50,&local_5c);
memmove(auStack_58,auStack_50,8) //possible issue identified - semgrep
local_51 = (byte)uVar4 ^ local_49;
memmove((void *)((int)local_60 + iVar7),auStack_48,8) //possible issue identified - semgrep
uVar4 = uVar4 + 1 & 0xff;
}
iVar6 = iVar6 + 1;
uVar5 = uVar5 + local_30 & 0xff;
} while (iVar6 != 6);
*param_6 = param_2 + 8;
memmove(param_5,auStack_58,8) //possible issue identified - semgrep
memmove((void *)((int)param_5 + 8),local_60,param_2) //possible issue identified - semgrep
os_free_mem(0,local_60);
uVar2 = 0;
}
}
else {
uVar2 = 0xffffffff;
if (RTDebugLevel != 0) {
printk("AES_Key_Wrap: 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;
}