public ProdEncryptedXciArchive(ISink outSink, ISource xciSource, KeyConfiguration keyConfig) { this.ConnectionList = new List <Connection>(); this.m_rng = new RNGCryptoServiceProvider(); this.m_keyConfig = keyConfig; this.SetCryptor(this.m_keyConfig); byte[] keyArea = new byte[(int)XciInfo.PageSize * (int)XciInfo.CardKeyAreaPageCount]; ByteData byteData = xciSource.PullData(0L, (int)XciInfo.PageSize * (int)XciInfo.CardKeyAreaPageCount); ArraySegment <byte> buffer1 = byteData.Buffer; byte[] array = buffer1.Array; buffer1 = byteData.Buffer; int offset = buffer1.Offset; byte[] numArray = keyArea; int dstOffset = 0; buffer1 = byteData.Buffer; int count = buffer1.Count; Buffer.BlockCopy((Array)array, offset, (Array)numArray, dstOffset, count); byte[] buffer2 = this.EncryptKeyArea(keyArea); MemorySource memorySource = new MemorySource(buffer2, 0, buffer2.Length); AdaptedSource adaptedSource = new AdaptedSource(xciSource, (ISource)memorySource, 0L, memorySource.Size); outSink.SetSize(adaptedSource.Size); this.ConnectionList.Add(new Connection((ISource)adaptedSource, outSink)); }
public static void MergeNintendoSubmissionPackageArchive(Stream outStream, List <Stream> inStreams) { SourceSinkDriver sourceSinkDriver = new SourceSinkDriver(); ISource source = (ISource) new PartitionFsArchiveSource(ArchiveReconstructionUtils.GetMergedNspInfo(inStreams.Select <Stream, NintendoSubmissionPackageReader>((Func <Stream, NintendoSubmissionPackageReader>)(x => new NintendoSubmissionPackageReader(x))).ToList <NintendoSubmissionPackageReader>())); ISink sink = (ISink) new StreamSink(outStream); sink.SetSize(source.Size); sourceSinkDriver.Add(source, sink); sourceSinkDriver.Run(); }
public static void CreateArchiveFromAdf(Stream stream, string adfPath, AuthoringConfiguration config) { SourceSinkDriver sourceSinkDriver = new SourceSinkDriver(); switch (ContentArchiveLibraryInterface.GetArchiveType(adfPath)) { case ArchiveFormatType.NintendoContent: ISource source1 = (ISource) new NintendoContentArchiveSource(new NintendoContentAdfReader(adfPath).GetFileSystemInfo(), config.GetKeyConfiguration(), false); ISink sink1 = (ISink) new StreamSink(stream); sink1.SetSize(source1.Size); sourceSinkDriver.Add(source1, sink1); break; case ArchiveFormatType.PartitionFs: ISource source2 = (ISource) new PartitionFsArchiveSource(new PartitionFsAdfReader(adfPath).GetFileSystemInfo()); ISink sink2 = (ISink) new StreamSink(stream); sink2.SetSize(source2.Size); sourceSinkDriver.Add(source2, sink2); break; case ArchiveFormatType.RomFs: ISource source3 = (ISource) new RomFsArchiveSource(new RomFsAdfReader(adfPath).GetFileSystemInfo()); ISink sink3 = (ISink) new StreamSink(stream); sink3.SetSize(source3.Size); sourceSinkDriver.Add(source3, sink3); break; case ArchiveFormatType.NintendoSubmissionPackage: NintendoSubmissionPackageAdfReader packageAdfReader = new NintendoSubmissionPackageAdfReader(adfPath); IConnector connector = (IConnector) new NintendoSubmissionPackageArchive((IReadableSink) new StreamSink(stream), packageAdfReader.GetFileSystemInfo(), config.GetKeyConfiguration()); sourceSinkDriver.Add(connector); break; default: throw new NotImplementedException(); } sourceSinkDriver.Run(); }