Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 30 additions & 7 deletions eaclogger/logger/eac.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import eaclogger
import time
import hashlib
import pprp
import whipper
from whipper.common import common
from whipper.result import result
Expand Down Expand Up @@ -205,13 +205,36 @@ def logRip(self, ripResult, epoch):
lines.append("End of status report")
lines.append("")

# Log checksum (uppercase hex encoded SHA256 hash of all lines)
# It isn't compatible with EAC's one: checklog fail
lines.append("")
hasher = hashlib.sha256()
hasher.update("\n".join(lines).encode("utf-8"))
lines.append("==== Log checksum %s ====" % hasher.hexdigest().upper())
# Log checksum
# Based off https://github.com/puddly/eac_logsigner
text = ''.join(lines)

# Setup Rijndael-256 with a 256-bit blocksize
cipher = pprp.crypto_3.rijndael(
key = bytes(bytearray.fromhex('9378716cf13e4265ae55338e940b376184da389e50647726b35f6f341ee3efd9')),
block_size = 256 // 8
)

# Encode the text as UTF-16-LE
plaintext = text.encode('utf-16-le')

# The IV is all zeroes so we don't have to handle it
signature = b'\x00' * 32

# Process it block-by-block
for i in range(0, len(plaintext), 32):
# Zero-pad the last block, if necessary
plaintext_block = plaintext[i:i + 32].ljust(32, b'\x00')

# CBC mode (XOR the previous ciphertext block into the plaintext)
cbc_plaintext = bytes(a ^ b for a, b in zip(signature, plaintext_block))

# New signature is the ciphertext.
signature = cipher.encrypt(cbc_plaintext)

# Textual signature is just the hex representation
lines.append("")
lines.append(f"==== Log checksum {signature.hex().upper()} ====")

return lines

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pprp==0.2.6