MCPcopy Create free account
hub / github.com/BernardoGiordano/Checkpoint / deviceSecret

Method deviceSecret

3ds/source/script/scripthost.cpp:473–493  ·  view source on GitHub ↗

The NAND CID: 16 bytes burnt into this console's internal storage, reachable only by asking FS (already initialised, so no service of our own to open and no way for this to start failing later). Deliberately NOT the SD CID as well — that would tie a sealed credential to the card it sits on, and cloning an SD onto a bigger one is a thing users routinely do; the console is what we mean to bind to.

Source from the content-addressed store, hash-verified

471 // card it sits on, and cloning an SD onto a bigger one is a thing users
472 // routinely do; the console is what we mean to bind to.
473 int deviceSecret(uint8_t* out, int want) override
474 {
475 if (want != DeviceKeySourceBest && want != DeviceKeySourceCtrNand) {
476 return -1;
477 }
478 u8 cid[16] = {0};
479 if (R_FAILED(FSUSER_GetNandCid(cid, sizeof(cid)))) {
480 return -1;
481 }
482 // Hashed rather than handed over raw, so the only thing that ever
483 // leaves this function is a value the CID cannot be read back out of.
484 mbedtls_sha256_context ctx;
485 mbedtls_sha256_init(&ctx);
486 mbedtls_sha256_starts_ret(&ctx, 0);
487 mbedtls_sha256_update_ret(&ctx, (const unsigned char*)"Checkpoint 3DS NAND CID v1", 26);
488 mbedtls_sha256_update_ret(&ctx, cid, sizeof(cid));
489 mbedtls_sha256_finish_ret(&ctx, out);
490 mbedtls_sha256_free(&ctx);
491 memset(cid, 0, sizeof(cid));
492 return DeviceKeySourceCtrNand;
493 }
494
495 bool randomBytes(void* out, size_t size) override
496 {

Callers 2

deriveKeyFunction · 0.45
ckpt_device_sealFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected