This sample code is to show the users about how to utilize the Cipher Hardware for
security verification and encryption/decryption with Cipher LIB API.


Sample code files tree
=================================
|__ scpu_ldb_server
├── build.sh
├── linux.mak
├── Makefile
├── README
├── sample_aes_sm4.c
├── sample.c
├── sample_cipher_common.h
├── sample_cipher_data_image.data
├── sample_cipher_data_image_nsign.data
├── sample_ecdh.c
├── sample_hash.c
├── sample_image_dec.c
├── sample_loadable.c
├── sample_nsign_verify.c
├── sample_rsa.c
├── sample_rsa_sign.c
└── sample_trng.c

sample.c is the entry of the program. Each sample_xxx.c is a sample for the specified
algorithm or function.

scpu_ldb_server is the entry of the loadable server, which is used to extend the function
of bootrom. The loadable server is run on secure cpu. scpu_ldb_server will generate array
scpu_ldb_rsa_sample_nsign_bin used by sample_loadable.c. More information about the
loadable server can be found in the scpu_ldb_server/README.


How to build the sample code
=================================
1.Edit the build.sh, change the path of the STAGING_DIR with your actual path where the lib
  and header are stored.
  The libes_memory.so and libes_cipher.so should be stored under STAGING_DIR/usr/lib/essdk
  The es_type.h, es_sys_memory.h and es_cipher.h should be stored under
  STAGING_DIR/usr/include/essdk
2.Edit the build.sh, change the CROSS_COMPILE with your actual path of the cross compile tool
2.Run "./build.sh"
  The executable program file named sample_cipher will be generated under the sample folder.
3.Run "make clean" to clean the generated .o and bin files


Run the program
=================================
[root@eswin-os:/opt/eswin/bin]$ ./sample_cipher
##########----Run a cipher sample:for example, ./sample_cipher 1----###############
    Please selset a cipher sample to run as fllow:
    [1] aes_sm4
    [2] hash
    [3] trng
    [4] image_dec
    [5] rsa
    [6] nsign_verify
    [7] ecdh
    [8] rsa sign and verify
    [9] loadable service

[root@eswin-os:/opt/eswin/bin]$ ./sample_cipher 1
[E][ES_MEM]  dmabuf_heap_open:  284 open /dev/dma_heap/secure_memory_nid_0_part_0 failed!
[E][ES_MEM]  dmabuf_heap_open:  284 open /dev/dma_heap/secure_memory_nid_0_part_1 failed!

~~~~~~~~~~~~~~~~~~ run sample_aes_sm4 ~~~~~~~~~~~~~~~~~~~
Hello sample_aes_sm4
external_CBC_AES128 begin---
external_CBC_AES128,start encrypt...
external_CBC_AES128,start decrypt...
multi_external_CBC_AES128 begin---
multi_external_CBC_AES128,start encrypt...
multi_external_CBC_AES128,start decrypt...

################# FUNCTION 1 RUN SUCCESS #################


Description for each sample_xxx.c
=================================
For the detailed description, please refer to the comment in each sample_xxx.c.