非標準環境でのwolfCryptテストおよびベンチマークアプリケーションの構築に関するご質問が当社のサポートチームに複数回よせられています。私たちはこうした人々のための課題解決策を提供しています! wolfSSL組み込みSSL/TLSライブラリには、これらのアプリケーションが両方とも付属しているため、ユーザはwolfSSLを目的のプラットフォームで起動、実行させることができます。
wolfCryptテストアプリケーションは、使用可能なすべてのアルゴリズムのアルゴリズムテストを実行して、プラットフォーム上で正しく動作していることを確認します。これは、wolfSSLを新しいプラットフォームに移植するときに最初に取るべきステップです。
wolfCryptベンチマークアプリケーションは、wolfSSLにそのビルドで組み込まれる全ての暗号アルゴリズムをベンチマークします。これにより、ユーザーは特定のプラットフォームと構成の暗号ライブラリのパフォーマンスを知ることができます。これは、ソフトウェア暗号化とハードウェア暗号化のパフォーマンス差異を確認するのにも役立ちます。
まず、アプリケーションからwolfCryptテストまたはベンチマークを呼び出す方法について説明します。
typedef struct func_args {
int argc;
char** argv;
int return_code;
} func_args;
/* ... other code ... */
int main (void)
{
/* other function declarations */
func_args args;
/* ... system setup and initialization ... */
/* for wolfcrypt test app: */
ret = wolfcrypt_test(&args);
/* for benchmark app: */
/* ret = benchmark_test(&args); */
if (ret != 0) {
printf("wolfCrypt tests failed!\n")
printf("test returned error code: %d\n", ret);
printf("the crypto error code was: %d\n", args.return_code);
} else {
printf("crypto tests PASSED!\n");
}
while (1)
{
/* Application code TODO: Logic here */
}
}
以下のリンクにある移植とチューニングのガイドに加えて、wolfCryptテストやベンチマークが実行される前に、設定に追加するその他の項目があるかもしれません。
wolfSSL移植ガイド
wolfSSLチューニングガイド
移植およびチューニングのガイドでカバーされていない項目には次のものが含まれます:
NO_MAIN_DRIVER
BENCH_EMBEDDED
NO_64BIT
USE_CERT_BUFFERS_XXX(X)
ALT_ECC_SIZE
ECC_USER_CURVES (and related defines)
FP_MAX_BITS.
fastmathと通常の数学ライブラリをカバーしていますが、fastmath(より多くのスタックと少ないヒープを使用)と通常の数学ライブラリ(より多くのヒープと少ないスタックを使用します)の違いを強調しながら、wolfCryptテストアプリケーション(/wolcrypt/test/test.c)とwolfCryptベンチマークアプリケーション(/wolfcrypt/benchmark/benchmark.c)を非標準環境に移植する際に、これらの定義を出発点として自由に使用してください!
/* Other defines as determined from the wolfSSL porting guide found here:
* https://wolfssl.com/wolfSSL/Docs-wolfssl-porting-guide.html
*/
/* Purpose:
* If running the wolfcrypt/benchmark/benchmark.c
* app will reduce stack use for embedded devices
*/
#define BENCH_EMBEDDED
/* Purpose:
* Embedded systems already have a main method typically
* will remove the "main" in benchmark.c and test.c
*/
#define NO_MAIN_DRIVER
/* Purpose:
* If working on a 32-bit system, it will sometimes use 2x 32-bit types to execute 64-bit
* math operations which greatly slows down computation time. This define can speeds
* things up. Commented by default, uncomment if computation speeds are too slow.
*/
/* #define NO_64BIT */
/* Begin RSA Section */
/* --------------------------------------------------- */
/* Uncomment the define for NO_RSA to remove RSA */
/* #define NO_RSA */
#ifndef NO_RSA
#error "Please set RSA key size then comment out or delete this line."
/* XXXX should be "2048" for 2048 bit RSA keys
* XXXX should be "1024" for 1024 bit RSA keys
* IE choose one of the following to uncomment
*/
/* #define USE_CERT_BUFFERS_2048 */
/* #define USE_CERT_BUFFERS_1024 */
/*
* the certificate buffers can be found in <wolfssl-root>/wolfssl/test_certs.h
*/
/* Purpose:
* To reduce stack based on RSA key size chosen
*/
#ifdef USE_CERT_BUFFERS_1024
#define FP_MAX_BITS 2048 /* (RSA key size selected x2) */
#elif defined(USE_CERT_BUFFERS_2048)
#define FP_MAX_BITS 4096
#endif /* USE_CERT_BUFFERS_1024 */
#endif /* NO_RSA */
/* --------------------------------------------------- */
/* End File System and RSA section */
/* Begin ECC Section */
/* --------------------------------------------------- */
/* Purpose:
* enable ECC. Comment to remove ECC
*/
#define HAVE_ECC
#ifdef HAVE_ECC
#define ECC_TIMING_RESISTANT /* See explenation for TFM_TIMING_RESISTANT */
#define USE_CERT_BUFFERS_256 /* for ecc, see File System and RSA Section above */
/* the certificate buffers can be found in <wolfssl-root>/wolfssl/test_certs.h
/* Purpose:
* Reduce ECC memory use
*/
#define ALT_ECC_SIZE
/* Purpose:
* Only allow for 256-bit ecc keys by default. To remove support for 256-bit ECC keys
* uncomment the next line.
*/
/* #define NO_ECC256 */
/*
* A list of supported ECC curves is included below, uncomment as desired.
* For other ECC defines see <wolfssl-root>/wolfcrypt/src/ecc.c
*/
#define ECC_USER_CURVES
/* #define HAVE_ECC112 */
/* #define HAVE_ECC128 */
/* #define HAVE_ECC160 */
/* #define HAVE_ECC192 */
/* #define HAVE_ECC224 */
/* #define HAVE_ECC239 */
/* #define HAVE_ECC320 */
/* #define HAVE_ECC384 */
/* #define HAVE_ECC512 */
/* #define HAVE_ECC521 */
#endif /* HAVE_ECC */
/* --------------------------------------------------- */
/* End ECC Section */
さらに詳しい情報は弊社問い合わせ窓口 (info@wolfssl.com, info@wolfssl.jp: 日本語)までお問い合わせください。
原文: https://www.wolfssl.com/wolfssl-test-benchmark-applications-non-standard-environment/
wolfSSLホーム:www.wolfssl.jp (English:www.wolfssl.com)
