messages-management.proto 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. // This file originates from the SatoshiLabs Trezor `common` repository at:
  2. // https://github.com/trezor/trezor-common/blob/master/protob/messages-management.proto
  3. // dated 28.05.2019, commit 893fd219d4a01bcffa0cd9cfa631856371ec5aa9.
  4. syntax = "proto2";
  5. package hw.trezor.messages.management;
  6. // Sugar for easier handling in Java
  7. option java_package = "com.satoshilabs.trezor.lib.protobuf";
  8. option java_outer_classname = "TrezorMessageManagement";
  9. import "messages-common.proto";
  10. /**
  11. * Request: Reset device to default state and ask for device details
  12. * @start
  13. * @next Features
  14. */
  15. message Initialize {
  16. optional bytes state = 1; // assumed device state, clear session if set and different
  17. optional bool skip_passphrase = 2; // this session should always assume empty passphrase
  18. }
  19. /**
  20. * Request: Ask for device details (no device reset)
  21. * @start
  22. * @next Features
  23. */
  24. message GetFeatures {
  25. }
  26. /**
  27. * Response: Reports various information about the device
  28. * @end
  29. */
  30. message Features {
  31. optional string vendor = 1; // name of the manufacturer, e.g. "trezor.io"
  32. optional uint32 major_version = 2; // major version of the firmware/bootloader, e.g. 1
  33. optional uint32 minor_version = 3; // minor version of the firmware/bootloader, e.g. 0
  34. optional uint32 patch_version = 4; // patch version of the firmware/bootloader, e.g. 0
  35. optional bool bootloader_mode = 5; // is device in bootloader mode?
  36. optional string device_id = 6; // device's unique identifier
  37. optional bool pin_protection = 7; // is device protected by PIN?
  38. optional bool passphrase_protection = 8; // is node/mnemonic encrypted using passphrase?
  39. optional string language = 9; // device language
  40. optional string label = 10; // device description label
  41. optional bool initialized = 12; // does device contain seed?
  42. optional bytes revision = 13; // SCM revision of firmware
  43. optional bytes bootloader_hash = 14; // hash of the bootloader
  44. optional bool imported = 15; // was storage imported from an external source?
  45. optional bool pin_cached = 16; // is PIN already cached in session?
  46. optional bool passphrase_cached = 17; // is passphrase already cached in session?
  47. optional bool firmware_present = 18; // is valid firmware loaded?
  48. optional bool needs_backup = 19; // does storage need backup? (equals to Storage.needs_backup)
  49. optional uint32 flags = 20; // device flags (equals to Storage.flags)
  50. optional string model = 21; // device hardware model
  51. optional uint32 fw_major = 22; // reported firmware version if in bootloader mode
  52. optional uint32 fw_minor = 23; // reported firmware version if in bootloader mode
  53. optional uint32 fw_patch = 24; // reported firmware version if in bootloader mode
  54. optional string fw_vendor = 25; // reported firmware vendor if in bootloader mode
  55. optional bytes fw_vendor_keys = 26; // reported firmware vendor keys (their hash)
  56. optional bool unfinished_backup = 27; // report unfinished backup (equals to Storage.unfinished_backup)
  57. optional bool no_backup = 28; // report no backup (equals to Storage.no_backup)
  58. }
  59. /**
  60. * Request: clear session (removes cached PIN, passphrase, etc).
  61. * @start
  62. * @next Success
  63. */
  64. message ClearSession {
  65. }
  66. /**
  67. * Request: change language and/or label of the device
  68. * @start
  69. * @next Success
  70. * @next Failure
  71. */
  72. message ApplySettings {
  73. optional string language = 1;
  74. optional string label = 2;
  75. optional bool use_passphrase = 3;
  76. optional bytes homescreen = 4;
  77. optional PassphraseSourceType passphrase_source = 5;
  78. optional uint32 auto_lock_delay_ms = 6;
  79. optional uint32 display_rotation = 7; // in degrees from North
  80. /**
  81. * Structure representing passphrase source
  82. */
  83. enum PassphraseSourceType {
  84. ASK = 0;
  85. DEVICE = 1;
  86. HOST = 2;
  87. }
  88. }
  89. /**
  90. * Request: set flags of the device
  91. * @start
  92. * @next Success
  93. * @next Failure
  94. */
  95. message ApplyFlags {
  96. optional uint32 flags = 1; // bitmask, can only set bits, not unset
  97. }
  98. /**
  99. * Request: Starts workflow for setting/changing/removing the PIN
  100. * @start
  101. * @next Success
  102. * @next Failure
  103. */
  104. message ChangePin {
  105. optional bool remove = 1; // is PIN removal requested?
  106. }
  107. /**
  108. * Request: Test if the device is alive, device sends back the message in Success response
  109. * @start
  110. * @next Success
  111. */
  112. message Ping {
  113. optional string message = 1; // message to send back in Success message
  114. optional bool button_protection = 2; // ask for button press
  115. optional bool pin_protection = 3; // ask for PIN if set in device
  116. optional bool passphrase_protection = 4; // ask for passphrase if set in device
  117. }
  118. /**
  119. * Request: Abort last operation that required user interaction
  120. * @start
  121. * @next Failure
  122. */
  123. message Cancel {
  124. }
  125. /**
  126. * Request: Request a sample of random data generated by hardware RNG. May be used for testing.
  127. * @start
  128. * @next Entropy
  129. * @next Failure
  130. */
  131. message GetEntropy {
  132. required uint32 size = 1; // size of requested entropy
  133. }
  134. /**
  135. * Response: Reply with random data generated by internal RNG
  136. * @end
  137. */
  138. message Entropy {
  139. required bytes entropy = 1; // chunk of random generated bytes
  140. }
  141. /**
  142. * Request: Request device to wipe all sensitive data and settings
  143. * @start
  144. * @next Success
  145. * @next Failure
  146. */
  147. message WipeDevice {
  148. }
  149. /**
  150. * Request: Load seed and related internal settings from the computer
  151. * @start
  152. * @next Success
  153. * @next Failure
  154. */
  155. message LoadDevice {
  156. optional string mnemonic = 1; // seed encoded as BIP-39 mnemonic (12, 18 or 24 words)
  157. optional hw.trezor.messages.common.HDNodeType node = 2; // BIP-32 node
  158. optional string pin = 3; // set PIN protection
  159. optional bool passphrase_protection = 4; // enable master node encryption using passphrase
  160. optional string language = 5 [default='english']; // device language
  161. optional string label = 6; // device label
  162. optional bool skip_checksum = 7; // do not test mnemonic for valid BIP-39 checksum
  163. optional uint32 u2f_counter = 8; // U2F counter
  164. }
  165. /**
  166. * Request: Ask device to do initialization involving user interaction
  167. * @start
  168. * @next EntropyRequest
  169. * @next Failure
  170. */
  171. message ResetDevice {
  172. optional bool display_random = 1; // display entropy generated by the device before asking for additional entropy
  173. optional uint32 strength = 2 [default=256]; // strength of seed in bits
  174. optional bool passphrase_protection = 3; // enable master node encryption using passphrase
  175. optional bool pin_protection = 4; // enable PIN protection
  176. optional string language = 5 [default='english']; // device language
  177. optional string label = 6; // device label
  178. optional uint32 u2f_counter = 7; // U2F counter
  179. optional bool skip_backup = 8; // postpone seed backup to BackupDevice workflow
  180. optional bool no_backup = 9; // indicate that no backup is going to be made
  181. }
  182. /**
  183. * Request: Perform backup of the device seed if not backed up using ResetDevice
  184. * @start
  185. * @next Success
  186. */
  187. message BackupDevice {
  188. }
  189. /**
  190. * Response: Ask for additional entropy from host computer
  191. * @next EntropyAck
  192. */
  193. message EntropyRequest {
  194. }
  195. /**
  196. * Request: Provide additional entropy for seed generation function
  197. * @next Success
  198. */
  199. message EntropyAck {
  200. optional bytes entropy = 1; // 256 bits (32 bytes) of random data
  201. }
  202. /**
  203. * Request: Start recovery workflow asking user for specific words of mnemonic
  204. * Used to recovery device safely even on untrusted computer.
  205. * @start
  206. * @next WordRequest
  207. */
  208. message RecoveryDevice {
  209. optional uint32 word_count = 1; // number of words in BIP-39 mnemonic
  210. optional bool passphrase_protection = 2; // enable master node encryption using passphrase
  211. optional bool pin_protection = 3; // enable PIN protection
  212. optional string language = 4 [default='english']; // device language
  213. optional string label = 5; // device label
  214. optional bool enforce_wordlist = 6; // enforce BIP-39 wordlist during the process
  215. // 7 reserved for unused recovery method
  216. optional RecoveryDeviceType type = 8; // supported recovery type
  217. optional uint32 u2f_counter = 9; // U2F counter
  218. optional bool dry_run = 10; // perform dry-run recovery workflow (for safe mnemonic validation)
  219. /**
  220. * Type of recovery procedure. These should be used as bitmask, e.g.,
  221. * `RecoveryDeviceType_ScrambledWords | RecoveryDeviceType_Matrix`
  222. * listing every method supported by the host computer.
  223. *
  224. * Note that ScrambledWords must be supported by every implementation
  225. * for backward compatibility; there is no way to not support it.
  226. */
  227. enum RecoveryDeviceType {
  228. // use powers of two when extending this field
  229. RecoveryDeviceType_ScrambledWords = 0; // words in scrambled order
  230. RecoveryDeviceType_Matrix = 1; // matrix recovery type
  231. }
  232. }
  233. /**
  234. * Response: Device is waiting for user to enter word of the mnemonic
  235. * Its position is shown only on device's internal display.
  236. * @next WordAck
  237. */
  238. message WordRequest {
  239. optional WordRequestType type = 1;
  240. /**
  241. * Type of Recovery Word request
  242. */
  243. enum WordRequestType {
  244. WordRequestType_Plain = 0;
  245. WordRequestType_Matrix9 = 1;
  246. WordRequestType_Matrix6 = 2;
  247. }
  248. }
  249. /**
  250. * Request: Computer replies with word from the mnemonic
  251. * @next WordRequest
  252. * @next Success
  253. * @next Failure
  254. */
  255. message WordAck {
  256. required string word = 1; // one word of mnemonic on asked position
  257. }
  258. /**
  259. * Request: Set U2F counter
  260. * @start
  261. * @next Success
  262. */
  263. message SetU2FCounter {
  264. optional uint32 u2f_counter = 1; // counter
  265. }