Advertising (This ad goes away for registered users. You can Login or Register)

Calculating title update download links with HMAC key

Open discussions on programming specifically for the PS Vita.
Forum rules
Forum rule Nº 15 is strictly enforced in this subforum.
Proxima
Guru
Posts: 47
Joined: Mon Jan 03, 2011 2:38 pm

Calculating title update download links with HMAC key

Post by Proxima » Mon Aug 31, 2015 1:39 am

Here's a sample program to calculate the title update download links. These links are similar to PS3, but have been updated on the Vita to include an HMAC-SHA256 of the title as part of the path.

The HMAC key is:

Code: Select all

E5E278AA1EE34082A088279C83F9BBC806821C52F2AB5D2B4ABD995450355114
Below is a little C function for generating the links for a title id (game updates). Just use a standard implementation of HMAC-SHA256 from anywhere (Apple, OpenSSL, somewhere on github, etc).

Code: Select all

// Generate Title Update download links for Vita
int main(void) {

	unsigned char key[32] =
	{
	    0xE5, 0xE2, 0x78, 0xAA, 0x1E, 0xE3, 0x40, 0x82, 0xA0, 0x88, 0x27, 0x9C, 0x83, 0xF9, 0xBB, 0xC8,
	    0x06, 0x82, 0x1C, 0x52, 0xF2, 0xAB, 0x5D, 0x2B, 0x4A, 0xBD, 0x99, 0x54, 0x50, 0x35, 0x51, 0x14, 
	} ;

	char title[0x10];															
	char uniqdata[0x20];
	unsigned char result[0x20];
	int i;													
											
	memset(uniqdata,0,0x20);
	memset(result,0,0x20);
	memset(title,0,0x10);
	
	printf("Enter title id name (PCSA00000):"); scanf("%s", title);

	sprintf(uniqdata,"np_%s", title );
	
	// use a standard implementation of a sha256 hmac
	hmac_sha256(key,0x20,uniqdata,strlen(uniqdata),result);
	
	printf("https://gs-sec.ww.np.dl.playstation.net/pl/np/%s/", title);
	for(i=0;i<0x20;i++) {
		printf("%02x", result[i]);
	}
	printf("/%s-ver.xml\n", title);
	
	return 0;
}
// Test Example
// Enter title id name (PCSA00000):PCSA00007
// https://gs-sec.ww.np.dl.playstation.net/pl/np/PCSA00007/86d7c3b64d554b9639c5ad69aac20e16ea34c2f513d412f38329257f4ad15782/PCSA00007-ver.xml
Enjoy!
Advertising

yifanlu
Guru
Posts: 760
Joined: Sun Mar 11, 2012 6:42 am
Contact:

Re: Calculating title update download links with HMAC key

Post by yifanlu » Mon Aug 31, 2015 2:24 am

Great job as always. Unfortunally most kids won't understand the implications as they are too busy fighting about some pool game on the PSP.
Advertising

ANU815
Posts: 118
Joined: Tue Jan 07, 2014 5:55 pm

Re: Calculating title update download links with HMAC key

Post by ANU815 » Mon Aug 31, 2015 2:56 am

Not all of us are worrying about that pool game. Especially those of us stubbornly holding onto 3.18. If I interpret correctly, does this mean we may be able to update our games without updating firmware? Using these custom direct links and package manager?

User avatar
HarmfulMushroom
Posts: 752
Joined: Wed Dec 25, 2013 10:02 pm

Re: Calculating title update download links with HMAC key

Post by HarmfulMushroom » Mon Aug 31, 2015 3:36 am

ANU815 wrote:Not all of us are worrying about that pool game. Especially those of us stubbornly holding onto 3.18. If I interpret correctly, does this mean we may be able to update our games without updating firmware? Using these custom direct links and package manager?
You could always update your games without upgrading firmware, you don't need to be connected to PSN to do so.

EchoDev
Posts: 68
Joined: Mon Mar 24, 2014 12:46 pm

Re: Calculating title update download links with HMAC key

Post by EchoDev » Mon Aug 31, 2015 9:39 am

If we could manipulate https data to the vita we prolly could feed it our own pkg files right? :lol: Change the pkg file to a different one from the Sony servers to see if it accepts it.

Does anyone know how the sha1sum is calculated in the xml file? It does not seem to be a standard sha1 calculation.

mr.gas
Guru
Posts: 163
Joined: Sat Apr 05, 2014 6:35 pm
Location: YEMEN

Re: Calculating title update download links with HMAC key

Post by mr.gas » Mon Aug 31, 2015 10:13 am

that's great

John V. North
Posts: 3
Joined: Mon Jul 14, 2014 4:21 pm

Re: Calculating title update download links with HMAC key

Post by John V. North » Mon Aug 31, 2015 11:37 am

Can someone explain what exactly can we do with it and what it can lead to?

User avatar
Omega2058
Developer
Posts: 246
Joined: Tue Sep 28, 2010 4:27 am
Contact:

Re: Calculating title update download links with HMAC key

Post by Omega2058 » Mon Aug 31, 2015 3:04 pm

Nice, thanks for sharing.

npt
VIP
Posts: 154
Joined: Wed Oct 27, 2010 3:32 pm

Re: Calculating title update download links with HMAC key

Post by npt » Mon Aug 31, 2015 6:15 pm

Very nicely done.

-npt

MooMooMan
Posts: 120
Joined: Tue Jul 22, 2014 5:39 pm
Location: McMurdo, Antartica

Re: Calculating title update download links with HMAC key

Post by MooMooMan » Thu Sep 03, 2015 12:37 am

EchoDev wrote:If we could manipulate https data to the vita we prolly could feed it our own pkg files right? :lol: Change the pkg file to a different one from the Sony servers to see if it accepts it.

Does anyone know how the sha1sum is calculated in the xml file? It does not seem to be a standard sha1 calculation.
I am willing to bet my manhood that what you are proposing is very difficult at the moment, or down right impossible.

If it were that easy, all you would need to do is set up a router to search for a specific https connection, and reroute it to another site, or better yet, your own home server with the files you need.

The idea is nice though, I wonder if something will ever come of it. I guess all we need is the keys? I don't know, I only code in JavaScript. Lol
Ps Vita 1000 3.60 HenKaku
PSP 3000 03g 6.20 LME 2.3 Perm (Black)
PSP 3000 03g 6.20 LME 2.3 Perm (Silver)

Post Reply

Return to “Programming and Security”