Result PS_EncryptSignDecryptVerifyAesCcm(u8* in, u32 in_size, u8* out, u32 out_size, u32 data_len, u32 mac_data_len, u32 mac_len, PS_AESAlgorithm aes_algo, PS_AESKeyType key_type, u8* nonce) { Result ret = 0; u32 *cmdbuf = getThreadCommandBuffer(); u32 *_nonce = (u32*)nonce; cmdbuf[0] = IPC_MakeHeader(0x5,10,4); // 0x50284 cmdbuf[1] = in_size; cmdbuf[2] = mac_data_len; cmdbuf[3] = data_len; cmdbuf[4] = out_size; cmdbuf[5] = mac_len; memcpy(&cmdbuf[6], _nonce, 12); cmdbuf[9] = aes_algo; cmdbuf[10] = key_type; cmdbuf[11] = IPC_Desc_Buffer(in_size, IPC_BUFFER_R); cmdbuf[12] = (u32)in; cmdbuf[13] = IPC_Desc_Buffer(out_size, IPC_BUFFER_W); cmdbuf[14] = (u32)out; if(R_FAILED(ret = svcSendSyncRequest(psHandle)))return ret; return (Result)cmdbuf[1]; }
Result AM_ListTitles(u8 mediatype, u32 titleCount, u64 *titleIdList, AM_TitleEntry *titleList) { Result ret = 0; u32 *cmdbuf = getThreadCommandBuffer(); cmdbuf[0] = IPC_MakeHeader(0x3,2,4); // 0x00030084 cmdbuf[1] = mediatype; cmdbuf[2] = titleCount; cmdbuf[3] = IPC_Desc_Buffer(titleCount*sizeof(u64),IPC_BUFFER_R); cmdbuf[4] = (u32)titleIdList; cmdbuf[5] = IPC_Desc_Buffer(titleCount*sizeof(AM_TitleEntry),IPC_BUFFER_W); cmdbuf[6] = (u32)titleList; if(R_FAILED(ret = svcSendSyncRequest(amHandle))) return ret; return (Result)cmdbuf[1]; }
Result sslcContextGetProtocolCipher(sslcContext *context, char *outprotocols, u32 outprotocols_maxsize, char *outcipher, u32 outcipher_maxsize) { u32* cmdbuf=getThreadCommandBuffer(); cmdbuf[0]=IPC_MakeHeader(0x1C,3,4); // 0x1C00C4 cmdbuf[1]=context->sslchandle; cmdbuf[2]=outprotocols_maxsize; cmdbuf[3]=outcipher_maxsize; cmdbuf[4]=IPC_Desc_Buffer(outprotocols_maxsize, IPC_BUFFER_W); cmdbuf[5]=(u32)outprotocols; cmdbuf[6]=IPC_Desc_Buffer(outcipher_maxsize, IPC_BUFFER_W); cmdbuf[7]=(u32)outcipher; Result ret=0; if(R_FAILED(ret=svcSendSyncRequest(context->servhandle)))return ret; ret = cmdbuf[1]; return ret; }
Result sslcOpenClientCertContext(u8 *cert, u32 certsize, u8 *key, u32 keysize, u32 *ClientCert_contexthandle) { u32* cmdbuf=getThreadCommandBuffer(); cmdbuf[0]=IPC_MakeHeader(0xD,2,4); // 0xD0084 cmdbuf[1]=certsize; cmdbuf[2]=keysize; cmdbuf[3]=IPC_Desc_Buffer(certsize, IPC_BUFFER_R); cmdbuf[4]=(u32)cert; cmdbuf[5]=IPC_Desc_Buffer(keysize, IPC_BUFFER_R); cmdbuf[6]=(u32)key; Result ret=0; if(R_FAILED(ret=svcSendSyncRequest(__sslc_servhandle)))return ret; ret = cmdbuf[1]; if(R_SUCCEEDED(ret))*ClientCert_contexthandle = cmdbuf[2]; return ret; }
static Result sslcipc_DataTransfer(sslcContext *context, void *buf, size_t len, u32 type) { u32* cmdbuf=getThreadCommandBuffer(); if(type >= 3)return -1; cmdbuf[0]=IPC_MakeHeader(0x15 + type,2,2); // 0x150082 cmdbuf[1]=context->sslchandle; cmdbuf[2]=len; if(type<2)cmdbuf[3]=IPC_Desc_Buffer(len, IPC_BUFFER_W); if(type==2)cmdbuf[3]=IPC_Desc_Buffer(len, IPC_BUFFER_R); cmdbuf[4]=(u32)buf; Result ret=0; if(R_FAILED(ret=svcSendSyncRequest(context->servhandle)))return ret; ret = cmdbuf[1]; if(R_SUCCEEDED(ret))ret = cmdbuf[2]; return ret; }
Result PS_GenerateRandomBytes(void* out, size_t len) { Result ret = 0; u32 *cmdbuf = getThreadCommandBuffer(); cmdbuf[0] = IPC_MakeHeader(0xD,1,2); // 0xD0042 cmdbuf[1] = len; cmdbuf[2] = IPC_Desc_Buffer(len, IPC_BUFFER_W); cmdbuf[3] = (u32)out; if(R_FAILED(ret = svcSendSyncRequest(psHandle)))return ret; return (Result)cmdbuf[1]; }
Result sslcGenerateRandomData(u8 *buf, u32 size) { u32* cmdbuf=getThreadCommandBuffer(); cmdbuf[0]=IPC_MakeHeader(0x11,1,2); // 0x110042 cmdbuf[1]=size; cmdbuf[2]=IPC_Desc_Buffer(size, IPC_BUFFER_W); cmdbuf[3]=(u32)buf; Result ret=0; if(R_FAILED(ret=svcSendSyncRequest(__sslc_servhandle)))return ret; return cmdbuf[1]; }
Result PS_EncryptDecryptAes(u32 size, u8* in, u8* out, PS_AESAlgorithm aes_algo, PS_AESKeyType key_type, u8* iv) { Result ret = 0; u32 *cmdbuf = getThreadCommandBuffer(); u32 *_iv = (u32*)iv; cmdbuf[0] = IPC_MakeHeader(0x4,8,4); // 0x40204 cmdbuf[1] = size; cmdbuf[2] = size; memcpy(&cmdbuf[3], _iv, 16); cmdbuf[7] = aes_algo; cmdbuf[8] = key_type; cmdbuf[9] = IPC_Desc_Buffer(size, IPC_BUFFER_R); cmdbuf[10] = (u32)in; cmdbuf[11] = IPC_Desc_Buffer(size, IPC_BUFFER_W); cmdbuf[12] = (u32)out; if(R_FAILED(ret = svcSendSyncRequest(psHandle)))return ret; memcpy(_iv, &cmdbuf[2], 16); return (Result)cmdbuf[1]; }
// See here for block IDs: // http://3dbrew.org/wiki/Config_Savegame#Configuration_blocks Result CFGU_GetConfigInfoBlk2(u32 size, u32 blkID, u8* outData) { Result ret = 0; u32 *cmdbuf = getThreadCommandBuffer(); cmdbuf[0] = IPC_MakeHeader(0x1,2,2); // 0x10082 cmdbuf[1] = size; cmdbuf[2] = blkID; cmdbuf[3] = IPC_Desc_Buffer(size,IPC_BUFFER_W); cmdbuf[4] = (u32)outData; if(R_FAILED(ret = svcSendSyncRequest(cfguHandle)))return ret; return (Result)cmdbuf[1]; }
Result AM_GetTitleIdList(u8 mediatype, u32 count, u64 *titleIDs) { Result ret = 0; u32 *cmdbuf = getThreadCommandBuffer(); cmdbuf[0] = IPC_MakeHeader(0x2,2,2); // 0x00020082 cmdbuf[1] = count; cmdbuf[2] = mediatype; cmdbuf[3] = IPC_Desc_Buffer(count*sizeof(u64),IPC_BUFFER_W); cmdbuf[4] = (u32)titleIDs; if(R_FAILED(ret = svcSendSyncRequest(amHandle))) return ret; return (Result)cmdbuf[1]; }
Result sslcAddCert(sslcContext *context, u8 *buf, u32 size) { u32* cmdbuf=getThreadCommandBuffer(); cmdbuf[0]=IPC_MakeHeader(0x20,2,2); // 0x200082 cmdbuf[1]=context->sslchandle; cmdbuf[2]=size; cmdbuf[3]=IPC_Desc_Buffer(size, IPC_BUFFER_R); cmdbuf[4]=(u32)buf; Result ret=0; if(R_FAILED(ret=svcSendSyncRequest(context->servhandle)))return ret; ret = cmdbuf[1]; return ret; }
static Result udsipc_ScanOnConnection(u8 *outbuf, u32 maxsize, nwmScanInputStruct *scaninput, u32 wlancommID, u8 id8) { u32* cmdbuf=getThreadCommandBuffer(); cmdbuf[0]=IPC_MakeHeader(0x22,16,2); // 0x220402 cmdbuf[1]=maxsize; memcpy(&cmdbuf[2], scaninput, sizeof(nwmScanInputStruct)); cmdbuf[15]=wlancommID; cmdbuf[16]=id8; cmdbuf[17]=IPC_Desc_Buffer(maxsize, IPC_BUFFER_W); cmdbuf[18]=(u32)outbuf; Result ret=0; if(R_FAILED(ret=svcSendSyncRequest(__uds_servhandle)))return ret; return cmdbuf[1]; }
static Result sslcipc_CertChainAddCert(u32 type, u32 contexthandle, u8 *cert, u32 certsize, u32 *cert_contexthandle) { u32* cmdbuf=getThreadCommandBuffer(); cmdbuf[0]=IPC_MakeHeader(0x5 + type*0x5,2,2); // 0x50082 cmdbuf[1]=contexthandle; cmdbuf[2]=certsize; cmdbuf[3]=IPC_Desc_Buffer(certsize, IPC_BUFFER_R); cmdbuf[4]=(u32)cert; Result ret=0; if(R_FAILED(ret=svcSendSyncRequest(__sslc_servhandle)))return ret; ret = cmdbuf[1]; if(R_SUCCEEDED(ret) && cert_contexthandle)*cert_contexthandle = cmdbuf[2]; return ret; }
static Result udsipc_RecvBeaconBroadcastData(u8 *outbuf, u32 maxsize, nwmScanInputStruct *scaninput, u32 wlancommID, u8 id8, Handle event) { u32* cmdbuf=getThreadCommandBuffer(); cmdbuf[0]=IPC_MakeHeader(0xF,16,4); // 0xF0404 cmdbuf[1]=maxsize; memcpy(&cmdbuf[2], scaninput, sizeof(nwmScanInputStruct)); cmdbuf[15]=wlancommID; cmdbuf[16]=id8; cmdbuf[17]=IPC_Desc_SharedHandles(1); cmdbuf[18]=event; cmdbuf[19]=IPC_Desc_Buffer(maxsize, IPC_BUFFER_W); cmdbuf[20]=(u32)outbuf; Result ret=0; if(R_FAILED(ret=svcSendSyncRequest(__uds_servhandle)))return ret; return cmdbuf[1]; }
Result PS_VerifyRsaSha256(u8 *hash, psRSAContext *ctx, u8 *signature) { Result ret = 0; u32 *cmdbuf = getThreadCommandBuffer(); u32 size; size = ctx->rsa_bitsize>>3; cmdbuf[0] = IPC_MakeHeader(0x2,9,4); // 0x20244 memcpy(&cmdbuf[1], hash, 32); cmdbuf[9] = size; cmdbuf[10] = IPC_Desc_StaticBuffer(0x208, 0); cmdbuf[11] = (u32)ctx; cmdbuf[12] = IPC_Desc_Buffer(size, IPC_BUFFER_R); cmdbuf[13] = (u32)signature; if(R_FAILED(ret = svcSendSyncRequest(psHandle)))return ret; return (Result)cmdbuf[1]; }
static Result sslcipc_CreateContext(sslcContext *context, int sockfd, u32 input_opt, char *hostname) { u32* cmdbuf=getThreadCommandBuffer(); u32 size = strlen(hostname)+1; cmdbuf[0]=IPC_MakeHeader(0x2,3,2); // 0x200C2 cmdbuf[1]=(u32)sockfd; cmdbuf[2]=input_opt; cmdbuf[3]=size; cmdbuf[4]=IPC_Desc_Buffer(size, IPC_BUFFER_R); cmdbuf[5]=(u32)hostname; Result ret=0; if(R_FAILED(ret=svcSendSyncRequest(__sslc_servhandle)))return ret; ret = cmdbuf[1]; if(R_SUCCEEDED(ret))context->sslchandle = cmdbuf[2]; return ret; }