是否可以从 iphone GPS 获取原子钟时间戳?

Is it possible to get the atomic clock timestamp from the iphone GPS?(是否可以从 iphone GPS 获取原子钟时间戳?)

本文介绍了是否可以从 iphone GPS 获取原子钟时间戳?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种可靠的方式来打发时间.它不能被篡改,它需要离线工作.所以没有互联网时间,设置中没有用户时间设置,并且自上次重启以来没有 BSD 正常运行时间.我想知道由于 GPS 使用原子钟工作,我是否可以访问该信息.

I'm looking for a reliable way to get the time. It can't be tampered with and it needs to work offline. So no internet time , no user time setup in settings and no BSD uptime time since last reboot. I was wondering since GPS works using atomic clock, whether I could access that information.

谢谢

推荐答案

这样可以获取 GPS 时间:

This works to get the GPS time:

#import <CoreLocation/CoreLocation.h>

CLLocation* gps = [[CLLocation alloc]
                       initWithLatitude:(CLLocationDegrees) 0.0
                       longitude:(CLLocationDegrees) 0.0];
NSDate* now = gps.timestamp;

但它似乎不是防篡改的.

It doesn't seem to be tamper-proof though.

我在 iPhone 4 上以飞行模式 (iOS 6.1) 尝试了此代码,即便如此,它仍然可以提供时间.但不幸的是,这个时间似乎随着系统时钟的变化而变化.呃.

I tried this code on an iPhone 4 in airplane mode (iOS 6.1), and even then it gives a time all right. But unfortunately this time seems to change with the system clock. Ugh.

我发现的有趣的事情(仍处于飞行模式)是,如果您篡改系统时钟(在打开 off 时间和日期的 自动设置 之后),然后将 Set Automatically 转回 on,机器会顺利恢复真实(原始)时间.即使在循环手机电源后也可以使用.因此,似乎存在设备内部维护的防篡改时间.但是如何访问呢?

Funny thing that I found (still in airplane mode) is that if you tamper with the system clock (after turning to off Time & Date's Set Automatically), and then turn Set Automatically back to on, the machine restores the real (original) time without a hitch. this works even after cycling the phone's power. So it seems that there is something like a tamper-proof time the device maintains internally. But how to access this?

附:2010 年的讨论.倒数第二条评论的作者在一个辐射避难所中尝试了这个:所以很明显手机没有从任何外部来源获得原始时间.

P.S. A discussion of this from 2010. The author of the penultimate comment tried this in a fallout shelter: so it's clear the phone is not getting the pristine time from any external source.

找到更多帖子(这里,这里和这里)关于另一种时间度量:系统内核启动时间.它通过如下调用访问:sysctlbyname("kern.boottime", &boottime, &size, NULL, 0);.不幸的是,即使没有重新启动,它也会随着用户调整的数据和时间而变化.另一个函数 gettimeofday() 类似地依赖于用户定义的时间.

Found a few more posts (here, here and here) about another kind of time measure: system kernel boot time. It's accessed through a call something like this: sysctlbyname("kern.boottime", &boottime, &size, NULL, 0);. Unfortunately it too changes with the user-adjusted data and time, even without reboot. Another function gettimeofday() is similarly dependent on user-defined time.

这篇关于是否可以从 iphone GPS 获取原子钟时间戳?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:是否可以从 iphone GPS 获取原子钟时间戳?

基础教程推荐