Exemple #1
0
        public static UserDataHeader ReadFrom(Stream source, byte[] key)
        {
            using var binReader = new BinaryReader(source, Encoding.Unicode, true);
            var result = new UserDataHeader();

            // info from plaintext
            var plainIV            = binReader.ReadBytes(AesSizes.IV);
            var plainNameLength    = binReader.ReadInt32();
            var encryptedPlainName = binReader.ReadBytes(plainNameLength);

            result.SecuredPlainName = new SecretFileName(encryptedPlainName, plainIV, key);

            result.TargetCipherIV       = binReader.ReadBytes(AesSizes.IV);
            result.TargetAuthentication = binReader.ReadBytes(AesSizes.Auth);
            result.TargetPath           = binReader.ReadString();

            result.IsUnlocked = binReader.ReadBoolean();

            return(result);
        }
Exemple #2
0
 public UserDataHeaderWriter(UserDataHeader underlying)
 {
     _underlying = underlying;
 }