1

My app will need to periodically access a trusted time source, so can not rely on system time since this one can be modified easily by user or batery failure etc. My first idea is to statically link to libntp (from ntp.org) and use its functions, is this a good idea?

Libntp looks a bit complex framework, is there some simpler, client implementation (preferably ANSI C since the app needs to be for different platforms... though can be also Cpp if can be compiled with gcc / MS VS)?

Is there some other alternative to ntp?

Thanks!!

Edit: Just to add some more info... it is important that the trusted-time-server values can not be modified (lets say, attacker modifies the trusted-time-server response and app accepts fake time). I started looking at ntp and see that it takes care of that issue. The question is now should i use ntp sources from ntp.org as a starting point or there are some simple client-only implementatios? Ideally, some pointer to which module / source files from ntp.org sources should I use for client-only implementation and which header file shows the API I need to use, like for example a call getTrustedTime()... etc.

Sasha Nikolic
  • 760
  • 1
  • 8
  • 22
  • 3
    If you can't trust the OS... All bets are off. OS can be configured to protect system time. Also, network connectivity may not always exist. Are you trying to implement license protection? If so, please clarify in your post – sehe Oct 12 '11 at 09:51
  • How accurate does it have to be? 1 or 2 seconds off is OK? Or does it have be millisecond precision? – Prof. Falken Oct 12 '11 at 10:03
  • My app is not trusting OS time but requiring (periodic) network connectivity (indeed related to license protection). As for the accuracy, up to few minutes is ok. – Sasha Nikolic Oct 12 '11 at 10:09

2 Answers2

0

If you can rely on there being a network connection, your application could ask a remote server for the time, perhaps also over a signed or encrypted connection.

Prof. Falken
  • 24,226
  • 19
  • 100
  • 173
0

If you are using Boost you could use this

MrJackV
  • 547
  • 3
  • 5
  • 12