mirror of
https://github.com/rvtr/ctr_eFuse.git
synced 2025-11-02 00:11:04 -04:00
sample:パッケージに含まれる readme の改訂。
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_eFuse@214 ff987cc8-cf2f-4642-8568-d52cce064691
This commit is contained in:
parent
be5d371dbc
commit
245d933cd7
146
trunk/readme.txt
146
trunk/readme.txt
@ -1,71 +1,107 @@
|
||||
CTR - ID生成関数について 2009/09/30
|
||||
|
||||
----------------------------
|
||||
要、opensslライブラリ(バージョン0.9.8以上)
|
||||
現在、openssl-1.0.0-beta2とopenssl-0.9.8kでテスト中。
|
||||
CTR - ID生成関数について : 2013/06/05
|
||||
|
||||
-----------------------------
|
||||
ファイル構成:
|
||||
readme.txt
|
||||
readme_openssl.txt
|
||||
LICENSE_en.txt
|
||||
LICENSE_jp.txt
|
||||
cr_generate_id.h
|
||||
cr_generate_id.c
|
||||
cr_alloc.h
|
||||
cr_alloc.c
|
||||
cr_gen_id_rsa_key_priv.c
|
||||
cr_gen_id_rsa_key_priv.h
|
||||
cr_gen_id_rsa_key_pub.c
|
||||
cr_gen_id_rsa_key_pub.h
|
||||
maim.c(使用サンプル)
|
||||
Makefile(Windows cygwin環境用)
|
||||
ファイル構成
|
||||
readme.txt
|
||||
このファイルです。
|
||||
|
||||
readme_openssl.txt
|
||||
LICENSE_en.txt
|
||||
LICENSE_jp.txt
|
||||
ID 生成関数ライブラリは OpenSSL の機能を一部利用しているため、これらのライセンスファイルを含んでいます。
|
||||
|
||||
libgenid.a
|
||||
ID 生成関数のライブラリファイルです。
|
||||
|
||||
cr_generate_id.h
|
||||
上記ライブラリのヘッダファイルです。
|
||||
|
||||
function_spec.pdf
|
||||
ID 生成関数の仕様について記述しています。
|
||||
|
||||
sample.c
|
||||
util.c
|
||||
util.h
|
||||
Makefile
|
||||
ID 生成関数を使った動作サンプルです。
|
||||
|
||||
----------------------------
|
||||
関数仕様:
|
||||
関数仕様
|
||||
|
||||
#define CR_ID_BUF_SIZE (2048/8)
|
||||
#define CR_NUM_OF_SERIAL 5
|
||||
function_spec.pdf をご参照下さい。
|
||||
|
||||
typedef signed char s8;
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned long u32;
|
||||
typedef unsigned long long u64;
|
||||
cr_generate_id 関数の実行速度は
|
||||
Intel Pentium4 3.2GHz CPU にて 約 85 msec です。
|
||||
|
||||
int cr_generate_id(u32 counter[CR_NUM_OF_SERIAL], u8 id[ID_BUF_SIZE]);
|
||||
/*
|
||||
Core2 Duo 2.66GHz 2GB で約0.016sec
|
||||
*/
|
||||
----------------------------
|
||||
使用サンプル:
|
||||
サンプル
|
||||
|
||||
main()
|
||||
展開したディレクトリの中で make を実行すると gen_id プログラムが作成されます。
|
||||
このプログラムは eFuseID を生成するサンプルプログラムです。
|
||||
|
||||
起動時にはボンディングオプションの指定が必要です。
|
||||
|
||||
例
|
||||
$ ./gen_id 00
|
||||
|
||||
プログラム中でキーボードからの入力受付を行います。
|
||||
以下のキーに対応しています。
|
||||
|
||||
p : デバイス ID とそれから生成される eFuseID データ、そして生成に掛かった平均時間を表示します。
|
||||
s : デバイス ID[0] をファイル名として実行ディレクトリにバイナリとして保存します。
|
||||
q : プログラムを終了します。
|
||||
|
||||
以下、sample.c の一部を抜粋します。
|
||||
util.c はユーティリティ関数を集めたもので ID 生成関数ライブラリで必要なものではありません。
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
u8 id_buf[CR_ID_BUF_SIZE]; /* 256byte(2048bit) */
|
||||
u32 counter_array[CR_NUM_OF_SERIAL];
|
||||
--- 省略 ---
|
||||
|
||||
u32 counter0 = 1;
|
||||
u64 counter1 = 2;
|
||||
u64 counter2 = 3;
|
||||
// cr_generate_id を使用する前に呼び出す
|
||||
ret_code = cr_generate_id_initialize( id_buf );
|
||||
if ( ret_code != CR_GENID_SUCCESS )
|
||||
{
|
||||
printf( "error : cr_generate_id_initialize\n" );
|
||||
return -1;
|
||||
}
|
||||
printf("done.\n");
|
||||
|
||||
--- 省略 ---
|
||||
|
||||
while( 1 ) {
|
||||
counter_array[0] = counter0;
|
||||
counter_array[1] = (u32)(counter1 & 0xffffffff );
|
||||
counter_array[2] = (u32)( (counter1 >> 32) & 0xffffffff );
|
||||
counter_array[3] = (u32)(counter2 & 0xffffffff );
|
||||
counter_array[4] = (u32)( (counter2 >> 32) & 0xffffffff );
|
||||
for ( i = 1; i < 0xffffffff; i++ )
|
||||
{
|
||||
|
||||
if( 0 != cr_generate_id(counter_array, id_buf) ) {
|
||||
fprintf(stderr,"cr_generate_id failed c=0x%08x\n",counter0);
|
||||
--- 省略 ---
|
||||
|
||||
// ID 生成
|
||||
time_start = gettimeofday_sec();
|
||||
ret_code = cr_generate_id( device_id, id_buf, bonding_option );
|
||||
if( ret_code != CR_GENID_SUCCESS )
|
||||
{
|
||||
fprintf(stderr, "cr_generate_id failed c=0x%08x\n", counter0);
|
||||
}
|
||||
else
|
||||
{
|
||||
time_end = gettimeofday_sec();
|
||||
time_total += (long double)(time_end - time_start);
|
||||
time_count++;
|
||||
}
|
||||
|
||||
--- 省略 ---
|
||||
}
|
||||
|
||||
end:
|
||||
--- 省略 ---
|
||||
|
||||
// cr_generate_id を使用した後に呼び出す
|
||||
if ( cr_generate_id_finalize( id_buf ) != CR_GENID_SUCCESS )
|
||||
{
|
||||
printf( "error : cr_generate_id_finalize\n" );
|
||||
return 0; // error
|
||||
}
|
||||
else {
|
||||
fwrite(id, CR_ID_BUF_SIZE, 1, fp);
|
||||
}
|
||||
counter0++;
|
||||
counter1 += (u64)rand();
|
||||
counter2 += (u64)rand();
|
||||
}
|
||||
|
||||
printf( "end of main.\n" );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user