github.com/artpar/rclone@v1.67.3/docs/content/crypt.md (about) 1 --- 2 title: "Crypt" 3 description: "Encryption overlay remote" 4 versionIntroduced: "v1.33" 5 --- 6 7 # {{< icon "fa fa-lock" >}} Crypt 8 9 Rclone `crypt` remotes encrypt and decrypt other remotes. 10 11 A remote of type `crypt` does not access a [storage system](https://rclone.org/overview/) 12 directly, but instead wraps another remote, which in turn accesses 13 the storage system. This is similar to how [alias](https://rclone.org/alias/), 14 [union](https://rclone.org/union/), [chunker](https://rclone.org/chunker/) 15 and a few others work. It makes the usage very flexible, as you can 16 add a layer, in this case an encryption layer, on top of any other 17 backend, even in multiple layers. Rclone's functionality 18 can be used as with any other remote, for example you can 19 [mount](https://rclone.org/commands/rclone_mount/) a crypt remote. 20 21 Accessing a storage system through a crypt remote realizes client-side 22 encryption, which makes it safe to keep your data in a location you do 23 not trust will not get compromised. 24 When working against the `crypt` remote, rclone will automatically 25 encrypt (before uploading) and decrypt (after downloading) on your local 26 system as needed on the fly, leaving the data encrypted at rest in the 27 wrapped remote. If you access the storage system using an application 28 other than rclone, or access the wrapped remote directly using rclone, 29 there will not be any encryption/decryption: Downloading existing content 30 will just give you the encrypted (scrambled) format, and anything you 31 upload will *not* become encrypted. 32 33 The encryption is a secret-key encryption (also called symmetric key encryption) 34 algorithm, where a password (or pass phrase) is used to generate real encryption key. 35 The password can be supplied by user, or you may chose to let rclone 36 generate one. It will be stored in the configuration file, in a lightly obscured form. 37 If you are in an environment where you are not able to keep your configuration 38 secured, you should add 39 [configuration encryption](https://rclone.org/docs/#configuration-encryption) 40 as protection. As long as you have this configuration file, you will be able to 41 decrypt your data. Without the configuration file, as long as you remember 42 the password (or keep it in a safe place), you can re-create the configuration 43 and gain access to the existing data. You may also configure a corresponding 44 remote in a different installation to access the same data. 45 See below for guidance to [changing password](#changing-password). 46 47 Encryption uses [cryptographic salt](https://en.wikipedia.org/wiki/Salt_(cryptography)), 48 to permute the encryption key so that the same string may be encrypted in 49 different ways. When configuring the crypt remote it is optional to enter a salt, 50 or to let rclone generate a unique salt. If omitted, rclone uses a built-in unique string. 51 Normally in cryptography, the salt is stored together with the encrypted content, 52 and do not have to be memorized by the user. This is not the case in rclone, 53 because rclone does not store any additional information on the remotes. Use of 54 custom salt is effectively a second password that must be memorized. 55 56 [File content](#file-encryption) encryption is performed using 57 [NaCl SecretBox](https://godoc.org/golang.org/x/crypto/nacl/secretbox), 58 based on XSalsa20 cipher and Poly1305 for integrity. 59 [Names](#name-encryption) (file- and directory names) are also encrypted 60 by default, but this has some implications and is therefore 61 possible to be turned off. 62 63 ## Configuration 64 65 Here is an example of how to make a remote called `secret`. 66 67 To use `crypt`, first set up the underlying remote. Follow the 68 `rclone config` instructions for the specific backend. 69 70 Before configuring the crypt remote, check the underlying remote is 71 working. In this example the underlying remote is called `remote`. 72 We will configure a path `path` within this remote to contain the 73 encrypted content. Anything inside `remote:path` will be encrypted 74 and anything outside will not. 75 76 Configure `crypt` using `rclone config`. In this example the `crypt` 77 remote is called `secret`, to differentiate it from the underlying 78 `remote`. 79 80 When you are done you can use the crypt remote named `secret` just 81 as you would with any other remote, e.g. `rclone copy D:\docs secret:\docs`, 82 and rclone will encrypt and decrypt as needed on the fly. 83 If you access the wrapped remote `remote:path` directly you will bypass 84 the encryption, and anything you read will be in encrypted form, and 85 anything you write will be unencrypted. To avoid issues it is best to 86 configure a dedicated path for encrypted content, and access it 87 exclusively through a crypt remote. 88 89 ``` 90 No remotes found, make a new one? 91 n) New remote 92 s) Set configuration password 93 q) Quit config 94 n/s/q> n 95 name> secret 96 Type of storage to configure. 97 Enter a string value. Press Enter for the default (""). 98 Choose a number from below, or type in your own value 99 [snip] 100 XX / Encrypt/Decrypt a remote 101 \ "crypt" 102 [snip] 103 Storage> crypt 104 ** See help for crypt backend at: https://rclone.org/crypt/ ** 105 106 Remote to encrypt/decrypt. 107 Normally should contain a ':' and a path, eg "myremote:path/to/dir", 108 "myremote:bucket" or maybe "myremote:" (not recommended). 109 Enter a string value. Press Enter for the default (""). 110 remote> remote:path 111 How to encrypt the filenames. 112 Enter a string value. Press Enter for the default ("standard"). 113 Choose a number from below, or type in your own value. 114 / Encrypt the filenames. 115 1 | See the docs for the details. 116 \ "standard" 117 2 / Very simple filename obfuscation. 118 \ "obfuscate" 119 / Don't encrypt the file names. 120 3 | Adds a ".bin" extension only. 121 \ "off" 122 filename_encryption> 123 Option to either encrypt directory names or leave them intact. 124 125 NB If filename_encryption is "off" then this option will do nothing. 126 Enter a boolean value (true or false). Press Enter for the default ("true"). 127 Choose a number from below, or type in your own value 128 1 / Encrypt directory names. 129 \ "true" 130 2 / Don't encrypt directory names, leave them intact. 131 \ "false" 132 directory_name_encryption> 133 Password or pass phrase for encryption. 134 y) Yes type in my own password 135 g) Generate random password 136 y/g> y 137 Enter the password: 138 password: 139 Confirm the password: 140 password: 141 Password or pass phrase for salt. Optional but recommended. 142 Should be different to the previous password. 143 y) Yes type in my own password 144 g) Generate random password 145 n) No leave this optional password blank (default) 146 y/g/n> g 147 Password strength in bits. 148 64 is just about memorable 149 128 is secure 150 1024 is the maximum 151 Bits> 128 152 Your password is: JAsJvRcgR-_veXNfy_sGmQ 153 Use this password? Please note that an obscured version of this 154 password (and not the password itself) will be stored under your 155 configuration file, so keep this generated password in a safe place. 156 y) Yes (default) 157 n) No 158 y/n> 159 Edit advanced config? (y/n) 160 y) Yes 161 n) No (default) 162 y/n> 163 Remote config 164 -------------------- 165 [secret] 166 type = crypt 167 remote = remote:path 168 password = *** ENCRYPTED *** 169 password2 = *** ENCRYPTED *** 170 -------------------- 171 y) Yes this is OK (default) 172 e) Edit this remote 173 d) Delete this remote 174 y/e/d> 175 ``` 176 177 **Important** The crypt password stored in `rclone.conf` is lightly 178 obscured. That only protects it from cursory inspection. It is not 179 secure unless [configuration encryption](https://rclone.org/docs/#configuration-encryption) of `rclone.conf` is specified. 180 181 A long passphrase is recommended, or `rclone config` can generate a 182 random one. 183 184 The obscured password is created using AES-CTR with a static key. The 185 salt is stored verbatim at the beginning of the obscured password. This 186 static key is shared between all versions of rclone. 187 188 If you reconfigure rclone with the same passwords/passphrases 189 elsewhere it will be compatible, but the obscured version will be different 190 due to the different salt. 191 192 Rclone does not encrypt 193 194 * file length - this can be calculated within 16 bytes 195 * modification time - used for syncing 196 197 ### Specifying the remote 198 199 When configuring the remote to encrypt/decrypt, you may specify any 200 string that rclone accepts as a source/destination of other commands. 201 202 The primary use case is to specify the path into an already configured 203 remote (e.g. `remote:path/to/dir` or `remote:bucket`), such that 204 data in a remote untrusted location can be stored encrypted. 205 206 You may also specify a local filesystem path, such as 207 `/path/to/dir` on Linux, `C:\path\to\dir` on Windows. By creating 208 a crypt remote pointing to such a local filesystem path, you can 209 use rclone as a utility for pure local file encryption, for example 210 to keep encrypted files on a removable USB drive. 211 212 **Note**: A string which do not contain a `:` will by rclone be treated 213 as a relative path in the local filesystem. For example, if you enter 214 the name `remote` without the trailing `:`, it will be treated as 215 a subdirectory of the current directory with name "remote". 216 217 If a path `remote:path/to/dir` is specified, rclone stores encrypted 218 files in `path/to/dir` on the remote. With file name encryption, files 219 saved to `secret:subdir/subfile` are stored in the unencrypted path 220 `path/to/dir` but the `subdir/subpath` element is encrypted. 221 222 The path you specify does not have to exist, rclone will create 223 it when needed. 224 225 If you intend to use the wrapped remote both directly for keeping 226 unencrypted content, as well as through a crypt remote for encrypted 227 content, it is recommended to point the crypt remote to a separate 228 directory within the wrapped remote. If you use a bucket-based storage 229 system (e.g. Swift, S3, Google Compute Storage, B2) it is generally 230 advisable to wrap the crypt remote around a specific bucket (`s3:bucket`). 231 If wrapping around the entire root of the storage (`s3:`), and use the 232 optional file name encryption, rclone will encrypt the bucket name. 233 234 ### Changing password 235 236 Should the password, or the configuration file containing a lightly obscured 237 form of the password, be compromised, you need to re-encrypt your data with 238 a new password. Since rclone uses secret-key encryption, where the encryption 239 key is generated directly from the password kept on the client, it is not 240 possible to change the password/key of already encrypted content. Just changing 241 the password configured for an existing crypt remote means you will no longer 242 able to decrypt any of the previously encrypted content. The only possibility 243 is to re-upload everything via a crypt remote configured with your new password. 244 245 Depending on the size of your data, your bandwidth, storage quota etc, there are 246 different approaches you can take: 247 - If you have everything in a different location, for example on your local system, 248 you could remove all of the prior encrypted files, change the password for your 249 configured crypt remote (or delete and re-create the crypt configuration), 250 and then re-upload everything from the alternative location. 251 - If you have enough space on the storage system you can create a new crypt 252 remote pointing to a separate directory on the same backend, and then use 253 rclone to copy everything from the original crypt remote to the new, 254 effectively decrypting everything on the fly using the old password and 255 re-encrypting using the new password. When done, delete the original crypt 256 remote directory and finally the rclone crypt configuration with the old password. 257 All data will be streamed from the storage system and back, so you will 258 get half the bandwidth and be charged twice if you have upload and download quota 259 on the storage system. 260 261 **Note**: A security problem related to the random password generator 262 was fixed in rclone version 1.53.3 (released 2020-11-19). Passwords generated 263 by rclone config in version 1.49.0 (released 2019-08-26) to 1.53.2 264 (released 2020-10-26) are not considered secure and should be changed. 265 If you made up your own password, or used rclone version older than 1.49.0 or 266 newer than 1.53.2 to generate it, you are *not* affected by this issue. 267 See [issue #4783](https://github.com/artpar/artpar/issues/4783) for more 268 details, and a tool you can use to check if you are affected. 269 270 ### Example 271 272 Create the following file structure using "standard" file name 273 encryption. 274 275 ``` 276 plaintext/ 277 ├── file0.txt 278 ├── file1.txt 279 └── subdir 280 ├── file2.txt 281 ├── file3.txt 282 └── subsubdir 283 └── file4.txt 284 ``` 285 286 Copy these to the remote, and list them 287 288 ``` 289 $ rclone -q copy plaintext secret: 290 $ rclone -q ls secret: 291 7 file1.txt 292 6 file0.txt 293 8 subdir/file2.txt 294 10 subdir/subsubdir/file4.txt 295 9 subdir/file3.txt 296 ``` 297 298 The crypt remote looks like 299 300 ``` 301 $ rclone -q ls remote:path 302 55 hagjclgavj2mbiqm6u6cnjjqcg 303 54 v05749mltvv1tf4onltun46gls 304 57 86vhrsv86mpbtd3a0akjuqslj8/dlj7fkq4kdq72emafg7a7s41uo 305 58 86vhrsv86mpbtd3a0akjuqslj8/7uu829995du6o42n32otfhjqp4/b9pausrfansjth5ob3jkdqd4lc 306 56 86vhrsv86mpbtd3a0akjuqslj8/8njh1sk437gttmep3p70g81aps 307 ``` 308 309 The directory structure is preserved 310 311 ``` 312 $ rclone -q ls secret:subdir 313 8 file2.txt 314 9 file3.txt 315 10 subsubdir/file4.txt 316 ``` 317 318 Without file name encryption `.bin` extensions are added to underlying 319 names. This prevents the cloud provider attempting to interpret file 320 content. 321 322 ``` 323 $ rclone -q ls remote:path 324 54 file0.txt.bin 325 57 subdir/file3.txt.bin 326 56 subdir/file2.txt.bin 327 58 subdir/subsubdir/file4.txt.bin 328 55 file1.txt.bin 329 ``` 330 331 ### File name encryption modes 332 333 Off 334 335 * doesn't hide file names or directory structure 336 * allows for longer file names (~246 characters) 337 * can use sub paths and copy single files 338 339 Standard 340 341 * file names encrypted 342 * file names can't be as long (~143 characters) 343 * can use sub paths and copy single files 344 * directory structure visible 345 * identical files names will have identical uploaded names 346 * can use shortcuts to shorten the directory recursion 347 348 Obfuscation 349 350 This is a simple "rotate" of the filename, with each file having a rot 351 distance based on the filename. Rclone stores the distance at the 352 beginning of the filename. A file called "hello" may become "53.jgnnq". 353 354 Obfuscation is not a strong encryption of filenames, but hinders 355 automated scanning tools picking up on filename patterns. It is an 356 intermediate between "off" and "standard" which allows for longer path 357 segment names. 358 359 There is a possibility with some unicode based filenames that the 360 obfuscation is weak and may map lower case characters to upper case 361 equivalents. 362 363 Obfuscation cannot be relied upon for strong protection. 364 365 * file names very lightly obfuscated 366 * file names can be longer than standard encryption 367 * can use sub paths and copy single files 368 * directory structure visible 369 * identical files names will have identical uploaded names 370 371 Cloud storage systems have limits on file name length and 372 total path length which rclone is more likely to breach using 373 "Standard" file name encryption. Where file names are 143 or fewer 374 characters in length issues should not be encountered, irrespective of 375 cloud storage provider. 376 377 An experimental advanced option `filename_encoding` is now provided to 378 address this problem to a certain degree. 379 For cloud storage systems with case sensitive file names (e.g. Google Drive), 380 `base64` can be used to reduce file name length. 381 For cloud storage systems using UTF-16 to store file names internally 382 (e.g. OneDrive, Dropbox, Box), `base32768` can be used to drastically reduce 383 file name length. 384 385 An alternative, future rclone file name encryption mode may tolerate 386 backend provider path length limits. 387 388 ### Directory name encryption 389 390 Crypt offers the option of encrypting dir names or leaving them intact. 391 There are two options: 392 393 True 394 395 Encrypts the whole file path including directory names 396 Example: 397 `1/12/123.txt` is encrypted to 398 `p0e52nreeaj0a5ea7s64m4j72s/l42g6771hnv3an9cgc8cr2n1ng/qgm4avr35m5loi1th53ato71v0` 399 400 False 401 402 Only encrypts file names, skips directory names 403 Example: 404 `1/12/123.txt` is encrypted to 405 `1/12/qgm4avr35m5loi1th53ato71v0` 406 407 408 ### Modification times and hashes 409 410 Crypt stores modification times using the underlying remote so support 411 depends on that. 412 413 Hashes are not stored for crypt. However the data integrity is 414 protected by an extremely strong crypto authenticator. 415 416 Use the `rclone cryptcheck` command to check the 417 integrity of an encrypted remote instead of `rclone check` which can't 418 check the checksums properly. 419 420 {{< rem autogenerated options start" - DO NOT EDIT - instead edit fs.RegInfo in backend/crypt/crypt.go then run make backenddocs" >}} 421 ### Standard options 422 423 Here are the Standard options specific to crypt (Encrypt/Decrypt a remote). 424 425 #### --crypt-remote 426 427 Remote to encrypt/decrypt. 428 429 Normally should contain a ':' and a path, e.g. "myremote:path/to/dir", 430 "myremote:bucket" or maybe "myremote:" (not recommended). 431 432 Properties: 433 434 - Config: remote 435 - Env Var: RCLONE_CRYPT_REMOTE 436 - Type: string 437 - Required: true 438 439 #### --crypt-filename-encryption 440 441 How to encrypt the filenames. 442 443 Properties: 444 445 - Config: filename_encryption 446 - Env Var: RCLONE_CRYPT_FILENAME_ENCRYPTION 447 - Type: string 448 - Default: "standard" 449 - Examples: 450 - "standard" 451 - Encrypt the filenames. 452 - See the docs for the details. 453 - "obfuscate" 454 - Very simple filename obfuscation. 455 - "off" 456 - Don't encrypt the file names. 457 - Adds a ".bin", or "suffix" extension only. 458 459 #### --crypt-directory-name-encryption 460 461 Option to either encrypt directory names or leave them intact. 462 463 NB If filename_encryption is "off" then this option will do nothing. 464 465 Properties: 466 467 - Config: directory_name_encryption 468 - Env Var: RCLONE_CRYPT_DIRECTORY_NAME_ENCRYPTION 469 - Type: bool 470 - Default: true 471 - Examples: 472 - "true" 473 - Encrypt directory names. 474 - "false" 475 - Don't encrypt directory names, leave them intact. 476 477 #### --crypt-password 478 479 Password or pass phrase for encryption. 480 481 **NB** Input to this must be obscured - see [rclone obscure](/commands/rclone_obscure/). 482 483 Properties: 484 485 - Config: password 486 - Env Var: RCLONE_CRYPT_PASSWORD 487 - Type: string 488 - Required: true 489 490 #### --crypt-password2 491 492 Password or pass phrase for salt. 493 494 Optional but recommended. 495 Should be different to the previous password. 496 497 **NB** Input to this must be obscured - see [rclone obscure](/commands/rclone_obscure/). 498 499 Properties: 500 501 - Config: password2 502 - Env Var: RCLONE_CRYPT_PASSWORD2 503 - Type: string 504 - Required: false 505 506 ### Advanced options 507 508 Here are the Advanced options specific to crypt (Encrypt/Decrypt a remote). 509 510 #### --crypt-server-side-across-configs 511 512 Deprecated: use --server-side-across-configs instead. 513 514 Allow server-side operations (e.g. copy) to work across different crypt configs. 515 516 Normally this option is not what you want, but if you have two crypts 517 pointing to the same backend you can use it. 518 519 This can be used, for example, to change file name encryption type 520 without re-uploading all the data. Just make two crypt backends 521 pointing to two different directories with the single changed 522 parameter and use rclone move to move the files between the crypt 523 remotes. 524 525 Properties: 526 527 - Config: server_side_across_configs 528 - Env Var: RCLONE_CRYPT_SERVER_SIDE_ACROSS_CONFIGS 529 - Type: bool 530 - Default: false 531 532 #### --crypt-show-mapping 533 534 For all files listed show how the names encrypt. 535 536 If this flag is set then for each file that the remote is asked to 537 list, it will log (at level INFO) a line stating the decrypted file 538 name and the encrypted file name. 539 540 This is so you can work out which encrypted names are which decrypted 541 names just in case you need to do something with the encrypted file 542 names, or for debugging purposes. 543 544 Properties: 545 546 - Config: show_mapping 547 - Env Var: RCLONE_CRYPT_SHOW_MAPPING 548 - Type: bool 549 - Default: false 550 551 #### --crypt-no-data-encryption 552 553 Option to either encrypt file data or leave it unencrypted. 554 555 Properties: 556 557 - Config: no_data_encryption 558 - Env Var: RCLONE_CRYPT_NO_DATA_ENCRYPTION 559 - Type: bool 560 - Default: false 561 - Examples: 562 - "true" 563 - Don't encrypt file data, leave it unencrypted. 564 - "false" 565 - Encrypt file data. 566 567 #### --crypt-pass-bad-blocks 568 569 If set this will pass bad blocks through as all 0. 570 571 This should not be set in normal operation, it should only be set if 572 trying to recover an encrypted file with errors and it is desired to 573 recover as much of the file as possible. 574 575 Properties: 576 577 - Config: pass_bad_blocks 578 - Env Var: RCLONE_CRYPT_PASS_BAD_BLOCKS 579 - Type: bool 580 - Default: false 581 582 #### --crypt-strict-names 583 584 If set, this will raise an error when crypt comes across a filename that can't be decrypted. 585 586 (By default, rclone will just log a NOTICE and continue as normal.) 587 This can happen if encrypted and unencrypted files are stored in the same 588 directory (which is not recommended.) It may also indicate a more serious 589 problem that should be investigated. 590 591 Properties: 592 593 - Config: strict_names 594 - Env Var: RCLONE_CRYPT_STRICT_NAMES 595 - Type: bool 596 - Default: false 597 598 #### --crypt-filename-encoding 599 600 How to encode the encrypted filename to text string. 601 602 This option could help with shortening the encrypted filename. The 603 suitable option would depend on the way your remote count the filename 604 length and if it's case sensitive. 605 606 Properties: 607 608 - Config: filename_encoding 609 - Env Var: RCLONE_CRYPT_FILENAME_ENCODING 610 - Type: string 611 - Default: "base32" 612 - Examples: 613 - "base32" 614 - Encode using base32. Suitable for all remote. 615 - "base64" 616 - Encode using base64. Suitable for case sensitive remote. 617 - "base32768" 618 - Encode using base32768. Suitable if your remote counts UTF-16 or 619 - Unicode codepoint instead of UTF-8 byte length. (Eg. Onedrive, Dropbox) 620 621 #### --crypt-suffix 622 623 If this is set it will override the default suffix of ".bin". 624 625 Setting suffix to "none" will result in an empty suffix. This may be useful 626 when the path length is critical. 627 628 Properties: 629 630 - Config: suffix 631 - Env Var: RCLONE_CRYPT_SUFFIX 632 - Type: string 633 - Default: ".bin" 634 635 #### --crypt-description 636 637 Description of the remote 638 639 Properties: 640 641 - Config: description 642 - Env Var: RCLONE_CRYPT_DESCRIPTION 643 - Type: string 644 - Required: false 645 646 ### Metadata 647 648 Any metadata supported by the underlying remote is read and written. 649 650 See the [metadata](/docs/#metadata) docs for more info. 651 652 ## Backend commands 653 654 Here are the commands specific to the crypt backend. 655 656 Run them with 657 658 rclone backend COMMAND remote: 659 660 The help below will explain what arguments each command takes. 661 662 See the [backend](/commands/rclone_backend/) command for more 663 info on how to pass options and arguments. 664 665 These can be run on a running backend using the rc command 666 [backend/command](/rc/#backend-command). 667 668 ### encode 669 670 Encode the given filename(s) 671 672 rclone backend encode remote: [options] [<arguments>+] 673 674 This encodes the filenames given as arguments returning a list of 675 strings of the encoded results. 676 677 Usage Example: 678 679 rclone backend encode crypt: file1 [file2...] 680 rclone rc backend/command command=encode fs=crypt: file1 [file2...] 681 682 683 ### decode 684 685 Decode the given filename(s) 686 687 rclone backend decode remote: [options] [<arguments>+] 688 689 This decodes the filenames given as arguments returning a list of 690 strings of the decoded results. It will return an error if any of the 691 inputs are invalid. 692 693 Usage Example: 694 695 rclone backend decode crypt: encryptedfile1 [encryptedfile2...] 696 rclone rc backend/command command=decode fs=crypt: encryptedfile1 [encryptedfile2...] 697 698 699 {{< rem autogenerated options stop >}} 700 701 ## Backing up an encrypted remote 702 703 If you wish to backup an encrypted remote, it is recommended that you use 704 `rclone sync` on the encrypted files, and make sure the passwords are 705 the same in the new encrypted remote. 706 707 This will have the following advantages 708 709 * `rclone sync` will check the checksums while copying 710 * you can use `rclone check` between the encrypted remotes 711 * you don't decrypt and encrypt unnecessarily 712 713 For example, let's say you have your original remote at `remote:` with 714 the encrypted version at `eremote:` with path `remote:crypt`. You 715 would then set up the new remote `remote2:` and then the encrypted 716 version `eremote2:` with path `remote2:crypt` using the same passwords 717 as `eremote:`. 718 719 To sync the two remotes you would do 720 721 rclone sync --interactive remote:crypt remote2:crypt 722 723 And to check the integrity you would do 724 725 rclone check remote:crypt remote2:crypt 726 727 ## File formats 728 729 ### File encryption 730 731 Files are encrypted 1:1 source file to destination object. The file 732 has a header and is divided into chunks. 733 734 #### Header 735 736 * 8 bytes magic string `RCLONE\x00\x00` 737 * 24 bytes Nonce (IV) 738 739 The initial nonce is generated from the operating systems crypto 740 strong random number generator. The nonce is incremented for each 741 chunk read making sure each nonce is unique for each block written. 742 The chance of a nonce being reused is minuscule. If you wrote an 743 exabyte of data (10¹⁸ bytes) you would have a probability of 744 approximately 2×10⁻³² of re-using a nonce. 745 746 #### Chunk 747 748 Each chunk will contain 64 KiB of data, except for the last one which 749 may have less data. The data chunk is in standard NaCl SecretBox 750 format. SecretBox uses XSalsa20 and Poly1305 to encrypt and 751 authenticate messages. 752 753 Each chunk contains: 754 755 * 16 Bytes of Poly1305 authenticator 756 * 1 - 65536 bytes XSalsa20 encrypted data 757 758 64k chunk size was chosen as the best performing chunk size (the 759 authenticator takes too much time below this and the performance drops 760 off due to cache effects above this). Note that these chunks are 761 buffered in memory so they can't be too big. 762 763 This uses a 32 byte (256 bit key) key derived from the user password. 764 765 #### Examples 766 767 1 byte file will encrypt to 768 769 * 32 bytes header 770 * 17 bytes data chunk 771 772 49 bytes total 773 774 1 MiB (1048576 bytes) file will encrypt to 775 776 * 32 bytes header 777 * 16 chunks of 65568 bytes 778 779 1049120 bytes total (a 0.05% overhead). This is the overhead for big 780 files. 781 782 ### Name encryption 783 784 File names are encrypted segment by segment - the path is broken up 785 into `/` separated strings and these are encrypted individually. 786 787 File segments are padded using PKCS#7 to a multiple of 16 bytes 788 before encryption. 789 790 They are then encrypted with EME using AES with 256 bit key. EME 791 (ECB-Mix-ECB) is a wide-block encryption mode presented in the 2003 792 paper "A Parallelizable Enciphering Mode" by Halevi and Rogaway. 793 794 This makes for deterministic encryption which is what we want - the 795 same filename must encrypt to the same thing otherwise we can't find 796 it on the cloud storage system. 797 798 This means that 799 800 * filenames with the same name will encrypt the same 801 * filenames which start the same won't have a common prefix 802 803 This uses a 32 byte key (256 bits) and a 16 byte (128 bits) IV both of 804 which are derived from the user password. 805 806 After encryption they are written out using a modified version of 807 standard `base32` encoding as described in RFC4648. The standard 808 encoding is modified in two ways: 809 810 * it becomes lower case (no-one likes upper case filenames!) 811 * we strip the padding character `=` 812 813 `base32` is used rather than the more efficient `base64` so rclone can be 814 used on case insensitive remotes (e.g. Windows, Box, Dropbox, Onedrive etc). 815 816 ### Key derivation 817 818 Rclone uses `scrypt` with parameters `N=16384, r=8, p=1` with an 819 optional user supplied salt (password2) to derive the 32+32+16 = 80 820 bytes of key material required. If the user doesn't supply a salt 821 then rclone uses an internal one. 822 823 `scrypt` makes it impractical to mount a dictionary attack on rclone 824 encrypted data. For full protection against this you should always use 825 a salt. 826 827 ## SEE ALSO 828 829 * [rclone cryptdecode](/commands/rclone_cryptdecode/) - Show forward/reverse mapping of encrypted filenames