NVbit : Accessing Bitlocker volumes from linux.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
1.5KB

  1. /*
  2. nvbit Bitlocker for linux
  3. ------------------------------
  4. Nitin Kumar nitin at nvlabs.in
  5. Vipin Kumar vipin at nvlabs.in
  6. web: http://www.nvlabs.in
  7. Licensed under GPL Version 3
  8. -------------------
  9. Copyright (c) 2008
  10. Released under the GPL Version 3
  11. http://www.gnu.org/licenses/gpl-3.0.txt
  12. */
  13. // This file contains some common definitions
  14. #include <stdio.h>
  15. #include <malloc.h>
  16. #include "common.h"
  17. #include "header.h"
  18. // all keys are 32 bytes or 256 bit
  19. // though this sgould be a function which should calculate key size from header and after header data
  20. // however, at this time it's hard code, however it's working till now !!!!!
  21. #define GetKeySize(x) 0x20
  22. // this will return a pointer to the next header
  23. HEADER *Next_Header(HEADER * header_ptr)
  24. {
  25. HEADER *header;
  26. header = header_ptr;
  27. header = (HEADER *)((int8 *)header + header->Size);
  28. if(header)
  29. return header;
  30. return NULL;
  31. }
  32. // this will return a pointer to data contained in the header
  33. int8 *Header_Data_Pointer(HEADER * header)
  34. {
  35. if ( header->Size > sizeof(HEADER))
  36. return ((int8 *)header + sizeof(HEADER));
  37. else
  38. return 0; // if no data then return 0
  39. }
  40. // this will allocate a buffer and zero it out
  41. void *malloc_zero(int32 Size)
  42. {
  43. void *ptr;
  44. ptr = malloc(Size);
  45. if(!ptr)
  46. return 0; // return if memory could not be allocated
  47. // now do a memset
  48. memset(ptr,0,Size);
  49. return ptr;
  50. }