Active Topics

 



Notices


Reply
Thread Tools
Estel's Avatar
Posts: 5,028 | Thanked: 8,613 times | Joined on Mar 2011
#21
Originally Posted by nman View Post
Version 7.x uses /dev/loop0 (at least on my n900) instead of /dev/mapper/truecrypt1...problem is, loop0 exists whether or not a decrypted TC volume is present, so can't use it's existence to trigger the script change.
Not exactly. TrueCrypt 7.1 uses /dev/loop0 only, when You're mounting volume with 'Hidden Volume Protection' - it's only effective way to actually protect hidden data, as regular mount wouldn't allow it. It's also possible, that it uses loop to mount file containers - will check that later, haven't used them due to security reasons on wear-leveled medium.

As for regular partitions dedicated as truecrypt devices, they're mounter as /dev/mapper/truecrypt1, truecrypt2 and so goes on... While testing your code, I was using one of such partitions, yet, it failed for me

Of course, this is how it looks on my device. I will absolutely believe, if for You it's using loop0 always - it's little strange to debug it. For me, initially making filesystem on TrueCrypt partition wasn't working at all, until I manually executed:
Code:
losetup /dev/mapper/truecrypt1 /dev/loop0
Then, '/dev/loop0' disappeared (!), replaced by /dev/loop2. After that, executing mkfs on /dev/loop0 (!!! - not a typo, executing it on loop that wasn't listed in /dev./), resulted on mkfs'ing properly.

After all, It's so strange, that NIM101 actually didn't believed my problems, and during IRC chat, pointed me out to go and read TrueCrypt documentation + learn how it works

From that time, it works normally for me, even if I delete all TC partitions and start everything from scratch (without losetup'ing anything). I can't explain, why it's working like that. Furthermore, there is no much that can be done about it, as we can't change TrueCrypt code (due to license) - we can only build wrappers around it etc. Of course, TrueCrypt code *is* open, so any bugs discovered may be reported to TC Foundation, and fixes will be included.
---

Yet, as for mass-storage sharing, I'm pretty sure it *should* work using one universal method for everyone. Please report back, if using 'protect hidden volumes' is true in Your case.

/Estel
__________________
N900's aluminum backcover / body replacement
-
N900's HDMI-Out
-
Camera cover MOD
-
Measure battery's real capacity on-device
-
TrueCrypt 7.1 | ereswap | bnf
-
Hardware's mods research is costly. To support my work, please consider donating. Thank You!

Last edited by Estel; 2012-01-16 at 20:19.
 
Posts: 124 | Thanked: 105 times | Joined on Jul 2010
#22
Originally Posted by Estel View Post
As for regular partitions dedicated as truecrypt devices, they're mounter as /dev/mapper/truecrypt1, truecrypt2 and so goes on... While testing your code, I was using one of such partitions, yet, it failed for me
That's how it worked when I first started playing with this, (sill using TC 6.X), but once I upgraded to 7.X it definitely uses /dev/loop0 (as a matter of fact directory /dev/mapper doesn't even exist anymore)

I'm not using any hidden volumes.

Anyway, you should be able to mount over usb regardless. For quick&dirty testing don't even bother with the extra <IF> statement - just start with "virgin" osso-usb-mass-storage-enable and replace "echo $1 > LUN0"

with echo "/dev/loop0" > LUN0
or
echo "/dev/mapper/truecrypt1" > LUN0

wherever the decrypted volume sits on your device
 

The Following User Says Thank You to nman For This Useful Post:
Estel's Avatar
Posts: 5,028 | Thanked: 8,613 times | Joined on Mar 2011
#23
Still no joy, no matter if I use loop (tried loop1 - loop7, as I have 7 of them), or /dev/mapper/truecrypt1 (tried all existing, of course they exist only, if I have TC volume mounted, so for 1 volume it's only truecrypt1).

Yet, to my surprise, just executing simple, unmodified:
Code:
osso-usb-mass-storage-enable.sh /dev/mapper/truecrypt1
...works flawlessly, and I can access volume from *both* N900 and desktop simultaneously! So, in my case, part of instructions from NIM101, telling that you need to mount without filesystem, isn't true.

One requirement, though - always run 'osso-usb-mass-storage-disable.sh' after finish, or your volume will appear as "still in use", when you try to unmount it.

Now, I wonder why "regular" mass-storage of MyDocs require umounting it from device... I've just tested this approach with my /dev/mmcblk1p1 (first partition of microSD card, vfat), and it also works - it's accessible through both N900 and desktop.

/Estel

//Edit

W$ndoze users, remember, that you can mass-storage only vfat partitions, as windows lack support for ext*, Yet, even when You try to open such partition from desktop, You'll see "this volume isn't formatted, do You want to format it now?" prompt, which prove that they're properly exported to desktop (as opposed to "no device connected" message).

// Edit 2

nmap and others, could You test approach with
Code:
osso-usb-mass-storage-enable.sh /dev/[your-encrypted-device]
(/dev/mapper/truecrypt*, or /dev/loop*, can verify it by 'truecrypt -t -l')...? If it works for everyone, I think it would be simplest method to include in 1st page. It would not even require inclusion of any scripts into next release, as osso-usb-mass-storage-enable.sh is already bundled in Maemo.
__________________
N900's aluminum backcover / body replacement
-
N900's HDMI-Out
-
Camera cover MOD
-
Measure battery's real capacity on-device
-
TrueCrypt 7.1 | ereswap | bnf
-
Hardware's mods research is costly. To support my work, please consider donating. Thank You!

Last edited by Estel; 2012-01-16 at 23:19.
 
Posts: 124 | Thanked: 105 times | Joined on Jul 2010
#24
Originally Posted by Estel View Post
nmap and others, could You test approach with
Code:
osso-usb-mass-storage-enable.sh /dev/[your-encrypted-device]
Works for me with /dev/loop0

BTW You can see where the decrypted volume block file is with "truecrypt -l"

Originally Posted by Estel View Post
Now, I wonder why "regular" mass-storage of MyDocs require umounting it from device... I've just tested this approach with my /dev/mmcblk1p1 (first partition of microSD card, vfat), and it also works - it's accessible through both N900 and desktop.
It probably doesn't require it per se, but developers probably thought it a bad idea to have a volume mounted in two places at once. In general I think I agree.
 

The Following 2 Users Say Thank You to nman For This Useful Post:
Estel's Avatar
Posts: 5,028 | Thanked: 8,613 times | Joined on Mar 2011
#25
Originally Posted by nman View Post
Works for me with /dev/loop0

BTW You can see where the decrypted volume block file is with "truecrypt -l"

Thanks for testing! One can also get it via 'truecrypt -t -l', to get result in terminal, instead of GUI. Of course, it's possible to add -v to both, thus getting many details about every volume (yet, in GUI, it doesn't fit screen for more than 1 partition, so -v is recommended to be used with -t)

Originally Posted by nman View Post
It probably doesn't require it per se, but developers probably thought it a bad idea to have a volume mounted in two places at once. In general I think I agree.
Rationale? If it's just aesthetic, I'm going to fix it for my device ASAP, as:

a) I don't like such irritating limitations - I can umount it from N900, when I feel it's appropriate. for the same reasons, I've glued a magnet to my N900, where it check for backcover presence or cut power from microSD (not fun, when You're using swap on microSD), and ''replaced'' it by set of scripts, used when I want to remove microSD during runtime.

