private static long GetTimeStamp(PKG.PkgProperties props) { // FIXME: This is incorrect when DST of current time and project time are different var timestamp = props.TimeStamp.Subtract(new DateTime(1970, 1, 1)).TotalSeconds; return((long)timestamp); }
/// <summary> /// Generates a PfsProperties object for the inner PFS image of a PKG with the given properties. /// </summary> /// <param name="props"></param> /// <returns></returns> public static PfsProperties MakeInnerPFSProps(PKG.PkgProperties props) { // Generate keystone for GP PKGs if it is not already there if (props.VolumeType == GP4.VolumeType.pkg_ps4_app && props.RootDir.GetFile("sce_sys/keystone") == null) { AddFile(props.RootDir, "sce_sys", "keystone", Util.Crypto.CreateKeystone(props.Passcode)); } var timestamp = props.TimeStamp.Subtract(new DateTime(1970, 1, 1)).TotalSeconds; return(new PfsProperties() { root = props.RootDir, BlockSize = 0x10000, Encrypt = false, Sign = false, FileTime = GetTimeStamp(props), }); }
/// <summary> /// Generates a PfsProperties object for the outer PFS image of a PKG with the given properties. /// </summary> /// <param name="props">PKG properties to convert from</param> /// <param name="innerPFS">Inner pfs image to use, presumably from MakeInnerPFSProps</param> /// <param name="EKPFS">Encryption key for PFS</param> /// <param name="encrypt">Set to false to make a non-encrypted PFS</param> /// <returns></returns> public static PfsProperties MakeOuterPFSProps(PKG.PkgProperties props, PfsBuilder innerPFS, byte[] EKPFS, bool encrypt = true) { var root = new FSDir(); root.Files.Add(new FSFile(innerPFS) { Parent = root, }); return(new PfsProperties() { root = root, BlockSize = 0x10000, Encrypt = encrypt, Sign = true, EKPFS = EKPFS, Seed = new byte[16], FileTime = GetTimeStamp(props), }); }
/// <summary> /// Generates a PfsProperties object for the outer PFS image of a PKG with the given properties. /// </summary> /// <param name="props">PKG properties to convert from</param> /// <param name="innerPFS">Inner pfs image to use, presumably from MakeInnerPFSProps</param> /// <param name="EKPFS">Encryption key for PFS</param> /// <param name="encrypt">Set to false to make a non-encrypted PFS</param> /// <returns></returns> public static PfsProperties MakeOuterPFSProps(PKG.PkgProperties props, PfsBuilder innerPFS, byte[] EKPFS, bool encrypt = true) { var root = new FSDir(); root.Files.Add(new FSFile(innerPFS) { Parent = root, }); return(new PfsProperties() { root = root, BlockSize = 0x10000, Encrypt = encrypt, Sign = true, EKPFS = EKPFS, // This doesn't seem to really matter when verifying a PKG so use all zeroes for now Seed = new byte[16], FileTime = GetTimeStamp(props), }); }