public void Given_PartitionType_Then_It_Should_Return_Result(PartitionType collection)
        {
            var entity = new UrlItemEntity();

            entity.PartitionKey.Should().Be(collection.ToString());
            entity.PartitionKeyPath.Should().Be("/collection");
        }
Beispiel #2
0
        public void Given_Values_When_Serialised_Then_It_Should_Return_Result(PartitionType collection)
        {
            var entityId = Guid.NewGuid();
            var now      = DateTimeOffset.UtcNow;

            var entity = new FakeItemEntity()
            {
                EntityId      = entityId,
                Collection    = collection,
                DateGenerated = now
            };

            var dateGenerated = JsonConvert.SerializeObject(now);

            var serialised = JsonConvert.SerializeObject(entity);

            serialised.Should().Contain($"\"id\":\"{entityId.ToString()}\"");
            serialised.Should().Contain($"\"collection\":\"{collection.ToString()}\"");
            serialised.Should().Contain($"\"dateGenerated\":{dateGenerated}");
        }
Beispiel #3
0
        public override bool OnInitialize()
        {
            base.OnInitialize();

            const int headerSize      = 0x440;
            const int bi2Size         = 0x2000;
            const int apploaderOffset = 0x2440;

            _name = String.Format("[{0}] {1}", Index, PartitionType.ToString());
            _info = Get <PartitionInfo>(0x2A4, true);

            long tmdOffset = _info._tmdOffset * OffMult;
            uint sigType   = Get <buint>(tmdOffset, true);

            _rsaType = (RSAType)sigType;
            if (sigType != 0)
            {
                tmdOffset += 4L;

                int size = 0x200 - (((int)sigType & 1) * 0x100);

                _rsaSig = GetBytes(tmdOffset, size, true);

                tmdOffset += size;
                tmdOffset  = ((tmdOffset + 64 - 1) & ~(64 - 1));

                _tmd       = Get <TMDInfo>(tmdOffset, true);
                tmdOffset += TMDInfo.Size;

                _tmdEntries = new List <TMDEntry>();
                for (int i = 0; i < _tmd._numContents; ++i)
                {
                    _tmdEntries.Add(Get <TMDEntry>(tmdOffset + i * TMDEntry.Size, true));
                }

                byte[] encryptedKey = GetBytes(0x1BF, 16, true);
                _iv = GetBytes(0x1DC, 8, true);
                Array.Resize(ref _iv, 16);

                using (AesManaged aesAlg = new AesManaged())
                {
                    aesAlg.Key     = ISONode.LoadedKey;
                    aesAlg.IV      = _iv;
                    aesAlg.Mode    = CipherMode.CBC;
                    aesAlg.Padding = PaddingMode.Zeros;

                    _titleKey = new byte[16];
                    ICryptoTransform decryptor = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV);
                    using (MemoryStream msDecrypt = new MemoryStream(encryptedKey))
                        using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
                            csDecrypt.Read(_titleKey, 0, 16);
                }
            }

            byte[] b = GetPartitionData(0, 0x440);
            _header = ToStruct <ISOPartitionHeader>(b);

            byte[]    dol    = GetPartitionData(_header._dolOffset * OffMult, 0x100);
            DOLHeader dolHdr = ToStruct <DOLHeader>(dol);

            byte[]       fullDol = GetPartitionData(_header._dolOffset * OffMult, (int)dolHdr.GetSize());
            UnsafeBuffer dolBuf  = GetBuffer(fullDol);

            _childBuffers.Add(dolBuf);
            new DOLNode().Initialize(this, dolBuf.Address, dolBuf.Length);

            return(true);
        }