Hi,

here's my 5 minute try of converting elfsign to use sha1. It builds fine, but 
I must admit that I have no clue how to test it. Maybe it helps 
nonetheless...

Cheers,
    Stefan.
--- elfsign-0.2.2.orig/lib/verify.c
+++ elfsign-0.2.2/lib/verify.c
@@ -10,7 +10,7 @@
 
 #include "openssl/objects.h"
 #include "openssl/rsa.h"
-#include "openssl/md5.h"
+#include "openssl/sha.h"
 
 #include "openssl/x509.h"
 #include "openssl/pem.h"
@@ -243,9 +243,9 @@
 	Elf32_Off sectionTableOffset;
 	Elf32_Half numSections;
 	Elf32_Ehdr *elfHeader;
-	MD5_CTX md5;
+	SHA_CTX sha1;
 
-	MD5_Init(&md5);
+	SHA1_Init(&sha1);
 
 	// Include the ELF header, but with the number of sections set minus one,
 	// under the assumption that any binary having its checksum
@@ -262,7 +262,7 @@
 	melf_elfSetSectionHeaderCount(melf, numSections - 1);
 	melf_elfSetSectionHeaderOffset(melf, 0);
 
-	MD5_Update(&md5, elfHeader, sizeof(Elf32_Ehdr));
+	SHA1_Update(&sha1, elfHeader, sizeof(Elf32_Ehdr));
 
 	melf_elfSetSectionHeaderCount(melf, numSections);
 	melf_elfSetSectionHeaderOffset(melf, sectionTableOffset);
@@ -301,10 +301,10 @@
 
 		// Include the section's body content in the checksum
 		if (currSection->content)
-			MD5_Update(&md5, currSection->content, currSection->contentLength);
+			SHA1_Update(&sha1, currSection->content, currSection->contentLength);
 
 		// Include the section's header in the checksum
-		MD5_Update(&md5, 
+		SHA1_Update(&sha1,
 				&currSection->spec.section, 
 				melf_elfGetSectionEntrySize(melf));
 
@@ -317,13 +317,13 @@
 		  currProgram;
 		  currProgram = melf_sectionEnumNext(melf, currProgram))
 	{
-		MD5_Update(&md5, 
+		SHA1_Update(&sha1, 
 				&currProgram->spec.program, 
 				melf_elfGetProgramEntrySize(melf));
 	}
 
 	// Finalize the digest
-	MD5_Final(digest, &md5);
+	SHA1_Final(digest, &sha1);
 
 	if (sigHeader)
 		*sigHeader = lSigHeader;

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to