예제 #1
0
        static void Main(string[] args)
        {
            Config        cfg        = new Config();
            var           liveClient = Login(cfg);
            CryptoManager cryptoMgr;

            if (cfg.Get("expanded-password", null) == null)
            {
                var password = cfg.Get("password", null);
                if (password == null)
                {
                    Console.WriteLine("passwordを指定してね");
                    return;
                }
                var salt = cfg.Get("password-salt", "encrypted-userspace-overlay-filesystem-over-cloud-storage");
                cryptoMgr = new CryptoManager(password, salt);
                cfg.Set("expanded-password", Convert.ToBase64String(cryptoMgr.Key));
                cfg.Delete("password");
                cfg.Save();
            }
            else
            {
                cryptoMgr = new CryptoManager(Convert.FromBase64String(cfg.Get("expanded-password", null)));
            }
            using (var baseFS = new OneDrive.FileSystem(cfg, liveClient))
                using (FileSystem fs = new FileSystem(cfg, baseFS, cryptoMgr)) {
                    if (Environment.OSVersion.Platform == PlatformID.Unix)
                    {
                        // Mono-FUSE
                        using (Fuse fuse = new Fuse(fs)) {
                            args            = fuse.ParseFuseArguments(args);
                            fuse.MountPoint = "/mnt/fuse";
                            fuse.Start();
                        }
                    }
                    else
                    {
                        // Dokan.NET (TODO)
                    }
                }
        }
예제 #2
0
 public WrapStream(Stream baseStream, CryptoManager mgr, byte[] tag, bool encryptMode)
 {
     _strm        = baseStream;
     _encryptMode = encryptMode;
     _ivSize      = mgr.AuthenticatedEncryption.IVByteSize;
     if (encryptMode)
     {
         // encrypt mode
         _tag = tag;
         byte[] iv = mgr.GetRandomBytes(_ivSize);
         baseStream.Write(iv, 0, iv.Length);
         _act = mgr.CreateAuthenticatedEncryptor(iv, null);
     }
     else
     {
         // decrypt mode
         byte[] iv = new byte[_ivSize];
         baseStream.ReadFull(iv, 0, iv.Length);
         _act = mgr.CreateAuthenticatedDecryptor(iv, null, tag);
     }
 }
예제 #3
0
        static void Main(string[] args)
        {
            string confDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "EncryptedOneDrive");

            if (!Directory.Exists(confDir))
            {
                Directory.CreateDirectory(confDir);
            }

            string tokenFile = Path.Combine(confDir, "token.txt");

            if (!File.Exists(tokenFile))
            {
                throw new FileNotFoundException(tokenFile);
            }
            string token;

            using (StreamReader reader = new StreamReader(tokenFile)) {
                token = reader.ReadLine().Trim();
            }

            OneDriveClient oneDriveClient = new OneDriveClient(token);
            CryptoManager  cryptoMgr      = new CryptoManager("password", "encrypted-userspace-filesystem-over-onedrive");

            using (FileSystem fs = new FileSystem(oneDriveClient, cryptoMgr)) {
                if (Environment.OSVersion.Platform == PlatformID.Unix)
                {
                    // Mono-FUSE
                    using (Fuse fuse = new Fuse(fs)) {
                        args            = fuse.ParseFuseArguments(args);
                        fuse.MountPoint = "/mnt/fuse";
                        fuse.Start();
                    }
                }
                else
                {
                    // Dokan.NET (TODO)
                }
            }
        }