Difference between revisions of "Settings services"

From Nintendo Switch Brew
Jump to navigation Jump to search
Line 48: Line 48:
 
| 12 || GetBatteryLot
 
| 12 || GetBatteryLot
 
|-
 
|-
| 14 || GetDeviceCertECC
+
| 14 || [[#GetDeviceCert]]
 
|-
 
|-
| 15 || GetETicketCertRSA
+
| 15 || [[#GetETicketCert]]
 
|-
 
|-
| 16 || GetSslKey
+
| 16 || [[#GetSslKey]]
 
|-
 
|-
| 17 || GetSslCert
+
| 17 || [[#GetSslCert]]
 
|-
 
|-
| 18 || GetGamecardKey
+
| 18 || [[#GetGameCardKey]]
 
|-
 
|-
| 19 || GetGamecardCert
+
| 19 || [[#GetGameCardCert]]
 
|-
 
|-
| 20 || GetDeviceKeyECC
+
| 20 || [[#GetDeviceKey]]
 
|-
 
|-
| 21 || GetETicketKeyRSA
+
| 21 || [[#GetETicketKey]]
 
|-
 
|-
 
| 22 || GetSpeakerCalibrationValues
 
| 22 || GetSpeakerCalibrationValues
Line 70: Line 70:
 
Used for accessing data calibrated at the factory.
 
Used for accessing data calibrated at the factory.
  
== GetDeviceCertECC ==
+
== GetDeviceCert ==
 
Takes a type-0x16 output buffer with fixed size 0x180.
 
Takes a type-0x16 output buffer with fixed size 0x180.
  
Returns the DeviceCert. This is identical to 3DS DeviceCert/CTCert besides the strings. NIM loads the DeviceId from this.
+
Returns the device certificate (ECC signed). This is identical to 3DS DeviceCert/CTCert besides the strings. NIM loads the DeviceId from this.
  
== GetETicketCertRSA ==
+
== GetETicketCert ==
 
Takes a type-0x16 output buffer with fixed size 0x240.
 
Takes a type-0x16 output buffer with fixed size 0x240.
  
Same as GetDeviceCertECC, except this returns more data and the data starts differing at offset 0x108 compared to GetDeviceCert.
+
Returns the ETicket certificate (RSA signed).
  
 
== GetSslKey ==
 
== GetSslKey ==
 
Takes a type-0x16 output buffer with fixed size 0x134.
 
Takes a type-0x16 output buffer with fixed size 0x134.
  
Returns a container-structure for the encrypted TLS client-privk. Decrypting this fails unless an unknown size >0x134 is passed to this setcal cmd?
+
Returns the extended SSL key (0x130 bytes) from [[Calibration#CAL0|CAL0]]. If the extended key is not programmed then it falls back to the normal SSL key (0x110 bytes).
  
 
Used by SSL-sysmodule, see [[SSL_services|here]].
 
Used by SSL-sysmodule, see [[SSL_services|here]].
Line 90: Line 90:
 
Takes a type-0x16 output buffer with fixed size 0x804.
 
Takes a type-0x16 output buffer with fixed size 0x804.
  
Returns a container-structure for the plaintext TLS client-cert.
+
Returns a [[Settings_services#setcal_Container_Structure|container]] with the plaintext SSL certificate.
  
 
Used by SSL-sysmodule, see [[SSL_services|here]].
 
Used by SSL-sysmodule, see [[SSL_services|here]].
  
=== setcal Container Structure ===
+
== GetGameCardKey ==
 +
Takes a type-0x16 output buffer with fixed size 0x134.
 +
 
 +
Returns the extended GameCard key (0x130 bytes) from [[Calibration#CAL0|CAL0]]. If the extended key is not programmed then it falls back to the normal GameCard key (0x110 bytes).
 +
 
 +
== GetGameCardCert ==
 +
Takes a type-0x16 output buffer with fixed size 0x404.
 +
 
 +
Returns a [[Settings_services#setcal_Container_Structure|container]] with the GameCard certificate.
 +
 
 +
== GetDeviceKey ==
 +
Returns the extended device ECC-B233 key (0x50 bytes) from [[Calibration#CAL0|CAL0]]. If the extended key is not programmed then it falls back to the normal device ECC-B233 key (0x30 bytes).
 +
 
 +
== GetETicketKey ==
 +
Takes a type-0x16 output buffer with fixed size 0x244.
 +
 
 +
Returns the extended ETicket RSA-2048 key (0x240 bytes) from [[Calibration#CAL0|CAL0]]. If the extended key is not programmed then it falls back to the normal ETicket RSA-2048 key (0x220 bytes).
 +
 
 +
== setcal Container Structure ==
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
|-
 
|-
Line 109: Line 127:
 
| Actual data starts here.
 
| Actual data starts here.
 
|}
 
|}
 +
 +
This container is used for returning data with variable sizes.
  
 
= set:sys =
 
= set:sys =
Line 115: Line 135:
 
! Cmd || Name
 
! Cmd || Name
 
|-
 
|-
| 3 || GetSystemVersion
+
| 3 || [[#GetSystemVersion]]
 
|-
 
|-
 
| 37 || QuerySetting
 
| 37 || QuerySetting
 
|-
 
|-
| 38 || ReadSetting
+
| 38 || [[#ReadSetting]]
 
|-
 
|-
 
| 56 || [[Flash_Filesystem#PRODINFOF|GetWirelessCertification]]
 
| 56 || [[Flash_Filesystem#PRODINFOF|GetWirelessCertification]]
 
|-
 
|-
| 62 || GetDebugMode
+
| 62 || [[#GetDebugMode]]
 
|-
 
|-
| 68 || GetSerialNumber
+
| 68 || [[#GetSerialNumber]]
 
|}
 
|}
  

Revision as of 14:53, 8 September 2017

set

Cmd Name
0 GetLanguageCode
1 SetLanguageCode
3
4

set:fd

set:cal

Cmd Name
0 GetBdAddress
1 GetConfigurationId1
2 GetAccelerometerOffset
3 GetAccelerometerScale
4 GetGyroscopeOffset
5 GetGyroscopeScale
6 GetWlanMacAddress
7 GetWlanCountryCodesNum
8 GetWlanCountryCodes
9 GetSerialNumber
10
11
12 GetBatteryLot
14 #GetDeviceCert
15 #GetETicketCert
16 #GetSslKey
17 #GetSslCert
18 #GetGameCardKey
19 #GetGameCardCert
20 #GetDeviceKey
21 #GetETicketKey
22 GetSpeakerCalibrationValues

Used for accessing data calibrated at the factory.

GetDeviceCert

Takes a type-0x16 output buffer with fixed size 0x180.

Returns the device certificate (ECC signed). This is identical to 3DS DeviceCert/CTCert besides the strings. NIM loads the DeviceId from this.

GetETicketCert

Takes a type-0x16 output buffer with fixed size 0x240.

Returns the ETicket certificate (RSA signed).

GetSslKey

Takes a type-0x16 output buffer with fixed size 0x134.

Returns the extended SSL key (0x130 bytes) from CAL0. If the extended key is not programmed then it falls back to the normal SSL key (0x110 bytes).

Used by SSL-sysmodule, see here.

GetSslCert

Takes a type-0x16 output buffer with fixed size 0x804.

Returns a container with the plaintext SSL certificate.

Used by SSL-sysmodule, see here.

GetGameCardKey

Takes a type-0x16 output buffer with fixed size 0x134.

Returns the extended GameCard key (0x130 bytes) from CAL0. If the extended key is not programmed then it falls back to the normal GameCard key (0x110 bytes).

GetGameCardCert

Takes a type-0x16 output buffer with fixed size 0x404.

Returns a container with the GameCard certificate.

GetDeviceKey

Returns the extended device ECC-B233 key (0x50 bytes) from CAL0. If the extended key is not programmed then it falls back to the normal device ECC-B233 key (0x30 bytes).

GetETicketKey

Takes a type-0x16 output buffer with fixed size 0x244.

Returns the extended ETicket RSA-2048 key (0x240 bytes) from CAL0. If the extended key is not programmed then it falls back to the normal ETicket RSA-2048 key (0x220 bytes).

setcal Container Structure

Offset Size Name
0x0 0x4 Size (same size used for decryption if needed)
0x4 {above size} Actual data starts here.

This container is used for returning data with variable sizes.

set:sys

Cmd Name
3 #GetSystemVersion
37 QuerySetting
38 #ReadSetting
56 GetWirelessCertification
62 #GetDebugMode
68 #GetSerialNumber

Official user-processes get a new service session handle each time a set:sys cmd is used, with the session being closed aftewards.

ReadSetting

Takes two type-0x19 input buffers and a type-0x6 output buffer. Returns an output u64 for the actual size written to the outbuf.

The outbuf_size is compared with the config_size. When config_size is larger than outbuf_size, outbuf_size is used for the memcpy, otherwise config_size is used. Afterwards the size used for the memcpy is written to output(see above).

If loading from main config fails, it will also attempt to load config from various state if the input strings match hard-coded strings.

GetSystemVersion

Takes a type-0x1A output buffer. User-processes use hard-coded size 0x100.

If needed, reads the content of the System_Version_Title "/file" into state. This is only done once.

Then the above 0x100-byte data is copied to the output buffer.

GetDebugMode

Returns an output u8.

Loads the 1-byte config for <"settings_debug", "is_debug_mode_enabled">. If that fails, value 0x1 is written to output. This uses the same func as ReadSetting internally.

Returned retval is always 0.

GetSerialNumber

Returns the 0x18-byte SerialNumber string.