Are there any simple examples on how to use smw security middleware?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Are there any simple examples on how to use smw security middleware?

跳至解决方案
1,105 次查看
JohnKlug
Senior Contributor I

I attempted to write a program to just do a hash-2 512.  This results in the smw_hash() function calling exit(1).  We also would like to do AES 256 with this library which will require key generation and storage.

Are there any example programs I could look at?  I realize there is a test program, which does work, but it is much more complicated than what I would like to do.

Here is a trace of what I see, just calling smw_hash:

#0  __GI__exit (status=status@entry=1) at /usr/src/debug/glibc/2.39+git/sysdeps/unix/sysv/linux/_exit.c:27
#1  0x0000fffff7d8e0e0 in __run_exit_handlers (status=status@entry=1, listp=0xfffff7ef0660 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true) at exit.c:131
#2  0x0000fffff7d8e1f0 in __GI_exit (status=status@entry=1) at exit.c:138
#3  0x0000fffff7f90e88 in config_db_mutex_lock () at /usr/src/debug/smw/git/core/config/database.c:66
#4  0x0000fffff7f916fc in smw_config_select_subsystem (operation_id=OPERATION_ID_HASH, args=0xfffffffff958, subsystem_id=subsystem_id@entry=0xfffffffff94c) at /usr/src/debug/smw/git/core/config/database.c:560
#5  0x0000fffff7f7beb8 in smw_utils_execute_common (operation_id=operation_id@entry=OPERATION_ID_HASH, args=args@entry=0xfffffffff958, subsystem_id=<optimized out>, op_step=op_step@entry=SMW_OP_STEP_ONESHOT, 
    implicit=implicit@entry=false) at /usr/src/debug/smw/git/core/utils/exec.c:38
#6  0x0000fffff7f7bf04 in smw_utils_execute_operation (operation_id=operation_id@entry=OPERATION_ID_HASH, args=args@entry=0xfffffffff958, subsystem_id=<optimized out>)
    at /usr/src/debug/smw/git/core/utils/exec.c:89
#7  0x0000fffff7f88728 in smw_hash (args=args@entry=0xfffffffff9b8) at /usr/src/debug/smw/git/core/crypto/hash.c:115
#8  0x0000aaaaaaaa0a84 in main () at simplehash.c:38

 

This appears to be the cause of the EXIT:
SMW_DBG_ASSERT(ctx);

In my code, I did this prior to calling smw_hash, and it is not getting an error:

    memset(&ctx_args, 0, sizeof(ctx_args));
    ctx_args.subsystem_name = SMW_SUBSYSTEM_NAME_ELE;

    // Allocate context
    smw_result = smw_allocate_context(&ctx_args);
    if (smw_result != SMW_STATUS_OK) {
        printf("Failed to allocate context: %d\n", smw_result);
        return -1;
    }

 I am using IMX91 with  FRDM board, and am building with imx-6.6.36-2.1.0.xml.

标签 (1)
0 项奖励
回复
1 解答
1,047 次查看
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hello,

There is no library to play with this Middleware, and the current just support smw_hash at 64KB. Sorry in this case you can search some solution on the web or wait until next release to see if developers add more space to smw_hash.

Regards

在原帖中查看解决方案

0 项奖励
回复
2 回复数
1,083 次查看
JohnKlug
Senior Contributor I
I found out that if I called smw_osal_lib_init() first, I could get the smw_hash() to work. However smw_hash() would not work with files much over 64K Bytes. If I want to hash 100MB, how do I do this? I don't think any of the test examples hash large files?
0 项奖励
回复
1,048 次查看
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hello,

There is no library to play with this Middleware, and the current just support smw_hash at 64KB. Sorry in this case you can search some solution on the web or wait until next release to see if developers add more space to smw_hash.

Regards

