Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include <ctr/types.h>
- #include <ctr/PS.h>
- #include <ctr/svc.h>
- #include <ctr/srv.h>
- Handle psHandle = 0;
- Result PS_Init() {
- return srv_getServiceHandle(NULL, &psHandle, "ps:ps");
- }
- void PS_Exit() {
- if(psHandle)
- svc_closeHandle(psHandle);
- }
- Result PS_EncryptDecryptAes(PS_ALGORITHM_TYPE algorithm, u8 key_type, u32 *IV, u32 *src, u32 size, u32 *dest) {
- u32 *cmdbuf = getThreadCommandBuffer();
- cmdbuf[0] = 0x00040204; //Request Header Code
- cmdbuf[1] = size; //Size
- cmdbuf[2] = 0; //Unused
- cmdbuf[3] = IV[0];
- cmdbuf[4] = IV[1];
- cmdbuf[5] = IV[2];
- cmdbuf[6] = IV[3]; //IV / CTR
- cmdbuf[7] = (u8)algorithm; //Algorythm type
- cmdbuf[8] = (u8)key_type; //Key type
- cmdbuf[9] = (size << 4) | 10;
- cmdbuf[10] = (u32)src; //Source Pointer
- cmdbuf[11] = (size << 4) | 12;
- cmdbuf[12] = (u32)dest; //Destination Pointer
- Result ret = 0;
- if((ret = svc_sendSyncRequest(psHandle))) return ret;
- return cmdbuf[1];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement