genid:HSM から時刻を取得するのは都合が悪いので廃止。

PC から時刻取得をするよう変更し、あまりに古い時は定義した標準時間を利用するようにした。
また、上記の兼ね合いで証明書期限は固定値とすることにした。

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_eFuse@207 ff987cc8-cf2f-4642-8568-d52cce064691
This commit is contained in:
n2460 2013-06-04 07:46:44 +00:00
parent 478c26ff13
commit 31cda8f0d5
3 changed files with 43 additions and 10 deletions

View File

@ -141,7 +141,7 @@
#include "cr_generate_id_private.h"
#define CR_CERT_EXPIRE_SECS ( 60*60*24*365* 20 ) // デバイス証明書期限 20年 ※うるう年は無視
#define CR_CERT_EXPIRE_SECS ( 60*60*24*365*20 ) // デバイス証明書期限 20年 ※うるう年は無視
u8 tempSign[ 70 ];

View File

@ -137,9 +137,10 @@ extern "C" {
#define ENCRYPT_AES 1 // 定義を有効でFIX.これが未定義の場合、IDの暗号化がRSAになる。
#define CR_GEN_ID_VERSION 5 // シャープへのリリースごとにUPする。
#define CR_GEN_ID_VERSION 6 // シャープへのリリースごとにUPする。
// 2010/02/02 Release ver.4
// 2010/03/15 Release ver.5
// TBD -----------------------------------> // 2013/06/XX Release ver.6
#ifdef USE_HSM
#define CR_GEN_ID_MAGICCODE 0xdeadb00f; /* 最終的にはこちらで動作。0xdeadbeefにするとRSAでコケる。 */
#else // !USE_HSM

View File

@ -135,6 +135,20 @@ errorInfoStruct;
static errorInfoStruct errorInfo;
// 標準時刻 : 2013/06/08(土) 12:15:30
// PC の時刻がおかしい場合の発行時刻に使用
#define DEFAULT_TM_SEC (30) // 秒
#define DEFAULT_TM_MINUTE (15) // 分
#define DEFAULT_TM_HOUR (12) // 時
#define DEFAULT_TM_DAY (8) // 日
#define DEFAULT_TM_MONTH (6) // 月
#define DEFAULT_TM_YEAR (113) // 年 (1900年からの年数)
// 期限ベース(pTime)に入れる数, 上記の標準時刻を秒数に変換したもの
// *注意* 値の変更は可能ですが、2038年を超えるとオーバフローするので誤動作します。
// *更に注意* 証明書作成時に期限として以下の値に20年加算するため2018年未満である必要もあります。
#define TIMEVAL_DEFAULT_VALUE (1370661330)
// タイムスタンプを取得してセット
int GetTimestamp( u8 *pYear, u8 *pMonth, u8 *pMday, u8 *pHour, u8 *pMin, u8 *pSec, time_t *pTime)
{
@ -142,7 +156,10 @@ int GetTimestamp( u8 *pYear, u8 *pMonth, u8 *pMday, u8 *pHour, u8 *pMin, u8 *pSe
struct tm *tm_time;
struct timeval tv;
#ifdef USE_HSM
// 2013/06/04
// USE_HSM の時はここで HSM から RTC を取得していたが、
// 電池切れで RTC が飛ぶ(そしてエラーになる)ため必ず PC から時間を取得することにする。
#if 0
ret_code = hsm_get_rtc( &tv.tv_sec );
if( ret_code != CR_GENID_SUCCESS ) {
SetErrorInfo( __FUNCTION__, __LINE__ );
@ -154,13 +171,28 @@ int GetTimestamp( u8 *pYear, u8 *pMonth, u8 *pMday, u8 *pHour, u8 *pMin, u8 *pSe
tm_time = gmtime( &tv.tv_sec );
*pYear = (u8)tm_time->tm_year;
*pMonth = (u8)tm_time->tm_mon + 1;
*pMday = (u8)tm_time->tm_mday;
*pHour = (u8)tm_time->tm_hour;
*pMin = (u8)tm_time->tm_min;
*pSec = (u8)tm_time->tm_sec;
*pTime = tv.tv_sec;
if (tm_time->tm_year + 1900 >= 2013)
{
*pYear = (u8)tm_time->tm_year;
*pMonth = (u8)tm_time->tm_mon + 1;
*pMday = (u8)tm_time->tm_mday;
*pHour = (u8)tm_time->tm_hour;
*pMin = (u8)tm_time->tm_min;
*pSec = (u8)tm_time->tm_sec;
}
else // あまりにも時間が古い場合は固定値を突っ込む
{
*pYear = DEFAULT_TM_YEAR;
*pMonth = DEFAULT_TM_MONTH;
*pMday = DEFAULT_TM_DAY;
*pHour = DEFAULT_TM_HOUR;
*pMin = DEFAULT_TM_MINUTE;
*pSec = DEFAULT_TM_SEC;
}
//*pTime = tv.tv_sec;
*pTime = TIMEVAL_DEFAULT_VALUE;
#if 0
{