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

Method deviceSecret

3ds/source/script/scripthost.cpp:438–458  ·  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

436 // card it sits on, and cloning an SD onto a bigger one is a thing users
437 // routinely do; the console is what we mean to bind to.
438 int deviceSecret(uint8_t* out, int want) override
439 {
440 if (want != DeviceKeySourceBest && want != DeviceKeySourceCtrNand) {
441 return -1;
442 }
443 u8 cid[16] = {0};
444 if (R_FAILED(FSUSER_GetNandCid(cid, sizeof(cid)))) {
445 return -1;
446 }
447 // Hashed rather than handed over raw, so the only thing that ever
448 // leaves this function is a value the CID cannot be read back out of.
449 mbedtls_sha256_context ctx;
450 mbedtls_sha256_init(&ctx);
451 mbedtls_sha256_starts_ret(&ctx, 0);
452 mbedtls_sha256_update_ret(&ctx, (const unsigned char*)"Checkpoint 3DS NAND CID v1", 26);
453 mbedtls_sha256_update_ret(&ctx, cid, sizeof(cid));
454 mbedtls_sha256_finish_ret(&ctx, out);
455 mbedtls_sha256_free(&ctx);
456 memset(cid, 0, sizeof(cid));
457 return DeviceKeySourceCtrNand;
458 }
459
460 bool randomBytes(void* out, size_t size) override
461 {

Callers 2

deriveKeyFunction · 0.45
ckpt_device_sealFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected