Reply
Thread Tools
Community Council | Posts: 4,920 | Thanked: 12,867 times | Joined on May 2012 @ Southerrn Finland
#1
I do have a bit special requirement for an utility;

I am now experimenting on encrypting the whole home directory on N9, to counter the relaxed security of the device caused by running in open mode. When I am in open mode I want same (or better) security as in closed mode, but on my own terms! I want to protect my own data, not to be protected from the system

I have managed to install encfs on the device, and am planning to set up home directory encryption. However, the challenge is to get the passphrase from user in preinit phase, when device is running in sinle user mode.

I am planning on mounting the encfs home just before OS selection (as I am runing nitdroid dual boot) so that both meego and android partitions can be encrypted.

The input that can easily be obtained from user at that phase is just keypresses; volume keys and power key. What I would like to do is build an utility that presents the user a virtual keypad for passphrase entry. However, I am unsure how to do it?

Is there a way of building for example a qt application that has all the needed component libraries linked statically to it, so that there is no need for external dependencies and it can be run stand-alone from the preinit script?

I thought of building some extra functionality to it, in addition of just passphrase entry via virtual keyboard; For example, it could show device owner contact information when incorrect passphrase is typed so that changes of getting lost device back would increase.
 

The Following User Says Thank You to juiceme For This Useful Post:
Community Council | Posts: 4,920 | Thanked: 12,867 times | Joined on May 2012 @ Southerrn Finland
#2
Aarrgh, now I suddenly realised the unpleasant truth...
The darn box is not yet running X at preinit stage, right?

So, propably qt is out of scope here, then.
Does anybody have any good suggestions on how to handle it?
Are there any libraries that handle raw input and output like on the device console? If not, do I need to read raw position events off some device or somerhing like that?
 

The Following 2 Users Say Thank You to juiceme For This Useful Post:
wook_sf's Avatar
Posts: 640 | Thanked: 435 times | Joined on Oct 2011 @ rajvoSa BA
#3
Originally Posted by juiceme View Post
Aarrgh, now I suddenly realised the unpleasant truth...
The darn box is not yet running X at preinit stage, right?

So, propably qt is out of scope here, then.
Does anybody have any good suggestions on how to handle it?
Are there any libraries that handle raw input and output like on the device console? If not, do I need to read raw position events off some device or somerhing like that?
afaik you can try to load some of drivers and cat events in /dev/input/
maybe?
or you can look evkey.c source: https://gitorious.org/android-n900/m.../evkey/evkey.c and do it like in there
__________________
~ # mv /usr/bin/smartsearch /usr/bin/stupidsearch
 

The Following 2 Users Say Thank You to wook_sf For This Useful Post:
Posts: 1,225 | Thanked: 1,905 times | Joined on Feb 2011 @ Quezon City, Philippines
#4
I'm guessing you'd be entering numbers using the volume and power buttons. Up to increment until it rolls around to 0, down to move cursor, power to enter.

Take a look at sillyboot for a pre-init component.
__________________
N9 PR 1.3 Open Mode + kernel-plus for Harmattan
@kenweknot, working on Glacier for Nemo.
 
Community Council | Posts: 4,920 | Thanked: 12,867 times | Joined on May 2012 @ Southerrn Finland
#5
Using evkey and just three buttons.... Well even that came into my mind but it is REALLY cumbersome to do it that way, I rather try to make it a decent UI even as it will be lots of more work.
Think about it for a moment, if you have a passphrase of maybe 30 letters and numbers it is next to impossible to enter that without making mistakes... No, keyboard is the way to go!

How I thought about implementing it now;

Yes, I need to get touch input, a steam of coordinates for the keypresses, For that there sure needs to be a driver, and in preinit I can modprobe it up and mknod the needed device.

For "keyboard" just an image suffices. There is no need really for visual confirmation of keypresses and that actually would be a bad thing, as it is needed for passphrase input. The image of the keyboard is just png file, shown up like in sillyboot.

For keypress confrmation I would like tactile feedback, so there needs also to be a device that can be written to to create the keypress vibrations.
 

The Following User Says Thank You to juiceme For This Useful Post:
wook_sf's Avatar
Posts: 640 | Thanked: 435 times | Joined on Oct 2011 @ rajvoSa BA
#6
it all can be done
you just need some time and good ideas
__________________
~ # mv /usr/bin/smartsearch /usr/bin/stupidsearch
 

The Following 2 Users Say Thank You to wook_sf For This Useful Post:
Community Council | Posts: 4,920 | Thanked: 12,867 times | Joined on May 2012 @ Southerrn Finland
#7
OK, so I did some tinkering and now I am able to read off coordinates from the touch screen. It turned out to be fairly easy after I found out the correct device to use, each touch will generate a burst of events, out of which I am filtering out all except absolute X and Y coordinate events. The following snippet shows how I am doing it.

Code:
  struct input_event ievent;
  int fd, xaxis, yaxis, flag=0, ret;

  if ((fdev = open("/dev/input/event3",  O_RDONLY)) < 0) {
    perror("cannot open input device");
    return -1;
  }

  while(1) {
    if((ret = read(fdev ,&ev ,sizeof(ievent))) < sizeof(ievent)) {
      printf("\nreceived only %d bytes on read", ret);
      return -1;
    }
    if(ievent.type == EV_ABS && ievent.code == ABS_X) {
      xaxis = ievent.value;
    }
    if(ievent.type == EV_ABS && ievent.code == ABS_Y) {
      yaxis = ievent.value;
      flag = 1;
    }
    if(flag) {
      flag = 0;
      printf("\ntouch = %d, %d", xaxis, yaxis);
    }
  }
Now, does anybody remember off the top of head how can I easily generate a short vibration effect for tactile feedback? I would assume it can be done by writing some structure to an output device, but what device and what kind of data?
 

The Following 2 Users Say Thank You to juiceme For This Useful Post:
Community Council | Posts: 4,920 | Thanked: 12,867 times | Joined on May 2012 @ Southerrn Finland
#8
Okay, tick to another box, tactile feedback covered

Checking syslog I found that the vibra device is created as "/dev/input/event6" and reading the device while trying out virtual keyboard indeed threw up some codes. Writing the events back to device produce small vibration. Nice!

Code:
  int fdev, ret;
  struct input_event ievent;

  if ((fdev = open("/dev/input/event6",  O_RDWR)) < 0) {
    perror("cannot open output device");
    return -1;
  }

  ievent.type = EV_FF;
  ievent.code = 30;
  ievent.value = 1;
  if((ret = write(fdev, &ievent ,sizeof(ievent))) < sizeof(ievent)) {
    printf("\nsent only %d bytes on write");
    return -1;
  }
Now, originally I thought of loading up .png of a keyboard image as a visual guide to the typing using first "/usr/bin/show_png" to show the image, and then launching my "silly_kbd" utility to capture touch input.
However, I need to have shift/caps-lock functionality, so what I need to do is to change bitmaps on the screen while running my utility.

There are propably at least 3 ways of doing this, which are of varying complexity...
  • If I can get source code of show_png I could stitch that in my utility, easiest but I am not sure if it is non-free Nokia code?
  • Can I launch external program via "system()" call or something so I can call the utility from inside my own utility... This is doable but not really optimal
  • I could exit from my utility with an EC that the calling shell script knows that it needs to change the background image and relaunch the kbd utility... not really nice because I would need to handle the already inputted characters somehow...

Any thoughts on this?
 

The Following 2 Users Say Thank You to juiceme For This Useful Post:
coderus's Avatar
Posts: 6,436 | Thanked: 12,699 times | Joined on Nov 2011 @ Ängelholm, Sweden
#9
4. you can turn your code into evtap and vibra command-line tools. it will be very handy for peoples. and write main code in another app, then just use evkey evtap and vibra tools (and show_png of corse) then need. also (maybe?) some tool for writing text in portait orientation? (landscape text with T2S is good, but i prefer portait)
 

The Following 2 Users Say Thank You to coderus For This Useful Post:
Community Council | Posts: 4,920 | Thanked: 12,867 times | Joined on May 2012 @ Southerrn Finland
#10
Originally Posted by coderus View Post
4. you can turn your code into evtap and vibra command-line tools. it will be very handy for peoples. and write main code in another app, then just use evkey evtap and vibra tools (and show_png of corse) then need. also (maybe?) some tool for writing text in portait orientation? (landscape text with T2S is good, but i prefer portait)
Well, actually I already thought about making a simple touch/tap interface change to sillyboot

See, when my son borrowed my N9 to play Angry Birds Space on nitdroid he instinctively tried to tap on the android icon in the booting phase instead of using the volume keys to change the default boot OS.

Hence I tried it, and it is quite simple to read a touch on either upper or lower part of the screen to select the desired image...
 

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

Thread Tools

 
Forum Jump


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