aboutsummaryrefslogtreecommitdiffstats
path: root/fw/pseudo/gcp.gcp_cmdFE0C_CreateCryptoSession.after.c
blob: 29d7741c766df8da7e891b6d63427d23496781bd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
int __fastcall gcp_cmdFE0C_CreateCryptoSession(struct gcp_ctx *ctx, struct ta_params *params)
{
  int v4; // r7
  struct gcp_crypto_session *crypto; // r5
  unsigned int *p_asd_refcount; // r6
  int v7; // r4
  unsigned int v8; // r2
  unsigned int v9; // r3
  unsigned __int64 arg18; // kr00_8
  unsigned int handle; // r0
  int v12; // r0

  v4 = 0;
  gcp_log(level: 0, fmt: aAmdTaGcpCreate_2);
  crypto = ctx->crypto;
  p_asd_refcount = &ctx->asd_refcount;
  while ( 1 )
  {
    if ( v4 == 0x40000000 )
    {
      v7 = 785;
      goto LABEL_10;
    }
    if ( crypto->state == 0 )
      break;
    v4 += 0x1000000;
    ++crypto;
  }
  gcp_lib_zero_fill_words(dst: crypto, len: 0x58u);
  crypto->state = 1;
  crypto->key = params->arg10;
  v8 = *p_asd_refcount;
  v9 = p_asd_refcount[2];
  arg18 = params->arg18;
  ++*p_asd_refcount;
  p_asd_refcount[2] = v9 + 1;
  handle = v9 & 0xFFFFFF | v4;
  crypto->field10 = arg18;
  crypto->handle = handle;
  if ( v8 == 0 )
  {
    v12 = gcp_asd_rpc_305(arg: 1u);
    if ( v12 != 0 )
    {
      v7 = v12 | 0x20000000;
      goto LABEL_10;
    }
    handle = crypto->handle;
  }
  params->out1950 = handle;
  v7 = 0;
  gcp_log(level: 0, fmt: aAmdTaGcpCreate_3);
LABEL_10:
  gcp_log(level: 0, fmt: aAmdTaGcpCreate_4);
  return v7;
}