0 项奖励
回复
%3CLINGO-SUB%20id%3D%22lingo-sub-2075311%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E6%9C%89%E6%B2%A1%E6%9C%89%E7%AE%80%E5%8D%95%E7%9A%84%E4%BE%8B%E5%AD%90%E4%BB%8B%E7%BB%8D%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%20smw%20%E5%AE%89%E5%85%A8%E4%B8%AD%E9%97%B4%E4%BB%B6%EF%BC%9F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2075311%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E6%88%91%E5%B0%9D%E8%AF%95%E7%BC%96%E5%86%99%E4%B8%80%E4%B8%AA%E7%A8%8B%E5%BA%8F%E6%9D%A5%E6%89%A7%E8%A1%8C%20hash-2%20512%E3%80%82%E8%BF%99%E5%AF%BC%E8%87%B4%20smw_hash()%20%E5%87%BD%E6%95%B0%E8%B0%83%E7%94%A8%20exit(1)%E3%80%82%E6%88%91%E4%BB%AC%E8%BF%98%E6%83%B3%E7%94%A8%E8%BF%99%E4%B8%AA%E5%BA%93%E6%9D%A5%E5%AE%9E%E7%8E%B0%20AES%20256%EF%BC%8C%E8%BF%99%E5%B0%86%E9%9C%80%E8%A6%81%E5%AF%86%E9%92%A5%E7%94%9F%E6%88%90%E5%92%8C%E5%AD%98%E5%82%A8%E3%80%82%3CBR%20%2F%3E%3CBR%20%2F%3E%E6%9C%89%E6%B2%A1%E6%9C%89%E6%88%91%E5%8F%AF%E4%BB%A5%E7%9C%8B%E7%9C%8B%E7%9A%84%E7%A4%BA%E4%BE%8B%E7%A8%8B%E5%BA%8F%EF%BC%9F%E6%88%91%E7%9F%A5%E9%81%93%E6%9C%89%E4%B8%80%E4%B8%AA%E6%B5%8B%E8%AF%95%E7%A8%8B%E5%BA%8F%EF%BC%8C%E5%AE%83%E7%A1%AE%E5%AE%9E%E5%8F%AF%E4%BB%A5%E5%B7%A5%E4%BD%9C%EF%BC%8C%E4%BD%86%E5%AE%83%E6%AF%94%E6%88%91%E6%83%B3%E8%A6%81%E5%81%9A%E7%9A%84%E8%A6%81%E5%A4%8D%E6%9D%82%E5%BE%97%E5%A4%9A%E3%80%82%3CBR%20%2F%3E%3CBR%20%2F%3E%E8%BF%99%E6%98%AF%E6%88%91%E6%89%80%E7%9C%8B%E5%88%B0%E7%9A%84%E7%97%95%E8%BF%B9%EF%BC%8C%E5%8F%AA%E6%98%AF%E8%B0%83%E7%94%A8%20smw_hash%EF%BC%9A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-c%22%3E%3CCODE%20translate%3D%22no%22%3E%230%20%20__GI__exit%20(status%3Dstatus%40entry%3D1)%20at%20%2Fusr%2Fsrc%2Fdebug%2Fglibc%2F2.39%2Bgit%2Fsysdeps%2Funix%2Fsysv%2Flinux%2F_exit.c%3A27%0A%231%20%200x0000fffff7d8e0e0%20in%20__run_exit_handlers%20(status%3Dstatus%40entry%3D1%2C%20listp%3D0xfffff7ef0660%20%26lt%3B__exit_funcs%26gt%3B%2C%20run_list_atexit%3Drun_list_atexit%40entry%3Dtrue%2C%20run_dtors%3Drun_dtors%40entry%3Dtrue)%20at%20exit.c%3A131%0A%232%20%200x0000fffff7d8e1f0%20in%20__GI_exit%20(status%3Dstatus%40entry%3D1)%20at%20exit.c%3A138%0A%233%20%200x0000fffff7f90e88%20in%20config_db_mutex_lock%20()%20at%20%2Fusr%2Fsrc%2Fdebug%2Fsmw%2Fgit%2Fcore%2Fconfig%2Fdatabase.c%3A66%0A%234%20%200x0000fffff7f916fc%20in%20smw_config_select_subsystem%20(operation_id%3DOPERATION_ID_HASH%2C%20args%3D0xfffffffff958%2C%20subsystem_id%3Dsubsystem_id%40entry%3D0xfffffffff94c)%20at%20%2Fusr%2Fsrc%2Fdebug%2Fsmw%2Fgit%2Fcore%2Fconfig%2Fdatabase.c%3A560%0A%235%20%200x0000fffff7f7beb8%20in%20smw_utils_execute_common%20(operation_id%3Doperation_id%40entry%3DOPERATION_ID_HASH%2C%20args%3Dargs%40entry%3D0xfffffffff958%2C%20subsystem_id%3D%3COPTIMIZED%20out%3D%22%22%3E%2C%20op_step%3Dop_step%40entry%3DSMW_OP_STEP_ONESHOT%2C%20%0A%20%20%20%20implicit%3Dimplicit%40entry%3Dfalse)%20at%20%2Fusr%2Fsrc%2Fdebug%2Fsmw%2Fgit%2Fcore%2Futils%2Fexec.c%3A38%0A%236%20%200x0000fffff7f7bf04%20in%20smw_utils_execute_operation%20(operation_id%3Doperation_id%40entry%3DOPERATION_ID_HASH%2C%20args%3Dargs%40entry%3D0xfffffffff958%2C%20subsystem_id%3D%3COPTIMIZED%20out%3D%22%22%3E)%0A%20%20%20%20at%20%2Fusr%2Fsrc%2Fdebug%2Fsmw%2Fgit%2Fcore%2Futils%2Fexec.c%3A89%0A%237%20%200x0000fffff7f88728%20in%20smw_hash%20(args%3Dargs%40entry%3D0xfffffffff9b8)%20at%20%2Fusr%2Fsrc%2Fdebug%2Fsmw%2Fgit%2Fcore%2Fcrypto%2Fhash.c%3A115%0A%238%20%200x0000aaaaaaaa0a84%20in%20main%20()%20at%20simplehash.c%3A38%3C%2FOPTIMIZED%3E%3C%2FOPTIMIZED%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CBR%20%2F%3E%3CP%3E%E8%BF%99%E4%BC%BC%E4%B9%8E%E6%98%AF%20EXIT%20%E7%9A%84%E5%8E%9F%E5%9B%A0%EF%BC%9A%3CBR%20%2F%3E%20SMW_DBG_ASSERT(ctx)%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%E5%9C%A8%E6%88%91%E7%9A%84%E4%BB%A3%E7%A0%81%E4%B8%AD%EF%BC%8C%E6%88%91%E5%9C%A8%E8%B0%83%E7%94%A8%20smw_hash%20%E4%B9%8B%E5%89%8D%E6%89%A7%E8%A1%8C%E4%BA%86%E6%AD%A4%E6%93%8D%E4%BD%9C%EF%BC%8C%E5%B9%B6%E4%B8%94%E6%B2%A1%E6%9C%89%E5%87%BA%E7%8E%B0%E9%94%99%E8%AF%AF%EF%BC%9A%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-c%22%3E%3CCODE%20translate%3D%22no%22%3E%20%20%20%20memset(%26amp%3Bctx_args%2C%200%2C%20sizeof(ctx_args))%3B%0A%20%20%20%20ctx_args.subsystem_name%20%3D%20SMW_SUBSYSTEM_NAME_ELE%3B%0A%0A%20%20%20%20%2F%2F%20Allocate%20context%0A%20%20%20%20smw_result%20%3D%20smw_allocate_context(%26amp%3Bctx_args)%3B%0A%20%20%20%20if%20(smw_result%20!%3D%20SMW_STATUS_OK)%20%7B%0A%20%20%20%20%20%20%20%20printf(%22Failed%20to%20allocate%20context%3A%20%25d%5Cn%22%2C%20smw_result)%3B%0A%20%20%20%20%20%20%20%20return%20-1%3B%0A%20%20%20%20%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%E6%88%91%E6%AD%A3%E5%9C%A8%E4%BD%BF%E7%94%A8%E5%B8%A6%E6%9C%89%20FRDM%20%E6%9D%BF%E7%9A%84%20IMX91%EF%BC%8C%E5%B9%B6%E4%BD%BF%E7%94%A8%20imx-6.6.36-2.1.0.xml%20%E8%BF%9B%E8%A1%8C%E6%9E%84%E5%BB%BA%E3%80%82%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2075311%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3EFRDM%20%E5%9F%B9%E8%AE%AD%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2075447%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E6%9C%89%E6%B2%A1%E6%9C%89%E5%85%B3%E4%BA%8E%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%20smw%20%E5%AE%89%E5%85%A8%E4%B8%AD%E9%97%B4%E4%BB%B6%E7%9A%84%E7%AE%80%E5%8D%95%E7%A4%BA%E4%BE%8B%EF%BC%9F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2075447%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E6%88%91%E5%8F%91%E7%8E%B0%E5%A6%82%E6%9E%9C%E6%88%91%E5%85%88%E8%B0%83%E7%94%A8%20smw_osal_lib_init()%EF%BC%8C%E6%88%91%E5%B0%B1%E5%8F%AF%E4%BB%A5%E8%AE%A9%20smw_hash()%20%E5%B7%A5%E4%BD%9C%E3%80%82%E4%BD%86%E6%98%AF%20smw_hash()%20%E4%B8%8D%E9%80%82%E7%94%A8%E4%BA%8E%E8%B6%85%E8%BF%87%2064K%20%E5%AD%97%E8%8A%82%E7%9A%84%E6%96%87%E4%BB%B6%E3%80%82%E5%A6%82%E6%9E%9C%E6%88%91%E6%83%B3%E5%AF%B9%20100MB%20%E8%BF%9B%E8%A1%8C%E5%93%88%E5%B8%8C%E5%A4%84%E7%90%86%EF%BC%8C%E6%88%91%E8%AF%A5%E6%80%8E%E4%B9%88%E5%81%9A%EF%BC%9F%E6%88%91%E8%AE%A4%E4%B8%BA%E6%B2%A1%E6%9C%89%E4%BB%BB%E4%BD%95%E6%B5%8B%E8%AF%95%E7%A4%BA%E4%BE%8B%E5%8F%AF%E4%BB%A5%E5%AF%B9%E5%A4%A7%E6%96%87%E4%BB%B6%E8%BF%9B%E8%A1%8C%E5%93%88%E5%B8%8C%E5%A4%84%E7%90%86%EF%BC%9F%3C%2FLINGO-BODY%3E