The Ctrl + V Game

  • Thread starter Thread starter smileyhead
  • Start date Start date
  • Views Views 574,587
  • Replies Replies 9,272
  • Likes Likes 15
upload_2017-9-17_20-2-25.png


For the context, my phone USB port broke, and only ads "for pieces" I find all have the USB port broken.
I'm seeing a fucking pattern here.
 
Code:
#define SHA1_LENGTH 20

struct rsa_cert {
   u32 signature_type;
   char rsa_signature[256]; // 2048 bits
   char unused[60];
};

struct tmd {
   char issuer[0x40];
   // more metadata...
   char content_hash[SHA1_LENGTH];
   // more content records and hashes...
}

struct signed_tmd {
   struct rsa_cert cert;
   struct tmd tmd;
}

int verify_tmd (struct signed_tmd stmd) {
  char decrypted_sig[256] = RSA_DecryptSig(CA_public_key, stmd.cert.rsa_signature);
  char sig_hash = decrypted_sig[256-SHA1_LENGTH:256];
  char payload_hash[SHA1_LENGTH] = SHA1(stmd.tmd);

  if (strncmp(payload_hash, sig_hash, SHA1_LENGTH) == 0) {
    return SIG_OK;
  } else {
    return SIG_BAD;
  }
}

int is_a_valid_disc(struct signed_tmd tmd, char *disc_hash) {
   if(verify_tmd(stmd) == SIG_BAD) {
    return DISC_BAD;
   }
   if(memcmp(stmd.tmd.content_hash, disc_hash, SHA1_LENGTH) != 0)  {
    return DISC_BAD;
   }

   return DISC_OK;
}

The bug here is that payload_hash is a binary SHA1 hash (not an ASCII string), and therefore may contain a NULL byte ('\0'). To quote from the first google hit for strncmp:

Compares up to num characters of the C string str1 to those of the C string str2. This function starts comparing the first character of each string. If they are equal to each other, it continues with the following pairs until the characters differ, until a terminating null-character is reached, or until num characters match in both strings, whichever happens first.
 
  • Like
Reactions: hobbledehoy899
What are 5 albums that you would suggest to someone? (This can include the OSTs for videogames.)
If you won the lottery, what would you use the money for, other than something like giving the money to charity?
What is the most disgusting snackfood/junkfood you've ever had?
What game(s) do you play that you would consider to be guilty pleasure games?
Are there any neat little websites you like that aren't very well known?
 
  • Like
Reactions: hobbledehoy899

Site & Scene News

Popular threads in this forum