JNUSTool/src/de/mas/jnustool/NUSTitle.java

75 lines
1.9 KiB
Java
Raw Normal View History

2016-02-02 19:38:53 +01:00
package de.mas.jnustool;
2016-02-01 20:54:01 +01:00
import java.io.IOException;
2016-02-02 19:38:53 +01:00
import de.mas.jnustool.util.Decryption;
import de.mas.jnustool.util.Downloader;
import de.mas.jnustool.util.Util;
2016-02-01 20:54:01 +01:00
public class NUSTitle {
private TitleMetaData tmd;
private long titleID;
private TIK ticket;
private FST fst;
2016-02-01 20:54:01 +01:00
public NUSTitle(long titleId,String key){
try {
titleID = titleId;
Downloader.getInstance().titleID = titleId;
Decryption decryption = new Decryption(Util.commonKey,titleId);
tmd = new TitleMetaData(Downloader.getInstance().downloadTMDToByteArray());
2016-02-02 19:38:53 +01:00
if(key == null){
2016-02-01 20:54:01 +01:00
ticket = new TIK(Downloader.getInstance().downloadTicketToByteArray(),tmd.titleID);
}else{
ticket = new TIK(key,titleId);
}
Downloader.getInstance().ticket = ticket;
decryption.init(ticket.getDecryptedKey(),0);
byte[] encryptedFST = Downloader.getInstance().downloadContentToByteArray(tmd.contents[0].ID);
byte[] decryptedFST = decryption.decrypt(encryptedFST);
2016-02-02 19:38:53 +01:00
fst = new FST(decryptedFST,tmd);
tmd.setFst(fst);
2016-02-01 20:54:01 +01:00
System.out.println("Total Size of Content Files: " + ((int)((getTotalContentSize()/1024.0/1024.0)*100))/100.0 +" MB");
System.out.println("Total Size of Decrypted Files: " + ((int)((fst.getTotalContentSizeInNUS()/1024.0/1024.0)*100))/100.0 +" MB");
System.out.println("Entries: " + fst.getTotalEntries());
System.out.println("Entries: " + fst.getFileCount());
System.out.println("Files in NUSTitle: " + fst.getFileCountInNUS());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public FST getFst() {
return fst;
}
public void setFst(FST fst) {
this.fst = fst;
}
2016-02-01 20:54:01 +01:00
public long getTitleID() {
return titleID;
}
public void setTitleID(long titleID) {
this.titleID = titleID;
}
public long getTotalContentSize() {
return tmd.getTotalContentSize();
}
}