How to Let New Added Block Cipher Pass The Auto Check

2 views
Skip to first unread message

weic...@gmail.com

unread,
Oct 25, 2018, 9:54:38 AM10/25/18
to LibTom Projects
Dear All:

I'm trying to add SM4 block cipher to libtomcrypt.
And I have almost done my work on my own repository and tried to request a pull.
But it can't pass auto-check. I tried to check my code locally with command:

/testme.sh "makefile -j4" "-DUSE_LTM -DLTM_DESC -I../libtommath" ../libtommath/libtommath.a

I find out that this script will compare generated files to the one in notes direcroty.
eg. It will compare cipher_tv.txt with notes/cipher_tv.txt using diff command and return failure if thay are not match.
I generate note/cipher_tv.txt with below script:

#!/bin/bash                                                                                                                                                                                                         
cp input.bin x.bin                                                                                                          
rm -rf sm4_tv.txt                                                                                                           
i=0                                                                                                                         
                                                                                                                            
echo 'Cipher: sm4' > sm4_tv.txt                                                                                             
echo 'Key Size: 16 bytes' >> sm4_tv.txt                                                                                     
                                                                                                                            
while [ $i -lt 50 ]; do                                                                                                     
    key=`xxd -u -p x.bin`                                                                                                   
    openssl enc -sm4-ecb -in x.bin -out y.bin -e -nopad -nosalt -K $key                                                     
    printf '%2d: %s\n' $i `xxd -p -u y.bin` >> sm4_tv.txt                                                                   
    mv y.bin x.bin                                                                                                          
    let i++                                                                                                                 
done  

And it passed after I merged sm4_tv.txt into cipher_tv.txt

But for other files like ccm_tv.txt eax_tv.txt gcm_tv.txt ......
I was struggling among these files.

Is there a way to generate these files automatically?

Thanks
Chao Wei
2018/08/25

Steffen Jaeckel

unread,
Oct 25, 2018, 10:04:44 AM10/25/18
to lib...@googlegroups.com, weic...@gmail.com
1. build the make-target tv_gen

> $ make -j9 CFLAGS=" -DLTM_DESC -I../libtommath/ -DUSE_LTM" EXTRALIBS="../libtommath/libtommath.a" tv_gen


2. run tv_gen

> $ ./tv_gen
> Generating hash vectors...done
> Generating cipher vectors...done
> Generating HMAC vectors...done
> Generating OMAC vectors...done
> Generating PMAC vectors...done
> Generating EAX vectors...done
> Generating OCB vectors...done
> Generating OCB3 vectors...done
> Generating CCM vectors...done
> Generating GCM vectors...done
> Generating BASE64 vectors...done
> Generating MATH vectors...done
> Generating ECC vectors...done
> Generating LRW vectors...done


3. update tv files

> $ mv *_tv.txt notes/


when checking-out your PR and doing exactly the steps above I get

> $ git status -s
> M notes/ccm_tv.txt
> M notes/cipher_tv.txt
> M notes/eax_tv.txt
> M notes/gcm_tv.txt
> M notes/ocb3_tv.txt
> M notes/ocb_tv.txt
> M notes/omac_tv.txt
> M notes/pmac_tv.txt


Btw. the PR basically looks good, you can open it again after fixing
this, thanks already!


HTH
Steffen
> --
> *** Please reply-to-all at all times ***
> *** (do not pretend to know who is subscribed and who is not) ***
> *** Please avoid top-posting. ***
> ---
> You received this message because you are subscribed to the Google
> Groups "LibTom Projects" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to libtom+un...@googlegroups.com
> <mailto:libtom+un...@googlegroups.com>.
> To post to this group, send email to lib...@googlegroups.com
> <mailto:lib...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/libtom.
> For more options, visit https://groups.google.com/d/optout.

--
Steffen Jaeckel - s_ja...@gmx.de
GnuPG fingerprint: C438 6A23 7ED4 3A47 5541 B942 7B2C D0DD 4BCF F59B
My OTR key has changed on 30. Sept. 2015!
jabber: jae...@jabber.ccc.de 93BA97FA F3702AB7 DCBEB7C7 291DB383 284996CB

weic...@gmail.com

unread,
Oct 25, 2018, 11:08:03 PM10/25/18
to LibTom Projects
Dear Steffen:

Following your guidance, I created a new pull request just now(#457). And it passed Travis-CI.
It's my first time contributing to a open source project. I hope it's a good start. ^_^
Thanks for your help.

Chao Wei
2018/10/26

在 2018年10月25日星期四 UTC+8下午10:04:44,Steffen Jaeckel写道:
Reply all
Reply to author
Forward
0 new messages