Compare commits

...

147 Commits

Author SHA1 Message Date
Hardcore Sushi 5144947a4a
Media player fixes: better handling of RTL & orientation 2 weeks ago
Muhmmad14333653 6b52eed9d0
update arabic translation 2 weeks ago
Muhmmad14333653 2a257d91d0
update Arabic translation 2 weeks ago
Hardcore Sushi f837556af5
Fix explorer info bar color in dark mode 2 weeks ago
Hardcore Sushi b7ab267d16
Arabic translation 2 weeks ago
Hardcore Sushi 5ea0b8ad41
Actually fix camera icon tint bug 2 weeks ago
Hardcore Sushi ec348383c6
Fix camera icon tint bug 2 weeks ago
Hardcore Sushi c8d266150c
Fix explorer menu display 2 weeks ago
CyanWolf 4bbc9360b4
Update Spanish translation 4 weeks ago
Hardcore Sushi 8aa2be2b05
Update libgocryptfs & Small UX fix 4 weeks ago
Hardcore Sushi e2248220c4
DroidFS v1.10.0 4 weeks ago
Hardcore Sushi 7959b20b3f
Update libgocryptfs 4 weeks ago
solokot 8cebe499f0
Updated Russian translation 4 weeks ago
cyanwolfg a22b9d8fa8
Update Spanish translation 4 weeks ago
Hardcore Sushi cba1418417
Fix move operation 4 weeks ago
Hardcore Sushi b6b8bba666
Save checkbox state if opening volume fails 4 weeks ago
Hardcore Sushi e00abdf5bb
Switch to Kotlin coroutines 4 weeks ago
Hardcore Sushi 72cce1d7e1
Show a fingerprint icon when password hash is saved 1 month ago
Hardcore Sushi 55b0ac0daa
Prefill text field with current name when renaming a volume 1 month ago
Hardcore Sushi 53f28e9475
Pin passwords 1 month ago
Hardcore Sushi f1d4b07726
Show total number of selected items 1 month ago
Hardcore Sushi 339309b00d
Fix image viewer rotation handling 1 month ago
Hardcore Sushi e6a1285e0a
Fix camera output rotation 1 month ago
Hardcore Sushi ab48f9219b
CameraActivity: only bind 2 use cases at most + some other fixes 1 month ago
Hardcore Sushi c521c7f998
Open default volume on application startup 1 month ago
Hardcore Sushi 1d13dfbde3
Always show total size & Add some explorer info bar translations 1 month ago
Hardcore Sushi 36ab66fb43
Show number of files & folders in current directory 1 month ago
Hardcore Sushi 1caabc2554
Fix explorer layouts 1 month ago
Hardcore Sushi f541504e07
Refactor RecyclerView adapters 1 month ago
Hardcore Sushi 4de5b41102
Thumbnails cache & Don't do full reload on selection change 1 month ago
Hardcore Sushi 4f9aa55dfe
Explorer grid layout 1 month ago
Hardcore Sushi 91de54018d
Prompt for password if fingerprint authentification fails 2 months ago
Hardcore Sushi 2697eaf11b
Spanish translation 2 months ago
Hardcore Sushi 9e69805ade
Update ptbr translation 2 months ago
Hardcore Sushi 18d0f50094
Update to libpdfviewer 13 2 months ago
Hardcore Sushi e32e106ce3
Fix video player controls 2 months ago
Hardcore Sushi 4608a7a165
Fix MainSettingsFragment crash 2 months ago
Hardcore Sushi 985be2de59
Add HEIC to the image extension list 2 months ago
solokot f07d99efed
Updated Russian translation 2 months ago
Hardcore Sushi 4a55d826d9
Volume renaming 2 months ago
Hardcore Sushi 2ee7a5b871
Allow changing thumbnail max size 2 months ago
Hardcore Sushi 72321b8ec5
Switch to StyledPlayerView 2 months ago
Hardcore Sushi 7226cc8218
Fix UI bug on too long volume paths 2 months ago
Hardcore Sushi 55be5cd0e7
DroidFS v1.9.0 2 months ago
solokot 3c4515e4e9
Update Russian translation 2 months ago
Hardcore Sushi 29eb34e1d5
New screenshots 2 months ago
Hardcore Sushi d6f727a142
Fix error message when creating volume on external SD card 2 months ago
Hardcore Sushi 6d5fc465c7
Fix UI bug on alert dialogs 2 months ago
Hardcore Sushi ed0b5eb483
Add PDF in OpenAs dialog & libpdfviewer dialog crash fix 2 months ago
Hardcore Sushi fd0296f801
Update libpdfviewer 2 months ago
Hardcore Sushi 58391802be
More accurate directory size 2 months ago
Hardcore Sushi e01b5a3098
Volume copy 2 months ago
Hardcore Sushi bea0906f65
Display file name on video player 2 months ago
Hardcore Sushi 71a314b0a0
New home UI 2 months ago
Hardcore Sushi 842667cdee
Update ptbr translation 3 months ago
Hardcore Sushi e5bcc5cfc2
Update dependencies 3 months ago
Hardcore Sushi 32508344fe
Update PGP key 3 months ago
Hardcore Sushi ee3df7c3bf
Icon for PDF files 3 months ago
Hardcore Sushi b18232615d
PDF viewer 3 months ago
Hardcore Sushi 83efc53edc
Update PGP keyserver 4 months ago
Hardcore Sushi f546e64c34
ImageViwer: retrieve screen size with Resources.getSystem().displayMetrics 4 months ago
Hardcore Sushi 822aba9481
Better build explanation 4 months ago
Hardcore Sushi 3007bf756c
Fix video player UI bug 4 months ago
solokot 87cd88232e
Update russian translation 4 months ago
Hardcore Sushi 832fd1d34b
DoubleTapPlayerView 4 months ago
Hardcore Sushi 3ae7e4df70
Remove DialogSingleChoiceAdapter 4 months ago
Hardcore Sushi 55883172a1
Consider WebP as image 4 months ago
Hardcore Sushi b366fa1877
Fill viewport in text editor 4 months ago
Hardcore Sushi 95eed07719
Natural file name sorting 4 months ago
Hardcore Sushi f15b17c936
Fix scroll issue on OpenActivity & ChangePasswordActivity 4 months ago
Hardcore Sushi 5d6f53b37a
Change icon of mode button when switching between photo & video mode 4 months ago
Hardcore Sushi 23d017780f
Flush previous image before loading the next in ImageViewer 5 months ago
Hardcore Sushi bee2997f90
Update dependencies 5 months ago
Hardcore Sushi 80c5277936
Reset flash state when switching to back camera in video mode 5 months ago
solokot a9d4284b43
Updated Russian translation 5 months ago
Hardcore Sushi 7ca9398766
Fix size formatting 5 months ago
Hardcore Sushi bd4c935c4c
Downscale image when decoding with BitmapFactory 5 months ago
Hardcore Sushi b65ee230be
Fix flash and timer for video recording 5 months ago
Hardcore Sushi 8b4adfbe21
Update dependencies 5 months ago
Hardcore Sushi 57e93f0b49
Fix video player auto rotation 5 months ago
Hang Hang be802aa5af
Legacy fullscreen mode option & Button to toggle screen orientation in video player 5 months ago
Hardcore Sushi d1a556b8c6
Invalidate options menu when changing explorer elements 5 months ago
solokot 83525159e3
Updated Russian translation to v1.7.0 6 months ago
Hardcore Sushi 4f8bf860e0
Don't use DayNight themes 6 months ago
Hardcore Sushi 2ee0c679fb
Fix bugs when renaming 6 months ago
Hardcore Sushi 23a20b7ddb
Fix delete icon color bug 6 months ago
Hardcore Sushi fd5ddc02b1
Thumbnails 6 months ago
Hardcore Sushi e3df7be3b5
Switch explorer from ListView to RecyclerView 6 months ago
Hardcore Sushi 65ecdd19ca
Remove some deprecation warnings 6 months ago
Hardcore Sushi d3f0d059f8
Switch from Cyanea to Themes 6 months ago
Hardcore Sushi d572a8d2dc
Update dependencies 6 months ago
Hardcore Sushi 01a9c261f5
Fix image viewer 6 months ago
Hardcore Sushi 1cab607fa1
Decode images with BitmapFactory instead of Glide 7 months ago
Hardcore Sushi 26153d44b9
Update description & build process for F-Droid 7 months ago
solokot 2d0ec3529d
Updated Russian translation 7 months ago
Hardcore Sushi e96d4724d3
Adapt to write access at Android/data/sushi.hardcore.droidfs on SD cards 7 months ago
Hardcore Sushi 6158b36c9f
Fix fingerprint checkbox behavior 7 months ago
Hardcore Sushi b273fa828b
Upgrade CameraX 7 months ago
Hardcore Sushi 5349d40da9
Add "Open as" option in explorer menu 7 months ago
Hardcore Sushi c858d556d5
Exoplayer repeat & shuffle controls 7 months ago
Hardcore Sushi e47d9f4548
XChaCha20-Ploy1305 support 7 months ago
Hardcore Sushi a377b61240
Use FFmpeg shared libraries & Update build instructions 7 months ago
Hardcore Sushi 497c22edc1
Fix recorded video rotation 7 months ago
Hardcore Sushi dc89c02b9f
Video recording 7 months ago
Hardcore Sushi fd98c42014
DroidFS v1.5.4 9 months ago
solokot 0fdd889697
Update Russian translation to v1.5.3 9 months ago
Hardcore Sushi b9a7411cdb
Remove some other deprecation warnings 9 months ago
Hardcore Sushi d36910ac19
Fix proguard rules 9 months ago
Hardcore Sushi dc62f73188
Update gradle plugin 9 months ago
Hardcore Sushi 4ede408aac
Remove some deprecation warnings 9 months ago
Hardcore Sushi 52eab2a2df
Fix a nasty bug with playlists 9 months ago
Hardcore Sushi b65ac79175
Update dependencies & Add camera capture mode settings 9 months ago
Hardcore Sushi ba42938f5a
Upgrade to OpenSSL v1.1.1l 9 months ago
Hardcore Sushi 54b6d03335
Upgrade to libgocryptfs v2.1 9 months ago
solokot de0f45a05c
Update Russian translation 9 months ago
Hardcore Sushi 6f49cec157
Delete root directory from background service when wiping 9 months ago
Hardcore Sushi faeab5d3f6
Add ".properties" to the text file extensions list 9 months ago
Hardcore Sushi c2c1e4b1e9
Delete file & folder on wipe 9 months ago
Anon7250 5cc9abfd76
Adding an 'Import/Encrypt Folder' button 9 months ago
Hardcore Sushi 60ba9531be
Upgrade gradle 9 months ago
mezysinc 47bd751b66
update ptbr 10 months ago
Hardcore Sushi a4a1454d91
Update dependencies 10 months ago
solokot 90c63f4599
Updated Russian language 10 months ago
Hardcore Sushi 5951237f2c
Optional folder mapping 10 months ago
mezysinc 7d5eb19eb7
ptbr update 11 months ago
Hardcore Sushi b8646b0fff
Upgrade libgocryptfs 11 months ago
Hardcore Sushi cffc24e4ba
Create new file in the current directory 11 months ago
Hardcore Sushi 286253c542
Set permissions when creating files and folders 11 months ago
Hardcore Sushi f58517e904
Thread-safe directory listing 11 months ago
Hardcore Sushi e5ed825557
Add F-Droid download links in README 11 months ago
Hardcore Sushi 2c69c59331
Specify NDK v21 in README 11 months ago
Hardcore Sushi e017fa85bd
Update README for v1.5.0 11 months ago
Hardcore Sushi 44a3511cd1
Add APK splits configuration 11 months ago
solokot e47592a794
Updated Russian language 11 months ago
Hardcore Sushi 401449d40a
Sort and display explorer elements only after recursive mapping 11 months ago
Hardcore Sushi 652fc98ba4
Reordering sort by menu items 11 months ago
Hardcore Sushi 4202106dcc
Remove sort_orders_values from translations 11 months ago
Hardcore Sushi 71d9447467
Migrate to viewBinding 11 months ago
Hardcore Sushi 1719c192a8
Update README: openssl-1.1.1k & libgocryptfs init 11 months ago
Hardcore Sushi 30508dd7e1
Add title to menu items 11 months ago
Hardcore Sushi ae93d78615
Switch to external libgocryptfs 11 months ago
Hardcore Sushi 5da1c05c7b
Add limitations section in README 12 months ago
Hardcore Sushi b0145e0192
Remove android:onClick properties 12 months ago
Hardcore Sushi 9cf3e71fd2
Ask storage permissions only when using external volumes 12 months ago
Hardcore Sushi 9f8b653cc7
Safe volume directory picking 12 months ago
Hardcore Sushi fcd382ca8b
Update gradle dependencies 12 months ago
Hardcore Sushi a4db2740a1
Fix crash when deleting a lonely image 1 year ago
  1. 6
      .gitmodules
  2. 105
      README.md
  3. 56
      app/CMakeLists.txt
  4. 59
      app/build.gradle
  5. 2
      app/ffmpeg/.gitignore
  6. 94
      app/ffmpeg/build.sh
  7. 1
      app/libgocryptfs
  8. 4
      app/libgocryptfs/.gitignore
  9. 75
      app/libgocryptfs/build.sh
  10. 168
      app/libgocryptfs/gocryptfs_internal/cryptocore/cryptocore.go
  11. 29
      app/libgocryptfs/gocryptfs_internal/cryptocore/hkdf.go
  12. 32
      app/libgocryptfs/gocryptfs_internal/cryptocore/nonce.go
  13. 55
      app/libgocryptfs/gocryptfs_internal/cryptocore/randprefetch.go
  14. 11
      app/libgocryptfs/gocryptfs_internal/eme/.travis.yml
  15. 21
      app/libgocryptfs/gocryptfs_internal/eme/LICENSE
  16. 111
      app/libgocryptfs/gocryptfs_internal/eme/README.md
  17. 3
      app/libgocryptfs/gocryptfs_internal/eme/benchmark.bash
  18. 206
      app/libgocryptfs/gocryptfs_internal/eme/eme.go
  19. BIN
      app/libgocryptfs/gocryptfs_internal/eme/paper-eme-fig2.png
  20. 97
      app/libgocryptfs/gocryptfs_internal/exitcodes/exitcodes.go
  21. 22
      app/libgocryptfs/gocryptfs_internal/jacobsa_crypto/.gitignore
  22. 4
      app/libgocryptfs/gocryptfs_internal/jacobsa_crypto/.travis.yml
  23. 202
      app/libgocryptfs/gocryptfs_internal/jacobsa_crypto/LICENSE
  24. 10
      app/libgocryptfs/gocryptfs_internal/jacobsa_crypto/README.md
  25. 23
      app/libgocryptfs/gocryptfs_internal/jacobsa_crypto/cmac/const.go
  26. 19
      app/libgocryptfs/gocryptfs_internal/jacobsa_crypto/cmac/doc.go
  27. 170
      app/libgocryptfs/gocryptfs_internal/jacobsa_crypto/cmac/hash.go
  28. 47
      app/libgocryptfs/gocryptfs_internal/jacobsa_crypto/cmac/hash_32bit.go
  29. 55
      app/libgocryptfs/gocryptfs_internal/jacobsa_crypto/cmac/hash_64bit.go
  30. 65
      app/libgocryptfs/gocryptfs_internal/jacobsa_crypto/cmac/subkey.go
  31. 18
      app/libgocryptfs/gocryptfs_internal/jacobsa_crypto/common/doc.go
  32. 26
      app/libgocryptfs/gocryptfs_internal/jacobsa_crypto/common/msb.go
  33. 36
      app/libgocryptfs/gocryptfs_internal/jacobsa_crypto/common/pad_block.go
  34. 37
      app/libgocryptfs/gocryptfs_internal/jacobsa_crypto/common/shiftleft.go
  35. 33
      app/libgocryptfs/gocryptfs_internal/jacobsa_crypto/common/xor.go
  36. 48
      app/libgocryptfs/gocryptfs_internal/jacobsa_crypto/siv/dbl.go
  37. 103
      app/libgocryptfs/gocryptfs_internal/jacobsa_crypto/siv/decrypt.go
  38. 21
      app/libgocryptfs/gocryptfs_internal/jacobsa_crypto/siv/doc.go
  39. 124
      app/libgocryptfs/gocryptfs_internal/jacobsa_crypto/siv/encrypt.go
  40. 98
      app/libgocryptfs/gocryptfs_internal/jacobsa_crypto/siv/s2v.go
  41. 44
      app/libgocryptfs/gocryptfs_internal/jacobsa_crypto/siv/xorend.go
  42. 119
      app/libgocryptfs/gocryptfs_internal/nametransform/diriv.go
  43. 153
      app/libgocryptfs/gocryptfs_internal/nametransform/longnames.go
  44. 133
      app/libgocryptfs/gocryptfs_internal/nametransform/names.go
  45. 64
      app/libgocryptfs/gocryptfs_internal/nametransform/pad16.go
  46. 7
      app/libgocryptfs/gocryptfs_internal/siv_aead/benchmark.bash
  47. 97
      app/libgocryptfs/gocryptfs_internal/siv_aead/siv_aead.go
  48. 8
      app/libgocryptfs/gocryptfs_internal/stupidgcm/autherr.go
  49. 3
      app/libgocryptfs/gocryptfs_internal/stupidgcm/benchmark.bash
  50. 28
      app/libgocryptfs/gocryptfs_internal/stupidgcm/locking.go
  51. 28
      app/libgocryptfs/gocryptfs_internal/stupidgcm/prefer.go
  52. 250
      app/libgocryptfs/gocryptfs_internal/stupidgcm/stupidgcm.go
  53. 52
      app/libgocryptfs/gocryptfs_internal/stupidgcm/without_openssl.go
  54. 1003
      app/libgocryptfs/main.go
  55. 325
      app/libgocryptfs/rewrites/configfile/config_file.go
  56. 74
      app/libgocryptfs/rewrites/configfile/feature_flags.go
  57. 101
      app/libgocryptfs/rewrites/configfile/scrypt.go
  58. 39
      app/libgocryptfs/rewrites/contentenc/bpool.go
  59. 335
      app/libgocryptfs/rewrites/contentenc/content.go
  60. 77
      app/libgocryptfs/rewrites/contentenc/file_header.go
  61. 71
      app/libgocryptfs/rewrites/contentenc/intrablock.go
  62. 135
      app/libgocryptfs/rewrites/contentenc/offsets.go
  63. 29
      app/libgocryptfs/rewrites/syscallcompat/emulate.go
  64. 151
      app/libgocryptfs/rewrites/syscallcompat/getdents_linux.go
  65. 1
      app/libgocryptfs/rewrites/syscallcompat/getdents_other.go
  66. 21
      app/libgocryptfs/rewrites/syscallcompat/helpers.go
  67. 44
      app/libgocryptfs/rewrites/syscallcompat/open_nofollow.go
  68. 221
      app/libgocryptfs/rewrites/syscallcompat/sys_common.go
  69. 215
      app/libgocryptfs/rewrites/syscallcompat/sys_darwin.go
  70. 153
      app/libgocryptfs/rewrites/syscallcompat/sys_linux.go
  71. 26
      app/libgocryptfs/rewrites/syscallcompat/unix2syscall_darwin.go
  72. 28
      app/libgocryptfs/rewrites/syscallcompat/unix2syscall_linux.go
  73. 12
      app/proguard-rules.pro
  74. 68
      app/src/main/AndroidManifest.xml
  75. 59
      app/src/main/java/sushi/hardcore/droidfs/BaseActivity.kt
  76. 560
      app/src/main/java/sushi/hardcore/droidfs/CameraActivity.kt
  77. 322
      app/src/main/java/sushi/hardcore/droidfs/ChangePasswordActivity.kt
  78. 11
      app/src/main/java/sushi/hardcore/droidfs/ColoredApplication.kt
  79. 79
      app/src/main/java/sushi/hardcore/droidfs/ConstValues.kt
  80. 206
      app/src/main/java/sushi/hardcore/droidfs/CreateActivity.kt
  81. 259
      app/src/main/java/sushi/hardcore/droidfs/FingerprintProtector.kt
  82. 149
      app/src/main/java/sushi/hardcore/droidfs/GocryptfsVolume.kt
  83. 55
      app/src/main/java/sushi/hardcore/droidfs/LoadingTask.kt
  84. 671
      app/src/main/java/sushi/hardcore/droidfs/MainActivity.kt
  85. 286
      app/src/main/java/sushi/hardcore/droidfs/OpenActivity.kt
  86. 13
      app/src/main/java/sushi/hardcore/droidfs/SensorOrientationListener.kt
  87. 133
      app/src/main/java/sushi/hardcore/droidfs/SettingsActivity.kt
  88. 53
      app/src/main/java/sushi/hardcore/droidfs/Volume.kt
  89. 292
      app/src/main/java/sushi/hardcore/droidfs/VolumeActionActivity.kt
  90. 31
      app/src/main/java/sushi/hardcore/droidfs/VolumeDatabase.kt
  91. 33
      app/src/main/java/sushi/hardcore/droidfs/adapters/DialogSingleChoiceAdapter.kt
  92. 279
      app/src/main/java/sushi/hardcore/droidfs/adapters/ExplorerElementAdapter.kt
  93. 7
      app/src/main/java/sushi/hardcore/droidfs/adapters/IconTextDialogAdapter.kt
  94. 1
      app/src/main/java/sushi/hardcore/droidfs/adapters/OpenAsDialogAdapter.kt
  95. 111
      app/src/main/java/sushi/hardcore/droidfs/adapters/SavedVolumesAdapter.kt
  96. 80
      app/src/main/java/sushi/hardcore/droidfs/adapters/SelectableAdapter.kt
  97. 111
      app/src/main/java/sushi/hardcore/droidfs/adapters/VolumeAdapter.kt
  98. 6
      app/src/main/java/sushi/hardcore/droidfs/add_volume/Action.kt
  99. 79
      app/src/main/java/sushi/hardcore/droidfs/add_volume/AddVolumeActivity.kt
  100. 207
      app/src/main/java/sushi/hardcore/droidfs/add_volume/CreateVolumeFragment.kt
  101. Some files were not shown because too many files have changed in this diff Show More

6
.gitmodules vendored

@ -0,0 +1,6 @@
[submodule "app/libgocryptfs"]
path = app/libgocryptfs
url = https://forge.chapril.org/hardcoresushi/libgocryptfs.git
[submodule "libpdfviewer"]
path = libpdfviewer
url = https://forge.chapril.org/hardcoresushi/libpdfviewer.git

105
README.md

@ -8,7 +8,7 @@ It currently only works with [gocryptfs](https://github.com/rfjakob/gocryptfs) b
<img src="https://forge.chapril.org/hardcoresushi/DroidFS/raw/branch/master/fastlane/metadata/android/en-US/images/phoneScreenshots/3.png" height="500">
</p>
# Disclamer
# Disclaimer
DroidFS is provided "as is", without any warranty of any kind.
It shouldn't be considered as an absolute safe way to store files.
DroidFS cannot protect you from screen recording apps, keyloggers, apk backdooring, compromised root accesses, memory dumps etc.
@ -42,13 +42,27 @@ It is strongly recommended to read the documentation of a feature before enablin
* Features requiring temporary writing of the plain file to disk (DroidFS internal storage). This file could be read by apps with root access or by physical access if your device is not encrypted.
# Download
You can download the latest version in the Releases section. All APKs from v1.3.0 are signed with my PGP key available on keyservers:
<a href="https://f-droid.org/packages/sushi.hardcore.droidfs">
<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png" height="75">
</a>
`gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 007F84120107191E` \
Fingerprint: `BD5621479E7B74D36A405BE8007F84120107191E` \
You can download DroidFS from [F-Droid](https://f-droid.org/packages/sushi.hardcore.droidfs) or from the "Releases" section in the repo.
APKs available here are signed with my PGP key available on keyservers:
`gpg --keyserver hkps://keyserver.ubuntu.com --recv-keys AFE384344A45E13A` \
Fingerprint: `B64E FE86 CEE1 D054 F082 1711 AFE3 8434 4A45 E13A` \
Email: `Hardcore Sushi <hardcore.sushi@disroot.org>`
To verify APKs: `gpg --verify <ASC file> <APK file>`
To verify APKs, save the PGP-signed message to a file and run `gpg --verify <the file>`. __Don't install any APK if the verification fails !__
If the signature is valid, you can compare the SHA256 checksums with:
```
sha256sum <APK file>
```
__Don't install the APK if the checksums don't match!__
F-Droid APKs should be signed with the F-Droid key. More details [here](https://f-droid.org/docs/Release_Channels_and_Signing_Keys).
# Permissions
DroidFS need some permissions to work properly. Here is why:
@ -61,62 +75,91 @@ DroidFS need some permissions to work properly. Here is why:
Required to encrypt/decrypt password hashes using a fingerprint protected key.
</li>
<li><h4>Camera:</h4>
Needed to take photos directly from DroidFS to import them securely. You can deny this permission if you don't want to use it.
Needed to take photos & videos directly encrypted inside DroidFS. You can deny this permission if you don't want to use it.
</li>
<li><h4>Record audio:</h4>
Required if you want sound on video recorded with DroidFS.
</li>
</ul>
# Limitations
DroidFS use some parts of the original gocryptfs code, which is designed to run on Linux x86 systems: it accesses the underlying file system with file paths and syscalls. However in Android, you can't access other apps files with file paths. Instead, you must use the [ContentProvider](https://developer.android.com/guide/topics/providers/content-providers) API. And obviously, the original gocryptfs code doesn't work with this API. This is why DroidFS can't open volumes provided by other applications, such as cloud storage clients. You can only use DroidFS with volumes located on shared storage or in the app's internal storage (hidden volumes). External storage such as SD cards are only supported in read-only access for now.
# Build
Most of the original gocryptfs code was used as is (written in Go) and compiled to native code. That's why you need [Go](https://golang.org) and the [Android Native Development Kit (NDK)](https://developer.android.com/ndk/) to build DroidFS from source.
#### Install Requirements
- [Android Studio](https://developer.android.com/studio/)
- [Android NDK and CMake](https://developer.android.com/studio/projects/install-ndk)
- [Go](https://golang.org/doc/install) (on debian: `$ sudo apt-get install golang-go`)
#### Install dependencies
On debian:
```
$ sudo apt-get install build-essential pkg-config libssl-dev
```
Install [Go](https://golang.org/doc/install):
```
$ sudo apt-get install golang-go
```
You also need to install the Android SDK build tools and the [Android NDK](https://developer.android.com/studio/projects/install-ndk).
#### Download Sources
```
$ git clone https://github.com/hardcore-sushi/DroidFS.git
$ git clone --recurse-submodules https://github.com/hardcore-sushi/DroidFS.git
$ cd DroidFS
```
Gocryptfs need OpenSSL to work:
[libgocryptfs](https://forge.chapril.org/hardcoresushi/libgocryptfs) needs OpenSSL:
```
$ cd DroidFS/app/libgocryptfs
$ wget https://www.openssl.org/source/openssl-1.1.1j.tar.gz
$ cd app/libgocryptfs
$ wget https://www.openssl.org/source/openssl-1.1.1n.tar.gz
```
Verify OpenSSL signature:
```
$ wget https://www.openssl.org/source/openssl-1.1.1j.tar.gz.asc
$ gpg --verify openssl-1.1.1j.tar.gz.asc openssl-1.1.1j.tar.gz
$ wget https://www.openssl.org/source/openssl-1.1.1n.tar.gz.asc
$ gpg --verify openssl-1.1.1n.tar.gz.asc openssl-1.1.1n.tar.gz
```
Continue **ONLY** if the signature is **VALID**.
```
$ tar -xvzf openssl-1.1.1j.tar.gz
$ tar -xvzf openssl-1.1.1n.tar.gz
```
#### Build
First, we need to build libgocryptfs.<br>
For this, we will need to install some dependencies:
DroidFS also need [FFmpeg](https://ffmpeg.org) to record encrypted video:
```
$ sudo apt-get install libcrypto++-dev libssl-dev pkg-config
$ cd app/ffmpeg
$ git clone --depth=1 https://git.ffmpeg.org/ffmpeg.git
```
And also Go dependencies:
#### Generate a keystore
APKs must be signed to be installed on an Android device. If you don't already have a keystore, you can generate one by running:
```
$ go get golang.org/x/sys/unix golang.org/x/sys/cpu golang.org/x/crypto/hkdf
$ keytool -genkey -keystore <output file> -alias <key alias> -keyalg EC -validity 10000
```
Then, retrieve your Android NDK installation path, usually someting like "/home/\<user\>/AndroidSDK/ndk/\<NDK version\>". We can now start the build process:
#### Build
Retrieve your Android NDK installation path, usually something like "/home/\<user\>/Android/SDK/ndk/\<NDK version\>". Now you can build libgocryptfs:
```
$ cd DroidFS/app/libgocryptfs
$ env ANDROID_NDK_HOME="<your ndk path>" OPENSSL_PATH="./openssl-1.1.1j" ./build.sh
$ env ANDROID_NDK_HOME="<your ndk path>" OPENSSL_PATH="./openssl-1.1.1n" ./build.sh
```
Then, open the DroidFS project with Android Studio.<br>
If a device (virtual or physical) is connected, just click on "Run".<br>
If you want to generate a signed APK, you can follow this [post](https://stackoverflow.com/a/28938286).
Then FFmpeg:
```
$ cd app/ffmpeg
$ env ANDROID_NDK_HOME="<your ndk path>" ./build.sh ffmpeg
```
Finally, compile the app:
```
$ ./gradlew assembleRelease
```
If the build succeeds, you will find the unsigned APKs in `app/build/outputs/apk/release/`. You need to sign them in order to install the app:
```
$ apksigner sign --out droidfs.apk -v --ks <keystore> app/build/outputs/apk/release/<unsigned apk file>
```
Now you can install `droidfs.apk` on your device.
# Third party code
Thanks to these open source projects that DroidFS uses:
### Modified code:
- [gocryptfs](https://github.com/rfjakob/gocryptfs) to encrypt your data
- [libgocryptfs](https://forge.chapril.org/hardcoresushi/libgocryptfs) (forked from [gocryptfs](https://github.com/rfjakob/gocryptfs)) to encrypt your data
- [libpdfviewer](https://forge.chapril.org/hardcoresushi/libpdfviewer) (forked from [PdfViewer](https://github.com/GrapheneOS/PdfViewer)) to open PDF files
- [DoubleTapPlayerView](https://github.com/vkay94/DoubleTapPlayerView) to add double-click controls to the video player
### Borrowed code:
- [MaterialFiles](https://github.com/zhanghai/MaterialFiles) for kotlin natural sorting implementation
### Libraries:
- [Cyanea](https://github.com/jaredrummler/Cyanea) to customize UI
- [Glide](https://github.com/bumptech/glide/) to display pictures
- [ExoPlayer](https://github.com/google/ExoPlayer) to play media files

56
app/CMakeLists.txt

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.4.1)
cmake_minimum_required(VERSION 3.10)
add_library(
gocryptfs
@ -23,6 +23,56 @@ target_link_libraries(
gocryptfs
)
include_directories(
${PROJECT_SOURCE_DIR}/libgocryptfs/build/${ANDROID_ABI}/
add_library(
avformat
SHARED
IMPORTED
)
set_target_properties(
avformat
PROPERTIES IMPORTED_LOCATION
${PROJECT_SOURCE_DIR}/ffmpeg/build/${ANDROID_ABI}/libavformat/libavformat.so
)
add_library(
avcodec
SHARED
IMPORTED
)
set_target_properties(
avcodec
PROPERTIES IMPORTED_LOCATION
${PROJECT_SOURCE_DIR}/ffmpeg/build/${ANDROID_ABI}/libavcodec/libavcodec.so
)
add_library(
avutil
SHARED
IMPORTED
)
set_target_properties(
avutil
PROPERTIES IMPORTED_LOCATION
${PROJECT_SOURCE_DIR}/ffmpeg/build/${ANDROID_ABI}/libavutil/libavutil.so
)
add_library(
mux
SHARED
src/main/native/libmux.c
)
target_link_libraries(
mux
avformat
avcodec
avutil
)
include_directories(
${PROJECT_SOURCE_DIR}/libgocryptfs/build/${ANDROID_ABI}
${PROJECT_SOURCE_DIR}/ffmpeg/build/${ANDROID_ABI}
)

59
app/build.gradle

@ -1,11 +1,10 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "30.0.3"
ndkVersion "21.4.7075529"
compileSdkVersion 31
buildToolsVersion "31"
ndkVersion "23.1.7779620"
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
@ -14,12 +13,22 @@ android {
defaultConfig {
applicationId "sushi.hardcore.droidfs"
minSdkVersion 21
//noinspection ExpiredTargetSdkVersion
targetSdkVersion 29
versionCode 13
versionName "1.4.5"
versionCode 27
versionName "1.10.1"
ndk {
abiFilters 'x86_64', 'armeabi-v7a', 'arm64-v8a'
abiFilters "x86", "x86_64", "armeabi-v7a", "arm64-v8a"
}
}
if (!file("fdroid").exists()) {
splits {
abi {
enable true
universalApk true
}
}
}
@ -27,6 +36,10 @@ android {
variant.resValue "string", "versionName", variant.versionName
}
buildFeatures {
viewBinding true
}
buildTypes {
release {
minifyEnabled true
@ -43,27 +56,29 @@ android {
}
dependencies {
implementation project(":libpdfviewer:app")
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "androidx.core:core-ktx:1.3.2"
implementation "androidx.appcompat:appcompat:1.2.0"
implementation "androidx.constraintlayout:constraintlayout:2.0.4"
implementation 'androidx.core:core-ktx:1.7.0'
implementation "androidx.appcompat:appcompat:1.4.1"
implementation "androidx.constraintlayout:constraintlayout:2.1.3"
implementation "androidx.sqlite:sqlite-ktx:2.1.0"
implementation "androidx.preference:preference-ktx:1.1.1"
implementation "androidx.sqlite:sqlite-ktx:2.2.0"
implementation "androidx.preference:preference-ktx:1.2.0"
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
implementation "com.jaredrummler:cyanea:1.0.2"
implementation "com.github.bumptech.glide:glide:4.11.0"
implementation "androidx.biometric:biometric:1.1.0"
implementation 'com.google.android.material:material:1.5.0'
implementation "com.github.bumptech.glide:glide:4.12.0"
implementation "androidx.biometric:biometric-ktx:1.2.0-alpha04"
def exoplayer_version = "2.13.2"
def exoplayer_version = "2.17.1"
implementation "com.google.android.exoplayer:exoplayer-core:$exoplayer_version"
implementation "com.google.android.exoplayer:exoplayer-ui:$exoplayer_version"
def camerax_v1 = "1.1.0-alpha03"
implementation "androidx.camera:camera-camera2:$camerax_v1"
implementation "androidx.camera:camera-lifecycle:$camerax_v1"
def camerax_v2 = "1.0.0-alpha23"
implementation "androidx.camera:camera-view:$camerax_v2"
implementation "androidx.camera:camera-extensions:$camerax_v2"
implementation "androidx.concurrent:concurrent-futures:1.1.0"
def camerax_version = "1.1.0-beta03"
implementation "androidx.camera:camera-camera2:$camerax_version"
implementation "androidx.camera:camera-lifecycle:$camerax_version"
implementation "androidx.camera:camera-view:$camerax_version"
implementation "androidx.camera:camera-extensions:$camerax_version"
}

2
app/ffmpeg/.gitignore vendored

@ -0,0 +1,2 @@
ffmpeg
build

94
app/ffmpeg/build.sh

@ -0,0 +1,94 @@
#!/bin/bash
if [ -z ${ANDROID_NDK_HOME+x} ]; then
echo "Error: \$ANDROID_NDK_HOME is not defined." >&2
exit 1
elif [ $# -lt 1 ]; then
echo "Usage: $0 <FFmpeg source directory> [<ABI>]" >&2
exit 1
else
FFMPEG_DIR=$1
compile_for_arch() {
echo "Compiling for $1..."
case $1 in
"x86_64")
CFN="x86_64-linux-android21-clang"
ARCH="x86_64"
;;
"x86")
CFN="i686-linux-android21-clang"
ARCH="i686"
EXTRA_FLAGS="--disable-asm"
;;
"arm64-v8a")
CFN="aarch64-linux-android21-clang"
ARCH="aarch64"
;;
"armeabi-v7a")
CFN="armv7a-linux-androideabi19-clang"
ARCH="arm"
;;
esac
(cd $FFMPEG_DIR && make clean;
./configure \
--cc="$CFN" \
--cxx="$CFN++" \
--arch="$ARCH" \
$EXTRA_FLAGS \
--target-os=android \
--enable-cross-compile \
--enable-version3 \
--disable-programs \
--disable-static \
--enable-shared \
--disable-bsfs \
--disable-parsers \
--disable-demuxers \
--disable-muxers \
--enable-muxer="mp4" \
--disable-decoders \
--disable-encoders \
--enable-encoder="aac" \
--disable-avdevice \
--disable-swresample \
--disable-swscale \
--disable-postproc \
--disable-avfilter \
--disable-network \
--disable-doc \
--disable-htmlpages \
--disable-manpages \
--disable-podpages \
--disable-txtpages \
--disable-sndio \
--disable-schannel \
--disable-securetransport \
--disable-xlib \
--disable-zlib \
--disable-cuvid \
--disable-nvenc \
--disable-vdpau \
--disable-videotoolbox \
--disable-audiotoolbox \
--disable-appkit \
--disable-alsa \
--disable-debug \
>/dev/null &&
make -j $(nproc --all) >/dev/null) &&
mkdir -p build/$1/libavformat build/$1/libavcodec build/$1/libavutil &&
cp $FFMPEG_DIR/libavformat/*.h $FFMPEG_DIR/libavformat/libavformat.so build/$1/libavformat &&
cp $FFMPEG_DIR/libavcodec/*.h $FFMPEG_DIR/libavcodec/libavcodec.so build/$1/libavcodec &&
cp $FFMPEG_DIR/libavutil/*.h $FFMPEG_DIR/libavutil/libavutil.so build/$1/libavutil ||
exit 1
}
export PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
if [ $# -eq 2 ]; then
compile_for_arch $2
else
declare -a ABIs=("x86_64" "x86" "arm64-v8a" "armeabi-v7a")
for abi in ${ABIs[@]}; do
compile_for_arch $abi
done
fi
fi

1
app/libgocryptfs

@ -0,0 +1 @@
Subproject commit 9e98192442b08362660b45f4e2e50221ba7bc65b

4
app/libgocryptfs/.gitignore vendored

@ -1,4 +0,0 @@
openssl*
lib
include
build

75
app/libgocryptfs/build.sh

@ -1,75 +0,0 @@
#!/bin/bash
if [ -z ${ANDROID_NDK_HOME+x} ]; then
echo "Error: \$ANDROID_NDK_HOME is not defined."
elif [ -z ${OPENSSL_PATH+x} ]; then
echo "Error: \$OPENSSL_PATH is not defined."
else
NDK_BIN_PATH="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin"
declare -a ABIs=("x86_64" "arm64-v8a" "armeabi-v7a")
compile_openssl(){
if [ ! -d "./lib/$1" ]; then
if [ "$1" = "x86_64" ]; then
OPENSSL_ARCH="android-x86_64"
elif [ "$1" = "arm64-v8a" ]; then
OPENSSL_ARCH="android-arm64"
elif [ "$1" = "armeabi-v7a" ]; then
OPENSSL_ARCH="android-arm"
else
echo "Invalid ABI: $1"
exit
fi
export CFLAGS=-D__ANDROID_API__=21
export PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$ANDROID_NDK_HOME/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin:$PATH
(cd "$OPENSSL_PATH" && if [ -f "Makefile" ]; then make clean; fi && ./Configure $OPENSSL_ARCH -D__ANDROID_API__=21 no-stdio && make build_libs)
mkdir -p "./lib/$1" && cp "$OPENSSL_PATH/libcrypto.a" "$OPENSSL_PATH/libssl.a" "./lib/$1"
mkdir -p "./include/$1" && cp -r "$OPENSSL_PATH"/include/* "./include/$1/"
fi
}
compile_for_arch(){
compile_openssl $1
MAIN_PACKAGE="main.go"
if [ "$1" = "x86_64" ]; then
CFN="x86_64-linux-android21-clang"
elif [ "$1" = "arm64-v8a" ]; then
CFN="aarch64-linux-android21-clang"
export GOARCH=arm64
export GOARM=7
elif [ "$1" = "armeabi-v7a" ]; then
CFN="armv7a-linux-androideabi21-clang"
export GOARCH=arm
export GOARM=7
MAIN_PACKAGE="main32.go"
#patch arch specific code
sed "s/C.malloc(C.ulong/C.malloc(C.uint/g" main.go > $MAIN_PACKAGE
sed -i "s/st.Mtim.Sec/int64(st.Mtim.Sec)/g" $MAIN_PACKAGE
else
echo "Invalid ABI: $1"
exit
fi
export CC="$NDK_BIN_PATH/$CFN"
export CXX="$NDK_BIN_PATH/$CFN++"
export CGO_ENABLED=1
export GOOS=android
export CGO_CFLAGS="-I ${PWD}/include/$1"
export CGO_LDFLAGS="-Wl,-soname=libgocryptfs.so -L${PWD}/lib/$1"
go build -o build/$1/libgocryptfs.so -buildmode=c-shared $MAIN_PACKAGE
if [ $MAIN_PACKAGE = "main32.go" ]; then
rm $MAIN_PACKAGE
fi
}
if [ "$#" -eq 1 ]; then
compile_for_arch $1
else
for abi in ${ABIs[@]}; do
echo "Compiling for $abi..."
compile_for_arch $abi
done
fi
echo "Done."
fi

168
app/libgocryptfs/gocryptfs_internal/cryptocore/cryptocore.go

@ -1,168 +0,0 @@
// Package cryptocore wraps OpenSSL and Go GCM crypto and provides
// a nonce generator.
package cryptocore
import (
"crypto/aes"
"crypto/cipher"
"crypto/sha512"
"fmt"
"log"
"runtime"
"../eme"
"../siv_aead"
"../stupidgcm"
)
const (
// KeyLen is the cipher key length in bytes. 32 for AES-256.
KeyLen = 32
// AuthTagLen is the length of a GCM auth tag in bytes.
AuthTagLen = 16
)
// AEADTypeEnum indicates the type of AEAD backend in use.
type AEADTypeEnum int
const (
// BackendOpenSSL specifies the OpenSSL backend.
BackendOpenSSL AEADTypeEnum = 3
// BackendGoGCM specifies the Go based GCM backend.
BackendGoGCM AEADTypeEnum = 4
// BackendAESSIV specifies an AESSIV backend.
BackendAESSIV AEADTypeEnum = 5
)
// CryptoCore is the low level crypto implementation.
type CryptoCore struct {
// EME is used for filename encryption.
EMECipher *eme.EMECipher
// GCM or AES-SIV. This is used for content encryption.
AEADCipher cipher.AEAD
// Which backend is behind AEADCipher?
AEADBackend AEADTypeEnum
// GCM needs unique IVs (nonces)
IVGenerator *nonceGenerator
IVLen int
}
// New returns a new CryptoCore object or panics.
//
// Even though the "GCMIV128" feature flag is now mandatory, we must still
// support 96-bit IVs here because they were used for encrypting the master
// key in gocryptfs.conf up to gocryptfs v1.2. v1.3 switched to 128 bits.
//
// Note: "key" is either the scrypt hash of the password (when decrypting
// a config file) or the masterkey (when finally mounting the filesystem).
func New(key []byte, aeadType AEADTypeEnum, IVBitLen int, useHKDF bool, forceDecode bool) *CryptoCore {
if len(key) != KeyLen {
log.Panic(fmt.Sprintf("Unsupported key length %d", len(key)))
}
// We want the IV size in bytes
IVLen := IVBitLen / 8
// Initialize EME for filename encryption.
var emeCipher *eme.EMECipher
var err error
{
var emeBlockCipher cipher.Block
if useHKDF {
emeKey := HkdfDerive(key, HkdfInfoEMENames, KeyLen)
emeBlockCipher, err = aes.NewCipher(emeKey)
for i := range emeKey {
emeKey[i] = 0
}
} else {
emeBlockCipher, err = aes.NewCipher(key)
}
if err != nil {
log.Panic(err)
}
emeCipher = eme.New(emeBlockCipher)
}
// Initialize an AEAD cipher for file content encryption.
var aeadCipher cipher.AEAD
if aeadType == BackendOpenSSL || aeadType == BackendGoGCM {
var gcmKey []byte
if useHKDF {
gcmKey = HkdfDerive(key, hkdfInfoGCMContent, KeyLen)
} else {
gcmKey = append([]byte{}, key...)
}
switch aeadType {
case BackendOpenSSL:
if IVLen != 16 {
log.Panic("stupidgcm only supports 128-bit IVs")
}
aeadCipher = stupidgcm.New(gcmKey, forceDecode)
case BackendGoGCM:
goGcmBlockCipher, err := aes.NewCipher(gcmKey)
if err != nil {
log.Panic(err)
}
aeadCipher, err = cipher.NewGCMWithNonceSize(goGcmBlockCipher, IVLen)
if err != nil {
log.Panic(err)
}
}
for i := range gcmKey {
gcmKey[i] = 0
}
} else if aeadType == BackendAESSIV {
if IVLen != 16 {
// SIV supports any nonce size, but we only use 16.
log.Panic("AES-SIV must use 16-byte nonces")
}
// AES-SIV uses 1/2 of the key for authentication, 1/2 for
// encryption, so we need a 64-bytes key for AES-256. Derive it from
// the 32-byte master key using HKDF, or, for older filesystems, with
// SHA256.
var key64 []byte
if useHKDF {
key64 = HkdfDerive(key, hkdfInfoSIVContent, siv_aead.KeyLen)
} else {
s := sha512.Sum512(key)
key64 = s[:]
}
aeadCipher = siv_aead.New(key64)
for i := range key64 {
key64[i] = 0
}
} else {
log.Panic("unknown backend cipher")
}
return &CryptoCore{
EMECipher: emeCipher,
AEADCipher: aeadCipher,
AEADBackend: aeadType,
IVGenerator: &nonceGenerator{nonceLen: IVLen},
IVLen: IVLen,
}
}
type wiper interface {
Wipe()
}
// Wipe tries to wipe secret keys from memory by overwriting them with zeros
// and/or setting references to nil.
//
// This is not bulletproof due to possible GC copies, but
// still raises to bar for extracting the key.
func (c *CryptoCore) Wipe() {
be := c.AEADBackend
if be == BackendOpenSSL || be == BackendAESSIV {
// We don't use "x, ok :=" because we *want* to crash loudly if the
// type assertion fails.
w := c.AEADCipher.(wiper)
w.Wipe()
}
// We have no access to the keys (or key-equivalents) stored inside the
// Go stdlib. Best we can is to nil the references and force a GC.
c.AEADCipher = nil
c.EMECipher = nil
runtime.GC()
}

29
app/libgocryptfs/gocryptfs_internal/cryptocore/hkdf.go

@ -1,29 +0,0 @@
package cryptocore
import (
"crypto/sha256"
"log"
"golang.org/x/crypto/hkdf"
)
const (
// "info" data that HKDF mixes into the generated key to make it unique.
// For convenience, we use a readable string.
HkdfInfoEMENames = "EME filename encryption"
hkdfInfoGCMContent = "AES-GCM file content encryption"
hkdfInfoSIVContent = "AES-SIV file content encryption"
)
// hkdfDerive derives "outLen" bytes from "masterkey" and "info" using
// HKDF-SHA256 (RFC 5869).
// It returns the derived bytes or panics.
func HkdfDerive(masterkey []byte, info string, outLen int) (out []byte) {
h := hkdf.New(sha256.New, masterkey, nil, []byte(info))
out = make([]byte, outLen)
n, err := h.Read(out)
if n != outLen || err != nil {
log.Panicf("hkdfDerive: hkdf read failed, got %d bytes, error: %v", n, err)
}
return out
}

32
app/libgocryptfs/gocryptfs_internal/cryptocore/nonce.go

@ -1,32 +0,0 @@
package cryptocore
import (
"crypto/rand"
"encoding/binary"
"log"
)
// RandBytes gets "n" random bytes from /dev/urandom or panics
func RandBytes(n int) []byte {
b := make([]byte, n)
_, err := rand.Read(b)
if err != nil {
log.Panic("Failed to read random bytes: " + err.Error())
}
return b
}
// RandUint64 returns a secure random uint64
func RandUint64() uint64 {
b := RandBytes(8)
return binary.BigEndian.Uint64(b)
}
type nonceGenerator struct {
nonceLen int // bytes
}
// Get a random "nonceLen"-byte nonce
func (n *nonceGenerator) Get() []byte {
return randPrefetcher.read(n.nonceLen)
}

55
app/libgocryptfs/gocryptfs_internal/cryptocore/randprefetch.go

@ -1,55 +0,0 @@
package cryptocore
import (
"bytes"
"log"
"sync"
)
// Number of bytes to prefetch.
// 512 looks like a good compromise between throughput and latency - see
// randsize_test.go for numbers.
const prefetchN = 512
func init() {
randPrefetcher.refill = make(chan []byte)
go randPrefetcher.refillWorker()
}
type randPrefetcherT struct {
sync.Mutex
buf bytes.Buffer
refill chan []byte
}
func (r *randPrefetcherT) read(want int) (out []byte) {
out = make([]byte, want)
r.Lock()
// Note: don't use defer, it slows us down!
have, err := r.buf.Read(out)
if have == want && err == nil {
r.Unlock()
return out
}
// Buffer was empty -> re-fill
fresh := <-r.refill
if len(fresh) != prefetchN {
log.Panicf("randPrefetcher: refill: got %d bytes instead of %d", len(fresh), prefetchN)
}
r.buf.Reset()
r.buf.Write(fresh)
have, err = r.buf.Read(out)
<