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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

Jump to solution
170 Views
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.

Labels (1)
0 Kudos
Reply
1 Solution
112 Views
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

View solution in original post

0 Kudos
Reply
2 Replies
148 Views
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 Kudos
Reply
113 Views
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 Kudos
Reply