Validate crypto_size before using it to access memory