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); }
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); }
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); }
public void DecryptFile(string inputFile, string outputFile, WrappedKey wrappedKey, ProtectionClass protectionClass, bool overwrite) { var key = UnwrapKey(wrappedKey, _classKeys, protectionClass); DecryptFileCore(inputFile, outputFile, key, overwrite); }
public static byte[] UnwrapKey(WrappedKey item, IReadOnlyDictionary <ProtectionClass, byte[]> classKeys, ProtectionClass protectionClass) { var kek = classKeys[protectionClass]; return(KeyWrapAlgorithm.UnwrapKey(kek, item.Key)); }
public static byte[] UnwrapKey(WrappedKey item, IReadOnlyDictionary <ProtectionClass, byte[]> classKeys) { var protectionClass = (ProtectionClass)item.Unknown[0]; return(UnwrapKey(item, classKeys, protectionClass)); }