コード例 #1
0
ファイル: KeyStore.cs プロジェクト: kknet/iPhoneTools
        public void SetManifestKey(byte[] wrappedKeyData)
        {
            if (wrappedKeyData is null)
            {
                throw new ArgumentNullException(nameof(wrappedKeyData));
            }

            _logger.LogInformation("Retrieving manifest wrapped encryption key");
            _wrappedManifestKey = WrappedKeyReader.Read(wrappedKeyData);
        }
コード例 #2
0
        public static WrappedKey Read(byte[] wrappedKeyData)
        {
            if (wrappedKeyData is null)
            {
                throw new ArgumentNullException(nameof(wrappedKeyData));
            }

            WrappedKey result = default;

            if (wrappedKeyData.Length == 44)
            {
                result = new WrappedKey
                {
                    Unknown = wrappedKeyData.AsSpan(0, 4).ToArray(),
                    Key     = wrappedKeyData.AsSpan(4, 40).ToArray(),
                };
            }

            return(result);
        }
コード例 #3
0
        private WrappedKey ReadEncryptionKey(BinaryReader reader)
        {
            const int PrefixLength = 4;

            WrappedKey result = default;

            int size = reader.ReadUInt16BigEndian();

            if (size != 0xFFFF && size > PrefixLength)
            {
                int keySize = size - PrefixLength;

                result = new WrappedKey
                {
                    Unknown = reader.ReadBytes(PrefixLength),
                    Key     = reader.ReadBytes(keySize),
                };
            }

            return(result);
        }
コード例 #4
0
ファイル: KeyStore.cs プロジェクト: kknet/iPhoneTools
        public void DecryptFile(string inputFile, string outputFile, WrappedKey wrappedKey, ProtectionClass protectionClass, bool overwrite)
        {
            var key = UnwrapKey(wrappedKey, _classKeys, protectionClass);

            DecryptFileCore(inputFile, outputFile, key, overwrite);
        }
コード例 #5
0
ファイル: KeyStore.cs プロジェクト: kknet/iPhoneTools
        public static byte[] UnwrapKey(WrappedKey item, IReadOnlyDictionary <ProtectionClass, byte[]> classKeys, ProtectionClass protectionClass)
        {
            var kek = classKeys[protectionClass];

            return(KeyWrapAlgorithm.UnwrapKey(kek, item.Key));
        }
コード例 #6
0
ファイル: KeyStore.cs プロジェクト: kknet/iPhoneTools
        public static byte[] UnwrapKey(WrappedKey item, IReadOnlyDictionary <ProtectionClass, byte[]> classKeys)
        {
            var protectionClass = (ProtectionClass)item.Unknown[0];

            return(UnwrapKey(item, classKeys, protectionClass));
        }