NS services: Difference between revisions

No edit summary
Line 1,676: Line 1,676:
Takes a type-0x15 input buffer containing a [[#SystemDeliveryInfo]], no output.
Takes a type-0x15 input buffer containing a [[#SystemDeliveryInfo]], no output.


This validates the [[#SystemDeliveryInfo]] HMAC and the protocol-version fields. Then an error is returned when SystemUpdateMetaVersion is less than a state field, otherwise 0 is returned (state field originates from [[System_Settings|system-setting]] <code>contents_delivery!required_system_version_to_deliver_application</code>).
This validates the [[#SystemDeliveryInfo]] HMAC and the protocol-version fields. Then an error is returned when SystemUpdateVersion is less than a state field, otherwise 0 is returned (state field originates from [[System_Settings|system-setting]] <code>contents_delivery!required_system_version_to_deliver_application</code>).


==== GetApplicationDeliveryInfo ====
==== GetApplicationDeliveryInfo ====
Line 1,764: Line 1,764:
* When the SystemDeliveryInfoPlatform from the input [[#SystemDeliveryInfo]] matches the [[System_Settings|sys-setting]], it does the following:
* When the SystemDeliveryInfoPlatform from the input [[#SystemDeliveryInfo]] matches the [[System_Settings|sys-setting]], it does the following:
* Calls the same func as [[#SelectLatestSystemDeliveryInfo]] for GetFunctionBlackListSystemVersionToAuthorize, returning the Result on failure.
* Calls the same func as [[#SelectLatestSystemDeliveryInfo]] for GetFunctionBlackListSystemVersionToAuthorize, returning the Result on failure.
* The output bool is set to: out_u8!=0 && out_u32 >= [[#SystemDeliveryInfo]] SystemUpdateMetaVersion (only the upper 16bits are used from the SystemUpdateMetaVersion).
* The output bool is set to: out_u8!=0 && out_u32 >= [[#SystemDeliveryInfo]] SystemUpdateVersion (only the upper 16bits are used from the SystemUpdateVersion).


==== EstimateRequiredSize ====
==== EstimateRequiredSize ====
Line 2,795: Line 2,795:
This validates the [[#SystemDeliveryInfo]] and generates a [[NCM_services#ContentMetaKey|ContentMetaKey]] from that, and creates the [[#IAsyncResult]] + the async thread which handles the [[#IAsyncResult]] operation.
This validates the [[#SystemDeliveryInfo]] and generates a [[NCM_services#ContentMetaKey|ContentMetaKey]] from that, and creates the [[#IAsyncResult]] + the async thread which handles the [[#IAsyncResult]] operation.


The above validation verifies that the HMAC and SystemDeliveryProtocolVersion are valid. The SystemUpdateMetaId ([20.0.0+] NewSystemUpdateMetaId, NewSystemUpdateMetaIdFlag ignored) must match the Id for the installed SystemUpdate as returned by [[NCM_services|ncm]].
The above validation verifies that the HMAC and SystemDeliveryProtocolVersion are valid. The OldSystemUpdateId ([20.0.0+] SystemUpdateId, SystemUpdateIdFlag ignored) must match the Id for the installed SystemUpdate as returned by [[NCM_services|ncm]].


Then the thread does:
Then the thread does:
Line 4,640: Line 4,640:
This is "nn::ns::SystemDeliveryInfo". This is a 0x100-byte struct.
This is "nn::ns::SystemDeliveryInfo". This is a 0x100-byte struct.


[20.0.0+] The used (New)SystemUpdateMetaId as selected by NewSystemUpdateMetaIdFlag must now match one of the Ids in [[System_Settings|system-setting]] <code>contents_delivery!acceptable_system_update_ids_string</code>.
[20.0.0+] The used (Old)SystemUpdateId as selected by SystemUpdateIdFlag must now match one of the Ids in [[System_Settings|system-setting]] <code>contents_delivery!acceptable_system_update_ids_string</code>.


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 4,656: Line 4,656:
| 0x9 || 0x3 || Reserved.
| 0x9 || 0x3 || Reserved.
|-
|-
| 0xC || 0x4 || SystemUpdateMetaVersion.
| 0xC || 0x4 || SystemUpdateVersion.
|-
|-
| 0x10 || 0x8 || SystemUpdateMetaId. [20.0.0+] Always the NX Id: this is loaded from [[System_Settings|system-setting]] <code>contents_delivery!old_system_update_id</code>.
| 0x10 || 0x8 || OldSystemUpdateId. [20.0.0+] Always the NX Id: this is loaded from [[System_Settings|system-setting]] <code>contents_delivery!old_system_update_id</code>.
|-
|-
| 0x18 || 0x1 || FirmwareVariationId. Used by [[#RequestSendSystemUpdate]]. This is set to 0xC on S2.
| 0x18 || 0x1 || FirmwareVariationId. Used by [[#RequestSendSystemUpdate]]. This is set to 0xC on S2.
Line 4,668: Line 4,668:
| 0x1B || 0x1 || [20.0.0+] SystemDeliveryInfoPlatform. Loaded from [[System_Settings|system-setting]] <code>ns.systemupdate!system_delivery_info_platform</code>. Elsewhere this is compared against the sys-setting, etc.
| 0x1B || 0x1 || [20.0.0+] SystemDeliveryInfoPlatform. Loaded from [[System_Settings|system-setting]] <code>ns.systemupdate!system_delivery_info_platform</code>. Elsewhere this is compared against the sys-setting, etc.
|-
|-
| 0x1C || 0x1 || [20.0.0+] NewSystemUpdateMetaIdFlag. When non-zero, NewSystemUpdateMetaId is used instead of SystemUpdateMetaId. Always set to 0x1 by [[#GetSystemDeliveryInfo]] with [20.0.0+].
| 0x1C || 0x1 || [20.0.0+] SystemUpdateIdFlag. When non-zero, SystemUpdateId is used instead of OldSystemUpdateId. Always set to 0x1 by [[#GetSystemDeliveryInfo]] with [20.0.0+].
|-
|-
| 0x1D || 0x3 || Padding
| 0x1D || 0x3 || Padding
|-
|-
| 0x20 || 0x8 || [20.0.0+] NewSystemUpdateMetaId. See above. With [20.0.0+] [[#GetSystemDeliveryInfo]] now writes the Id here instead of SystemUpdateMetaId. On S2 this is set to the Ounce Id.
| 0x20 || 0x8 || [20.0.0+] SystemUpdateId. See above. With [20.0.0+] [[#GetSystemDeliveryInfo]] now writes the Id here instead of OldSystemUpdateId (for the installed SystemUpdate). On S2 this is set to the Ounce Id.
|-
|-
| 0x28 || 0xB8 || Unused by [[#RequestSendSystemUpdate]]/[[#RequestReceiveSystemUpdate]], besides HMAC validation.
| 0x28 || 0xB8 || Reserved
|-
|-
| 0xE0 || 0x20 || HMAC-SHA256 over the previous 0xE0-bytes.
| 0xE0 || 0x20 || HMAC-SHA256 over the previous 0xE0-bytes.