Advertisement
Guest User

lol

a guest
Jun 26th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. // ---------------------------------------------------------------------------------------
  2. // Big Number Representations
  3. //
  4. // Multiple precision numbers are arranged as an array of digits, with the least
  5. // significant digit coming first ("little-endian digit ordering"), regardless
  6. // of the word size or byte ordering of the digit itself.
  7. //
  8. // A single digit is either a DWORD (4 bytes) or a QWORD (8 bytes). A bignum that
  9. // consists of a series of DWORD digits is tagged "BnDw", whereas a bignum that
  10. // consists of a series of QWORD digits is tagged "BnQw". A bignum function
  11. // is tagged with one of these two to specify the digit size it expects, and it
  12. // takes a length parameter that specifies the number of digits in the number.
  13. //
  14. // Consider a 8-byte number written in radix 256 notation. Here R=256.
  15. //
  16. // b7*(R^7)+b6*(R^6)+b5*(R^5)+b4*(R^5)+b3*(R^3)+b2*(R^2)+b1*(R^1)+b0*(R^0)
  17. //
  18. // A BnDw bignum consists of a series of DWORD digits. The DWORD can be encoded
  19. // in either little-endian or big-endian byte ordering. Thus there are two
  20. // possible formats for these digits.
  21. //
  22. // DwLe [b0 b1 b2 b3][b4 b5 b6 b7]
  23. // DwBe [b3 b2 b1 b0][b7 b6 b5 b4]
  24. //
  25. // A BnQw bignum consists of a series of QWORD digits. The QWORD can be encoded
  26. // in either little-endian or big-endian byte ordering. Thus there are two
  27. // possible formats for these digits.
  28. //
  29. // QwLe [b0 b1 b2 b3 b4 b5 b6 b7]
  30. // QwBe [b7 b6 b5 b4 b3 b2 b1 b0]
  31. //
  32. // A particular platform has a natural byte order (Le or Be). We use the tag Ne
  33. // to mean the natural byte order.
  34. //
  35. // Most low level bignum routines require inputs that are in QwNe format. That
  36. // is, QWORD digits in natural byte order for the platform. They take an array
  37. // of QWORD digits and a count of digits. The caller is responsible for converting
  38. // the bignum into the expected format.
  39. //
  40. // A full complement of conversion functions is available. The BnDw functions
  41. // will convert a bignum made up of a series of DWORD digits between DwLe, DwBe,
  42. // and DwNe formats. The BnQw functions will convert a bignum made up of a series
  43. // of QWORD digits between QwLe, QwBe, and QwNe formats. The BnQw functions can
  44. // also convert between BnDw and BnQw bignum formats, but since the length parameter
  45. // specifies the number of QWORD digits, the BnDw bignum must contain an even number
  46. // of DWORD digits.
  47. //
  48. // When a bignum is to be stored or used on multiple platforms, the application
  49. // must choose a concrete representation for the number. In the case of digital
  50. // signatures, we choose to store them in QwBe format. This was chosen to match
  51. // the natural word size and byte ordering of the Xenon console, so that the
  52. // signature checking code would be as small and fast as possible on that platform.
  53. // ---------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement