Esempio n. 1
0
 public KeysEntry(string contentId, string passcode)
 {
     Keys       = new PkgEntryKey[7];
     seedDigest = Crypto.Sha256(Encoding.ASCII.GetBytes(contentId.PadRight(48, '\0')));
     for (uint i = 0; i < 7; i++)
     {
         var passcodeKey = Crypto.ComputeKeys(contentId, passcode, i);
         Keys[i] = new PkgEntryKey
         {
             digest = Crypto.Sha256(passcodeKey).Xor(passcodeKey),
             key    = Crypto.RSA2048EncryptKey(Util.Keys.PkgPublicKeys[i], passcodeKey)
         };
     }
     Keys[0].key = Crypto.RSA2048EncryptKey(Util.Keys.PkgPublicKeys[0], Encoding.ASCII.GetBytes(passcode));
 }
Esempio n. 2
0
        public static KeysEntry Read(MetaEntry e, Stream pkg)
        {
            pkg.Position = e.DataOffset;
            var seedDigest = pkg.ReadBytes(32);
            var digests    = new byte[7][];
            var keys       = new PkgEntryKey[7];

            for (var x = 0; x < 7; x++)
            {
                digests[x] = pkg.ReadBytes(32);
            }
            for (var x = 0; x < 7; x++)
            {
                keys[x] = new PkgEntryKey
                {
                    digest = digests[x],
                    key    = pkg.ReadBytes(256)
                };
            }
            return(new KeysEntry(seedDigest, keys)
            {
                meta = e
            });
        }