mss_sys_services.h 105 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500
  1. /*******************************************************************************
  2. * (c) Copyright 2012-2016 Microsemi SoC Products Group. All rights reserved.
  3. *
  4. * SmartFusion2 MSS System Services bare metal software driver public API.
  5. *
  6. * SVN $Revision: 8680 $
  7. * SVN $Date: 2016-11-25 14:18:13 +0530 (Fri, 25 Nov 2016) $
  8. */
  9. /*=========================================================================*//**
  10. @mainpage SmartFusion2 MSS System Services Bare Metal Driver.
  11. @section intro_sec Introduction
  12. The SmartFusion2 microcontroller subsystem (MSS) includes a communication
  13. block (COMM_BLK) allowing it to communicate with the SmartFusion2 System
  14. Controller. The SmartFusion2 System Controller performs a variety of system
  15. wide services. This software driver provides a set of functions to access
  16. these System Services. The driver can be adapted for use as part of an
  17. operating system, but the implementation of the adaptation layer between the
  18. driver and the operating system's driver model is outside the scope of the
  19. driver.
  20. @section hw_dependencies Hardware Flow Dependencies
  21. The MSS System Services driver does not require any configuration. It relies
  22. on the SmartFusion2 communication block (MSS_COMM_BLK) to communicate with the
  23. System Controller. The MSS_COMM_BLK is always enabled.
  24. The base address, register addresses and interrupt number assignment for the
  25. MSS_COMM_BLK are defined as constants in the SmartFusion2 CMSIS HAL. You must
  26. ensure that the latest SmartFusion2 CMSIS HAL is included in the project
  27. settings of the software tool chain used to build your project and that it is
  28. generated into your project.
  29. @section theory_op Theory of Operation
  30. The System Services driver provides access to the SmartFusion2 System
  31. Controller services. These system services are loosely grouped into the
  32. following features:
  33. - Reading system information
  34. - Cryptography
  35. - Non-deterministic random bit generator
  36. - Flash*Freeze
  37. - Zeroization
  38. - Asynchronous Messages
  39. - Programming Services
  40. - Digest Check Service
  41. Note: Refer to the function descriptions for further details about the
  42. features of each individual service.
  43. Reading System Information
  44. The System Services driver can be used to read information about the
  45. SmartFusion2 device and the design programmed into it using the following
  46. functions:
  47. - MSS_SYS_get_serial_number()
  48. - MSS_SYS_get_user_code()
  49. - MSS_SYS_get_design_version()
  50. - MSS_SYS_get_device_certificate()
  51. - MSS_SYS_get_secondary_device_certificate()
  52. Cryptography Services
  53. The System Services driver provides cryptographic services using the following
  54. functions:
  55. - MSS_SYS_128bit_aes()
  56. - MSS_SYS_256bit_aes()
  57. - MSS_SYS_sha256()
  58. - MSS_SYS_hmac()
  59. - MSS_SYS_challenge_response()
  60. - MSS_SYS_key_tree()
  61. Non-Deterministic Random Bit Generator
  62. The System Services driver provides random number generation services using
  63. the following functions:
  64. - MSS_SYS_nrbg_instantiate()
  65. - MSS_SYS_nrbg_self_test()
  66. - MSS_SYS_nrbg_generate()
  67. - MSS_SYS_nrbg_reseed()
  68. - MSS_SYS_nrbg_uninstantiate()
  69. - MSS_SYS_nrbg_reset()
  70. Flash*Freeze
  71. The System Services driver can be used to request the system to enter
  72. Flash*Freeze mode using the following function:
  73. - MSS_SYS_flash_freeze()
  74. The System Controller sends an asynchronous message to the MSS COMM_BLK when
  75. the device is either about to enter or has exited Flash*Freeze mode. The
  76. MSS_SYS_init() function can register a callback function with the System
  77. Services driver to handle these asynchronous messages.
  78. Zeroization
  79. The System Service driver can be used to destroy sensitive information on the
  80. SmartFusion2 device using the following function.
  81. - MSS_SYS_zeroize_device()
  82. The zeroization system service erases all user configuration data, user keys,
  83. user security settings, NVM, SRAM, FPGA flip-flops, System Controller memory,
  84. and crypto-engine registers. The zeroization system service is enabled and
  85. configured in the Libero hardware flow.
  86. Note: The zeroization system service can render the SmartFusion2 device
  87. permanently and irrevocably disabled depending on the configuration
  88. selected in the Libero hardware flow.
  89. Asynchronous Messages
  90. The System Controller sends asynchronous messages to the MSS COMM_BLK when
  91. certain events are detected during the execution of the following system
  92. services:
  93. •Flash*Freeze
  94. •Power-on-reset (POR) digest check
  95. •Tamper detect events
  96. The MSS_SYS_init() function can register a callback function with the System
  97. Services driver to handle these asynchronous messages allowing the user
  98. application code to take remedial or defensive action. If the application
  99. code does not provide an asynchronous event handler function then the driver
  100. simply reads and discards these asynchronous messages.
  101. Flash*Freeze Entry and Exit
  102. The System Controller sends a Flash*Freeze entry or exit message to the MSS
  103. COMM_BLK when the SmartFusion2 device is either about to enter or has exited
  104. Flash*Freeze mode. The driver passes the entry/exit message opcode as a
  105. parameter to the event handler callback function.
  106. Power-on Reset (POR) Digest Error
  107. The POR digest check service is enabled in the Libero hardware flow and if
  108. enabled is automatically performed as part of the device’s power up sequence.
  109. The System Controller sends a POR digest check error message to the MSS
  110. COMM_BLK when the result of the POR digest check is a mismatch between the
  111. original stored digest and the current digest. The driver passes the command
  112. byte and the error flags byte from the error message as parameters to the
  113. event handler callback function.
  114. Tamper detect events
  115. The System Controller sends tamper message to the MSS COMM_BLK when the
  116. tamper event is detected. This tamper message is of one byte contain only
  117. command opcode. The driver pass the tamper message opcode as a parameter
  118. to the event handler callback function.
  119. Programming Service
  120. The In-System Programming (ISP) system service can be used for field upgrades
  121. of the hardware design programmed in the FPGA fabric. The application program
  122. running on the Cortex-M3 controls the ISP operations, it must retrieve the
  123. programming file from memory or from a communication port and feed it to
  124. the System Controller through the ISP system service. The System Controller
  125. performs the actual programming of the FPGA (fabric and eNVM) using the
  126. programming data it receives from the Cortex-M3 as part of the ISP system
  127. service.
  128. Programming files are large and cannot always be entirely retrieved by the
  129. application before starting the ISP operation. The ISP system service is
  130. designed to work around this issue by handling programming one page at a
  131. time. The application initiates the ISP operation through a call to
  132. MSS_SYS_start_isp(), passing two function pointers as parameters. These two
  133. function pointers point to a page read handler function and an ISP completion
  134. handler function that must be implemented as part of the application. The
  135. system services driver will call the application’s page read handler
  136. function every time it is ready to program the FPGA with a new page of
  137. programming data. The page read handler function is responsible for splitting
  138. the programming file into suitably sized pages. The page size is not fixed
  139. and can be chosen to suit the application. The system services driver will
  140. call the ISP completion handler function once the last page has been
  141. programmed.
  142. The application must keep track of the pages of programming data is has
  143. passed to the ISP system service. It must provide the location of the next
  144. programming page by writing the address of the page into the location
  145. pointed to by the pp_next_page pointer passed as parameter to the page read
  146. handler function. The page read handler must return the size of the page or
  147. zero if the last page has already been given to the ISP system service.
  148. The In-Application Programming (IAP) system service provides another field
  149. upgrade method of the hardware design programmed in FPGA fabric. Using this
  150. method, the user application first writes the FPGA fabric design into the SPI
  151. Flash connected to MSS SPI-0 before invoking the IAP system service. The FPGA
  152. fabric is then programmed under control of the SmartFusion2 system controller
  153. without intervention of the Cortex-M3 processor. The application must
  154. configure the SPI peripheral and provide exclusive access to the IAP service
  155. before invoking the IAP system service.
  156. When the IAP service is invoked, the system controller will send the SPI
  157. command 0Bh i.e. single read operation command to the SPI flash to retrieve
  158. the FPGA fabric design. The system controller will perform one of the
  159. following operations based on the mode selected when invoking the service:
  160. a) Authenticate the fabric design.
  161. b) Program the fabric design into FPGA.
  162. c) Verify that the programming was successful.
  163. The system controller will take 2 to 3 minutes to complete each operation.
  164. The application must provide the starting location address of the new FPGA
  165. fabric design present in SPI Flash when invoking the IAP service.
  166. The system controller will return a response indicating the status of the
  167. operation on completing the execution of the IAP service except in the case
  168. of successful programming. The system controller will reset the device and
  169. start execution of the new FPGA fabric design after successfully programming
  170. the device. The system controller will not return any response information
  171. when a successful programming operation completes.
  172. Digest Check Service
  173. The System Service driver can be used to recalculate and compare digests of
  174. selected components using the following function.
  175. - MSS_SYS_check_digest()
  176. Note: This function is not used for the power-on-reset (POR) digest check
  177. service. An asynchronous event handler registered with the
  178. MSS_SYS_init() function is used to support the POR digest check
  179. service.
  180. Elliptic Curve services
  181. The System Service driver can be used to perform elliptic curve cryptography
  182. (ECC) mathematical operations over the field defined by the NIST P-384
  183. curve. point addition and point multiplication using the following functions
  184. are provided:
  185. - MSS_SYS_ecc_point_multiplication()
  186. - MSS_SYS_ecc_point_addition()
  187. - MSS_SYS_ecc_get_base_point()
  188. One example use of these functions is the elliptic curve Diffie-Hellman
  189. (ECDH) key establishment protocol. In this protocol, a public key is computed
  190. by performing a point multiplication of a 384-bit private key with the base
  191. point for the NIST P-384 curve. Both parties involved in the key
  192. establishment compute their public keys and send them to each other. A shared
  193. secret is established by point multiplication of each party’s private key
  194. with the remote party’s public key. The elliptic curve mathematical
  195. properties ensure that the private key point multiplication with the remote
  196. party’s public key results in the same point on the curve for both parties.
  197. The coordinates of this point on the curve is used as the shared secret for
  198. further cryptographic operations.
  199. Note: There is no checking done to see if the given input point or points
  200. are valid points on the elliptic curve. Supplying illegal X-Y coordinates
  201. for a point will result in a garbage output. However, if a valid point or
  202. points are given, then the resulting output point is guaranteed to be valid.
  203. PUF Services
  204. The SRAM-PUF system services provide a Physically Unclonable Function (PUF)
  205. that can be used for key generation and storage as well as device
  206. authentication.
  207. The large SmartFusion2 devices starting from the M2S060 include an SRAM-PUF
  208. hardware block as part of the System Controller. This hardware block makes
  209. use of a 16Kbit SRAM block to determine an intrinsic secret unique to each
  210. device. This intrinsic secret is in turn used to regenerate keys enrolled
  211. with the SRAM-PUF hardware block.
  212. The SRAM-PUF is also used in design security. Although the system services
  213. are not used for design security, it is possible to retrieve the design
  214. security ECC public key for device authentication purpose.
  215. The SRAM-PUF start-up value can also be used to generate a random number
  216. generator seed.
  217. Note: PUF service should be executed from DDR/SRAM/eNVM-0 except for the
  218. M2S060 device. On the M2S060 device, PUF service should be executed
  219. from DDR/SRAM.
  220. Activation Code
  221. An activation code is required by the SRAM-PUF to regenerate the intrinsic
  222. secret from the SRAM-PUF start-up value. The start-up value of the PUF’s SRAM
  223. block is slightly different from one power-up to the next. Some processing is
  224. performed on the PUF’s SRAM start-up value to eliminate randomness and
  225. retrieve the exact same intrinsic secret on each power-up cycle. This
  226. processing is performed using the activation code, which can be thought of as
  227. parity bits that are used to reconstruct the same PUF intrinsic secret each
  228. time, in spite of the fact that some SRAM bits are flipped compared to the
  229. original snapshot used when the activation code was first enrolled.
  230. The devices are shipped with one activation code that was enrolled during
  231. the manufacturing process. The PUF secret computed from this enrollment is
  232. used to protect a 376-bit ECC private key that may be used for design
  233. security purposes as described elsewhere. The user may optionally enroll a
  234. second activation code in special “S” -suffix (i.e., security enabled)
  235. devices. The activation code is usually generated only once, typically when
  236. the system containing the SmartFusion2 device is being commissioned, using a
  237. JTAG or SPI programming command. Alternatively, the activation code is
  238. created using the following system service function:
  239. - MSS_SYS_puf_create_activation_code()
  240. This might be used if the first user activation code were intentionally
  241. deleted and a new one was desired. The activation code is stored the System
  242. Controller’s private eNVM after being created. Its value is never exported in
  243. clear text from the System Controller. Because of the inherent noise in each
  244. SRAM start-up, there is a negligible probability two activation codes or the
  245. associated PUF intrinsic secret are ever the same, even if the same device is
  246. repeatedly re-enrolled.
  247. The activation code can later be destroyed using the following function:
  248. - MSS_SYS_puf_delete_activation_code()
  249. This function would typically only be used when the system containing
  250. SmartFusion2 is being decommissioned or repurposed.
  251. Enrolling Keys
  252. The SRAM-PUF can be used to store cryptographic keys. The keys are stored in
  253. such a way that the key’s actual value never appears in the system unless it
  254. is retrieved by the user. A so-called "Key Code" is stored in the System
  255. Controller’s private eNVM instead of the key’s value. The key code is
  256. generated when a key is enrolled. The key code value is created from the
  257. enrolled key’s value and the intrinsic secret value. The key’s value can then
  258. later be regenerated from the key code value and intrinsic secret value upon
  259. user request.
  260. NOTE:Note: Key #0 and key #1 are used for design security and are not
  261. accessible to the user. Key Code #2 may be used to store a user
  262. data security key, but has an important optional use in JTAG- or
  263. SPI-based key validation, as will be described below.
  264. The enrolled keys can be intrinsic keys or extrinsic keys. The value of an
  265. intrinsic key is a random number generated from the SRAM-PUF start-up value.
  266. Intrinsic keys are useful where a security protocol executing on SmartFusion2
  267. needs to generate a key’s value and store it for later use. For example, the
  268. user could request a 384-bit long intrinsic key to be enrolled and use it as
  269. private key in an elliptic curve Diffie-Hellman key exchange.
  270. The value of an extrinsic key is specified by the user. For example, the user
  271. could request a symmetric key obtained from a key exchange protocol to be
  272. enrolled for later use.
  273. The following functions are used for key enrollment:
  274. - MSS_SYS_puf_get_number_of_keys()
  275. - MSS_SYS_puf_enroll_key()
  276. - MSS_SYS_puf_fetch_key()
  277. - MSS_SYS_puf_delete_key()
  278. Keys are identified by a number and must be enrolled sequentially. Key codes
  279. #0 and #1 are reserved as a 256-bit symmetric extrinsic key and a 384-bit
  280. private (asymmetric) intrinsic key, both used for design security only, and
  281. are enrolled by JTAG (or SPI) programming commands. These commands also
  282. enroll the user activation code and key code #2, a 256-bit value that has a
  283. special use in key validation, and which is enrolled at the same time as key
  284. code #1, as will be described below.
  285. The first step in enrolling a new key is to determine how many keys are
  286. already enrolled. This is achieved by a call to function
  287. MSS_SYS_puf_get_number_of_keys() which returns the number of enrolled keys.
  288. Keys are numbered from 0 up to 57 (the maximum number of keys assuming all
  289. user keys are less than or equal to 256 bits in length). For example,
  290. assuming only the first three key codes mentioned above have been enrolled
  291. using the JTAG programming commands, the value returned would be ‘3’. The
  292. number of keys returned by MSS_SYS_puf_get_number_of_keys() can then be used
  293. as the newly enrolled key identification number since key numbering is zero
  294. based. Thus, the first data security key enrolled by the user would generate
  295. key code #3.
  296. A key is enrolled through a call to function MSS_SYS_puf_enroll_key(). This
  297. function takes the following parameters:
  298. • The key identification number that will be used to later retrieve the
  299. key’s value. This is the value returned by a call to
  300. MSS_SYS_puf_get_number_of_keys().
  301. • The key size.
  302. • A pointer to the buffer containing the value of the key to enroll. The
  303. value of this pointer must be NULL if enrolling an intrinsic key where
  304. the SRAM-PUF will generate the actual key value.
  305. • A pointer to the buffer where the enrolled key will be regenerated when
  306. later fetched by the user.
  307. The value of the enrolled keys can be regenerated through a call to function
  308. MSS_SYS_puf_fetch_key(). The identification number of the key to fetch is
  309. passed as parameter to this function. The requested key’s value will be
  310. regenerated and copied to the buffer specified during key enrollment. The
  311. key’s value is then available for use until it is no further required and
  312. wiped, by the user’s application, from the memory buffer it was fetched into.
  313. Note: It is not possible to fetch a key if the key codes have been exported
  314. and not re-imported.
  315. A key can be removed from the system through a call to function
  316. MSS_SYS_puf_delete_key(). This function only requires the key identification
  317. number to specify which key should be removed from the SRAM-PUF.
  318. Note: If a new key is enrolled in a key-slot where a key was previously
  319. enrolled and deleted and which is not the highest key number enrolled,
  320. it must be the same size as the key it replaced or an error will be
  321. reported.
  322. Exporting and Importing Key Codes
  323. The activation code and key codes used to regenerate the enrolled keys can be
  324. exported out of the SRAM-PUF. The exported activation code and key codes are
  325. encrypted using a one-time pad. The one-time pad is stored in the System
  326. Controller’s private eNVM and is never exported. This means that the exported
  327. activation and key codes can only be decrypted by the unique device that
  328. exported them.
  329. The activation and key code values stored in eNVM are replaced with hash
  330. values of themselves as part of the export procedure. This means that
  331. enrolled keys cannot be regenerated anymore after the activation and key
  332. codes have been exported. The enrolled keys will only be regenerated
  333. successfully if the exported activation and key codes for that unique
  334. SmartFusion2 device are imported back.
  335. The activation and all the key codes are exported in one single operation
  336. using the following function:
  337. - MSS_SYS_puf_export_keycodes()
  338. The MSS_SYS_puf_export_keycodes() function can only be called once since the
  339. activation and key codes are not present anymore in the device after this
  340. function completes. The activation and key codes must be imported back
  341. before they can be exported again.
  342. The activation and all the key codes are imported back in one single
  343. operation using the following function:
  344. - MSS_SYS_puf_import_keycodes()
  345. It is only possible to import activation and key codes exported from the
  346. same unique device. The imported activation and key codes are decrypted
  347. using the one-time pad stored in eNVM used during the export procedure.
  348. The decrypted activation and key codes are then checked again the hash
  349. values stored in place of the activation and key codes. The activation
  350. and key codes will only be successfully imported back if the hash values
  351. for the imported activation and key codes match the hash values stored in
  352. eNVM during the export procedure. Imported activation and key codes are
  353. never again restored to non-volatile memory; rather, they are imported to
  354. volatile scratch-pad memory, used to regenerate a key, and then deleted.
  355. Therefore, they must be re-imported each time a key is needed.
  356. Retrieving the Design Security ECC Public Key
  357. When the 384 bit user design security private ECC key is intrinsically
  358. generated and key code #1 is stored using the JTAG or SPI programming
  359. commands, the associated 768 bit public key is also generated and stored
  360. in the system controller’s private eNVM. At the same time, the256 bit SHA-256
  361. hash of the ECC public key is enrolled to key code #2.
  362. The 768 bit design security ECC public key can be retrieved using the following
  363. system service function:
  364. - MSS_SYS_puf_fetch_ecc_public_key()
  365. Note that the public key is also exported via JTAG (or SPI) programming
  366. commands when it is used in ECDH design security operations such as
  367. bitstream encryption or device authentication.
  368. In order to mitigate man-in-the-middle attacks on the public key when it is
  369. exported and used, it is recommended that the ECC public key is validated
  370. using an already trusted key. This could be a user design security key, for
  371. example. Perhaps the most convenient keys to use are one of the Microsemi
  372. certified ECC key pairs, which are trusted because of the verifiable
  373. Microsemi signatures on the X.509 public key certificates. This is why when
  374. the 384 bit user ECC private key was generated and stored using key code #1,
  375. the 256 bit hash of the associated 768 bit public key was stored using key
  376. code #2. The JTAG (or SPI) key verification protocol has a special option
  377. which includes the value stored in key code #2 in the computation. Thus,
  378. besides also validating the device really “knows” the already trusted key,
  379. with this option selected, the 256-bit value stored using key code #2 is also
  380. validated. If this is the hash of the user ECC public key, then it is proved
  381. that the public key is the authentic public key as stored in the device, and
  382. not one supplied by an adversary in a man-in-the-middle attack on this key.
  383. After the user ECC public key has been thus validated, key code #2 can be
  384. deleted and replaced with another 256-bit value the user wishes to validate,
  385. such as the hash of user data security key. It is recommended that key code
  386. #2 only be used to store hashes of critical security parameters such as
  387. secret or private keys, and not the actual secrets, themselves.
  388. Note: The user's application need to reserve a defined block of SRAM when
  389. using PUF system services, to prevent the compiler from using the SRAM
  390. memory range from address 0x2000800 to 0x2000802F inclusive. This is
  391. the default location used by the system controller to automatically
  392. enroll KC#2, when KC#1 is enrolled.
  393. Random Number Generator Seed
  394. The PUF’s SRAM start-up value randomness can be harvested to generate a
  395. 256-bit full entropy true random seed. A random seed can be obtained using
  396. function:
  397. - MSS_SYS_puf_get_random_seed()
  398. Note: Random seeds can only be generated after the SRAM-PUF has been powered
  399. -down for 250 msec. Thus, if the PUF has been used more recently than
  400. that, there may be a delay before the seed is generated.
  401. Tamper control service
  402. The tamper control system services provide the following services:
  403. - Enable/disable clock monitoring
  404. - Control power to PUF
  405. - Clear mesh short tamper
  406. - Clear lock parity tamper
  407. The tamper control services are accessed using the following functions:
  408. - MSS_SYS_start_clock_monitor()
  409. - MSS_SYS_stop_clock_monitor()
  410. - MSS_SYS_enable_puf_power_down()
  411. - MSS_SYS_disable_puf_power_down()
  412. - MSS_SYS_clear_lock_parity()
  413. - MSS_SYS_clear_mesh_short()
  414. *//*=========================================================================*/
  415. #ifndef __MSS_SYS_SERVICES_H_
  416. #define __MSS_SYS_SERVICES_H_ 1
  417. #include "../../CMSIS/m2sxxx.h"
  418. #include "mss_comblk_page_handler.h"
  419. #ifdef __cplusplus
  420. extern "C" {
  421. #endif
  422. /*==============================================================================
  423. * Status codes:
  424. */
  425. /*-------------------------------------------------------------------------*//**
  426. These constants are used by multiple services to communicate the outcome of a
  427. system services request. These status codes are used across all types of
  428. services.
  429. - MSS_SYS_SUCCESS:
  430. Indicates that the system services completed successfully.
  431. - MSS_SYS_UNEXPECTED_ERROR:
  432. Indicates that the system failed in an unexpected way.
  433. - MSS_SYS_MEM_ACCESS_ERROR:
  434. Indicates that the System Controller could not access the memory used to
  435. pass parameters to the System Controller or to return a service result to
  436. the Cortex-M3.
  437. - MSS_SYS_SERVICE_DISABLED_BY_FACTORY:
  438. Indicates that the requested system service is not available on the
  439. SmartFusion2 device.
  440. - MSS_SYS_SERVICE_DISABLED_BY_USER:
  441. Indicates that the requested system service has been disabled as part of
  442. the hardware design.
  443. - MSS_SYS_SERVICE_NOT_LICENSED
  444. Indicates that the license is not available in SmartFusion2 device for
  445. this service.
  446. - MSS_SYS_CLK_DIVISOR_ERROR
  447. Indicates that on 060 device the divisor values for fclk, pclk0, pclk1,
  448. clk_fic64 are not equal to each other or the divisor values is set to
  449. divide by 32.
  450. */
  451. #define MSS_SYS_SUCCESS 0u
  452. #define MSS_SYS_UNEXPECTED_ERROR 200u
  453. #define MSS_SYS_CLK_DIVISOR_ERROR 201u
  454. #define MSS_SYS_MEM_ACCESS_ERROR 127u
  455. #define MSS_SYS_SERVICE_NOT_LICENSED 253u
  456. #define MSS_SYS_SERVICE_DISABLED_BY_FACTORY 254u
  457. #define MSS_SYS_SERVICE_DISABLED_BY_USER 255u
  458. /*-------------------------------------------------------------------------*//**
  459. These constants are used by PUF services to communicate the outcome of a
  460. system services request. These status codes are only used by PUF services.
  461. - MSS_SYS_ENVM_ERROR:
  462. Indicates that a eNVM error occurred for both create and delete user
  463. activation code sub command.
  464. - MSS_SYS_PUF_ERROR_WHEN_CREATING:
  465. Indicates that PUF error occur while creating new user activation code.
  466. - MSS_SYS_INVALID_SUBCMD:
  467. Indicates that the sub command is invalid.
  468. - MSS_SYS_INVALID_REQUEST_OR_KC:
  469. Indicates that request or Key code is invalid, when exporting or
  470. importing.
  471. - MSS_SYS_INVALID_KEYNUM_OR_ARGUMENT
  472. Indicates that the supplied key number or argument is invalid.
  473. - MSS_SYS_NO_VALID_PUBLIC_KEY
  474. Indicates that no valid public key present in eNVM.
  475. - MSS_SYS_INVALID_MEMORY_ADDRESS:
  476. Indicates that memory address is invalid.
  477. - MSS_SYS_ENVM_PROGRAM_ERROR
  478. Indicates that the eNVM program error occur when writing to the private eNVM
  479. for both create and delete user activation code sub command.
  480. - MSS_SYS_INVALID_HASH:
  481. Indicates that 32 byte hash is invalid.
  482. - MSS_SYS_INVALID_USER_AC1:
  483. Indicates that invalid user activation code has been imported.
  484. - MSS_SYS_ENVM_VERIFY_ERROR:
  485. Indicates that the eNVM verify error occur when writing to the private eNVM
  486. for both create and delete user activation code sub command.
  487. - MSS_SYS_INCORRECT_KEYSIZE_FOR_RENEWING_A_KC:
  488. Indicates that the supplied key size is incorrect while renewing the key
  489. code.
  490. - MSS_SYS_PRIVATE_ENVM_USER_DIGEST_MISMATCH:
  491. Indicates that digest mismatch occurs for private eNVM.
  492. - MSS_SYS_USER_KEY_CODE_INVALID_SUBCMD:
  493. Indicate that the sub command is invalid.
  494. - MSS_SYS_DRBG_ERROR:
  495. Indicates that DRBG error occurred while populating one time pad reminder
  496. by random bits.
  497. */
  498. #define MSS_SYS_ENVM_ERROR 1u
  499. #define MSS_SYS_PUF_ERROR_WHEN_CREATING 2u
  500. #define MSS_SYS_INVALID_SUBCMD 3u
  501. #define MSS_SYS_INVALID_REQUEST_OR_KC 3u
  502. #define MSS_SYS_INVALID_KEYNUM_OR_ARGUMENT 3u
  503. #define MSS_SYS_NO_VALID_PUBLIC_KEY 3u
  504. #define MSS_SYS_INVALID_MEMORY_ADDRESS 4u
  505. #define MSS_SYS_ENVM_PROGRAM_ERROR 4u
  506. #define MSS_SYS_INVALID_HASH 5u
  507. #define MSS_SYS_INVALID_USER_AC1 6u
  508. #define MSS_SYS_ENVM_VERIFY_ERROR 7u
  509. #define MSS_SYS_INCORRECT_KEYSIZE_FOR_RENEWING_A_KC 8u
  510. #define MSS_SYS_PRIVATE_ENVM_USER_DIGEST_MISMATCH 10u
  511. #define MSS_SYS_USER_KEY_CODE_INVALID_SUBCMD 11u
  512. #define MSS_SYS_DRBG_ERROR 12u
  513. /*-------------------------------------------------------------------------*//**
  514. * Programming services specific status codes:
  515. */
  516. #define MSS_SYS_CHAINING_MISMATCH 1u
  517. #define MSS_SYS_UNEXPECTED_DATA_RECEIVED 2u
  518. #define MSS_SYS_INVALID_ENCRYPTION_KEY 3u
  519. #define MSS_SYS_INVALID_COMPONENT_HEADER 4u
  520. #define MSS_SYS_BACK_LEVEL_NOT_SATISFIED 5u
  521. #define MSS_SYS_DSN_BINDING_MISMATCH 7u
  522. #define MSS_SYS_ILLEGAL_COMPONENT_SEQUENCE 8u
  523. #define MSS_SYS_INSUFFICIENT_DEV_CAPABILITIES 9u
  524. #define MSS_SYS_INCORRECT_DEVICE_ID 10u
  525. #define MSS_SYS_UNSUPPORTED_BITSTREAM_PROT_VER 11u
  526. #define MSS_SYS_VERIFY_NOT_PERMITTED_ON_BITSTR 12u
  527. #define MSS_SYS_INVALID_DEVICE_CERTIFICATE 13u
  528. #define MSS_SYS_ABORT 127u
  529. #define MSS_SYS_NVM_VERIFY_FAILED 129u
  530. #define MSS_SYS_DEVICE_SECURITY_PROTECTED 130u
  531. #define MSS_SYS_PROGRAMMING_MODE_NOT_ENABLED 131u
  532. #define MSS_SYS_ENVM_PROGRAMMING_OPERATION_FAIL 132u
  533. #define MSS_SYS_ENVM_VERIFY_OPERATION_FAIL 133u
  534. #define MSS_SYS_ACCESS_ERROR 134u
  535. #define MSS_SYS_PUF_ACCESS_ERROR 135u
  536. #define MSS_SYS_BAD_COMPONENT 136u
  537. /*-------------------------------------------------------------------------*//**
  538. These constants are used to specify the event_opcode parameter for the
  539. event_handler() function registered with the MSS_SYS_init() function. They are
  540. used to specify which asynchronous event is notified to the Cortex-M3 software
  541. by the System Controller. Asynchronous events are sent by the System
  542. Controller to the Cortex-M3 when some system events of interest occur.
  543. - FLASH_FREEZE_SHUTDOWN_OPCODE:
  544. Indicates that the system is being shutdown as a result of entering the
  545. Flash*Freeze mode.
  546. - FLASH_FREEZE_EXIT_OPCODE:
  547. Indicates that the system is exiting Flash*Freeze mode.
  548. - POR_DIGEST_ERROR_OPCODE
  549. Indicates that the MSS has received the POR Digest Check message.
  550. - TAMPER_ATTEMPT_BOUNDARY_SCAN_OPCODE
  551. Indicates that the MSS has received the tamper boundary scan attempt
  552. detected.
  553. - TAMPER_ATTEMPT_BUFFER_ACCESS_OPCODE
  554. Indicates that the MSS has received the tamper buffer access attempt
  555. detected.
  556. - TAMPER_ATTEMPT_DEBUG_OPCODE
  557. Indicates that the MSS has received the tamper debug attempt detected.
  558. - TAMPER_ATTEMPT_CHECK_DIGESTS_OPCODE
  559. Indicates that the MSS has received the tamper check digest attempt
  560. detected.
  561. - TAMPER_ATTEMPT_ECC_SETUP_INSTRUCTION_OPCODE
  562. Indicates that the MSS has received the tamper ECC setup instruction
  563. attempt detected.
  564. - TAMPER_ATTEMPT_FACTORY_PRIVATE_OPCODE
  565. Indicates that the MSS has received the tamper factory private attempt
  566. detected.
  567. - TAMPER_ATTEMPT_KEY_VALIDATION_OPCODE
  568. Indicates that the MSS has received the tamper key validation attempt
  569. detected.
  570. - TAMPER_ATTEMPT_MISC_OPCODE
  571. Indicates that the MSS has received the tamper misc attempt detected.
  572. - TAMPER_ATTEMPT_PASSCODE_MATCH_OPCODE
  573. Indicates that the MSS has received the tamper passcode match attempt
  574. detected.
  575. - TAMPER_ATTEMPT_PASSCODE_SETUP_INSTRUCTION_OPCODE
  576. Indicates that the MSS has received the tamper passcode setup instruction
  577. attempt detected.
  578. - TAMPER_ATTEMPT_PROGRAMMING_OPCODE
  579. Indicates that the MSS has received the tamper programming attempt detected.
  580. - TAMPER_ATTEMPT_PUBLIC_INFORMATION_OPCODE
  581. Indicates that the MSS has received the tamper public information attempt
  582. detected.
  583. - TAMPER_ATTEMPT_PUF_KEY_MANAGEMENT_OPCODE
  584. Indicates that the MSS has received the tamper PUF key management attempt
  585. detected.
  586. - TAMPER_ATTEMPT_UNUSED_OPCODE
  587. Indicates that the MSS has received the tamper unused attempt detected.
  588. - TAMPER_ATTEMPT_USER_JTAG_OPCODE
  589. Indicates that the MSS has received the tamper user JTAG attempt detected.
  590. - TAMPER_ATTEMPT_ZEROIZATION_RECOVERY_OPCODE
  591. Indicates that the MSS has received the tamper zeroization recovery
  592. attempt detected.
  593. - TAMPER_FAILURE_BOUNDARY_SCAN_OPCODE
  594. Indicates that the MSS has received the tamper boundary scan failure
  595. detected.
  596. - TAMPER_FAILURE_BUFFER_ACCESS_OPCODE
  597. Indicates that the MSS has received the tamper buffer access
  598. failure detected.
  599. - TAMPER_FAILURE_DEBUG_OPCODE
  600. Indicates that the MSS has received the tamper debug failure detected.
  601. - TAMPER_FAILURE_CHECK_DIGESTS_OPCODE
  602. Indicates that the MSS has received the tamper check digest failure
  603. detected.
  604. - TAMPER_FAILURE_ECC_SETUP_INSTRUCTION_OPCODE
  605. Indicates that the MSS has received the tamper ECC setup instruction
  606. failure detected.
  607. - TAMPER_FAILURE_FACTORY_PRIVATE_OPCODE
  608. Indicates that the MSS has received the tamper factory private failure
  609. detected.
  610. - TAMPER_FAILURE_KEY_VALIDATION_OPCODE
  611. Indicates that the MSS has received the tamper key validation failure
  612. detected.
  613. - TAMPER_FAILURE_MISC_OPCODE
  614. Indicates that the MSS has received the tamper misc failure detected.
  615. - TAMPER_FAILURE_PASSCODE_MATCH_OPCODE
  616. Indicates that the MSS has received the tamper passcode match failure
  617. detected.
  618. - TAMPER_FAILURE_PASSCODE_SETUP_INSTRUCTION_OPCODE
  619. Indicates that the MSS has received the tamper passcode setup instruction
  620. failure detected.
  621. - TAMPER_FAILURE_PROGRAMMING_OPCODE
  622. Indicates that the MSS has received the tamper programming failure detected.
  623. - TAMPER_FAILURE_PUBLIC_INFORMATION_OPCODE
  624. Indicates that the MSS has received the tamper public information failure
  625. detected.
  626. - TAMPER_FAILURE_PUF_KEY_MANAGEMENT_OPCODE
  627. Indicates that the MSS has received the tamper PUF key management failure
  628. detected.
  629. - TAMPER_FAILURE_UNUSED_OPCODE
  630. Indicates that the MSS has received the tamper unused failure detected.
  631. - TAMPER_FAILURE_USER_JTAG_OPCODE
  632. Indicates that the MSS has received the tamper user jtag failure detected.
  633. - TAMPER_FAILURE_ZEROIZATION_RECOVERY_OPCODE
  634. Indicates that the MSS has received the tamper zeroization recovery
  635. failure detected.
  636. - TAMPER_CLOCK_ERROR_DETECT_OPCODE0
  637. Indicates that the MSS has received the tamper clock monitor error detected.
  638. - TAMPER_HARDWARE_MONITOR_JTAGACTIVE_ERROR_OPCODE
  639. Indicates that the MSS has received the tamper jtag active hardware
  640. monitor error detected.
  641. - TAMPER_HARDWARE_MONITOR_LOCKPARITY_ERROR_OPCODE
  642. Indicates that the MSS has received the tamper lock parity hardware
  643. monitor error detected.
  644. - TAMPER_HARDWARE_MONITOR_MESHSHORT_ERROR_OPCODE
  645. Indicates that the MSS has received the tamper mesh short hardware monitor
  646. error detected.
  647. */
  648. #define FLASH_FREEZE_SHUTDOWN_OPCODE 0xE0u
  649. #define FLASH_FREEZE_EXIT_OPCODE 0xE1u
  650. #define POR_DIGEST_ERROR_OPCODE 0xF1u
  651. #define TAMPER_ATTEMPT_BOUNDARY_SCAN_OPCODE 0x80u
  652. #define TAMPER_ATTEMPT_BUFFER_ACCESS_OPCODE 0x81u
  653. #define TAMPER_ATTEMPT_DEBUG_OPCODE 0x82u
  654. #define TAMPER_ATTEMPT_CHECK_DIGESTS_OPCODE 0x83u
  655. #define TAMPER_ATTEMPT_ECC_SETUP_INSTRUCTION_OPCODE 0x84u
  656. #define TAMPER_ATTEMPT_FACTORY_PRIVATE_OPCODE 0x85u
  657. #define TAMPER_ATTEMPT_KEY_VALIDATION_OPCODE 0x86u
  658. #define TAMPER_ATTEMPT_MISC_OPCODE 0x87u
  659. #define TAMPER_ATTEMPT_PASSCODE_MATCH_OPCODE 0x88u
  660. #define TAMPER_ATTEMPT_PASSCODE_SETUP_INSTRUCTION_OPCODE 0x89u
  661. #define TAMPER_ATTEMPT_PROGRAMMING_OPCODE 0x8Au
  662. #define TAMPER_ATTEMPT_PUBLIC_INFORMATION_OPCODE 0x8Bu
  663. #define TAMPER_ATTEMPT_PUF_KEY_MANAGEMENT_OPCODE 0x8Cu
  664. #define TAMPER_ATTEMPT_UNUSED_OPCODE 0x8Du
  665. #define TAMPER_ATTEMPT_USER_JTAG_OPCODE 0x8Eu
  666. #define TAMPER_ATTEMPT_ZEROIZATION_RECOVERY_OPCODE 0x8Fu
  667. #define TAMPER_FAILURE_BOUNDARY_SCAN_OPCODE 0x90u
  668. #define TAMPER_FAILURE_BUFFER_ACCESS_OPCODE 0x91u
  669. #define TAMPER_FAILURE_DEBUG_OPCODE 0x92u
  670. #define TAMPER_FAILURE_CHECK_DIGESTS_OPCODE 0x93u
  671. #define TAMPER_FAILURE_ECC_SETUP_INSTRUCTION_OPCODE 0x94u
  672. #define TAMPER_FAILURE_FACTORY_PRIVATE_OPCODE 0x95u
  673. #define TAMPER_FAILURE_KEY_VALIDATION_OPCODE 0x96u
  674. #define TAMPER_FAILURE_MISC_OPCODE 0x97u
  675. #define TAMPER_FAILURE_PASSCODE_MATCH_OPCODE 0x98u
  676. #define TAMPER_FAILURE_PASSCODE_SETUP_INSTRUCTION_OPCODE 0x99u
  677. #define TAMPER_FAILURE_PROGRAMMING_OPCODE 0x9Au
  678. #define TAMPER_FAILURE_PUBLIC_INFORMATION_OPCODE 0x9Bu
  679. #define TAMPER_FAILURE_PUF_KEY_MANAGEMENT_OPCODE 0x9Cu
  680. #define TAMPER_FAILURE_UNUSED_OPCODE 0x9Du
  681. #define TAMPER_FAILURE_USER_JTAG_OPCODE 0x9Eu
  682. #define TAMPER_FAILURE_ZEROIZATION_RECOVERY_OPCODE 0x9Fu
  683. #define TAMPER_CLOCK_ERROR_DETECT_OPCODE 0xA0u
  684. #define TAMPER_HARDWARE_MONITOR_JTAGACTIVE_ERROR_OPCODE 0xB1u
  685. #define TAMPER_HARDWARE_MONITOR_LOCKPARITY_ERROR_OPCODE 0xB2u
  686. #define TAMPER_HARDWARE_MONITOR_MESHSHORT_ERROR_OPCODE 0xB4u
  687. /*-------------------------------------------------------------------------*//**
  688. These constants are used to specify the options parameter for the
  689. MSS_SYS_flash_freeze() function.
  690. - MSS_SYS_FPGA_POWER_DOWN:
  691. Indicates that the MSS_SYS_flash_freeze() function should request the FPGA
  692. fabric to enter Flash*Freeze mode.
  693. - MSS_SYS_MPLL_POWER_DOWN:
  694. Indicates that the MSS_SYS_flash_freeze() function should request the MSS
  695. PLL to enter Flash*Freeze mode.
  696. */
  697. #define MSS_SYS_FPGA_POWER_DOWN 0x00u
  698. #define MSS_SYS_MPLL_POWER_DOWN 0x04u
  699. /*-------------------------------------------------------------------------*//**
  700. These constants are used to specify the mode parameter for the
  701. MSS_SYS_128aes() and MSS_SYS_256bit_aes() functions.
  702. - MSS_SYS_ECB_ENCRYPT:
  703. Indicates that the cryptography function should perform encryption using
  704. the Electronic Codebook (ECB) mode.
  705. - MSS_SYS_ECB_DECRYPT:
  706. Indicates that the cryptography function should perform decryption using
  707. the Electronic Codebook (ECB) mode.
  708. - MSS_SYS_CBC_ENCRYPT:
  709. Indicates that the cryptography function should perform encryption using
  710. the Cipher-Block Chaining (CBC) mode.
  711. - MSS_SYS_CBC_DECRYPT:
  712. Indicates that the cryptography function should perform decryption using
  713. the Cipher-Block Chaining (CBC) mode.
  714. - MSS_SYS_OFB_ENCRYPT:
  715. Indicates that the cryptography function should perform encryption using
  716. the Output Feedback (OFB) mode.
  717. - MSS_SYS_OFB_DECRYPT:
  718. Indicates that the cryptography function should perform decryption using
  719. the Output Feedback (OFB) mode.
  720. - MSS_SYS_CTR_ENCRYPT:
  721. Indicates that the cryptography function should perform encryption using
  722. the Counter (CTR) mode.
  723. - MSS_SYS_CTR_DECRYPT:
  724. Indicates that the cryptography function should perform decryption using
  725. the Counter (CTR) mode.
  726. */
  727. #define MSS_SYS_ECB_ENCRYPT 0x00u
  728. #define MSS_SYS_ECB_DECRYPT 0x80u
  729. #define MSS_SYS_CBC_ENCRYPT 0x01u
  730. #define MSS_SYS_CBC_DECRYPT 0x81u
  731. #define MSS_SYS_OFB_ENCRYPT 0x02u
  732. #define MSS_SYS_OFB_DECRYPT 0x82u
  733. #define MSS_SYS_CTR_ENCRYPT 0x03u
  734. #define MSS_SYS_CTR_DECRYPT 0x83u
  735. /*------------------------------------------------------------------------------
  736. These constants are used by non deterministic random bit generator (NDRBG)
  737. services to communicate the outcome of a system services request. These status
  738. codes are only used by NDRBG services.
  739. - MSS_SYS_NRBG_CATASTROPHIC_ERROR:
  740. Indicates that a catastrophic error occurred.
  741. - MSS_SYS_NRBG_MAX_INST_EXCEEDED:
  742. Indicates that the maximum number of NDRBG instances has been exceeded.
  743. You need to release already instantiated NDRBG instances using the
  744. MSS_SYS_ndrbg_uninstantiate() function.
  745. - MSS_SYS_NRBG_INVALID_HANDLE:
  746. Indicates that the handle parameter has an invalid value.
  747. - MSS_SYS_NRBG_GEN_REQ_TOO_BIG:
  748. Indicates that the requested random number is too long. The requested
  749. length is larger than the maximum number of digits that can be generated.
  750. - MSS_SYS_NRBG_MAX_LENGTH_EXCEEDED:
  751. Indicates that the supplied additional data length is exceeded.
  752. */
  753. #define MSS_SYS_NRBG_CATASTROPHIC_ERROR 1u
  754. #define MSS_SYS_NRBG_MAX_INST_EXCEEDED 2u
  755. #define MSS_SYS_NRBG_INVALID_HANDLE 3u
  756. #define MSS_SYS_NRBG_GEN_REQ_TOO_BIG 4u
  757. #define MSS_SYS_NRBG_MAX_LENGTH_EXCEEDED 5u
  758. /*-------------------------------------------------------------------------*//**
  759. The sys_serv_isp_complete_handler_t typedef specifies the function prototype
  760. of the in-system programming (ISP) completion handler that is passed as a
  761. parameter to the MSS_SYS_start_isp() function. The ISP completion handler
  762. function must be implemented by the application program and it is called by
  763. the System Services driver when an ISP operation initiated by a call to
  764. MSS_SYS_start_isp() completes. The ISP completion handler function receives
  765. a status parameter indicating the outcome of the ISP operation. Refer to the
  766. description of the MSS_SYS_start_isp() function for more details.
  767. */
  768. typedef void (*sys_serv_isp_complete_handler_t)(uint32_t status);
  769. /*-------------------------------------------------------------------------*//**
  770. The sys_serv_async_event_handler_t type specifies the function prototype of
  771. an asynchronous event handler that can be implemented by the application to
  772. handle asynchronous messages from the System Controller. The System
  773. Controller sends asynchronous messages to the MSS COMM_BLK when certain
  774. events such as Flash*Freeze shutdown, Flash*Freeze exit and power-on-reset
  775. (POR) digest check errors are detected during the execution of the following
  776. system services:
  777. - Flash*Freeze
  778. - Power-on-reset (POR) digest check
  779. The asynchronous event handler function is registered with the System
  780. Services driver through the MSS_SYS_init() function. The driver calls the
  781. asynchronous event handler when the MSS COMM_BLK receives an asynchronous message.
  782. */
  783. typedef void (*sys_serv_async_event_handler_t)(uint8_t event_opcode, uint8_t response);
  784. /*-------------------------------------------------------------------------*//**
  785. This constant is used as parameter to the MSS_SYS_init() function to indicate
  786. that the application code does not supply an asynchronous event handler
  787. function.
  788. */
  789. #define MSS_SYS_NO_EVENT_HANDLER ((sys_serv_async_event_handler_t)0)
  790. /*-------------------------------------------------------------------------*//**
  791. The MSS_SYS_init function initializes the system services communication with
  792. the System Controller.
  793. @param
  794. The event_handler parameter specifies an optional asynchronous event
  795. handler function. This event handler function is provided by the
  796. application. It will be called by the System Services driver whenever an
  797. asynchronous event is received from the SmartFusion2 System controller.
  798. This event handler is typically used to handle entry and exit of
  799. Flash*Freeze mode.
  800. @return
  801. This function does not return a value.
  802. */
  803. void MSS_SYS_init
  804. (
  805. sys_serv_async_event_handler_t event_handler
  806. );
  807. /*==============================================================================
  808. * Device and Design Information Services.
  809. */
  810. /*-------------------------------------------------------------------------*//**
  811. The MSS_SYS_get_serial_number function fetches the 128-bit Device Serial
  812. Number (DSN).
  813. @param p_serial_number
  814. The p_serial_number parameter is a pointer to the 16-bytes buffer where the
  815. serial number will be written by this system service.
  816. @return
  817. The MSS_SYS_get_serial_number function returns one of following status codes:
  818. - MSS_SYS_SUCCESS
  819. - MSS_SYS_MEM_ACCESS_ERROR
  820. - MSS_SYS_UNEXPECTED_ERROR
  821. */
  822. uint8_t MSS_SYS_get_serial_number
  823. (
  824. uint8_t * p_serial_number
  825. );
  826. /*-------------------------------------------------------------------------*//**
  827. The MSS_SYS_get_user_code functions fetches the 32-bit USERCODE.
  828. @param p_user_code
  829. The p_user_code parameter is a pointer to the 4-bytes buffer where the
  830. USERCODE will be written by this system service.
  831. @return
  832. The MSS_SYS_get_user_code function returns one of following status codes:
  833. - MSS_SYS_SUCCESS
  834. - MSS_SYS_MEM_ACCESS_ERROR
  835. - MSS_SYS_UNEXPECTED_ERROR
  836. */
  837. uint8_t MSS_SYS_get_user_code
  838. (
  839. uint8_t * p_user_code
  840. );
  841. /*-------------------------------------------------------------------------*//**
  842. The MSS_SYS_get_design_version function fetches the design version.
  843. @param p_design_version
  844. The p_design_version parameter is a pointer to the 2-bytes buffer where the
  845. design version will be written by this system service.
  846. @return
  847. The MSS_SYS_get_design_version function returns one of following status codes:
  848. - MSS_SYS_SUCCESS
  849. - MSS_SYS_MEM_ACCESS_ERROR
  850. - MSS_SYS_UNEXPECTED_ERROR
  851. */
  852. uint8_t MSS_SYS_get_design_version
  853. (
  854. uint8_t * p_design_version
  855. );
  856. /*-------------------------------------------------------------------------*//**
  857. The MSS_SYS_get_device_certificate function fetches the device certificate.
  858. @param p_device_certificate
  859. The p_device_certificate parameter is a pointer to the 512-bytes buffer
  860. where the device certificate will be written by this system service.
  861. @return
  862. The MSS_SYS_get_device_certificate function returns one of following status
  863. codes:
  864. - MSS_SYS_SUCCESS
  865. - MSS_SYS_MEM_ACCESS_ERROR
  866. - MSS_SYS_UNEXPECTED_ERROR
  867. */
  868. uint8_t MSS_SYS_get_device_certificate
  869. (
  870. uint8_t * p_device_certificate
  871. );
  872. /*-------------------------------------------------------------------------*//**
  873. The MSS_SYS_get_secondary_device_certificate function fetches the secondary
  874. device certificate. The secondary device certificate is second ECC Key
  875. Certificate which is a 640-byte digitally-signed X-509 certificate programmed
  876. during manufacturing. This certificate only contains the public key for the
  877. ECC key and is otherwise unused by the device.
  878. @param p_secondary_device_certificate
  879. The p_secondary_device_certificate parameter is a pointer to the 640-bytes
  880. buffer where the secondary device certificate will be written by this system
  881. service.
  882. @return
  883. The MSS_SYS_get_secondary_device_certificate function returns one of
  884. following status codes:
  885. - MSS_SYS_SUCCESS
  886. - MSS_SYS_MEM_ACCESS_ERROR
  887. - MSS_SYS_UNEXPECTED_ERROR
  888. */
  889. uint8_t MSS_SYS_get_secondary_device_certificate
  890. (
  891. uint8_t * p_secondary_device_certificate
  892. );
  893. /*-------------------------------------------------------------------------*//**
  894. The MSS_SYS_flash_freeze function requests the FPGA to enter the Flash*Freeze
  895. mode.
  896. @param options
  897. The options parameter can be used to power down additional parts of
  898. SmartFusion2 when the FPGA fabric enters Flash*Freeze mode. This parameter
  899. is a bit mask of the following options:
  900. - MSS_SYS_FPGA_POWER_DOWN
  901. - MSS_SYS_MPLL_POWER_DOWN
  902. MSS_SYS_FPGA_POWER_DOWN on its own will only power down the FPGA fabric.
  903. MSS_SYS_MPLL_POWER_DOWN specifies that the MSS PLL is powered down during
  904. the Flash*Freeze period.
  905. @return
  906. The MSS_SYS_flash_freeze function returns one of following status codes:
  907. - MSS_SYS_SUCCESS
  908. - MSS_SYS_SERVICE_DISABLED_BY_FACTORY
  909. - MSS_SYS_SERVICE_DISABLED_BY_USER
  910. - MSS_SYS_UNEXPECTED_ERROR
  911. - MSS_SYS_CLK_DIVISOR_ERROR
  912. The following example demonstrates how to request the FPGA fabric to enter
  913. the Flash*Freeze mode:
  914. @code
  915. MSS_SYS_flash_freeze(MSS_SYS_FPGA_POWER_DOWN | MSS_SYS_MPLL_POWER_DOWN);
  916. @endcode
  917. */
  918. uint8_t MSS_SYS_flash_freeze(uint8_t options);
  919. /*==============================================================================
  920. * Cryptographic Services.
  921. */
  922. /*-------------------------------------------------------------------------*//**
  923. The MSS_SYS_128bit_aes function provides access to the SmartFusion2 AES-128
  924. cryptography service.
  925. @param key
  926. The key parameter is a pointer to a 16-bytes array containing the key to use
  927. for the requested encryption/decryption operation.
  928. @param iv
  929. The iv parameter is a pointer to a 16-bytes array containing the
  930. initialization vector that will be used as part of the requested
  931. encryption/decryption operation. Its use is different depending on the mode.
  932. -----------------------------------------
  933. | Mode | Usage |
  934. -----------------------------------------
  935. | ECB | Ignored. |
  936. -----------------------------------------
  937. | CBC | Randomization. |
  938. -----------------------------------------
  939. | OFB | Randomization. |
  940. -----------------------------------------
  941. | CTR | Used as initial counter value. |
  942. -----------------------------------------
  943. @param nb_blocks
  944. The nb_blocks parameter specifies the number of 128-bit blocks of
  945. plaintext/ciphertext to be processed by the AES-128 system service.
  946. @param mode
  947. The mode parameter specifies the cipher mode of operation and whether the
  948. source text must be encrypted or decrypted. The modes of operation are:
  949. - Electronic Codebook (ECB)
  950. - Cipher-Block Chaining (CBC)
  951. - Output Feedback (OFB)
  952. - Counter (CTR)
  953. The CTR mode uses the content of the initialization vector as its initial
  954. counter value. The counter increment is 2^64.
  955. Allowed values for the mode parameter are:
  956. - MSS_SYS_ECB_ENCRYPT
  957. - MSS_SYS_ECB_DECRYPT
  958. - MSS_SYS_CBC_ENCRYPT
  959. - MSS_SYS_CBC_DECRYPT
  960. - MSS_SYS_OFB_ENCRYPT
  961. - MSS_SYS_OFB_DECRYPT
  962. - MSS_SYS_CTR_ENCRYPT
  963. - MSS_SYS_CTR_DECRYPT
  964. @param dest_addr
  965. The dest_addr parameter is a pointer to the memory buffer where the result
  966. of the encryption/decryption operation will be stored.
  967. @param src_addr
  968. The src_addr parameter is a pointer to the memory buffer containing the source
  969. plaintext/ciphertext to be encrypted/decrypted.
  970. @return
  971. The MSS_SYS_128bit_aes function returns one of following status codes:
  972. - MSS_SYS_SUCCESS
  973. - MSS_SYS_MEM_ACCESS_ERROR
  974. - MSS_SYS_SERVICE_NOT_LICENSED
  975. - MSS_SYS_SERVICE_DISABLED_BY_FACTORY
  976. - MSS_SYS_SERVICE_DISABLED_BY_USER
  977. */
  978. uint8_t MSS_SYS_128bit_aes
  979. (
  980. const uint8_t * key,
  981. const uint8_t * iv,
  982. uint16_t nb_blocks,
  983. uint8_t mode,
  984. uint8_t * dest_addr,
  985. const uint8_t * src_addr
  986. );
  987. /*-------------------------------------------------------------------------*//**
  988. The MSS_SYS_256bit_aes function provides access to the SmartFusion2 AES-256
  989. cryptography service.
  990. @param key
  991. The key parameter is a pointer to a 32-bytes array containing the key to use
  992. for the requested encryption/decryption operation.
  993. @param iv
  994. The iv parameter is a pointer to a 16-bytes array containing the
  995. initialization vector that will be used as part of the requested
  996. encryption/decryption operation. Its use is different depending on the mode.
  997. -----------------------------------------
  998. | Mode | Usage |
  999. -----------------------------------------
  1000. | ECB | Ignored. |
  1001. -----------------------------------------
  1002. | CBC | Randomization. |
  1003. -----------------------------------------
  1004. | OFB | Randomization. |
  1005. -----------------------------------------
  1006. | CTR | Used as initial counter value. |
  1007. -----------------------------------------
  1008. @param nb_blocks
  1009. The nb_blocks parameter specifies the number of 128-bit blocks of
  1010. plaintext/ciphertext requested to be processed by the AES-128 system service.
  1011. @param mode
  1012. The mode parameter specifies the cipher mode of operation and whether the
  1013. source text must be encrypted or decrypted. The modes of operation are:
  1014. - Electronic Codebook (ECB)
  1015. - Cypher-Block Chaining (CBC)
  1016. - Output Feedback (OFB)
  1017. - Counter (CTR)
  1018. The CTR mode uses the content of the initialization vector as its initial
  1019. counter value. The counter increment is 2^64.
  1020. Allowed values for the mode parameter are:
  1021. - MSS_SYS_ECB_ENCRYPT
  1022. - MSS_SYS_ECB_DECRYPT
  1023. - MSS_SYS_CBC_ENCRYPT
  1024. - MSS_SYS_CBC_DECRYPT
  1025. - MSS_SYS_OFB_ENCRYPT
  1026. - MSS_SYS_OFB_DECRYPT
  1027. - MSS_SYS_CTR_ENCRYPT
  1028. - MSS_SYS_CTR_DECRYPT
  1029. @param dest_addr
  1030. The dest_addr parameter is a pointer to the memory buffer where the result
  1031. of the encryption/decryption operation will be stored.
  1032. @param src_addr
  1033. The src_addr parameter is a pointer to the memory buffer containing the source
  1034. plaintext/ciphertext to be encrypted/decrypted.
  1035. @return
  1036. The MSS_SYS_256bit_aes function returns one of following status codes:
  1037. - MSS_SYS_SUCCESS
  1038. - MSS_SYS_MEM_ACCESS_ERROR
  1039. - MSS_SYS_SERVICE_NOT_LICENSED
  1040. - MSS_SYS_SERVICE_DISABLED_BY_FACTORY
  1041. - MSS_SYS_SERVICE_DISABLED_BY_USER
  1042. */
  1043. uint8_t MSS_SYS_256bit_aes
  1044. (
  1045. const uint8_t * key,
  1046. const uint8_t * iv,
  1047. uint16_t nb_blocks,
  1048. uint8_t mode,
  1049. uint8_t * dest_addr,
  1050. const uint8_t * src_addr
  1051. );
  1052. /*-------------------------------------------------------------------------*//**
  1053. The MSS_SYS_sha256 function provides access to the SmartFusion2 SHA-256
  1054. cryptography service.
  1055. @param p_data_in
  1056. The p_data_in parameter is a pointer to the memory location containing the
  1057. data that will be hashed using the SHA-256 system service.
  1058. @param length
  1059. The length parameter specifies the length in bits of the data to hash.
  1060. @param result
  1061. The result parameter is a pointer to a 32 bytes buffer where the hash result
  1062. will be stored.
  1063. @return
  1064. The MSS_SYS_sha256 function returns one of following status codes:
  1065. - MSS_SYS_SUCCESS
  1066. - MSS_SYS_MEM_ACCESS_ERROR
  1067. - MSS_SYS_SERVICE_NOT_LICENSED
  1068. - MSS_SYS_SERVICE_DISABLED_BY_FACTORY
  1069. - MSS_SYS_SERVICE_DISABLED_BY_USER
  1070. */
  1071. uint8_t MSS_SYS_sha256
  1072. (
  1073. const uint8_t * p_data_in,
  1074. uint32_t length,
  1075. uint8_t * result
  1076. );
  1077. /*-------------------------------------------------------------------------*//**
  1078. The MSS_SYS_hmac function provides access to the SmartFusion2 HMAC
  1079. cryptography service. The HMAC system service generates message authentication
  1080. codes using the SHA-256 hash function.
  1081. @param key
  1082. The key parameter is a pointer to a 32 bytes array containing the key used
  1083. to generate the message authentication code.
  1084. @param p_data_in
  1085. The p_data_in parameter is a pointer to the data to be authenticated.
  1086. @param length
  1087. The length parameter specifies the number of data bytes for which to generate
  1088. the authentication code. It is the size of the data pointed to by the
  1089. p_data_in parameter.
  1090. @param p_result
  1091. The p_result parameter is a pointer to a 32 bytes buffer where the
  1092. authentication code generated by the HMAC system service will be stored.
  1093. @return
  1094. The MSS_SYS_hmac function returns one of following status codes:
  1095. - MSS_SYS_SUCCESS
  1096. - MSS_SYS_MEM_ACCESS_ERROR
  1097. - MSS_SYS_SERVICE_NOT_LICENSED
  1098. - MSS_SYS_SERVICE_DISABLED_BY_FACTORY
  1099. - MSS_SYS_SERVICE_DISABLED_BY_USER
  1100. */
  1101. uint8_t MSS_SYS_hmac
  1102. (
  1103. const uint8_t * key,
  1104. const uint8_t * p_data_in,
  1105. uint32_t length,
  1106. uint8_t * p_result
  1107. );
  1108. /*-------------------------------------------------------------------------*//**
  1109. The MSS_SYS_key_tree() function provides access to a SHA-256 based key-tree
  1110. cryptography algorithm. The key-tree service begins with a user-supplied root
  1111. key and derives an output key based on a 7-bit parameter which can be used to
  1112. create uniqueness for different applications using the same root key, and a
  1113. 128-bit path variable. Both the 7-bit input parameter and the 128-bit path
  1114. variable are assumed to be publicly known. One common use for the output key
  1115. is as a keyed validator, similar to a message authentication code tag.
  1116. @param p_key
  1117. The p_key parameter is a pointer to a 32 bytes array containing root key
  1118. used to generate derived key by Key Tree service and also used to store the
  1119. derived key.
  1120. @param op_type
  1121. The op_type parameter specifies the operational parameter to be used to
  1122. generate the output key.
  1123. @param path
  1124. The path parameter specifies the 128-bit path to be used to generate the
  1125. output key.
  1126. @return
  1127. The MSS_SYS_key_tree function returns one of following status codes:
  1128. - MSS_SYS_SUCCESS
  1129. - MSS_SYS_MEM_ACCESS_ERROR
  1130. - MSS_SYS_SERVICE_NOT_LICENSED
  1131. - MSS_SYS_MEM_ACCESS_ERROR
  1132. - MSS_SYS_SERVICE_DISABLED_BY_USER
  1133. */
  1134. uint8_t MSS_SYS_key_tree
  1135. (
  1136. uint8_t* p_key,
  1137. uint8_t op_type,
  1138. const uint8_t* path
  1139. );
  1140. /*-------------------------------------------------------------------------*//**
  1141. The MSS_SYS_challenge_response function...
  1142. The MSS_SYS_challenge_response() function accept a challenge comprising a
  1143. 7-bit optype and 128-bit path and return a 256-bit response unique to the
  1144. given challenge and the device.
  1145. @param p_key
  1146. The key parameter is a pointer to a 32 bytes array containing 256 bit
  1147. unique response to the given challenge.
  1148. @param op_type
  1149. The op_type parameter specifies the operational parameter to be used to
  1150. generate the unique 256-bits unique response.
  1151. @param path
  1152. The path parameter specifies the 128-bit path to be used to generate the
  1153. unique 256-bits unique response.
  1154. @return
  1155. The MSS_SYS_challenge_response function returns one of following status
  1156. codes:
  1157. - MSS_SYS_SUCCESS
  1158. - MSS_SYS_MEM_ACCESS_ERROR
  1159. - MSS_SYS_SERVICE_NOT_LICENSED
  1160. - MSS_SYS_SERVICE_DISABLED_BY_FACTORY
  1161. - MSS_SYS_SERVICE_DISABLED_BY_USER
  1162. */
  1163. uint8_t MSS_SYS_challenge_response
  1164. (
  1165. uint8_t* p_key,
  1166. uint8_t op_type,
  1167. const uint8_t* path
  1168. );
  1169. /*==============================================================================
  1170. * Non Deterministic Random Bit Generator Services.
  1171. */
  1172. /*-------------------------------------------------------------------------*//**
  1173. The MSS_SYS_nrbg_reset() function is used to reset the
  1174. non-deterministic random bit generator (NRBG).
  1175. @return
  1176. The MSS_SYS_nrbg_self_test function returns one of following status codes:
  1177. - MSS_SYS_SUCCESS
  1178. - MSS_SYS_NRBG_CATASTROPHIC_ERROR
  1179. - MSS_SYS_NRBG_MAX_INST_EXCEEDED
  1180. - MSS_SYS_NRBG_INVALID_HANDLE
  1181. - MSS_SYS_NRBG_GEN_REQ_TOO_BIG
  1182. - MSS_SYS_NRBG_MAX_LENGTH_EXCEEDED
  1183. - MSS_SYS_MEM_ACCESS_ERROR
  1184. - MSS_SYS_SERVICE_NOT_LICENSED
  1185. - MSS_SYS_SERVICE_DISABLED_BY_FACTORY
  1186. - MSS_SYS_SERVICE_DISABLED_BY_USER
  1187. - MSS_SYS_UNEXPECTED_ERROR
  1188. */
  1189. uint8_t MSS_SYS_nrbg_reset(void);
  1190. /*-------------------------------------------------------------------------*//**
  1191. The MSS_SYS_nrbg_self_test() function performs a self test of the
  1192. non-deterministic random bit generator (NRBG).
  1193. @return
  1194. The MSS_SYS_nrbg_self_test function returns one of following status codes:
  1195. - MSS_SYS_SUCCESS
  1196. - MSS_SYS_NRBG_CATASTROPHIC_ERROR
  1197. - MSS_SYS_NRBG_MAX_INST_EXCEEDED
  1198. - MSS_SYS_NRBG_INVALID_HANDLE
  1199. - MSS_SYS_NRBG_GEN_REQ_TOO_BIG
  1200. - MSS_SYS_NRBG_MAX_LENGTH_EXCEEDED
  1201. - MSS_SYS_MEM_ACCESS_ERROR
  1202. - MSS_SYS_SERVICE_NOT_LICENSED
  1203. - MSS_SYS_SERVICE_DISABLED_BY_FACTORY
  1204. - MSS_SYS_SERVICE_DISABLED_BY_USER
  1205. - MSS_SYS_UNEXPECTED_ERROR
  1206. */
  1207. uint8_t MSS_SYS_nrbg_self_test(void);
  1208. /*-------------------------------------------------------------------------*//**
  1209. The MSS_SYS_nrbg_instantiate() function instantiates a non-deterministic
  1210. random bit generator (NRBG) instance. A maximum of two concurrent instances
  1211. are available.
  1212. @param personalization_str
  1213. The personalization_str parameter is a pointer to a buffer containing a
  1214. random bit generator personalization string. The personalization string
  1215. can be up to 128 bytes long.
  1216. @param personalization_str_length
  1217. The personalization_str_length parameter specifies the byte length of the
  1218. personalization string pointed to by personalization_str.
  1219. @param p_nrbg_handle
  1220. The p_nrbg_handle parameter is a pointer to a byte that will contain the
  1221. handle of the instantiated NRBG if this function call succeeds.
  1222. @return
  1223. The MSS_SYS_nrbg_instantiate function returns one of following status codes:
  1224. - MSS_SYS_SUCCESS
  1225. - MSS_SYS_NRBG_CATASTROPHIC_ERROR
  1226. - MSS_SYS_NRBG_MAX_INST_EXCEEDED
  1227. - MSS_SYS_NRBG_INVALID_HANDLE
  1228. - MSS_SYS_NRBG_GEN_REQ_TOO_BIG
  1229. - MSS_SYS_NRBG_MAX_LENGTH_EXCEEDED
  1230. - MSS_SYS_MEM_ACCESS_ERROR
  1231. - MSS_SYS_SERVICE_NOT_LICENSED
  1232. - MSS_SYS_SERVICE_DISABLED_BY_FACTORY
  1233. - MSS_SYS_SERVICE_DISABLED_BY_USER
  1234. */
  1235. uint8_t MSS_SYS_nrbg_instantiate
  1236. (
  1237. const uint8_t * personalization_str,
  1238. uint16_t personalization_str_length,
  1239. uint8_t * p_nrbg_handle
  1240. );
  1241. /*-------------------------------------------------------------------------*//**
  1242. The MSS_SYS_nrbg_generate function generates a random bit sequence up to
  1243. 128 bytes long.
  1244. @param p_requested_data
  1245. The p_requested_data parameter is a pointer to the buffer where the requested
  1246. random data will be stored on completion of this system service.
  1247. @param p_additional_input
  1248. The p_additional_input parameter is a pointer to the buffer containing
  1249. additional input data for the random bit generation.
  1250. @param requested_length
  1251. The requested_length parameter specifies the number of random data bytes
  1252. requested to be generated. The maximum generated data length is 128 bytes.
  1253. @param additional_input_length
  1254. The additional_input_length parameter specifies the number of additional
  1255. input bytes to use in the random data generation.
  1256. @param pr_req
  1257. The pr_req parameter specifies if prediction resistance is requested.
  1258. @param nrbg_handle
  1259. The nrbg_handle parameter specifies which non-deterministic random bit
  1260. generator (NRBG) instance will be used to generate the random data. The
  1261. value of nrbg_handle is obtained as a result of a previous call to the
  1262. MSS_SYS_nrbg_instantiate() function.
  1263. @return
  1264. The MSS_SYS_nrbg_generate function returns one of following status codes:
  1265. - MSS_SYS_SUCCESS
  1266. - MSS_SYS_NRBG_CATASTROPHIC_ERROR
  1267. - MSS_SYS_NRBG_MAX_INST_EXCEEDED
  1268. - MSS_SYS_NRBG_INVALID_HANDLE
  1269. - MSS_SYS_NRBG_GEN_REQ_TOO_BIG
  1270. - MSS_SYS_NRBG_MAX_LENGTH_EXCEEDED
  1271. - MSS_SYS_MEM_ACCESS_ERROR
  1272. - MSS_SYS_SERVICE_NOT_LICENSED
  1273. - MSS_SYS_SERVICE_DISABLED_BY_FACTORY
  1274. - MSS_SYS_SERVICE_DISABLED_BY_USER
  1275. */
  1276. uint8_t MSS_SYS_nrbg_generate
  1277. (
  1278. const uint8_t * p_requested_data,
  1279. const uint8_t * p_additional_input,
  1280. uint8_t requested_length,
  1281. uint8_t additional_input_length,
  1282. uint8_t pr_req,
  1283. uint8_t nrbg_handle
  1284. );
  1285. /*-------------------------------------------------------------------------*//**
  1286. The MSS_SYS_nrbg_reseed() function is used to reseed the non-deterministic
  1287. random bit generator (NRBG) identified by the nrbg_handle parameter.
  1288. @param p_additional_input
  1289. The additional_input_length parameter specifies the number of additional
  1290. input bytes used to reseed the NRBG identified by the nrbg_handle parameter.
  1291. @param additional_input_length
  1292. The additional_input_length parameter specifies the number of additional
  1293. input bytes used to reseed the NRBG.
  1294. @param nrbg_handle
  1295. The nrbg_handle parameter specifies which NRBG instance to reseed. The value
  1296. of nrbg_handle is obtained as a result of a previous call to the
  1297. MSS_SYS_nrbg_instantiate() function.
  1298. @return
  1299. The MSS_SYS_nrbg_reseed function returns one of following status codes:
  1300. - MSS_SYS_SUCCESS
  1301. - MSS_SYS_NRBG_CATASTROPHIC_ERROR
  1302. - MSS_SYS_NRBG_MAX_INST_EXCEEDED
  1303. - MSS_SYS_NRBG_INVALID_HANDLE
  1304. - MSS_SYS_NRBG_GEN_REQ_TOO_BIG
  1305. - MSS_SYS_NRBG_MAX_LENGTH_EXCEEDED
  1306. - MSS_SYS_MEM_ACCESS_ERROR
  1307. - MSS_SYS_SERVICE_NOT_LICENSED
  1308. - MSS_SYS_SERVICE_DISABLED_BY_FACTORY
  1309. - MSS_SYS_SERVICE_DISABLED_BY_USER
  1310. */
  1311. uint8_t MSS_SYS_nrbg_reseed
  1312. (
  1313. const uint8_t * p_additional_input,
  1314. uint8_t additional_input_length,
  1315. uint8_t nrbg_handle
  1316. );
  1317. /*-------------------------------------------------------------------------*//**
  1318. The MSS_SYS_nrbg_uninstantiate() function releases the non-deterministic
  1319. random bit generator (NRBG) identified by the nrbg_handle parameter.
  1320. @param nrbg_handle
  1321. The nrbg_handle parameter specifies which NRBG instance will be released.
  1322. The value of nrbg_handle is obtained as a result of a previous call to the
  1323. MSS_SYS_nrbg_instantiate() function.
  1324. @return
  1325. The MSS_SYS_nrbg_uninstantiate function returns one of following status codes:
  1326. - MSS_SYS_SUCCESS
  1327. - MSS_SYS_NRBG_CATASTROPHIC_ERROR
  1328. - MSS_SYS_NRBG_MAX_INST_EXCEEDED
  1329. - MSS_SYS_NRBG_INVALID_HANDLE
  1330. - MSS_SYS_NRBG_GEN_REQ_TOO_BIG
  1331. - MSS_SYS_NRBG_MAX_LENGTH_EXCEEDED
  1332. - MSS_SYS_MEM_ACCESS_ERROR
  1333. - MSS_SYS_SERVICE_NOT_LICENSED
  1334. - MSS_SYS_SERVICE_DISABLED_BY_FACTORY
  1335. - MSS_SYS_SERVICE_DISABLED_BY_USER
  1336. - MSS_SYS_UNEXPECTED_ERROR
  1337. */
  1338. uint8_t MSS_SYS_nrbg_uninstantiate
  1339. (
  1340. uint8_t nrbg_handle
  1341. );
  1342. /*==============================================================================
  1343. * Zeroization Services.
  1344. */
  1345. /*-------------------------------------------------------------------------*//**
  1346. The MSS_SYS_zeroize_device() function destroys sensitive information stored on
  1347. the device. Zeroization system services driver will destroy all user configuration
  1348. data, user keys, user security settings, NVM, SRAM, FPGA fabric, system
  1349. controller memory, and crypto-engine registers are erased. The level of
  1350. information destroyed by this function is configured as part of the hardware
  1351. flow of the design programmed into the device.
  1352. @param
  1353. This function does not take any parameters
  1354. @return
  1355. This function does not return any value.
  1356. */
  1357. void MSS_SYS_zeroize_device
  1358. (
  1359. void
  1360. );
  1361. /*==============================================================================
  1362. * Programming Services.
  1363. */
  1364. #define MSS_SYS_PROG_AUTHENTICATE 0u
  1365. #define MSS_SYS_PROG_PROGRAM 1u
  1366. #define MSS_SYS_PROG_VERIFY 2u
  1367. /*-------------------------------------------------------------------------*//**
  1368. The MSS_SYS_start_isp() function starts the In-System Programming (ISP)
  1369. system service which allows the Cortex-M3 processor to directly provide a
  1370. bitstream for programming the SmartFusion2 device.
  1371. The ISP system service can perform these services:
  1372. • Authenticate a programming bitstream
  1373. • Program the device with a programming bitstream
  1374. • Verify that a programming bitstream has been correctly programmed
  1375. The mode parameter specifies the ISP system service to perform. The
  1376. application must also provide two functions as parameters to the
  1377. MSS_SYS_start_isp() function. The first function is used by the ISP system
  1378. service to read the programming bitstream. The second function is used by
  1379. the ISP system service to notify the application that the ISP system service
  1380. has completed.
  1381. @param mode
  1382. The mode parameter specifies ISP service to perform. It can be one of:
  1383. - MSS_SYS_PROG_AUTHENTICATE
  1384. - MSS_SYS_PROG_PROGRAM
  1385. - MSS_SYS_PROG_VERIFY
  1386. @param page_read_handler
  1387. The page_read_handler parameter is a pointer to a function with the
  1388. following prototype:
  1389. uint32_t page_read_handler(uint8 const ** pp_next_page);
  1390. The page_read_handler function must be implemented by the application
  1391. program to provide the System Services driver with the address of the
  1392. next page of programming data to be sent to the System Controller and
  1393. the number of bytes contained in the next page. Refer to the description
  1394. of the comblk_page_handler_t type for details of the page_read_handler
  1395. function’s parameters and return values.
  1396. @param isp_completion_handler
  1397. The isp_completion_handler parameter is a pointer to a function with the
  1398. following prototype.
  1399. void (*sys_serv_isp_complete_handler_t)(uint32_t status);
  1400. The isp_completion_handler function must be implemented by the application
  1401. program and it is called by the System Services driver when an ISP
  1402. operation initiated by a call to MSS_SYS_start_isp() completes.
  1403. The isp_completion_handler function receives one of the following status
  1404. codes through its status parameter indicating the outcome of the ISP
  1405. operation:
  1406. - MSS_SYS_SUCCESS
  1407. - MSS_SYS_CHAINING_MISMATCH
  1408. - MSS_SYS_UNEXPECTED_DATA_RECEIVED
  1409. - MSS_SYS_INVALID_ENCRYPTION_KEY
  1410. - MSS_SYS_INVALID_COMPONENT_HEADER
  1411. - MSS_SYS_BACK_LEVEL_NOT_SATISFIED
  1412. - MSS_SYS_DSN_BINDING_MISMATCH
  1413. - MSS_SYS_ILLEGAL_COMPONENT_SEQUENCE
  1414. - MSS_SYS_INSUFFICIENT_DEV_CAPABILITIES
  1415. - MSS_SYS_INCORRECT_DEVICE_ID
  1416. - MSS_SYS_UNSUPPORTED_BITSTREAM_PROT_VER
  1417. - MSS_SYS_VERIFY_NOT_PERMITTED_ON_BITSTR
  1418. - MSS_SYS_ABORT
  1419. - MSS_SYS_NVM_VERIFY_FAILED
  1420. - MSS_SYS_DEVICE_SECURITY_PROTECTED
  1421. - MSS_SYS_PROGRAMMING_MODE_NOT_ENABLED
  1422. - MSS_SYS_SERVICE_DISABLED_BY_USER
  1423. @return
  1424. This function return status as MSS_SYS_CLK_DIVISOR_ERROR, if fclk, pclk0,
  1425. pclk1 and clk_fic64 divisor are not equal to each other or set to divide by
  1426. 32 on 060 device.
  1427. */
  1428. uint8_t MSS_SYS_start_isp
  1429. (
  1430. uint8_t mode,
  1431. comblk_page_handler_t page_read_handler,
  1432. sys_serv_isp_complete_handler_t isp_completion_handler
  1433. );
  1434. /*-------------------------------------------------------------------------*//**
  1435. The MSS_SYS_initiate_iap() function invokes the In application programming
  1436. system service by sending the request to System Controller to reprogram the
  1437. device using a bitstream present in SPI FLASH connected to MSS SPI-0. The
  1438. IAP Service is initiated by a call to MSS_SYS_initiate_iap(). The IAP
  1439. Service can perform these services:
  1440. - authenticate a programming bitstream
  1441. - program a bitstream
  1442. - verify that a programming bitstream has been correctly programmed
  1443. @param mode
  1444. The mode parameter specifies IAP service to perform. It can be one of:
  1445. - MSS_SYS_PROG_AUTHENTICATE
  1446. - MSS_SYS_PROG_PROGRAM
  1447. - MSS_SYS_PROG_VERIFY
  1448. @param bitstream_spi_addr
  1449. The bitstream_spi_addr parameter specifies the starting location address of
  1450. the programmed bitstream present in SPI flash connected to MSS SPI 0.
  1451. User should copy the programming bitstream into SPI Flash before calling
  1452. IAP system service.
  1453. @return
  1454. The MSS_SYS_initiate_iap function will receive one of the following status
  1455. codes:
  1456. - MSS_SYS_SUCCESS
  1457. - MSS_SYS_CHAINING_MISMATCH
  1458. - MSS_SYS_UNEXPECTED_DATA_RECEIVED
  1459. - MSS_SYS_INVALID_ENCRYPTION_KEY
  1460. - MSS_SYS_INVALID_COMPONENT_HEADER
  1461. - MSS_SYS_BACK_LEVEL_NOT_SATISFIED
  1462. - MSS_SYS_DSN_BINDING_MISMATCH
  1463. - MSS_SYS_ILLEGAL_COMPONENT_SEQUENCE
  1464. - MSS_SYS_INSUFFICIENT_DEV_CAPABILITIES
  1465. - MSS_SYS_INCORRECT_DEVICE_ID
  1466. - MSS_SYS_UNSUPPORTED_BITSTREAM_PROT_VER
  1467. - MSS_SYS_VERIFY_NOT_PERMITTED_ON_BITSTR
  1468. - MSS_SYS_INVALID_DEVICE_CERTIFICATE
  1469. - MSS_SYS_ABORT
  1470. - MSS_SYS_NVM_VERIFY_FAILED
  1471. - MSS_SYS_DEVICE_SECURITY_PROTECTED
  1472. - MSS_SYS_PROGRAMMING_MODE_NOT_ENABLED
  1473. - MSS_SYS_ENVM_PROGRAMMING_OPERATION_FAIL
  1474. - MSS_SYS_ENVM_VERIFY_OPERATION_FAIL
  1475. - MSS_SYS_ACCESS_ERROR
  1476. - MSS_SYS_PUF_ACCESS_ERROR
  1477. - MSS_SYS_BAD_COMPONENT
  1478. - MSS_SYS_SERVICE_DISABLED_BY_USER
  1479. - MSS_SYS_CLK_DIVISOR_ERROR
  1480. */
  1481. uint8_t MSS_SYS_initiate_iap
  1482. (
  1483. uint8_t mode,
  1484. uint32_t bitstream_spi_addr
  1485. );
  1486. /*-------------------------------------------------------------------------*//**
  1487. The MSS_SYS_check_digest() function is used to recalculate and compare
  1488. cryptographic digests of selected NVM component(s) – FPGA fabric, eNVM0, and
  1489. eNVM1 – to those previously computed and saved in NVM.
  1490. Note: The FPGA fabric will enter the Flash*Freeze state if it is powered up
  1491. when its digest is checked.
  1492. @param options
  1493. The options parameter specifies which components' digest will be recalculated
  1494. and checked. The allowed values for the options parameter are any one of the
  1495. following bitmask constants or a bitwise OR of more than one:
  1496. • MSS_SYS_DIGEST_CHECK_FABRIC (bit mask = 0x01)
  1497. • MSS_SYS_DIGEST_CHECK_ENVM0 (bit mask = 0x02)
  1498. • MSS_SYS_DIGEST_CHECK_ENVM1 (bit mask = 0x04)
  1499. • MSS_SYS_DIGEST_CHECK_SYS (bit mask = 0x08)
  1500. • MSS_SYS_DIGEST_CHECK_ENVMFP (bit mask = 0x10)
  1501. • MSS_SYS_DIGEST_CHECK_ENVMUP (bit mask = 0x20)
  1502. NOTE: Private factory eNVM and private user eNVM digest checks are only
  1503. available on the M2S060 and larger devices.
  1504. @return
  1505. The MSS_SYS_check_digest function returns the result of the digest check as
  1506. an 8-bit unsigned integer. The meaning of the digest check return value is
  1507. as follows:
  1508. bit 0: Fabric digest error
  1509. bit 1: ENVM0 digest error
  1510. bit 2: ENVM1 digest error
  1511. bit 3: System Controller ROM digest error
  1512. bit 4: Private eNVM factory digest error
  1513. bit 5: Private eNVM user digest error
  1514. bit 7: Service Disable by user lock.
  1515. A '1' in one of the above bits indicates a digest mismatch. The return
  1516. value can be compared to the bitmask constants specified as allowed values
  1517. for the options parameter to discover which of the NVM components produced
  1518. a digest check error.
  1519. On 060 device, the MSS_SYS_check_digest function returns
  1520. MSS_SYS_CLK_DIVISOR_ERROR, if the the divisor values of fclk, pclk0, pclk1
  1521. and clk_fic64 divisor are not equal to each other or set to divide by 32.
  1522. */
  1523. #define MSS_SYS_DIGEST_CHECK_FABRIC 0x01u
  1524. #define MSS_SYS_DIGEST_CHECK_ENVM0 0x02u
  1525. #define MSS_SYS_DIGEST_CHECK_ENVM1 0x04u
  1526. #define MSS_SYS_DIGEST_CHECK_SYS 0x08u
  1527. #define MSS_SYS_DIGEST_CHECK_ENVMFP 0x10u
  1528. #define MSS_SYS_DIGEST_CHECK_ENVMUP 0x20u
  1529. #define MSS_SYS_DIGEST_CHECK_SVCDISABLED 0x80u
  1530. uint8_t MSS_SYS_check_digest
  1531. (
  1532. uint8_t options
  1533. );
  1534. /*-------------------------------------------------------------------------*//**
  1535. The MSS_SYS_puf_create_activation_code() function is used to create the
  1536. SRAM-PUF user activation code. This function is typically only used once when
  1537. enrolling the device into the overall system it operates in. It creates an
  1538. activation code which will be used to regenerate the SRAM-PUF secret key after
  1539. each power-up of the SRAM-PUF. The activation code is used to eliminate the
  1540. randomness of the SRAM-PUF power-up content in order to retrieve the device’s
  1541. unique PUF secret key.
  1542. Note: This system service is only available on large SmartFusion2 devices
  1543. starting with the M2S060.
  1544. @param
  1545. This function does not take any parameters.
  1546. @return
  1547. The MSS_SYS_puf_create_activation_code() function returns one of the
  1548. following status codes:
  1549. - MSS_SYS_SUCCESS
  1550. - MSS_SYS_ENVM_ERROR
  1551. - MSS_SYS_PUF_ERROR_WHEN_CREATING
  1552. - MSS_SYS_INVALID_SUBCMD
  1553. - MSS_SYS_ENVM_PROGRAM_ERROR
  1554. - MSS_SYS_ENVM_VERIFY_ERROR
  1555. - MSS_SYS_MEM_ACCESS_ERROR
  1556. - MSS_SYS_SERVICE_NOT_LICENSED
  1557. - MSS_SYS_SERVICE_DISABLED_BY_FACTORY
  1558. - MSS_SYS_SERVICE_DISABLED_BY_USER
  1559. - MSS_SYS_UNEXPECTED_ERROR
  1560. */
  1561. uint8_t MSS_SYS_puf_create_activation_code
  1562. (
  1563. void
  1564. );
  1565. /*-------------------------------------------------------------------------*//**
  1566. The MSS_SYS_puf_delete_activation_code() function is used to delete the user
  1567. activation code. This function would typically be used only once when
  1568. decommissioning the device.
  1569. Note: This system services is only available on large SmartFusion2 devices
  1570. starting with the M2S060.
  1571. @param
  1572. This function does not take any parameters.
  1573. @return
  1574. The MSS_SYS_puf_delete_activation_code() function returns one of the
  1575. following status codes:
  1576. - MSS_SYS_SUCCESS
  1577. - MSS_SYS_ENVM_ERROR
  1578. - MSS_SYS_PUF_ERROR_WHEN_CREATING
  1579. - MSS_SYS_INVALID_SUBCMD
  1580. - MSS_SYS_ENVM_PROGRAM_ERROR
  1581. - MSS_SYS_ENVM_VERIFY_ERROR
  1582. - MSS_SYS_MEM_ACCESS_ERROR
  1583. - MSS_SYS_SERVICE_NOT_LICENSED
  1584. - MSS_SYS_SERVICE_DISABLED_BY_FACTORY
  1585. - MSS_SYS_SERVICE_DISABLED_BY_USER
  1586. - MSS_SYS_UNEXPECTED_ERROR
  1587. */
  1588. uint8_t MSS_SYS_puf_delete_activation_code
  1589. (
  1590. void
  1591. );
  1592. /*-------------------------------------------------------------------------*//**
  1593. The MSS_SYS_puf_get_number_of_keys() function is used to retrieve the number
  1594. of user keys enrolled with the SRAM-PUF service. The number of enrolled keys
  1595. is also the key identification number to use for the next key to enroll since
  1596. keys must be enrolled sequentially and the key numbering starts at zero. Up
  1597. to 58 keys can be enrolled. Keys number 0 and 1 are used for design security
  1598. and are not available to the user.
  1599. Note: This system service is only available on large SmartFusion2 devices
  1600. starting with the M2S060.
  1601. @param p_number_of_user_keys
  1602. The p_user_key parameter is a pointer to the byte in which the number of
  1603. keys will be written on successful completion of the system service.
  1604. @return
  1605. The MSS_SYS_puf_get_number_of_user_keys() function returns one of the
  1606. following status codes:
  1607. - MSS_SYS_SUCCESS
  1608. - MSS_SYS_ENVM_ERROR
  1609. - MSS_SYS_PUF_ERROR_WHEN_CREATING
  1610. - MSS_SYS_ENVM_PROGRAM_ERROR
  1611. - MSS_SYS_INVALID_HASH
  1612. - MSS_SYS_INVALID_USER_AC1
  1613. - MSS_SYS_ENVM_VERIFY_ERROR
  1614. - MSS_SYS_PRIVATE_ENVM_USER_DIGEST_MISMATCH
  1615. - MSS_SYS_DRBG_ERROR
  1616. - MSS_SYS_MEM_ACCESS_ERROR
  1617. - MSS_SYS_SERVICE_NOT_LICENSED
  1618. - MSS_SYS_SERVICE_DISABLED_BY_FACTORY
  1619. - MSS_SYS_SERVICE_DISABLED_BY_USER
  1620. - MSS_SYS_UNEXPECTED_ERROR
  1621. */
  1622. uint8_t MSS_SYS_puf_get_number_of_keys
  1623. (
  1624. uint8_t* p_number_of_keys
  1625. );
  1626. /*-------------------------------------------------------------------------*//**
  1627. The MSS_SYS_puf_enroll_key() function is used to enroll keys into the
  1628. SRAM-PUF hardware block. Keys can be either intrinsic keys or extrinsic keys.
  1629. An intrinsic key’s value is randomly generated by the SRAM-PUF hardware block
  1630. during key enrollment. An extrinsic key’s value is supplied by the user. A key
  1631. code is created and stored in the System Controller’s private eNVM during key
  1632. enrollment. The key code along with the activation code created as part of the
  1633. call to MSS_SYS_puf_create_activation_code() and the SRAM-PUF start-up value
  1634. can then be used later to regenerate the enrolled key’s value. Enrolled keys
  1635. can be later reconstructed and retrieved using the MSS_SYS_puf_fetch_key()
  1636. function. The value of the key is protected until it is fetched since its
  1637. actual value is not stored anywhere in the system.
  1638. Note: This system service is only available on large SmartFusion2 devices
  1639. starting with the M2S060.
  1640. @param key_number
  1641. The key_number parameter specifies the key number that will be used to
  1642. identify the key in later use after enrollment. The key number will be used
  1643. to identify which key to retrieve in subsequent calls to function
  1644. MSS_SYS_puf_fetch_key().
  1645. Keys must be enrolled sequentially. Therefore, an arbitrary value cannot be
  1646. used for key_number when enrolling a new key. The value for key_number must
  1647. be derived from a call to MSS_SYS_puf_get_number_of_keys() to find the
  1648. number of keys currently enrolled and derive the next key number in the
  1649. sequence.
  1650. Note: Valid values for key identification numbers are 2 to 57. Keys number
  1651. 0 and 1 are used for design security and not available to the user.
  1652. @param key_size
  1653. The key_size parameter specifies the size of the key to enroll. The key size
  1654. is a multiple of 64-bit up to 4096-bit.
  1655. @param p_key_value
  1656. The p_key_value parameter is a pointer to the buffer containing the value of
  1657. the key to enroll. The buffer pointed to by p_key_value contains the value
  1658. of the extrinsic key specified by the user.
  1659. Setting this pointer’s value to zero specifies that an intrinsic key is to
  1660. be enrolled. In this case, a random value is generated using the SRAM-PUF as
  1661. the key value.
  1662. @param p_key_location
  1663. The p_key_location parameter is a pointer to the buffer where the key will
  1664. be copied when it is fetched through a call to MSS_SYS_puf_fetch_key().
  1665. @return
  1666. The MSS_SYS_puf_enroll_key() function returns one of the following status
  1667. codes:
  1668. - MSS_SYS_SUCCESS
  1669. - MSS_SYS_ENVM_ERROR
  1670. - MSS_SYS_PUF_ERROR_WHEN_CREATING
  1671. - MSS_SYS_INVALID_REQUEST_OR_KC
  1672. - MSS_SYS_ENVM_PROGRAM_ERROR
  1673. - MSS_SYS_INVALID_HASH
  1674. - MSS_SYS_INVALID_USER_AC1
  1675. - MSS_SYS_ENVM_VERIFY_ERROR
  1676. - MSS_SYS_INCORRECT_KEYSIZE_FOR_RENEWING_A_KC
  1677. - MSS_SYS_PRIVATE_ENVM_USER_DIGEST_MISMATCH
  1678. - MSS_SYS_USER_KEY_CODE_INVALID_SUBCMD
  1679. - MSS_SYS_DRBG_ERROR
  1680. - MSS_SYS_MEM_ACCESS_ERROR
  1681. - MSS_SYS_SERVICE_NOT_LICENSED
  1682. - MSS_SYS_SERVICE_DISABLED_BY_FACTORY
  1683. - MSS_SYS_SERVICE_DISABLED_BY_USER
  1684. - MSS_SYS_UNEXPECTED_ERROR
  1685. */
  1686. uint8_t MSS_SYS_puf_enroll_key
  1687. (
  1688. uint8_t key_number,
  1689. uint16_t key_size,
  1690. uint8_t* p_key_value,
  1691. uint8_t* p_key_location
  1692. );
  1693. /*-------------------------------------------------------------------------*//**
  1694. The MSS_SYS_puf_delete_key() function is used to delete a previously enrolled
  1695. key from the SRAM-PUF.
  1696. Note: This system service is only available on large SmartFusion2 devices
  1697. starting with the M2S060.
  1698. @param key_number
  1699. The key_number parameter specifies the key number of the key to delete.
  1700. @return
  1701. The MSS_SYS_puf_delete_key() function returns one of the following status
  1702. codes:
  1703. - MSS_SYS_SUCCESS
  1704. - MSS_SYS_ENVM_ERROR
  1705. - MSS_SYS_PUF_ERROR_WHEN_CREATING
  1706. - MSS_SYS_INVALID_REQUEST_OR_KC
  1707. - MSS_SYS_ENVM_PROGRAM_ERROR
  1708. - MSS_SYS_INVALID_HASH
  1709. - MSS_SYS_INVALID_USER_AC1
  1710. - MSS_SYS_ENVM_VERIFY_ERROR
  1711. - MSS_SYS_INCORRECT_KEYSIZE_FOR_RENEWING_A_KC
  1712. - MSS_SYS_PRIVATE_ENVM_USER_DIGEST_MISMATCH
  1713. - MSS_SYS_USER_KEY_CODE_INVALID_SUBCMD
  1714. - MSS_SYS_DRBG_ERROR
  1715. - MSS_SYS_MEM_ACCESS_ERROR
  1716. - MSS_SYS_SERVICE_NOT_LICENSED
  1717. - MSS_SYS_SERVICE_DISABLED_BY_FACTORY
  1718. - MSS_SYS_SERVICE_DISABLED_BY_USER
  1719. - MSS_SYS_UNEXPECTED_ERROR
  1720. */
  1721. uint8_t MSS_SYS_puf_delete_key
  1722. (
  1723. uint8_t key_number
  1724. );
  1725. /*-------------------------------------------------------------------------*//**
  1726. The MSS_SYS_puf_fetch_key() function is used to retrieve a user PUF key from
  1727. the SRAM-PUF hardware block. The key must have been previously enrolled using
  1728. the MSS_SYS_puf_enroll_key() function. The key to retrieve is identified
  1729. through the key number used at key enrollment time. The key value is copied
  1730. into the buffer location specified at key enrollment time. The location of
  1731. this buffer is returned through function argument pp_key.
  1732. The key value is reconstructed based on the SRAM-PUF power-on value, the
  1733. activation code created when the device was commissioned using the
  1734. MSS_SYS_puf_create_activation_code() function and the key code stored in the
  1735. SRAM-PUF hardware block’s private eNVM at key enrollment time. The key value
  1736. does not exist anywhere in the system until it is retrieved by a call to
  1737. MSS_SYS_puf_fetch_key(). Care must be taken to destroy the key value returned
  1738. by MSS_SYS_puf_fetch_key() once it is not required anymore.
  1739. Note: This system service is only available on large SmartFusion2 devices
  1740. starting with the M2S060.
  1741. @param key_number
  1742. The key_number parameter specifies the key number identifying the user key
  1743. to fetch. The valid range of key numbers is from 2 to 57.
  1744. @param pp_key
  1745. The pp_key parameter is a pointer to a pointer to the buffer that will
  1746. contain the user key value on successful completion of the system service.
  1747. The pp_key parameter can be set to zero if your application keeps track of
  1748. the location of the key specified though the call to function
  1749. MSS_SYS_puf_enroll_key() at key enrollment time.
  1750. @return
  1751. The MSS_SYS_puf_fetch_key() function returns one of the following status
  1752. codes:
  1753. - MSS_SYS_SUCCESS
  1754. - MSS_SYS_PUF_ERROR_WHEN_CREATING
  1755. - MSS_SYS_INVALID_KEYNUM_OR_ARGUMENT
  1756. - MSS_SYS_INVALID_HASH
  1757. - MSS_SYS_PRIVATE_ENVM_USER_DIGEST_MISMATCH
  1758. - MSS_SYS_MEM_ACCESS_ERROR
  1759. - MSS_SYS_SERVICE_NOT_LICENSED
  1760. - MSS_SYS_SERVICE_DISABLED_BY_FACTORY
  1761. - MSS_SYS_SERVICE_DISABLED_BY_USER
  1762. - MSS_SYS_UNEXPECTED_ERROR
  1763. */
  1764. uint8_t MSS_SYS_puf_fetch_key
  1765. (
  1766. uint8_t key_number,
  1767. uint8_t ** pp_key
  1768. );
  1769. /*-------------------------------------------------------------------------*//**
  1770. The MSS_SYS_puf_export_keycodes() function is used to export an encrypted
  1771. copy of all the key codes used internally by the SRAM-PUF hardware block to
  1772. reconstruct the enrolled keys. Up to 3894 bytes of data can be exported
  1773. depending on the number and size of keys enrolled.
  1774. Keys cannot be fetched any more after calling MSS_SYS_puf_export_keycodes()
  1775. until a subsequent call to function MSS_SYS_puf_import_keycodes() is made
  1776. with the exported encrypted key codes.
  1777. Calling MSS_SYS_puf_export_keycodes() and moving the exported data off chip
  1778. is similar to removing the enrolled keys from the device. The enrolled keys
  1779. will only be available again if the exported key codes are imported back into
  1780. the device.
  1781. A SmartFusion2 device will only accept imported key codes generated from the
  1782. last set of enrolled keys on that specific device. This makes the exported
  1783. key codes data specific to one unique SmartFuson2 device. Key codes cannot
  1784. be exported from one SmartFusion2 device and imported into another
  1785. SmartFusion2 device. The exported key codes data is specific to the unique
  1786. SmartFusion2 device it was exported from.
  1787. Keys cannot be reconstructed from the exported key codes data since the
  1788. intrinsic secret of the SRAM-PUF is required to reconstruct the keys from
  1789. the key codes. Furthermore, the key codes data is also encrypted using a
  1790. random key generated from the SRAM-PUF thus preventing an attacker from
  1791. deriving useful information from the exported key codes data.
  1792. Note: This system service is only available on large SmartFusion2 devices
  1793. starting with the M2S060.
  1794. @param p_keycodes
  1795. The p_keycodes parameter is a pointer to the buffer where the PUF key codes
  1796. will be exported.
  1797. @return
  1798. The MSS_SYS_puf_export_keycodes() function returns one of the following
  1799. status codes:
  1800. - MSS_SYS_SUCCESS
  1801. - MSS_SYS_ENVM_ERROR
  1802. - MSS_SYS_PUF_ERROR_WHEN_CREATING
  1803. - MSS_SYS_INVALID_REQUEST_OR_KC
  1804. - MSS_SYS_ENVM_PROGRAM_ERROR
  1805. - MSS_SYS_INVALID_HASH
  1806. - MSS_SYS_INVALID_USER_AC1
  1807. - MSS_SYS_ENVM_VERIFY_ERROR
  1808. - MSS_SYS_INCORRECT_KEYSIZE_FOR_RENEWING_A_KC
  1809. - MSS_SYS_PRIVATE_ENVM_USER_DIGEST_MISMATCH
  1810. - MSS_SYS_USER_KEY_CODE_INVALID_SUBCMD
  1811. - MSS_SYS_DRBG_ERROR
  1812. - MSS_SYS_MEM_ACCESS_ERROR
  1813. - MSS_SYS_SERVICE_NOT_LICENSED
  1814. - MSS_SYS_SERVICE_DISABLED_BY_FACTORY
  1815. - MSS_SYS_SERVICE_DISABLED_BY_USER
  1816. - MSS_SYS_UNEXPECTED_ERROR
  1817. */
  1818. uint8_t MSS_SYS_puf_export_keycodes
  1819. (
  1820. uint8_t * p_keycodes
  1821. );
  1822. /*-------------------------------------------------------------------------*//**
  1823. The MSS_SYS_puf_import_keycodes() function is used to import a set of PUF
  1824. key codes that was previously exported using the MSS_SYS_puf_export_keycodes()
  1825. function. Importing the exported key codes allows the enrolled keys to be
  1826. regenerated. Enrolled keys cannot be regenerated while the key codes have
  1827. been exported and not imported back.
  1828. Importing back the key codes results in all keys being regenerated and copied
  1829. to the memory locations specified during key enrollment. The content of the
  1830. buffer holding the imported key codes is modified by function
  1831. MSS_SYS_puf_import_keycodes() to contain the list of pointers to the
  1832. locations where the keys have been regenerated. This list starts with the
  1833. address where key number 2 has been regenerated. The location for keys 0 and
  1834. 1 are not contained in that list because these keys are used for design
  1835. security and are not accessible to the user.
  1836. Note: This system service is only available on large SmartFusion2 devices
  1837. starting with the M2S060.
  1838. @param p_keycodes
  1839. The p_keycodes parameter is a pointer to the buffer containing the PUF key
  1840. codes to import.
  1841. @return
  1842. The MSS_SYS_puf_import_keycodes() function returns one of the following status codes:
  1843. - MSS_SYS_SUCCESS
  1844. - MSS_SYS_ENVM_ERROR
  1845. - MSS_SYS_PUF_ERROR_WHEN_CREATING
  1846. - MSS_SYS_INVALID_REQUEST_OR_KC
  1847. - MSS_SYS_ENVM_PROGRAM_ERROR
  1848. - MSS_SYS_INVALID_HASH
  1849. - MSS_SYS_INVALID_USER_AC1
  1850. - MSS_SYS_ENVM_VERIFY_ERROR
  1851. - MSS_SYS_INCORRECT_KEYSIZE_FOR_RENEWING_A_KC
  1852. - MSS_SYS_PRIVATE_ENVM_USER_DIGEST_MISMATCH
  1853. - MSS_SYS_USER_KEY_CODE_INVALID_SUBCMD
  1854. - MSS_SYS_DRBG_ERROR
  1855. - MSS_SYS_MEM_ACCESS_ERROR
  1856. - MSS_SYS_SERVICE_NOT_LICENSED
  1857. - MSS_SYS_SERVICE_DISABLED_BY_FACTORY
  1858. - MSS_SYS_SERVICE_DISABLED_BY_USER
  1859. - MSS_SYS_UNEXPECTED_ERROR
  1860. */
  1861. uint8_t MSS_SYS_puf_import_keycodes
  1862. (
  1863. uint8_t * p_keycodes
  1864. );
  1865. /*-------------------------------------------------------------------------*//**
  1866. The MSS_SYS_puf_fetch_ecc_public_key() function is used to fetch PUF ECC
  1867. public key from eNVM.
  1868. @param p_puf_public_key
  1869. The p_puf_public_key parameter is a pointer to buffer where the PUF ECC
  1870. public key will be stored on successful completion of system service.
  1871. Note: This system service is only available on large SmartFusion2 devices
  1872. starting with the M2S060.
  1873. @return
  1874. The MSS_SYS_puf_fetch_ecc_public_key() function returns one of the following
  1875. status codes:
  1876. - MSS_SYS_SUCCESS
  1877. - MSS_SYS_NO_VALID_PUBLIC_KEY
  1878. - MSS_SYS_PRIVATE_ENVM_USER_DIGEST_MISMATCH
  1879. - MSS_SYS_MEM_ACCESS_ERROR
  1880. - MSS_SYS_SERVICE_NOT_LICENSED
  1881. - MSS_SYS_SERVICE_DISABLED_BY_FACTORY
  1882. - MSS_SYS_SERVICE_DISABLED_BY_USER
  1883. - MSS_SYS_UNEXPECTED_ERROR
  1884. */
  1885. uint8_t MSS_SYS_puf_fetch_ecc_public_key
  1886. (
  1887. uint8_t* p_puf_public_key
  1888. );
  1889. /*-------------------------------------------------------------------------*//**
  1890. The MSS_SYS_puf_get_random_seed() function is used to generate a 256-bit true
  1891. random number seed using the SmartFusion2 SRAM-PUF.
  1892. @param p_puf_seed
  1893. The p_puf_seed parameter is a pointer to the buffer where the PUF seed will
  1894. be stored on successful completion of the system service.
  1895. Note: This system service is only available on large SmartFusion2 devices
  1896. starting with the M2S060.
  1897. @return
  1898. The MSS_SYS_puf_get_random_seed() function returns one of the following
  1899. status codes:
  1900. - MSS_SYS_SUCCESS
  1901. - MSS_SYS_PUF_ERROR_WHEN_CREATING
  1902. - MSS_SYS_MEM_ACCESS_ERROR
  1903. - MSS_SYS_SERVICE_NOT_LICENSED
  1904. - MSS_SYS_SERVICE_DISABLED_BY_FACTORY
  1905. - MSS_SYS_SERVICE_DISABLED_BY_USER
  1906. - MSS_SYS_UNEXPECTED_ERROR
  1907. */
  1908. uint8_t MSS_SYS_puf_get_random_seed
  1909. (
  1910. uint8_t* p_puf_seed
  1911. );
  1912. /*-------------------------------------------------------------------------*//**
  1913. The MSS_SYS_ecc_point_multiplication() function provides access to the
  1914. SmartFusion2 System Controller’s Elliptic Curve Cryptography (ECC) point
  1915. multiplication system service. The MSS_SYS_ecc_point_multiplication() function
  1916. computes the point multiplication of a point P on the NIST-384 curve by a
  1917. scalar value d. The point multiplication results in point Q as follows:
  1918. d * P = Q
  1919. The points are defined by their x and y coordinates as follows:
  1920. P = (x1, y1)
  1921. Q = (x2, y2)
  1922. Each x and y coordinate and the scalar d are 384-bit long big-endian numbers.
  1923. Note: The point at infinity is specified using point x =0, y = 0.
  1924. Note: This system service is only available on large SmartFusion2 devices
  1925. starting with the M2S060.
  1926. @param p_scalar_d
  1927. The p_scalar_d parameter is a pointer to a buffer containing the 384-bit
  1928. scalar d. The scalar d is 384-bit long meaning that p_scalar_d should point
  1929. to a 96 bytes buffer.
  1930. @param p_point_p
  1931. The p_point_p parameter is a pointer to a buffer containing the (x1, y1)
  1932. coordinates of input point P. Each x and y coordinate is 384-bit long
  1933. meaning that p_point_p should point to a 96 bytes buffer.
  1934. @param p_point_q
  1935. The p_point_q parameter is a pointer to a buffer where the (x2, y2)
  1936. coordinates of result Q will be stored. Each x and y coordinate is 384-bit
  1937. long meaning that p_point_q should point to a 96 bytes buffer.
  1938. @return
  1939. The MSS_SYS_ecc_point_multiplication function returns one of the following
  1940. status codes:
  1941. - MSS_SYS_SUCCESS
  1942. - MSS_SYS_MEM_ACCESS_ERROR
  1943. - MSS_SYS_SERVICE_NOT_LICENSED
  1944. - MSS_SYS_SERVICE_DISABLED_BY_FACTORY
  1945. - MSS_SYS_SERVICE_DISABLED_BY_USER
  1946. - MSS_SYS_UNEXPECTED_ERROR
  1947. */
  1948. uint8_t MSS_SYS_ecc_point_multiplication
  1949. (
  1950. uint8_t* p_scalar_d,
  1951. uint8_t* p_point_p,
  1952. uint8_t* p_point_q
  1953. );
  1954. /*-------------------------------------------------------------------------*//**
  1955. The MSS_SYS_ecc_point_addition() function provides access to the SmartFusion2
  1956. System Controller’s Elliptic Curve Cryptography (ECC) point addition system
  1957. service. The MSS_SYS_ecc_point_addition() function computes the addition of
  1958. two points, P and Q, on the NIST P-384 curve. The point addition results in
  1959. point R as follows:
  1960. P + Q = R
  1961. The points are defined by their x and y coordinates as follows:
  1962. P = (x1, y1)
  1963. Q = (x2, y2)
  1964. R = (x3, y3)
  1965. Each x and y coordinate are 384-bit long big-endian numbers.
  1966. Note: The point at infinity is specified using point x =0, y = 0.
  1967. Note: This system service is only available on large SmartFusion2 devices
  1968. starting with the M2S060.
  1969. @param p_point_p
  1970. The p_point_p parameter is a pointer to a buffer containing the (x1, y1)
  1971. coordinates of input point P. Each x and y coordinate is 384-bit long
  1972. meaning that p_point_p should point to a 96 bytes buffer.
  1973. @param p_point_q
  1974. The p_point_q parameter is a pointer to a buffer containing the (x2, y2)
  1975. coordinates of input point Q. Each x and y coordinate is 384-bit long
  1976. meaning that p_point_q should point to a 96 bytes buffer.
  1977. @param p_point_r
  1978. The p_point_r parameter is a pointer to a buffer where the (x3, y3)
  1979. coordinates of result R will be stored. Each x and y coordinate is 384-bit
  1980. long meaning that p_point_r should point to a 96 bytes buffer.
  1981. @return
  1982. The MSS_SYS_ecc_point_addition() function returns one of the following
  1983. status codes:
  1984. - MSS_SYS_SUCCESS
  1985. - MSS_SYS_MEM_ACCESS_ERROR
  1986. - MSS_SYS_SERVICE_NOT_LICENSED
  1987. - MSS_SYS_SERVICE_DISABLED_BY_FACTORY
  1988. - MSS_SYS_SERVICE_DISABLED_BY_USER
  1989. - MSS_SYS_UNEXPECTED_ERROR
  1990. */
  1991. uint8_t MSS_SYS_ecc_point_addition
  1992. (
  1993. uint8_t* p_point_p,
  1994. uint8_t* p_point_q,
  1995. uint8_t* p_point_r
  1996. );
  1997. /*-------------------------------------------------------------------------*//**
  1998. The MSS_SYS_ecc_get_base_point() function provides the value of the base
  1999. point G for NIST elliptic curve P-384. The value of the base point can then
  2000. be used to generate a public key by multiplying the base point G with a
  2001. private key using function MSS_SYS_ecc_point_multiplication().
  2002. Note: This system service is only available on large SmartFusion2 devices
  2003. starting with the M2S060.
  2004. @param p_point_p
  2005. The p_point_g parameter is a pointer to a buffer where the coordinate of
  2006. base point G (xG, yG) for curve P-384 will be stored. Each x and y
  2007. coordinate is 384-bit long meaning that p_point_g should point to a 96
  2008. bytes buffer.
  2009. @return
  2010. This function does not return a value.
  2011. */
  2012. void MSS_SYS_ecc_get_base_point
  2013. (
  2014. uint8_t* p_point_g
  2015. );
  2016. /*-------------------------------------------------------------------------*//**
  2017. The MSS_SYS_start_clock_monitor() function enables clock monitoring based on
  2018. user configuration. The system controller will start monitoring the 50MHz
  2019. clock timing reference for four 1MHz clock cycle. The expected count is 200
  2020. +/- tolerance. If the clock fall outside the tolerance limits, interrupt will
  2021. be generated and system controller will send clock monitor tamper detect
  2022. event through COMBLK. MSS should inform to the application about clock
  2023. monitoring tamper detect event though call back function.
  2024. NOTE: Do not enable both start clock monitoring and stop clock monitoring at
  2025. the same time.
  2026. Note: This system service is only available on large SmartFusion2 devices
  2027. starting with the M2S060.
  2028. @param
  2029. This function does not take any parameters
  2030. @return
  2031. The MSS_SYS_start_clock_monitor() function returns one of the following
  2032. status codes:
  2033. • MSS_SYS_SUCCESS
  2034. • MSS_SYS_UNEXPECTED_ERROR
  2035. */
  2036. uint8_t MSS_SYS_start_clock_monitor
  2037. (
  2038. void
  2039. );
  2040. /*-------------------------------------------------------------------------*//**
  2041. The MSS_SYS_stop_clock_monitor() function is used to stop the clock monitoring.
  2042. System controller will disable 50 MHZ timing clock monitoring and clock
  2043. monitor tamper detect interrupt.
  2044. NOTE: Do not enable both start clock monitoring and stop clock monitoring at
  2045. the same time.
  2046. NOTE: This system service is only available on large SmartFusion2 devices
  2047. starting with the M2S060.
  2048. @param
  2049. This function does not take any parameters
  2050. @return
  2051. The MSS_SYS_stop_clock_monitor() function returns one of the following
  2052. status codes:
  2053. • MSS_SYS_SUCCESS
  2054. • MSS_SYS_UNEXPECTED_ERROR
  2055. */
  2056. uint8_t MSS_SYS_stop_clock_monitor
  2057. (
  2058. void
  2059. );
  2060. /*-------------------------------------------------------------------------*//**
  2061. The MSS_SYS_enable_puf_power_down() function is used to instruct the system
  2062. controller to power down the PUF after each of the following operations:
  2063. • key fetch
  2064. • key creation
  2065. • key import
  2066. • random seed generation
  2067. Powering down the PUF after these operations is the default PUF behaviour.
  2068. Note: This system service is only available on large SmartFusion2 devices
  2069. starting with the M2S060.
  2070. @param
  2071. This function does not take any parameters.
  2072. @return
  2073. The MSS_SYS_enable_puf_power_down() function returns one of the following
  2074. status codes:
  2075. • MSS_SYS_SUCCESS
  2076. • MSS_SYS_UNEXPECTED_ERROR
  2077. */
  2078. uint8_t MSS_SYS_enable_puf_power_down
  2079. (
  2080. void
  2081. );
  2082. /*-------------------------------------------------------------------------*//**
  2083. The MSS_SYS_disable_puf_power_down() function is used to retain PUF power
  2084. after the following operations:
  2085. • key fetch
  2086. • key creation
  2087. • key import
  2088. • random seed generation
  2089. Note: This system service is only available on large SmartFusion2 devices
  2090. starting with the M2S060.
  2091. @param
  2092. This function does not take any parameters
  2093. @return
  2094. The MSS_SYS_disable_puf_power_down() function returns one of the following
  2095. status codes:
  2096. • MSS_SYS_SUCCESS
  2097. • MSS_SYS_UNEXPECTED_ERROR
  2098. */
  2099. uint8_t MSS_SYS_disable_puf_power_down
  2100. (
  2101. void
  2102. );
  2103. /*-------------------------------------------------------------------------*//**
  2104. The MSS_SYS_clear_lock_parity() function is used to clear the previously set
  2105. Lock Parity tamper flag. System controller will set this flag on detection of
  2106. parity error on internal lock data. To clear lock parity flag, use tamper
  2107. control service with bit 4 of Option set to 1, then the LOCKPARITY tamper flag
  2108. is cleared provided the hardware conditions are no longer present to raise
  2109. this flag.
  2110. Note: This system service is only available on large SmartFusion2 devices
  2111. starting with the M2S060.
  2112. @param
  2113. This function does not take any parameters
  2114. @return
  2115. The MSS_SYS_clear_lock_parity() function returns one of the following
  2116. status codes:
  2117. • MSS_SYS_SUCCESS
  2118. • MSS_SYS_UNEXPECTED_ERROR
  2119. */
  2120. uint8_t MSS_SYS_clear_lock_parity
  2121. (
  2122. void
  2123. );
  2124. /*-------------------------------------------------------------------------*//**
  2125. The MSS_SYS_clear_mesh_short() function is used to clear the previously mesh
  2126. short tamper flag. System Controller monitors the security flash array for
  2127. invasive tampering using an active mesh. This mesh is driven by LFSR and the
  2128. return value is monitored for discrepancies against the expected value generated
  2129. by the LFSR. When a tamper event is detected the MESHSHORT tamper flag is set,
  2130. generating a tamper interrupt. To clear mesh short tamper flag, use tamper
  2131. control service with bit 5 of Options set to 1. The MESHSHORT tamper flag is
  2132. cleared provided the hardware conditions are no longer present to raise this
  2133. flag.
  2134. Note: This system service is only available on large SmartFusion2 devices
  2135. starting with the M2S060.
  2136. @param
  2137. This function does not take any parameters
  2138. @return
  2139. The MSS_SYS_clear_mesh_short() function returns one of the following
  2140. status codes:
  2141. • MSS_SYS_SUCCESS
  2142. • MSS_SYS_UNEXPECTED_ERROR
  2143. */
  2144. uint8_t MSS_SYS_clear_mesh_short
  2145. (
  2146. void
  2147. );
  2148. /*-------------------------------------------------------------------------*//**
  2149. The IAP Service requests the System Controller to reprogram the device using
  2150. a bitstream already programmed into MSS SPI 0. The IAP Service is initiated by
  2151. a call to MSS_SYS_initiate_IAP(). The IAP Service can:
  2152. - authenticate a programming bitstream
  2153. - program a bitstream
  2154. - verify that a programming bitstream has been correctly programmed
  2155. @param mode
  2156. The mode parameter specifies IAP service to perform. It can be one of:
  2157. - MSS_SYS_PROG_AUTHENTICATE
  2158. - MSS_SYS_PROG_PROGRAM
  2159. - MSS_SYS_PROG_VERIFY
  2160. @param bitstream_spi_addr
  2161. The bitstream_spi_addr parameter specifies the address of the programming
  2162. bitstream within the SPI flash connected to MSS SPI 0.
  2163. @return
  2164. The MSS_SYS_initiate_IAP function will receive one of the following status
  2165. codes:
  2166. - MSS_SYS_SUCCESS
  2167. - MSS_SYS_CHAINING_MISMATCH
  2168. - MSS_SYS_UNEXPECTED_DATA_RECEIVED
  2169. - MSS_SYS_INVALID_ENCRYPTION_KEY
  2170. - MSS_SYS_INVALID_COMPONENT_HEADER
  2171. - MSS_SYS_BACK_LEVEL_NOT_SATISFIED
  2172. - MSS_SYS_DSN_BINDING_MISMATCH
  2173. - MSS_SYS_ILLEGAL_COMPONENT_SEQUENCE
  2174. - MSS_SYS_INSUFFICIENT_DEV_CAPABILITIES
  2175. - MSS_SYS_INCORRECT_DEVICE_ID
  2176. - MSS_SYS_UNSUPPORTED_BITSTREAM_PROT_VER
  2177. - MSS_SYS_VERIFY_NOT_PERMITTED_ON_BITSTR
  2178. - MSS_SYS_INVALID_DEVICE_CERTIFICATE
  2179. - MSS_SYS_ABORT
  2180. - MSS_SYS_NVM_VERIFY_FAILED
  2181. - MSS_SYS_DEVICE_SECURITY_PROTECTED
  2182. - MSS_SYS_PROGRAMMING_MODE_NOT_ENABLED
  2183. - MSS_SYS_ENVM_PROGRAMMING_OPERATION_FAIL
  2184. - MSS_SYS_ENVM_VERIFY_OPERATION_FAIL
  2185. - MSS_SYS_ACCESS_ERROR
  2186. - MSS_SYS_PUF_ACCESS_ERROR
  2187. - MSS_SYS_BAD_COMPONENT
  2188. - MSS_SYS_SERVICE_DISABLED_BY_USER
  2189. */
  2190. uint8_t MSS_SYS_initiate_IAP
  2191. (
  2192. uint8_t mode,
  2193. uint32_t bitstream_spi_addr
  2194. );
  2195. #ifdef __cplusplus
  2196. }
  2197. #endif
  2198. #endif /* __MSS_SYS_SERVICES_H_ */