{"type": "func", "start": 8863736, "end": 8864196, "name": "CMS_add1_recipient_cert", "pseudocode": "// \n// CMS_add1_recipient_cert from 0x873ff8 to 0x8741c4 (460 bytes)\n// \n// 1 xrefs:\n// > <???> @ 0x6a1bc\n// \n// This function is hookable on this platform!\n// \n// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA\n// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings\n// \n\n_DWORD *__fastcall CMS_add1_recipient_cert(int *a1, int a2, int a3)\n{\n  int v5; // r10\n  _DWORD *v6; // r4\n  int v7; // r0\n  int v8; // r11\n  int ri_type; // r0\n  _DWORD *v11; // r0\n  _DWORD *v12; // r5\n  int v13; // r3\n  int v14; // r2\n  int *v15; // r0\n\n  v5 = cms_get0_enveloped(a1);\n  if ( !v5 )\n  {\n    v6 = nullptr;\n    goto LABEL_10;\n  }\n  v6 = ASN1_item_new((int)CMS_RecipientInfo_it);\n  if ( !v6 )\n    goto LABEL_22;\n  v7 = X509_get0_pubkey(a2);\n  v8 = v7;\n  if ( !v7 )\n  {\n    ERR_put_error(46, 101, 113, (int)\"crypto/cms/cms_env.c\", 195);\n    goto LABEL_10;\n  }\n  ri_type = cms_pkey_get_ri_type(v7);\n  if ( !ri_type )\n  {\n    v11 = ASN1_item_new((int)&CMS_KeyTransRecipientInfo_it);\n    v12 = v11;\n    v6[1] = v11;\n    if ( !v11 )\n      goto LABEL_10;\n    v13 = a3 & 0x10000;\n    if ( (a3 & 0x10000) != 0 )\n      v13 = 2;\n    *v6 = 0;\n    v14 = (a3 & 0x10000) != 0 ? 1 : v13;\n    *v11 = v13;\n    if ( !cms_set1_SignerIdentifier(v11[1], a2, v14) )\n      goto LABEL_10;\n    X509_up_ref(a2);\n    EVP_PKEY_up_ref(v8);\n    v12[5] = v8;\n    v12[4] = a2;\n    if ( (a3 & 0x40000) != 0 )\n    {\n      v15 = (int *)EVP_PKEY_CTX_new(v8, nullptr);\n      v12[6] = v15;\n      if ( !v15 || EVP_PKEY_encrypt_init(v15) <= 0 )\n        goto LABEL_10;\n    }\n    else if ( !cms_env_asn1_ctrl(v6, a3 & 0x40000) )\n    {\n      goto LABEL_10;\n    }\n    goto LABEL_7;\n  }\n  if ( ri_type == 1 )\n  {\n    if ( cms_RecipientInfo_kari_init(v6, a2, v8, a3) )\n    {\nLABEL_7:\n      if ( OPENSSL_sk_push(*(int **)(v5 + 8), (int)v6) )\n        return v6;\nLABEL_22:\n      ERR_put_error(46, 101, 65, (int)\"crypto/cms/cms_env.c\", 224);\n    }\n  }\n  else\n  {\n    ERR_put_error(46, 101, 125, (int)\"crypto/cms/cms_env.c\", 213);\n  }\nLABEL_10:\n  ASN1_item_free(v6, CMS_RecipientInfo_it);\n  return nullptr;\n}", "assembly": "; \n; CMS_add1_recipient_cert from 0x873ff8 to 0x8741c4 (460 bytes)\n; \n; 1 xrefs:\n; > <???> @ 0x6a1bc\n; \n; This function is hookable on this platform!\n; \n; Using BromaIDA 8.0.0 @ https:;github.com/Stazzical/BromaIDA\n; Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https:;github.com/geode-sdk/bindings\n; \n\nPUSH            {R4-R11,LR}                                            ; +0x0, 0x873ff8\nSUB             SP, SP, #0xC                                           ; +0x4, 0x873ffc\nMOV             R6, R1                                                 ; +0x8, 0x874000\nMOV             R8, R2                                                 ; +0xc, 0x874004\nBL              cms_get0_enveloped                                     ; +0x10, 0x874008\nLDR             R5, =(_GLOBAL_OFFSET_TABLE_ - 0x87401C)                ; +0x14, 0x87400c\nLDR             R3, =(CMS_RecipientInfo_it_ptr - 0xAB8990)             ; +0x18, 0x874010\nADD             R5, PC, R5; _GLOBAL_OFFSET_TABLE_                      ; +0x1c, 0x874014\nSUBS            R10, R0, #0                                            ; +0x20, 0x874018\nBEQ             loc_874194                                             ; +0x24, 0x87401c\nLDR             R7, [R5,R3]; CMS_RecipientInfo_it                      ; +0x28, 0x874020\nMOV             R0, R7                                                 ; +0x2c, 0x874024\nBL              ASN1_item_new                                          ; +0x30, 0x874028\nSUBS            R4, R0, #0                                             ; +0x34, 0x87402c\nBEQ             loc_87415C                                             ; +0x38, 0x874030\nMOV             R0, R6                                                 ; +0x3c, 0x874034\nBL              X509_get0_pubkey                                       ; +0x40, 0x874038\nSUBS            R11, R0, #0                                            ; +0x44, 0x87403c\nBEQ             loc_8741A0                                             ; +0x48, 0x874040\nBL              cms_pkey_get_ri_type                                   ; +0x4c, 0x874044\nSUBS            R9, R0, #0                                             ; +0x50, 0x874048\nBEQ             loc_8740CC                                             ; +0x54, 0x87404c\nCMP             R9, #1                                                 ; +0x58, 0x874050\nBNE             loc_874094                                             ; +0x5c, 0x874054\nMOV             R1, R6                                                 ; +0x60, 0x874058\nMOV             R2, R11                                                ; +0x64, 0x87405c\nMOV             R3, R8                                                 ; +0x68, 0x874060\nMOV             R0, R4                                                 ; +0x6c, 0x874064\nBL              cms_RecipientInfo_kari_init                            ; +0x70, 0x874068\nCMP             R0, #0                                                 ; +0x74, 0x87406c\nBEQ             loc_8740B4                                             ; +0x78, 0x874070\nLDR             R0, [R10,#8]                                           ; +0x7c, 0x874074\nMOV             R1, R4                                                 ; +0x80, 0x874078\nBL              OPENSSL_sk_push                                        ; +0x84, 0x87407c\nCMP             R0, #0                                                 ; +0x88, 0x874080\nBEQ             loc_87415C                                             ; +0x8c, 0x874084\nMOV             R0, R4                                                 ; +0x90, 0x874088\nADD             SP, SP, #0xC                                           ; +0x94, 0x87408c\nPOP             {R4-R11,PC}                                            ; +0x98, 0x874090\nMOV             R3, #0xD5                                              ; +0x9c, 0x874094\nSTR             R3, [SP,#0xC+var_C]                                    ; +0xa0, 0x874098\nLDR             R3, =(aCryptoCmsCmsEn - 0x8740B4); \"crypto/cms/cms_env.c\" ; +0xa4, 0x87409c\nMOV             R0, #0x2E ; '.'                                        ; +0xa8, 0x8740a0\nMOV             R1, #0x65 ; 'e'                                        ; +0xac, 0x8740a4\nMOV             R2, #0x7D ; '}'                                        ; +0xb0, 0x8740a8\nADD             R3, PC, R3; \"crypto/cms/cms_env.c\"                     ; +0xb4, 0x8740ac\nBL              ERR_put_error                                          ; +0xb8, 0x8740b0\nMOV             R0, R4                                                 ; +0xbc, 0x8740b4\nMOV             R1, R7                                                 ; +0xc0, 0x8740b8\nBL              ASN1_item_free                                         ; +0xc4, 0x8740bc\nMOV             R0, #0                                                 ; +0xc8, 0x8740c0\nADD             SP, SP, #0xC                                           ; +0xcc, 0x8740c4\nPOP             {R4-R11,PC}                                            ; +0xd0, 0x8740c8\nLDR             R3, =(CMS_KeyTransRecipientInfo_it_ptr - 0xAB8990)     ; +0xd4, 0x8740cc\nLDR             R0, [R5,R3]; CMS_KeyTransRecipientInfo_it              ; +0xd8, 0x8740d0\nBL              ASN1_item_new                                          ; +0xdc, 0x8740d4\nCMP             R0, #0                                                 ; +0xe0, 0x8740d8\nMOV             R5, R0                                                 ; +0xe4, 0x8740dc\nSTR             R0, [R4,#4]                                            ; +0xe8, 0x8740e0\nBEQ             loc_8740B4                                             ; +0xec, 0x8740e4\nANDS            R3, R8, #0x10000                                       ; +0xf0, 0x8740e8\nMOVNE           R3, #2                                                 ; +0xf4, 0x8740ec\nSTR             R9, [R4]                                               ; +0xf8, 0x8740f0\nMOVNE           R2, #1                                                 ; +0xfc, 0x8740f4\nMOVEQ           R2, R3                                                 ; +0x100, 0x8740f8\nSTR             R3, [R0]                                               ; +0x104, 0x8740fc\nMOV             R1, R6                                                 ; +0x108, 0x874100\nLDR             R0, [R0,#4]                                            ; +0x10c, 0x874104\nBL              cms_set1_SignerIdentifier                              ; +0x110, 0x874108\nCMP             R0, #0                                                 ; +0x114, 0x87410c\nBEQ             loc_8740B4                                             ; +0x118, 0x874110\nMOV             R0, R6                                                 ; +0x11c, 0x874114\nBL              X509_up_ref                                            ; +0x120, 0x874118\nMOV             R0, R11                                                ; +0x124, 0x87411c\nBL              EVP_PKEY_up_ref                                        ; +0x128, 0x874120\nANDS            R1, R8, #0x40000                                       ; +0x12c, 0x874124\nSTR             R11, [R5,#0x14]                                        ; +0x130, 0x874128\nSTR             R6, [R5,#0x10]                                         ; +0x134, 0x87412c\nBEQ             loc_874180                                             ; +0x138, 0x874130\nMOV             R0, R11                                                ; +0x13c, 0x874134\nMOV             R1, #0                                                 ; +0x140, 0x874138\nBL              EVP_PKEY_CTX_new                                       ; +0x144, 0x87413c\nCMP             R0, #0                                                 ; +0x148, 0x874140\nSTR             R0, [R5,#0x18]                                         ; +0x14c, 0x874144\nBEQ             loc_8740B4                                             ; +0x150, 0x874148\nBL              EVP_PKEY_encrypt_init                                  ; +0x154, 0x87414c\nCMP             R0, #0                                                 ; +0x158, 0x874150\nBGT             loc_874074                                             ; +0x15c, 0x874154\nB               loc_8740B4                                             ; +0x160, 0x874158\nMOV             R3, #0xE0                                              ; +0x164, 0x87415c\nSTR             R3, [SP,#0xC+var_C]                                    ; +0x168, 0x874160\nLDR             R3, =(aCryptoCmsCmsEn - 0x87417C); \"crypto/cms/cms_env.c\" ; +0x16c, 0x874164\nMOV             R0, #0x2E ; '.'                                        ; +0x170, 0x874168\nMOV             R1, #0x65 ; 'e'                                        ; +0x174, 0x87416c\nMOV             R2, #0x41 ; 'A'                                        ; +0x178, 0x874170\nADD             R3, PC, R3; \"crypto/cms/cms_env.c\"                     ; +0x17c, 0x874174\nBL              ERR_put_error                                          ; +0x180, 0x874178\nB               loc_8740B4                                             ; +0x184, 0x87417c\nMOV             R0, R4                                                 ; +0x188, 0x874180\nBL              cms_env_asn1_ctrl                                      ; +0x18c, 0x874184\nCMP             R0, #0                                                 ; +0x190, 0x874188\nBNE             loc_874074                                             ; +0x194, 0x87418c\nB               loc_8740B4                                             ; +0x198, 0x874190\nMOV             R4, R10                                                ; +0x19c, 0x874194\nLDR             R7, [R5,R3]; CMS_RecipientInfo_it                      ; +0x1a0, 0x874198\nB               loc_8740B4                                             ; +0x1a4, 0x87419c\nMOV             R3, #0xC3                                              ; +0x1a8, 0x8741a0\nSTR             R3, [SP,#0xC+var_C]                                    ; +0x1ac, 0x8741a4\nLDR             R3, =(aCryptoCmsCmsEn - 0x8741C0); \"crypto/cms/cms_env.c\" ; +0x1b0, 0x8741a8\nMOV             R0, #0x2E ; '.'                                        ; +0x1b4, 0x8741ac\nMOV             R1, #0x65 ; 'e'                                        ; +0x1b8, 0x8741b0\nMOV             R2, #0x71 ; 'q'                                        ; +0x1bc, 0x8741b4\nADD             R3, PC, R3; \"crypto/cms/cms_env.c\"                     ; +0x1c0, 0x8741b8\nBL              ERR_put_error                                          ; +0x1c4, 0x8741bc\nB               loc_8740B4                                             ; +0x1c8, 0x8741c0", "xrefs": ["<???> @ 0x6a1bc"], "is_objc": false, "is_arm32": false, "is_arm64": false, "bida_info": "8.0.0 @ https://github.com/Stazzical/BromaIDA", "bindings_info": "commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings"}