Linux_SDK_V0.9.5

This commit is contained in:
thead_admin
2022-09-13 11:10:52 +08:00
commit 1f563c5db5
8142 changed files with 259305 additions and 0 deletions

View File

@@ -0,0 +1 @@
feedfacedeadbeeffeedfacedeadbeefabaddad2

View File

@@ -0,0 +1,186 @@
#!/bin/bash
##############################################################################
# Copyright (c) 2021 by Rambus, Inc. and/or its subsidiaries
# All rights reserved. Unauthorized use (including, without limitation,
# distribution and copying) is strictly prohibited. All use requires,
# and is subject to, explicit written authorization and nondisclosure
# Rambus, Inc. and/or its subsidiaries
#
# For more information or support, please go to our online support system at
# https://sipsupport.rambus.com.
# In case you do not have an account for this system, please send an e-mail
# to sipsupport@rambus.com.
##############################################################################
############################ constants ############################
result=0
ENGINE_ID_120=eip120
KERNEL_MODULE=umpci_k
OPENSSL=$OPENSSL_DIR/apps/openssl
O1="cipherout1.txt" # Temporary file, used for cipher eip120 output
O2="cipherout2.txt" # Temporary file, used for cipher 'internal' output
#MES=testdatain.txt #Data to encrypt or Decrypt
MES=message.txt
BIGMES=testdatain.txt
IVFILE=iv.txt # IV file for test application
KEYFILE=key.txt # Key file for test application
TAGFILE=tag.txt # tag file for test application
AADFILE=aad.txt # aad file for test application
RED='\033[0;31m'
GRN='\033[0;32m'
NC='\033[0m' # No Color
testarray=(aes-128-ecb aes-192-ecb aes-256-ecb
aes-128-cbc aes-192-cbc aes-256-cbc
aes-128-ctr aes-192-ctr aes-256-ctr
des-ecb des-cbc des-cfb des-ofb
des-ede3-ecb des-ede3-cbc des-ede3-cfb des-ede3-ofb
sm4-ecb sm4-cbc sm4-ctr)
keysizearray=(16 24 32
16 24 32
16 24 32
8 8 8 8
24 24 24 24
16 16 16)
ivsizearray=(0 0 0
16 16 16
16 16 16
0 8 8 8
0 8 8 8
0 16 16)
testarrayxts=(aes-128-xts aes-256-xts)
testarraygcm=(aes-128-gcm aes-192-gcm aes-256-gcm)
DATESTAMP=$(date +%y%m%d_%H%M)
TEMPFILE=tempfile.txt
VALGRIND_CMD='valgrind --leak-check=full --show-leak-kinds=all --log-file='$TEMPFILE
############################ functions ############################
validate_environment()
{
if [ ! -f $OPENSSL ]; then
echo "Error: openssl client not found"
exit 1
fi
if [ -z $OPENSSL_ENGINES ]; then
echo "Error: Environment variable OPENSSL_ENGINES is undefined"
exit 1
fi
if [ $(lsmod | grep "$KERNEL_MODULE" -c) -ne 1 ]; then
echo "Error: kernel module $KERNEL_MODULE not found"
exit 1
fi
${OPENSSL} engine -t ${ENGINE_ID_120} &> /dev/null
if [ $? -ne 0 ]; then
echo -e "\n${RED}Error: OpenSSL engine ${ENGINE_ID_120} is not loaded${NC}"
exit 1
fi
}
check_diff()
{
diff ${O1} ${O2} > /dev/null
if [ $? -ne 0 ]; then
echo -e "\n${RED}$1 $2 tests FAILED${NC}"
result=1
return
fi
if [ $2 = e ]; then
echo $1 ENCRYPTION PASSED
else
echo $1 DECRYPTION PASSED
fi
}
test_aes()
{
if [ $DO_VALGRIND ]; then
echo "// test_aes $1 $2" >> ciphertest_$DATESTAMP.log
fi
$VALGRIND ./../build/cipher --type $1 --engine ${ENGINE_ID_120} --in ${BIGMES} --out ${O1} --op $2 --iv ${IVFILE} --key ${KEYFILE} > /dev/null
if [ $1 = aes-128-ecb ] || [ $1 = aes-192-ecb ] || [ $1 = aes-256-ecb ] ||
[ $1 = des-ecb ] || [ $1 = des-ede3-ecb ] || [ $1 = sm4-ecb ]; then
${OPENSSL} $1 -nosalt -in ${BIGMES} -out ${O2} -$2 -K ${ckey:0:$3} -nopad > /dev/null
else
${OPENSSL} $1 -nosalt -in ${BIGMES} -out ${O2} -$2 -K ${ckey:0:$3} -iv ${ivkey:0:$4} -nopad > /dev/null
fi
check_diff $1 $2
if [ $DO_VALGRIND ]; then
cat $TEMPFILE >> ciphertest_$DATESTAMP.log
fi
}
test_xts()
{
if [ $DO_VALGRIND ]; then
echo "// test_xts $1 $2" >> ciphertest_$DATESTAMP.log
fi
$VALGRIND ./../build/cipher --type $1 --engine ${ENGINE_ID_120} --in ${MES} --out ${O1} --outdef ${O2} --op $2 --iv ${IVFILE} --key ${KEYFILE} > /dev/null
check_diff $1 $2
if [ $DO_VALGRIND ]; then
cat $TEMPFILE >> ciphertest_$DATESTAMP.log
fi
}
test_gcm()
{
if [ $DO_VALGRIND ]; then
echo "// test_gcm $1 $2" >> ciphertest_$DATESTAMP.log
fi
if [ $2 = e ]; then
$VALGRIND ./../build/cipher --type $1 --engine ${ENGINE_ID_120} --in ${MES} --out ${O1} --outdef ${O2} --op $2 --iv ${IVFILE} --key ${KEYFILE} --tag ${TAGFILE} --aad ${AADFILE} > /dev/null
check_diff $1 $2
else
$VALGRIND ./../build/cipher --type $1 --engine ${ENGINE_ID_120} --in ${O1} --out ${O1} --outdef ${O2} --op $2 --iv ${IVFILE} --key ${KEYFILE} --tag ${TAGFILE} --aad ${AADFILE} > /dev/null
check_diff $1 $2
fi
if [ $DO_VALGRIND ]; then
cat $TEMPFILE >> ciphertest_$DATESTAMP.log
fi
}
main () {
${OPENSSL} version
validate_environment
if [ "$1" = "-v" ]; then
DO_VALGRIND=1
VALGRIND=$VALGRIND_CMD
echo "// OS_IK ciphertest valgrind results - $DATESTAMP" > ciphertest_$DATESTAMP.log
fi
ckey=$(<${KEYFILE})
ivkey=$(<${IVFILE})
for ((loop = 0; loop < ${#testarray[@]}; loop++)); do
test_aes ${testarray[loop]} e ${keysizearray[loop]}*2 ${ivsizearray[loop]}*2
test_aes ${testarray[loop]} d ${keysizearray[loop]}*2 ${ivsizearray[loop]}*2
done
for loop in ${testarraygcm[@]}; do
test_gcm $loop e
test_gcm $loop d
done
for loop in ${testarrayxts[@]}; do
test_xts $loop e
test_xts $loop d
done
rm ${O1} ${O2}
if [ ${result} -ne 0 ]; then
echo -e "\n${RED}Cipher tests FAILED${NC}"
return
fi
echo -e "\n${GRN}Cipher tests PASSED${NC}"
if [ $DO_VALGRIND ]; then
rm $TEMPFILE
fi
}
main "$@"

View File

@@ -0,0 +1 @@
2b7e151628aed2a6abf7158809cf4f3c

View File

@@ -0,0 +1 @@
0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b

View File

@@ -0,0 +1,219 @@
#!/bin/bash
#*****************************************************************************
# Copyright (c) 2021 by Rambus, Inc. and/or its subsidiaries
# All rights reserved. Unauthorized use (including, without limitation,
# distribution and copying) is strictly prohibited. All use requires,
# and is subject to, explicit written authorization and nondisclosure
# Rambus, Inc. and/or its subsidiaries
#
# For more information or support, please go to our online support system at
# https://sipsupport.rambus.com.
# In case you do not have an account for this system, please send an e-mail
# to sipsupport@rambus.com.
#*****************************************************************************
############################ constants ############################
result=0
ENGINE_ID_120=eip120
KERNEL_MODULE=umpci_k
OPENSSL=$OPENSSL_DIR/apps/openssl
O1="htest_tmp1.txt" # Temporary file, used for hash eip120 output
O2="htest_tmp2.txt" # Temporary file, used for hash 'internal' output
HKEY=hkey.txt # HMAC key file
CKEY=ckey.txt # CMAC key file
RED='\033[0;31m'
GRN='\033[0;32m'
NC='\033[0m' # No Color
DATESTAMP=$(date +%y%m%d_%H%M)
TEMPFILE=tempfile.txt
VALGRIND_CMD='valgrind --leak-check=full --show-leak-kinds=all --log-file='$TEMPFILE
############################ functions ############################
validate_environment()
{
if [ ! -f $OPENSSL_DIR/apps/openssl ]; then
echo -e "${RED}Error: openssl client not found${NC}"
exit 1
fi
if [ -z $OPENSSL_ENGINES ]; then
echo -e "${RED}Error: Environment variable OPENSSL_ENGINES is undefined${NC}"
exit 1
fi
if [ $(lsmod | grep "$KERNEL_MODULE" -c) -ne 1 ]; then
echo -e "${RED}Error: kernel module $KERNEL_MODULE not found${NC}"
exit 1
fi
${OPENSSL} engine -t ${ENGINE_ID_120} &> /dev/null
if [ $? -ne 0 ]; then
echo -e "\n${RED}Error: OpenSSL engine ${ENGINE_ID_120} is not loaded${NC}"
exit 1
fi
}
check_diff()
{
diff ${O1} ${O2} > /dev/null
if [ $? -ne 0 ]; then
echo $1 "(psize "$2")" FAILED
result=1
return
fi
echo $1 "(psize "$2")" PASSED
}
test_hmac()
{
if [ $DO_VALGRIND ]; then
echo "// $1 $2" >> htest_$DATESTAMP.log
fi
head -c $2 lorum.txt | $VALGRIND ${OPENSSL} dgst -engine ${ENGINE_ID_120} -$1 -out ${O1} -mac HMAC -macopt hexkey:$hkey &> /dev/null
if [ $? -ne 0 ]; then
echo "openssl with " $1 "(psize "$2")" FAILED
result=1
return
fi
if [ $DO_VALGRIND ]; then
cat $TEMPFILE >> htest_$DATESTAMP.log
fi
head -c $2 lorum.txt | ${OPENSSL} dgst -$1 -out ${O2} -mac HMAC -macopt hexkey:$hkey > /dev/null
check_diff HMAC-$1 $2
}
test_hmacs()
{
psizes=$2
for psize in ${psizes[@]}; do
test_hmac $1 $psize
done
}
test_cmac()
{
if [ $DO_VALGRIND ]; then
echo "// $1 $2" >> htest_$DATESTAMP.log
fi
head -c $2 lorum.txt | $VALGRIND ${OPENSSL} dgst -engine ${ENGINE_ID_120} -out ${O1} -mac CMAC -macopt cipher:$1 -macopt hexkey:$ckey &> /dev/null
if [ $? -ne 0 ]; then
echo "openssl with cipher " $1 "(psize "$2")" FAILED
result=1
return
fi
if [ $DO_VALGRIND ]; then
cat $TEMPFILE >> htest_$DATESTAMP.log
fi
head -c $2 lorum.txt | ${OPENSSL} dgst -out ${O2} -mac CMAC -macopt cipher:$1 -macopt hexkey:$ckey > /dev/null
check_diff CMAC-$1 $2
}
test_cmacs()
{
psizes=$2
for psize in ${psizes[@]}; do
test_cmac $1 $psize
done
}
test_hash()
{
if [ $DO_VALGRIND ]; then
echo "// $1 $2" >> htest_$DATESTAMP.log
fi
head -c $2 lorum.txt | $VALGRIND ${OPENSSL} dgst -out ${O1} -$1 -engine eip120 -engine_impl &> /dev/null
if [ $? -ne 0 ]; then
echo "openssl with" $1 "(psize "$2")" FAILED
result=1
return
fi
if [ $DO_VALGRIND ]; then
cat $TEMPFILE >> htest_$DATESTAMP.log
fi
head -c $2 lorum.txt | ${OPENSSL} dgst -out ${O2} -$1 &> /dev/null
check_diff HASH-$1 $2
}
test_hashes()
{
psizes=$2
for psize in ${psizes[@]}; do
test_hash $1 $psize
done
}
main () {
${OPENSSL} version
validate_environment
if [ "$1" = "-v" ]; then
DO_VALGRIND=1
VALGRIND=$VALGRIND_CMD
echo "// OS_IK eip120 hash valgrind results - $DATESTAMP" > htest_$DATESTAMP.log
fi
hkey=$(<${HKEY})
test_hmacs sha1 '0 3 56 64 128 192 256 320 1023'
test_hmacs sha224 '0 3 56 64 128 192 256 320 1023'
test_hmacs sha256 '0 3 56 64 128 192 256 320 1023'
test_hmacs sha384 '0 3 56 128 256 384 512 640 1023'
test_hmacs sha512 '0 3 56 128 256 384 512 640 1023'
test_hmacs sha3-224 '0 3 56 144 288 432 576 720 1023'
test_hmacs sha3-256 '0 3 56 136 272 408 544 680 1023'
test_hmacs sha3-384 '0 3 56 104 208 312 416 520 1023'
test_hmacs sha3-512 '0 3 56 72 144 216 288 360 1023'
test_hmacs sm3 '0 3 56 64 128 256 384 512 640 1023'
ckey=$(<${CKEY})
test_cmacs aes-128-ecb '0 16 32 48 64 80 1023'
test_cmacs sm4-ecb '0 16 32 48 64 80 1023'
test_hashes sha1 '128 192 256 320 1023'
test_hashes sha224 '128 192 256 320 1023'
test_hashes sha256 '128 192 256 320 1023'
test_hashes sha384 '256 384 512 640 1023'
test_hashes sha512 '256 384 512 640 1023'
test_hashes sha3-224 '288 432 576 720 1023'
test_hashes sha3-256 '272 408 544 680 1023'
test_hashes sha3-384 '208 312 416 520 1023'
test_hashes sha3-512 '144 216 288 360 1023'
test_hashes sm3 '128 256 384 512 640 1023'
if [ $DO_VALGRIND ]; then
rm $TEMPFILE
fi
unset DO_VALGRIND
unset VALGRIND
test_hashes sha1 '3 56 64'
test_hashes sha224 '3 56 64'
test_hashes sha256 '3 56 64'
test_hashes sha384 '3 56 128'
test_hashes sha512 '3 56 128'
test_hashes sha3-224 '3 56 144'
test_hashes sha3-256 '3 56 136'
test_hashes sha3-384 '3 56 104'
test_hashes sha3-512 '3 56 72'
test_hashes sm3 '3 56 64'
rm ${O1} ${O2}
if [ ${result} -ne 0 ]; then
echo -e "\n${RED}Hash tests FAILED${NC}"
return
fi
echo -e "\n${GRN}Hash tests PASSED${NC}"
}
main "$@"

View File

@@ -0,0 +1 @@
12345678901234567890123456789012

View File

@@ -0,0 +1 @@
feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308

View File

@@ -0,0 +1,3 @@
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed dictum, urna a auctor ultrices, turpis quam fringilla elit, sed gravida sapien ex ut augue. Ut id sapien pellentesque, vulputate odio quis, posuere eros. Sed tincidunt, arcu vitae feugiat vehicula, leo turpis dictum lorem, a pulvinar ex elit sed metus. Phasellus mattis semper erat, sit amet dapibus neque consequat vitae. Quisque maximus enim et blandit eleifend. Aenean non est non neque aliquet venenatis. Nullam imperdiet justo vel finibus accumsan. Integer fermentum varius maximus.
Aenean sagittis eu mi in pretium. Morbi in justo ac tellus pulvinar ultrices ac vitae arcu. Donec facilisis justo a arcu ornare vulputate. Sed at dui et erat scelerisque pellentesque. In sed tortor risus. Pellentesque placerat et augue eget hendrerit. Nulla dolor sapien, iaculis vel egestas vitae, tincidunt id ante. Morbi sed auctor felis. Ut pellentesque placerat consectetur. Donec sit amet erat et risus viverra vestibulum. Mauris congue cursus lacus in lobortis laoreet.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long