b) It isn't working reliably for me anyway - after *every* mass-storage'ing - that include MyDocs - MyDocs isn't mounted back into N900, despite using safe device removal etc. I must use my custom script (that mount it again using proper --fs-options) to get it back.
---

Anyway, I've written final version of mass-storage mode instructions and included them in first post - mirroring it here for convenience:

Originally Posted by Estel
You can use N900's encrypted partitions via mass-storage mode, *without* need for TrueCrypt installed on desktop (all decrypted in N900, transparently for desktop). This way, You can use content of Your encrypted volumes in desktops, without actually using them to input passwords/keyfiles = no risk, that software or hardware keyloggers attached to said desktops, will catch your password. Just remember, that it *doesn't* protect Your encrypted volume from getting unwanted files written by malware, or even being deleted/overwritten, if connected in read&write mode.

It's very simple to achieve - just execute in terminal (as root):
Code:
osso-usb-mass-storage-enable.sh [you-encrypted-device]
...replacing [your-encrypted-device] with path to Your encrypted device (*not* partition containing it). Examples:
Code:
osso-usb-mass-storage-enable.sh /dev/mapper/truecrypt1
Code:
osso-usb-mass-storage-enable.sh /dev/loop0
It's very easy, to determine, where Your encrypted device is located - just execute:
Code:
truecrypt -t -l
in terminal. First column is partition/container location, 2nd one is Your encrypted device location, and 3th is mountpoint for actual file access. You use 2nd one, as argument for mass-storage'ing.

Side note:
If, for any reasons, You want simple code to grep your encrypted device location, by providing it's actual location (partition or encrypted file container), you can use this (courtesy of NIN101):
Code:
/usr/sbin/osso-usb-mass-storage-enable.sh `truecrypt -t -l | grep [path to volume] | cut -f3 -d" "`
...where [path to volume] should be replaced with path to partition or file container (for example, /dev/mmcblk1p2, or /home/user/MyDocs/my-encrypted-file-container).

It doesn't have any benefit over writing argument directly, but may be useful, if You're planning to write simple GUI for that, or to include support for it in your program.

Known flaws:
Mass-storage'd volumes doesn't respect special filesystem options passed to Maemo by trueCrypt, during mounting (they're still valid for Maemo, but not for desktop). So, if You mount Your volume with read-only flag, and latter mass-storage it, desktop will be able to write to it anyway. Of course, Maemo still respects read and write flags. If You want to export volume for desktop via mass-storage in read-only state, you must create Your copy of [b]osso-usb-mass-storage-enable.sh (remember to chmod +x it afterwards), edit it to use read-only, and use it instead of vanilla osso-usb-mass-storage-enable.sh, everytime You want to export volume as read-only.

Known "special" benefits:
As for volumes with ''Hidden volume protection'', mass storage respect it and provide some kind of extended plausible deniability. Such volume, when exported to desktop via mass-storage, still protect blocks of hidden volume, yet *doesn't* throw any warnings on desktop side. Furthermore, "blocked" file appear to be written successfully from desktop side. For example, if You copy music file, that gets write blocked, it's fully usable from desktop, as long as You don't disconnect mass-storage and connect it again.

That is, You can have, lets say, 20MB outer volume, with 15MB hidden volume inside, then copy 17MB music file to outer volume (obviously, with "hidden Volume Protection", it will get blocked as soon as it reach any hidden volume block), and then, perfectly play it from desktop - from start to the end. Also, using "safe device removal" will not pop-up any errors.

in reality, such file will be copied only in part that was written to outer volume, with rest just plain cut-off (in my tests, I was able to play such music file furthermore, but instead 3 minutes, it played only for 29 seconds).

Of course, I've tested it with another music file occupying 98% of hidden volume, and despite "writing" repeatedly many different files to outer volume (from desktop, via mass-storage mode), file on hidden volume was kept intact.

Only one moment, when You'll get notification "warning, TrueCrypt protected hidden volume from damage (...)", is when You unmount TrueCrypt containers (if you've followed my advice and disabled "background task").

(technical explanation of this phenomena)
When volumes are mounted successfully with hidden volume protection, they're mounted as encrypted loop devices (for example, /dev/loop0). Unlike filesystem options (like read and write flags), which are set at later part - while mounting encrypted device as actual access point for filesystem (i.e. /media/truecrypt1), thus ignored by mass-storage target desktop - "hidden volume protection" is set as special option of such loop device. As we export loop device as mass-storage, protecting bits are respected, yet desktop OS doesn't have a clue about them, and isn't informed. Common sense would tell, that during "Safe Device Removal", desktop's Os should be informed about "delayed write fail", yet, it seems that it's not informed about any failures, and consider operation finished OK.

Normally, this would be bug, but in our case, it's a feature providing additional benefit
Also, I've added suggestion to disable TrueCrypt background task:

Originally Posted by Estel
It's *heavily* recommended, to turn TrueCrypt background task off - in our case, it doesn't provide any true benefit, yet consumes ~17MB of memory and CPU cycles. To do it, from TrueCrypt GUI enter "Settings -> Preferrences -> Background Task (Tab)" and untick "Enabled".
/Estel
__________________
N900's aluminum backcover / body replacement
-
N900's HDMI-Out
-
Camera cover MOD
-
Measure battery's real capacity on-device
-
TrueCrypt 7.1 | ereswap | bnf
-
Hardware's mods research is costly. To support my work, please consider donating. Thank You!

Last edited by Estel; 2012-01-17 at 01:44.
 
Posts: 124 | Thanked: 105 times | Joined on Jul 2010
#26
Originally Posted by Estel View Post
Rationale? If it's just aesthetic, I'm going to fix it for my device ASAP, as:
Well because bad things might happen if the same file is accessed simultaneously from both mounts. At best, error message, at worst, some corruption.
Not an issue for computer geeks but safer for general users.
Also, things like tracker scanning MyDocs while USB-d would probably slow things down.

Nice writeup, one thing I would add is instruction not to select USB mass storage mode when n900 is plugged into PC. Obvious to some but probably not all.
 

The Following User Says Thank You to nman For This Useful Post:
Posts: 124 | Thanked: 105 times | Joined on Jul 2010
#27
So I followed your advice from other thread about running TC as root and guess what? /dev/mapper/truecrypt1, lol.
Looks like it uses /dev/loop0 when it's NOT run as root.

Still curious why my script mod doesn't work for you. Works for me as root or not, (as long as I put the appropriate device in)
 

The Following User Says Thank You to nman For This Useful Post:
Posts: 115 | Thanked: 342 times | Joined on Dec 2010
#28
works flawlessly, and I can access volume from *both* N900 and desktop simultaneously! So, in my case, part of instructions from NIM101, telling that you need to mount without filesystem, isn't true.
Don't you think there is a reason why Maemo unmounts the sd card and MyDocs? Don't you think it's safer anyway? It is common sense why you should unmount before exporting it.

