Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/reference/development/supported-snap-hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The following hooks are currently implemented:
- install-device hook
- interface hooks
- prepare-device hook
- prepare-serial hook
- pre-refresh hook
- post-refresh hook
- remove hook
Expand Down Expand Up @@ -167,6 +168,13 @@ This hook is only supported in gadget snaps.

See {ref}`The gadget snap <reference-development-yaml-schemas-the-gadget-snap>` documentation for more details.

<h2 id='heading--prepare-serial'>The prepare-serial hook</h2>

This hook is only supported in gadget snaps.

See {ref}`The gadget snap <reference-development-yaml-schemas-the-gadget-snap>` documentation for more details.


<h2 id='heading--pre-refresh'>The pre-refresh hook</h2>

The `pre-refresh` hook is called whenever the snap gets refreshed.
Expand Down
23 changes: 23 additions & 0 deletions docs/reference/development/yaml-schemas/the-gadget-snap.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,3 +387,26 @@ snapctl set -s registration.proposed-serial="DEVICE-SERIAL"
snapctl set registration.body='mac: "00:00:00:00:ff:00"'
```

## prepare-serial hook

The optional `prepare-serial` hook will be called on the gadget at the start of the device initialisation process, after the gadget snap has been installed and if secure registration is required.

This hook can be used to provide the necessary device attestation information which is passed back to the device service by setting the `registration.body` to the appropriate stanza suitable for method of secure registration being used.

### prepare-serial options

```bash
#!/bin/sh

# Get the request-id for registration
REQUEST_ID="$(snapctl get registration.request-id)"

# Sign request_id with HW ID private key

# set hardware identity attestation information
snapctl set registration.body="{\"hardware-id-key-sha3-384\": \"${HASH}\",
\"signature-hash-algorithm\": \"${SIG_HASH}\",
\"request-id-signature\": \"${SIGNATURE}\"
}"
```

Loading