Skip to content

Instantly share code, notes, and snippets.

@pixel-stuck
Created June 14, 2019 22:03
Show Gist options
  • Save pixel-stuck/0802faf737530cbf94c516c5c0433811 to your computer and use it in GitHub Desktop.
Save pixel-stuck/0802faf737530cbf94c516c5c0433811 to your computer and use it in GitHub Desktop.
int32_t verify_cert_chain(int **certificate_chain,int type)
{
int32_t iVar1;
int iVar2;
char *type_str;
int **ppiVar3;
type_str = "XS";
if (type == 0x2) {
type_str = "CP";
}
ppiVar3 = certificate_chain + 0x5;
while( true ) {
if ((type != 0x0) && (iVar1 = memcmp(*certificate_chain + 0x13,type_str,0x2), iVar1 != 0x0)) {
return -0x1;
}
/* check if this is the root cert */
iVar2 = strcmp((char *)(*certificate_chain + 0x3),"Root");
if (iVar2 == 0x0) {
/* Pass NULL as second arg to check Root signature */
iVar1 = verify_cert_signature(*certificate_chain,NULL);
return iVar1;
}
/* Pass next cert in to verify previous cert */
iVar1 = verify_cert_signature(*certificate_chain,certificate_chain[0x1]);
if (iVar1 != 0x0) break;
certificate_chain = certificate_chain + 0x1;
if ((int)ppiVar3 <= (int)certificate_chain) {
return 0x0;
}
}
return -0x1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment