3

i want to implement a secure timebased auto-lock function for my app (similar to the auto-lock-feature in 1password). The user can chose a passcode and a time period (1,2,3,5,10,30 minutes) after the lock is activated. Basically I could write a timestamp (encrypted) on my device and compare it with the current time of the next usage. If the delta is bigger than the chosen time period, the user has to enter the passcode. But this feature could be leavered out by changing the local time on the device. There must be a secure way (e.g. special system timer) to do that. So you can't lever out 1Password in this way. Any ideas?

Thanks a lot

Jürgen

JHC42
  • 35
  • 4

2 Answers2

0

you should be using an Internet time server. They are using a standardized protocol called NTP. The iOS has built-in support for reading NTP server time, but this is not accessible for you as an application developer. Either you implement this yourself, or you could maybe use an open source library, like ios-ntp or HS NTP.

Community
  • 1
  • 1
Siba Prasad Hota
  • 4,779
  • 1
  • 20
  • 40
  • If the user can change the system time, he can even disable the internet connection... ;-) – LombaX Nov 16 '12 at 08:04
  • Then you can try to grt from the carrier (through the NITZ). – Siba Prasad Hota Nov 16 '12 at 08:06
  • Ideally the time is updating from the GPS - which is the most accurate time that you can get (it's an atomic clock basically), BUt if he turnoff GPS then you can't get by this also. – Siba Prasad Hota Nov 16 '12 at 08:33
  • Yes. I think that the best option is to read time from all this sources, and if all are unavailable...simply ask for password, ignoring the system time (that can be compromised). Or, alternative, but not sure Apple will approve the app, update the time in background (by using a background task, but it's only max 10 minutes) – LombaX Nov 16 '12 at 08:37
  • See how core location is calculating your location - GPS, cell, Wifi, etc. Like that you can Update the time from available Sources. – Siba Prasad Hota Nov 16 '12 at 08:40
  • What is about the systemUptime of the NSProcessInfo Class? Could this function be useful for my issue? – JHC42 Nov 16 '12 at 08:48
  • https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSProcessInfo_Class/Reference/Reference.html SystemUPtime Returns how long it has been since the computer has been restarted. Available in OS X v10.6 and later. so you cant use for iPhone app. – Siba Prasad Hota Nov 16 '12 at 08:54
  • but it is also available in iOS 4.0 or later [see this link](https://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSProcessInfo_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40003715) – JHC42 Nov 16 '12 at 08:59
0

Use:

[[UIApplication sharedApplication] setIdleTimerDisabled:YES];

Now set a timer:

  [NSTimer scheduledTimerWithTimeInterval:240 target:self selector:@selector(disableIdleTimer) userInfo:nil repeats:NO];

disableIdleTimer method set this:

[[UIApplication sharedApplication] setIdleTimerDisabled:NO];

Done!!

GhostCode
  • 452
  • 6
  • 17