Mass-storage'd volumes doesn't respect special filesystem options passed to Maemo by trueCrypt, during mounting (they're still valid for Maemo, but not for desktop). So, if You mount Your volume with read-only flag, and latter mass-storage it, desktop will be able to write to it anyway.
More than obvious. Simply don't play around with that simultaneously stuff. You only create a lot of potential issues with that.

that instead of writing quite sophisticated '/usr/sbin/osso-usb-mass-storage-enable.sh `truecrypt -t -l | grep [path to volume] | cut -f3 -d" "`'...
#

Nobody said something about writing, put it in a script and you have less problems than with a static, PITA pointer to /dev/mapper...
 
Estel's Avatar
Posts: 5,028 | Thanked: 8,613 times | Joined on Mar 2011
#29
@nman
Thanks for checking with root. As for not choosing "mass storage mode" you're of course right - yet, even if one choose to, it *still* works after executing
Code:
osso-usb-mass-storage-mode-enable.sh /dev/[encrypted-device]
MyDocs get just "replaced" on desktop by encrypted volume.

By the way, do you have any idea, how to properly modify osso-usb-mass-storage-enable.sh, to mount lun0 as read-only?

@NIN101
Unless good enough reason (with technical rationale) is provided, I'm not going to re-use Nokia way "because they know better". Anyway, on my device, vanilla osso-usb-mass-storage-enable.sh already set MMC for simultaneous access (that is, don't unmount it), I'm using it like that from the very beginning, and haven't run into *any* single issue.

As for "more than obvious" - maybe for You yes, but while writing instructions, I'm perfectly sure that it was good to mention it. Also, AFAICT, you haven't had idea if "hidden volume protected" option will work or not (well, at least during our last IRC conversation), so I performed extensive research on every possible combination.

Also, not respecting "read only" tick from TrueCrypt GUI is *not* obvious in any way, as You can select it even, when you've already tick'ed "do not mount". So, it's a little glitch in TrueCrypt itself - it's allowing to tick option, that is meaningless, if You do not mount filesystem (so, no read&write flags).
---

Still don't see why You're afraid of using it simultaneously, but it's up to You. IMO, the reasoning is exactly like nman said - they were afraid of "casual users" writing to the same file, simultaneously, from 2 sources.

After all, no one is forced to have simultaneous N900/desktop access to TC volumes - heck, I'll even add a note on how to do it exclusively, for less tech'y people.

/Estel

// Edit

And please NIM101, if You quote, don't cut it in a way that changes meaning I've said: "writing by hand *or* saving as sh script".

Well, as for merit itself - in your command, you're grep'ping 1 value, by providing another 1 value - IMO pointless for any other reason, that setting it up for other program/GUI. Also, i don't see any reason to save scripts for executing 1 short command with 1 short value, like
[code]osso-usb-mass-storage-enable.sh /dev/mapper/truecrypt1/code]
...or so. Using auto-completion via TAB, it's much faster to write by hand.

Of course, it's up to everyone which method to use, that's why I've informed about *both* in tutorial. Lets bee "free as in freedom" to choose best method for ourselves
__________________
N900's aluminum backcover / body replacement
-
N900's HDMI-Out
-
Camera cover MOD
-
Measure battery's real capacity on-device
-
TrueCrypt 7.1 | ereswap | bnf
-
Hardware's mods research is costly. To support my work, please consider donating. Thank You!

Last edited by Estel; 2012-01-17 at 23:27.
 
Posts: 124 | Thanked: 105 times | Joined on Jul 2010
#30
Originally Posted by Estel View Post
@nman
Thanks for checking with root. As for not choosing "mass storage mode" you're of course right - yet, even if one choose to, it *still* works after executing
Code:
osso-usb-mass-storage-mode-enable.sh /dev/[encrypted-device]
MyDocs get just "replaced" on desktop by encrypted volume.
Hmm not on my device - I get error "already mounted" if I try that.

Originally Posted by Estel View Post
By the way, do you have any idea, how to properly modify osso-usb-mass-storage-enable.sh, to mount lun0 as read-only?
Try adding "ro=1" to the line "/sbin/modprobe g_file_storage stall=0 luns=2" This would affect both LUNS tho.

Originally Posted by Estel View Post
@NIN101
Unless good enough reason (with technical rationale) is provided, I'm not going to re-use Nokia way "because they know better". Anyway, on my device, vanilla osso-usb-mass-storage-enable.sh already set MMC for simultaneous access (that is, don't unmount it), I'm using it like that from the very beginning, and haven't run into *any* single issue.
It's not just Nokia way.... read warning on page below
(other good info on that site too)

http://www.linux-usb.org/gadget/file_storage.html
 

The Following User Says Thank You to nman For This Useful Post:
Reply

Tags
cryptography, encrypted, kernelcrypto, security, truecrypt


 
Forum Jump


All times are GMT. The time now is 22:01.