genid:フォーマットは変更されないためバージョンを上げるのを中止。

outputSharpID:small fix

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_eFuse@210 ff987cc8-cf2f-4642-8568-d52cce064691
This commit is contained in:
n2460 2013-06-05 06:21:51 +00:00
parent 4b691fc8dd
commit d3a9fa08e9
4 changed files with 159 additions and 142 deletions

View File

@ -10,8 +10,8 @@ OBJS = $(notdir $(SRCS:.c=.o))
ifeq ($(DEV_CYGWIN),TRUE) ifeq ($(DEV_CYGWIN),TRUE)
CC := C:/Cygwin/bin/gcc CC := C:/Cygwin/bin/gcc-3
LD = C:/Cygwin/bin/gcc LD = C:/Cygwin/bin/gcc-3
CFLAGS += -mno-cygwin -DDEV_CYGWIN -Wall -I./ CFLAGS += -mno-cygwin -DDEV_CYGWIN -Wall -I./
LDFLAGS += -Wl,--subsystem,console -mwindows -mno-cygwin -L./ LDFLAGS += -Wl,--subsystem,console -mwindows -mno-cygwin -L./
LDLIBS += -lgenid LDLIBS += -lgenid

View File

@ -108,8 +108,8 @@ LDLIBS = -lcrypto -lssl
MERGE_PROG = merge_lib_objs.plx MERGE_PROG = merge_lib_objs.plx
ifeq ($(DEV_CYGWIN),TRUE) ifeq ($(DEV_CYGWIN),TRUE)
CC := C:/Cygwin/bin/gcc CC := C:/Cygwin/bin/gcc-3
LD = C:/Cygwin/bin/gcc LD = C:/Cygwin/bin/gcc-3
CFLAGS += -mno-cygwin -DDEV_CYGWIN CFLAGS += -mno-cygwin -DDEV_CYGWIN
LDFLAGS += -Wl,--subsystem,console -mno-cygwin LDFLAGS += -Wl,--subsystem,console -mno-cygwin
TARGET_DEL = $(TARGET).exe TARGET_DEL = $(TARGET).exe

View File

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

View File

@ -1,3 +1,27 @@
/*
testSharpID ID
*1* HSM 使(Linux) Windows(Cygwin)
Shift-JIS CR+LF (2)
Windows LF
*2*
testSharpID
testSharpID
(1) dummyKey dev, prod
eFuse_aesKey.bin, eFuse_privKey.der, eFuse_pubKey.der ( OK)
(2) realKey dev, prod
eFuse_aesKey.bin, eFuse_privKey.der, eFuse_pubKey.der
dummyKey dev, prod NCT2_priv.der, NCT2_priv.pem, NCT2_pub.pem
Makefile.testSharpID ifeq ($(USE_DUMMY_KEY),TRUE) endif
DEV_DER_KEY_DIR = ./dummyKey/dev -> ./realKey/dev
PROD_DER_KEY_DIR = ./dummyKey/prod -> ./realKey/prod
*/
#define RAND_MAX 0xffffffff #define RAND_MAX 0xffffffff
#include <stdio.h> #include <stdio.h>
@ -53,7 +77,9 @@ int kbhit( void )
int nread; int nread;
if ( peek_character != -1 ) if ( peek_character != -1 )
{
return 1; return 1;
}
new_setting.c_cc[VMIN] = 0; new_setting.c_cc[VMIN] = 0;
tcsetattr( 0, TCSANOW, &new_setting ); tcsetattr( 0, TCSANOW, &new_setting );
nread = read( 0, &ch, 1 ); nread = read( 0, &ch, 1 );
@ -95,41 +121,53 @@ static int str_to_u32(u32 *num, const char *str)
*num = 0; *num = 0;
if( *str == '0' && *(str+1) == 'x' ) { if( *str == '0' && *(str+1) == 'x' )
{
hex_mode = 1; hex_mode = 1;
s = (char *)(str + 2); s = (char *)(str + 2);
} }
else { else
{
s = (char *)str; s = (char *)str;
} }
while( *s != '\0' ) { while( *s != '\0' )
{
if( shift > 8 ) { if( shift > 8 )
{
return -1; /* error */ return -1; /* error */
} }
if( hex_mode ) { if( hex_mode )
if( '0' <= *s && *s <= '9' ) { {
if( '0' <= *s && *s <= '9' )
{
c = (u32)(*s - '0'); c = (u32)(*s - '0');
} }
else if( 'a' <= *s && *s <= 'f' ) { else if( 'a' <= *s && *s <= 'f' )
{
c = (u32)(*s - 'a') + 10; c = (u32)(*s - 'a') + 10;
} }
else if( 'A' <= *s && *s <= 'F' ) { else if( 'A' <= *s && *s <= 'F' )
{
c = (u32)(*s - 'A') + 10; c = (u32)(*s - 'A') + 10;
} }
else { else
{
return -1; /* error */ return -1; /* error */
} }
*num <<= 4; *num <<= 4;
*num |= c; *num |= c;
} }
else { else
if( '0' <= *s && *s <= '9' ) { {
if( '0' <= *s && *s <= '9' )
{
c = (u32)(*s - '0'); c = (u32)(*s - '0');
} }
else { else
{
return -1; /* error */ return -1; /* error */
} }
*num *= 10; *num *= 10;
@ -147,21 +185,21 @@ static double gettimeofday_sec(void)
struct timeval tv; struct timeval tv;
#if 0 #if 0
struct timeval { struct timeval
{
time_t tv_sec; /* 秒 */ time_t tv_sec; /* 秒 */
suseconds_t tv_usec; /* マイクロ秒 */ suseconds_t tv_usec; /* マイクロ秒 */
}; };
struct timezone { struct timezone
{
int tz_minuteswest; /* グリニッジ標準時との差 (西方に分単位) */ int tz_minuteswest; /* グリニッジ標準時との差 (西方に分単位) */
int tz_dsttime; /* 夏時間調整の型 */ int tz_dsttime; /* 夏時間調整の型 */
}; };
int gettimeofday(struct timeval *tv, struct timezone *tz); int gettimeofday(struct timeval *tv, struct timezone *tz);
#endif #endif
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
return tv.tv_sec + (double)tv.tv_usec*1e-6; return tv.tv_sec + (double)tv.tv_usec*1e-6;
} }
@ -218,7 +256,14 @@ int main(int ac, char *argv[])
} }
else else
{ {
sprintf( path, "output/outputSharpID.txt" ); if (bonding_option == BONDING_OPTION_DEV)
{
sprintf( path, "output/outputSharpID_Dev.txt" );
}
else
{
sprintf( path, "output/outputSharpID_Prod.txt" );
}
} }
// ファイルを開く // ファイルを開く
@ -316,8 +361,16 @@ int main(int ac, char *argv[])
} }
// 書き込み // 書き込み
{
int i;
fprintf( fp, "%08X, %08X %08X, %08X %08X, ", fprintf( fp, "%08X, %08X %08X, %08X %08X, ",
(unsigned int)device_id[0], (unsigned int)device_id[2], (unsigned int)device_id[1], (unsigned int)device_id[4], (unsigned int)device_id[3] ); (unsigned int)device_id[0], (unsigned int)device_id[2], (unsigned int)device_id[1], (unsigned int)device_id[4], (unsigned int)device_id[3] );
for (i = 0; i < CR_ID_BUF_SIZE; i++ )
{
fprintf( fp, "%02X", id[i] );
}
fprintf( fp, "\n" );
}
if (kbhit()) if (kbhit())
{ {
@ -341,41 +394,6 @@ int main(int ac, char *argv[])
} }
} }
if( ac == 4 ) {
if( 0 == str_to_u32(&device_id[0], argv[1]) && 0 == str_to_u32(&device_id[1], argv[2]) ) {
printf("ID[0] = 0x%08x\n", (unsigned int)device_id[0]);
printf("ID[1] = 0x%08x%08x\n", (unsigned int)device_id[2], (unsigned int)device_id[1] );
printf("ID[2] = 0x%08x%08x\n", (unsigned int)device_id[4], (unsigned int)device_id[3] );
fp = fopen( argv[3], "wb" );
if( fp == NULL ) {
fprintf(stderr, "failed to fopen %s\n",argv[3]);
}
else {
time_start = gettimeofday_sec();
if( 0 != cr_generate_id( device_id, id, bonding_option ) )
{
fprintf(stderr,"cr_generate_id failed s1=0x%08x s2_lo=0x%08x s2_hi=0x%08x\n",
(int)device_id[0], (int)device_id[1], (int)device_id[2]);
}
else {
time_end = gettimeofday_sec();
fwrite(id, CR_ID_BUF_SIZE, 1, fp);
}
fclose(fp);
}
}
else {
goto err_print;
}
}
else {
err_print:
fprintf(stderr,"Invalid argument!\n");
fprintf(stderr,"Usage: %s\n", argv[0]);
fprintf(stderr,"Usage: %s device_id(32bit) filename.dat\n", argv[0]);
}
end: end:
// ファイルのクローズ // ファイルのクローズ
if (fp) if (fp)