diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/ fil0crypt.cc
index 75efcdfdab0..095b9f706c0 100644
--- a/storage/innobase/fil/fil0crypt.cc
+++ b/storage/innobase/fil/fil0crypt.cc
@@ -1179,10 +1179,11 @@ fil_crypt_start_encrypting_space(
/* 3 - compute location to store crypt data */
byte* frame = buf_block_get_frame(block);
- ulint maxsize = 0;
ut_ad(crypt_data);
- crypt_data->page0_offset =
- fsp_header_get_crypt_offset(page_size, &maxsize);
+ crypt_data->page0_offset = FSP_HEADER_OFFSET
+ + fsp_header_get_encryption_offset(page_size);
+ const ulint maxsize = page_size.logical()
+ - crypt_data->page0_offset - FIL_PAGE_DATA_END;