qcom_hibernation.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #ifndef __SOC_QCOM_HIBERNATION_H__
  6. #define __SOC_QCOM_HIBERNATION_H__
  7. #include <linux/blk_types.h>
  8. #include <linux/blkdev.h>
  9. #define AES256_KEY_SIZE 32
  10. #define NUM_KEYS 2
  11. #define PAYLOAD_KEY_SIZE (AES256_KEY_SIZE * NUM_KEYS)
  12. #define RAND_INDEX_SIZE 8
  13. #define NONCE_LENGTH 8
  14. #define MAC_LENGTH 16
  15. #define TIME_STRUCT_LENGTH 48
  16. #define WRAP_PAYLOAD_LENGTH \
  17. (PAYLOAD_KEY_SIZE + RAND_INDEX_SIZE + TIME_STRUCT_LENGTH)
  18. #define AAD_LENGTH 20
  19. #define AAD_WITH_PAD_LENGTH 32
  20. #define WRAPPED_KEY_SIZE \
  21. (AAD_WITH_PAD_LENGTH + WRAP_PAYLOAD_LENGTH + MAC_LENGTH + \
  22. NONCE_LENGTH)
  23. #define IV_SIZE 12
  24. struct qcom_crypto_params {
  25. unsigned int authsize;
  26. unsigned int authslot_count;
  27. unsigned char key_blob[WRAPPED_KEY_SIZE];
  28. unsigned char iv[IV_SIZE];
  29. unsigned char aad[12];
  30. };
  31. struct hib_bio_batch {
  32. atomic_t count;
  33. wait_queue_head_t wait;
  34. blk_status_t error;
  35. struct blk_plug plug;
  36. };
  37. extern struct block_device *hiber_bdev;
  38. #endif /* __SOC_QCOM_HIBERNATION_H__ */