Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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){
- SHA256_CTX ctx;
- uint32_t mbuffer[64];
- uint8_t sha_digest[32];
- size_t out_offset = (in == out) ? encr_start : 0;
- hashlib_Sha256Init(&ctx, mbuffer);
- hashlib_Sha256Update(&ctx, in, in_len-32);
- hashlib_Sha256Final(&ctx, sha_digest);
- if(!hashlib_CompareDigest(&in[in_len-33], sha_digest, 32))
- return AES_INVALID_CIPHERTEXT;
- return hashlib_AESDecrypt(&in[encr_start], encr_len, &out[out_offset], key, iv, ciphermode, SCHM_DEFAULT);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement