Last active
December 7, 2023 09:12
-
-
Save RealEnder/ae1330350f612c7f558e9f6533d3842a to your computer and use it in GitHub Desktop.
Verify machine voting files from BG elections 11 July 2021, 14 November 2021, 21 November 2021, 2 October 2022, 2 April 2023, 5 November 2023
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Verify machine voting files from BG elections 11 July 2021, 14 November 2021, 21 November 2021, 2 October 2022, 2 April 2023, 5 November 2023 | |
# (c) 2021-2023 Alex Stanev <alex@stanev.org>, MIT license | |
# Opendata URLs for different elections: | |
# Parliamentary elections 11 July 2021: https://results.cik.bg/pi2021_07/export.zip | |
# Parliamentary and presidential elections 14 November 2021: https://results.cik.bg/pvrns2021/tur1/export.zip | |
# Presidential elections 21 November 2021: https://results.cik.bg/pvrns2021/tur2/export.zip | |
# Parliamentary elections 11 July 2021: https://results.cik.bg/ns2022/export.zip | |
# Parliamentary elections 02 October 2022: https://results.cik.bg/ns2022/export.zip | |
# Parliamentary elections 02 April 2023: https://results.cik.bg/ns2023/export.zip | |
# Local elections 2023 tour2 05 November 2023: https://results.cik.bg/mi2023/tur2/opendata/export.zip | |
# Change the URL below for the selected election. | |
wget https://results.cik.bg/mi2023/tur2/opendata/export.zip -U 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36' -O export.zip | |
unzip -oq export.zip "suemg/*" | |
unzip -oqc suemg/ca.zip > chain.pem | |
TMPDIR=$(mktemp -d) | |
if [ ! -d "$TMPDIR" ]; then echo "Error creating temp dir!"; exit 1; fi | |
for Z in $(find suemg -name '?????????*.zip') | |
do | |
SIKID=${Z%%.*} | |
SIKID=${SIKID##*/} | |
echo -ne $SIKID '\t' | |
unzip -oq "$Z" -d "$TMPDIR" | |
openssl cms -verify -inform PEM -in "$TMPDIR/$SIKID.csv.p7s" -content "$TMPDIR/$SIKID.csv" -CAfile chain.pem -purpose any -out /dev/null | |
if [ $? -ne 0 ]; then exit 1; fi | |
done | |
rm -rf "$TMPDIR" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment