Guest User

Untitled

a guest
Jul 16th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. module M
  2.  
  3. open FStar.HyperStack.ST
  4.  
  5. module HS = FStar.HyperStack
  6. module LB = LowStar.Buffer
  7. module L = FStar.List.Tot
  8.  
  9. noextract
  10. type _vector = {
  11. _key: string;
  12. }
  13.  
  14. noeq
  15. type vector = {
  16. key: LB.buffer UInt8.t;
  17. key_len: UInt32.t;
  18. }
  19.  
  20. let v_key: LB.buffer UInt8.t = LB.gcmalloc_of_list HS.root [
  21. 0xAAuy; 0xBBuy; 0xCCuy;
  22. ]
  23.  
  24. inline_for_extraction
  25. let v_key_len = 3ul
  26.  
  27. let v = {
  28. key = v_key;
  29. key_len = v_key_len;
  30. }
  31.  
  32. noextract
  33. let _v = {
  34. _key = "AABBCC";
  35. }
  36.  
  37. open FStar.UInt32
  38.  
  39. noextract
  40. let digit_to_int = function
  41. | '0' -> 0
  42. | '1' -> 1
  43. | '2' -> 2
  44. | '3' -> 3
  45. | '4' -> 4
  46. | '5' -> 5
  47. | '6' -> 6
  48. | '7' -> 7
  49. | '8' -> 8
  50. | '9' -> 9
  51. | 'a' | 'A' -> 10
  52. | 'b' | 'B' -> 11
  53. | 'c' | 'C' -> 12
  54. | 'd' | 'D' -> 13
  55. | 'e' | 'E' -> 14
  56. | 'f' | 'F' -> 15
  57.  
  58. noextract
  59. let hex_to_uint8 a b =
  60. UInt8.uint_to_t FStar.Mul.(digit_to_int a * 16 + digit_to_int b)
  61.  
  62. noextract
  63. val hex_list_to_uint8: list Char.char -> list UInt8.t
  64. let rec hex_list_to_uint8 s =
  65. match s with
  66. | a :: b :: s' -> hex_to_uint8 a b :: hex_list_to_uint8 s'
  67. | _ -> []
  68.  
  69. noextract
  70. let _v'_key = hex_list_to_uint8 (String.list_of_string _v._key)
  71.  
  72. let v'_key = LB.gcmalloc_of_list HS.root (normalize_term _v'_key)
  73.  
  74. let v' = {
  75. key = v'_key;
  76. key_len = normalize_term (UInt32.uint_to_t (List.Tot.length _v'_key));
  77. }
Add Comment
Please, Sign In to add comment