#!/bin/bash

#------------------------------------------------------------------------------#
# @file  md5sum
# @brief Retrieves the three `power side-channel' acquisition campaigns of the
#        `DPA contest' 1st edition from internet and checks for their integrity.
# @note  Location: https://svn.comelec.enst.fr/dpacontest/website/md5sum
#------------------------------------------------------------------------------#

### Retrieving the DPA campaigns:

BASE_URL=http://projects.comelec.enst.fr/dpacontest/traces_fs

for ZIP in \
	secmatv1_2006_04_0809.zip.part{0..3} \
	secmatv3_20070924_des.zip \
	secmatv3_20071219_des.zip.part{0..5}; do
	wget $BASE_URL/$ZIP
done

### Building the whole ZIP files from the multi-part archives:

cat secmatv1_2006_04_0809.zip.part{0..3} >secmatv1_2006_04_0809.zip
cat secmatv3_20071219_des.zip.part{0..5} >secmatv3_20071219_des.zip

### Checking the integrity of the three ZIP files:

cat <<MD5 |md5sum -c
12335f573cf85b37a2ccc95f0af4f69a  secmatv1_2006_04_0809.zip
e2de87cb6d38db9dc1a5081e513a5e06  secmatv3_20070924_des.zip
8d58b6e4170b050d43ca56dd02df5bf0  secmatv3_20071219_des.zip
MD5

### Removing the parts so as to keep only the complete ZIP files:

rm -f \
	secmatv1_2006_04_0809.zip.part{0..3} \
	secmatv3_20071219_des.zip.part{0..5}
