Advertisement
AnthonyCagliano

Untitled

Jan 10th, 2022
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. aes_error_t hashlib_AESAuthDecrypt(const uint8_t* in, size_t in_len, uint8_t* out, aes_ctx* key, const uint8_t* iv, uint8_t ciphermode, size_t encr_start, size_t encr_len){
  2. SHA256_CTX ctx;
  3. uint32_t mbuffer[64];
  4. uint8_t sha_digest[32];
  5. size_t out_offset = (in == out) ? encr_start : 0;
  6.  
  7. hashlib_Sha256Init(&ctx, mbuffer);
  8. hashlib_Sha256Update(&ctx, in, in_len-32);
  9. hashlib_Sha256Final(&ctx, sha_digest);
  10. if(!hashlib_CompareDigest(&in[in_len-33], sha_digest, 32))
  11. return AES_INVALID_CIPHERTEXT;
  12.  
  13. return hashlib_AESDecrypt(&in[encr_start], encr_len, &out[out_offset], key, iv, ciphermode, SCHM_DEFAULT);
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement