1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[misc] add SHA-256 checksum computation

* Closes #607
This commit is contained in:
Pete Batard 2015-09-29 23:53:07 +01:00
parent 3238c9e637
commit c2293b5177
7 changed files with 286 additions and 95 deletions

View file

@ -517,7 +517,7 @@ t MSG_268 "Applying Windows image..."
t MSG_269 "Preserve timestamps"
t MSG_270 "USB debug"
t MSG_271 "Computing image checksums: %0.1f%% completed"
t MSG_272 "Compute the SHA1 and MD5 checksums for the selected image"
t MSG_272 "Compute the MD5, SHA1 and SHA256 checksums for the selected image"
t MSG_273 "Change the application language"
t MSG_274 "ISOHybrid image detected"
# '%s' below will be replaced with your translations for MSG_036 ("ISO Image") and MSG_095 ("DD Image")
@ -962,7 +962,7 @@ t MSG_268 "تطبيق صورة (إيميج) ويندوز..."
t MSG_269 "الحفاظ على الطوابع الزمنية"
t MSG_270 "تنقيح الأخطاء عن طريق USB"
t MSG_271 "حساب مجاميع اختبار (checksums) الصورة: %0.1f%% تم"
t MSG_272 "حساب مجاميع اختبار (checksums) SHA1 و MD5 للصورة المختارة"
t MSG_272 "حساب مجاميع اختبار (checksums) SHA256 و SHA1 و MD5 للصورة المختارة"
t MSG_273 "تغيير لغة التطبيق"
t MSG_274 "إكتشاف صورة ISOHybrid"
t MSG_275 "الصورة التي اخترتها هي صورة 'ISOHybrid'. هذا يعني أنه يمكن كتابتها في "
@ -1437,7 +1437,7 @@ t MSG_268 "Прилагане на Windows образ..."
t MSG_269 "Запазване на времеви маркер"
t MSG_270 "Отсраняване USB грешки"
t MSG_271 "Изчисление на контролерите на образа: %0.1f%% завършено"
t MSG_272 "Изчисли SHA1 MD5 контролера на избраният образ"
t MSG_272 "Изчисли MD5, SHA1, SHA256 контролера на избраният образ"
t MSG_273 "Смени езикът на приложението:"
t MSG_274 "Отркрит е ISOHybrid образ "
t MSG_275 "Образът който сте избрали е тип 'ISOHybrid'. Това означава че може да бъде записан като: "
@ -3087,7 +3087,7 @@ t MSG_268 "Použití Windows obrazu..."
t MSG_269 "Zachovat časovou značku"
t MSG_270 "USB ladění"
t MSG_271 "Výpočet kontrolních součtů: %0.1f%% komplet"
t MSG_272 "Vypočet SHA1 a MD5 kontrolního součty pro vybraný obraz"
t MSG_272 "Vypočet MD5, SHA1 a SHA256 kontrolního součty pro vybraný obraz"
t MSG_273 "Změna jazyka aplikace"
t MSG_274 "ISOHybridní obraz detekován"
t MSG_275 "Obráz, který jste si vybrali, je obraz 'ISOHybrid'. To znamená, že může být zapsán buď v "
@ -3522,7 +3522,7 @@ t MSG_268 "Anvender Windows-image..."
t MSG_269 "Bevar tidsstempler"
t MSG_270 "USB debug"
t MSG_271 "Beregner imagechecksumme: %0.1f%% fuldført"
t MSG_272 "Beregner SHA1- og MD5-checksumme for det valgte diskbillede"
t MSG_272 "Beregner MD5-, SHA1- og SHA256-checksumme for det valgte diskbillede"
t MSG_273 "Skift programsprog"
t MSG_274 "ISOHybrid-diskbillede opdaget"
t MSG_275 "Det diskbillede du har valgt er et 'ISOHybrid'-diskbillede. Det betyder at det både kan skrives som "
@ -3975,7 +3975,7 @@ t MSG_268 "Windows image wordt toegepast..."
t MSG_269 "Behoud bestandsdata"
t MSG_270 "USB debug"
t MSG_271 "Image checksums berekenen: %0.1f%% voltooid"
t MSG_272 "Bereken de SHA1 en MD5 checksums voor de geselecteerde image"
t MSG_272 "Bereken de MD5, SHA1 en SHA256 checksums voor de geselecteerde image"
t MSG_273 "Verander de taal van het programma"
t MSG_274 "ISOHybride image gedetecteerd"
t MSG_275 "De geselecteerde image is een 'ISOHybride' image. Dit betekent dat het in "
@ -4419,7 +4419,7 @@ t MSG_268 "Asetetaan Windows-levykuvaa..."
t MSG_269 "Aikaleimojen käyttö"
t MSG_270 "USB-virheenkorjaus"
t MSG_271 "Lasketaan levykuvan tarkistussummia: %0.1f%% suoritettu"
t MSG_272 "Laske valitun levykuvan SHA1- ja MD5-tarkistussummat."
t MSG_272 "Laske valitun levykuvan MD5-, SHA1- ja SHA256-tarkistussummat."
t MSG_273 "Vaihda sovelluksen kieltä"
t MSG_274 "ISOHybrid-levykuva havaittu"
t MSG_275 "Valitsemasi levykuva on muotoa 'ISOHybrid'. Tämä tarkoittaa, että se voidaan "
@ -4832,8 +4832,8 @@ t MSG_268 "Application de l'image Windows..."
t MSG_269 "Préservation des dates de fichiers"
t MSG_270 "Debug USB"
t MSG_271 "Calculation des checksums de l'image: %0.1f%% complété"
t MSG_272 "Calcule ses checksums SHA1 et MD5 pour l'image sélectionée"
t MSG_273 "Changer la langue de l'application"
t MSG_272 "Calcule les checksums MD5, SHA1 et SHA256 pour l'image sélectionée"
t MSG_273 "Change la langue de l'application"
t MSG_274 "Image ISOHybrid détectée"
t MSG_275 "L'image que vous avez sélectionnée est une image 'ISOHybrid'. Cela veut dire quelle peut "
"être écrite soit en mode %s (copie de fichiers) ou en mode %s (image disque).\n"
@ -5273,7 +5273,7 @@ t MSG_268 "Windows-Abbild aufspielen..."
t MSG_269 "Zeitstempel bewahren"
t MSG_270 "USB Testmodus"
t MSG_271 "Berechne Abbild-Prüfsumme: %0.1f%% fertiggestellt"
t MSG_272 "Berechne SHA1- und MD5-Prüfsumme für das gewählte Abbild"
t MSG_272 "Berechne MD5-, SHA1- und SHA256-Prüfsumme für das gewählte Abbild"
t MSG_273 "Sprache der Anwendung ändern"
t MSG_274 "Hybrides ISO-Abbild erkannt"
t MSG_275 "Das gewählte Abbild ist eine hybrides ISO-Abbild. Es kann entweder im "
@ -5748,7 +5748,7 @@ t MSG_268 "Εγγραφή ειδώλου Windows..."
t MSG_269 "Διατήρηση ημερομηνιών αρχείων"
t MSG_270 "USB debug"
t MSG_271 "Υπολογισμός checksums ειδώλου: %0.1f%% ολοκληρώθηκε"
t MSG_272 "Υπολογισμός checksums SHA1 και MD5 για το επιλεγμένο είδωλο"
t MSG_272 "Υπολογισμός checksums MD5, SHA1 και SHA256 για το επιλεγμένο είδωλο"
t MSG_273 "Αλλαγή γλώσσας"
t MSG_274 "Ανιχνεύθηκε είδωλο τύπου ISOHybrid"
t MSG_275 "Το είδωλο που χρησιμοποιήσατε είναι τύπου 'ISOHybrid'. Αυτό σημαίνει πως μπορεί να εγγραφεί "
@ -6181,7 +6181,7 @@ t MSG_268 "Windows kép alkalmazása..."
t MSG_269 "Fájl dátumának megtartása"
t MSG_270 "USB hibakeresés"
t MSG_271 "Képfájl ellenörző összegének számítása: %0.1f%% kész"
t MSG_272 "SHA1 és MD5 ellenörzőösszegek kiszámítása a kiválasztott képhez"
t MSG_272 "MD5, SHA1 és SHA256 ellenörzőösszegek kiszámítása a kiválasztott képhez"
t MSG_273 "Alkalmazás nyelvének megváltoztatása"
t MSG_274 "ISOHybrid képfájl észlelve"
t MSG_275 "A képfájl, amit kiválasztottál egy 'ISOHybrid' képfájl. Ez azt jelenti, hogy írható: "
@ -6660,7 +6660,7 @@ t MSG_268 "Menerapkan image Windows..."
t MSG_269 "Pertahankan timestamps"
t MSG_270 "USB debug"
t MSG_271 "Menghitung ceksum image: %0.1f%% selesai"
t MSG_272 "Hitung ceksum SHA1 dan MD5 pada image yang dipilih"
t MSG_272 "Hitung ceksum MD5, SHA1 dan SHA256 pada image yang dipilih"
t MSG_273 "Ubah bahasa aplikasi"
t MSG_274 "Image ISOHybrid terdeteksi"
t MSG_275 "Image yang Anda pilih merupakan image 'ISOHybrid'. Ini artinya image tersebut dapat ditulis dalam "
@ -7086,7 +7086,7 @@ t MSG_268 "Applicazione immagine Windows..."
t MSG_269 "Preserva data/ora"
t MSG_270 "Debug USB"
t MSG_271 "Calcolo checksum immagine: %0.1f%% completato"
t MSG_272 "Calcola le checksum SHA1 e MD5 per l'immagine selezionata"
t MSG_272 "Calcola le checksum MD5, SHA1 e SHA256 per l'immagine selezionata"
t MSG_273 "Cambia la lingua dell'interfaccia"
t MSG_274 "Rilevata immagine ISO ibrida"
t MSG_275 "L'immagine selezionata è un'immagine ISO ibrida. Questo significa che può essere registrata in modo "
@ -7988,7 +7988,7 @@ t MSG_268 "Windows 이미지 적용..."
t MSG_269 "타임 스탬프를 보존"
t MSG_270 "USB 디버그"
t MSG_271 "이미지 체크섬을 계산 중: %0.1f%% 완료"
t MSG_272 "선택한 이미지의 SHA1 및 MD5 체크섬을 계산"
t MSG_272 "선택한 이미지의 MD5, SHA1 및 SHA256 체크섬을 계산"
t MSG_273 "응용 프로그램 언어 변경"
t MSG_274 "ISOHybrid 이미지 검색 됨"
t MSG_275 "선택한 이미지는 'ISOHybrid'이미지입니다. 이 이미지는 ISO 이미지 모드 "
@ -8450,7 +8450,7 @@ t MSG_268 "Pielietots Windows imidžs..."
t MSG_269 "Atļauja laika zīmogam"
t MSG_270 "USB-atkļūdošana"
t MSG_271 "Kontrolsummu skaitļošana: pabeigts %0.1f%%"
t MSG_272 "Izskaitļot SHA1 un MD5 kontrolsummas izvēlētajam imidžam"
t MSG_272 "Izskaitļot MD5, SHA1 un SHA256 kontrolsummas izvēlētajam imidžam"
t MSG_273 "Mainīt aplikācijas valodu"
t MSG_274 "Pamanīts ISOHybrid-imidžs"
t MSG_275 "Izvēlētajam imidžam ir 'ISOHybrid' formāts. Tas nozīmē ka imidžu var ierakstīt "
@ -9760,7 +9760,7 @@ t MSG_268 "Legger til Windows bilde..."
t MSG_269 "Bevarer tidskode"
t MSG_270 "USB avkoding"
t MSG_271 "Regner ut bilde sjekksummer: %0.1f%% fullført"
t MSG_272 "Regner ut SHA1 og MD5 sjekksummer for det valgte bilde"
t MSG_272 "Regner ut MD5, SHA1 og SHA256 sjekksummer for det valgte bilde"
t MSG_273 "Bytt program språk"
t MSG_274 "ISOHybrid bilde oppdaget"
t MSG_275 "Bildet du har valgt er en 'ISOHybrid' bilde. Dette betyr det enten kan bli skrevet i "
@ -10230,7 +10230,7 @@ t MSG_268 "Zastosowywanie obrazu Windows..."
t MSG_269 "Zachowaj znacziki czasu"
t MSG_270 "Debugowanie USB"
t MSG_271 "Obliczanie sum kontrolnych obrazu: ukończono %0.1f%%"
t MSG_272 "Oblicz sumy kontrolne SHA1 oraz MD5 dla wybranego obrazu"
t MSG_272 "Oblicz sumy kontrolne MD5, SHA1 oraz SHA256 dla wybranego obrazu"
t MSG_273 "Zmień język aplikacji"
t MSG_274 "Wykryto obraz ISOHybrid"
t MSG_275 "Obraz który wybrałeś to obraz 'ISOHybrid'. To znacza iż może zostać zapisany w trybie "
@ -10660,7 +10660,7 @@ t MSG_268 "Aplicando imagem do Windows"
t MSG_269 "Preservar marcas de tempo"
t MSG_270 "Debugar USB"
t MSG_271 "Calculando o checksum das imagens: %0.1f%% concluído"
t MSG_272 "Calcular os checksums SHA1 e MD5 da imagem selecionada"
t MSG_272 "Calcular os checksums MD5, SHA1 e SHA256 da imagem selecionada"
t MSG_273 "Mudar o idioma do aplicativo"
t MSG_274 "Imagem ISOHybrid detectada"
t MSG_275 "A imagem que você selecionou é do tipo 'ISOHybrid'. Isso significa que pode ser escrita em "
@ -11115,7 +11115,7 @@ t MSG_268 "Aplicar imagem Windows..."
t MSG_269 "Manter data dos ficheiros"
t MSG_270 "Depuração USB"
t MSG_271 "Cálculo do checksums da imagem: %0.1f%% completo"
t MSG_272 "Calcular SHA1 e MD5 para a imagem selecionada"
t MSG_272 "Calcular MD5, SHA1 e SHA256 para a imagem selecionada"
t MSG_273 "Alterar o idioma da aplicação"
t MSG_274 "Imagem ISOHybrid detetada"
t MSG_275 "A imagem selecionada é uma 'ISOHybrid'. Isto significa que pode ser escrita no modo "
@ -11527,7 +11527,7 @@ t MSG_268 "Aplicarea imaginei Windows..."
t MSG_269 "Păstrare mărci temporale"
t MSG_270 "Depanare USB"
t MSG_271 "Calcularea sumelor de control: %0.1f%% complet"
t MSG_272 "Calcularea sumelor de control SHA1 și MD5 pentru imaginea selectată"
t MSG_272 "Calcularea sumelor de control MD5, SHA1 și SHA256 pentru imaginea selectată"
t MSG_273 "Schimbare limba aplicației"
t MSG_274 "Imagine detectată ISOHybrid"
t MSG_275 "Imaginea selectată este 'ISOHybrid'. Înseamnă că poate fi scris fie în "
@ -11959,7 +11959,7 @@ t MSG_268 "Использование Windows-образа..."
t MSG_269 "Сохранять метки"
t MSG_270 "Режим USB-отладки"
t MSG_271 "Вычисление контрольных сумм: %0.1f%% завершено"
t MSG_272 "Вычислить контрольные суммы SHA1 и MD5 для выбранного образа"
t MSG_272 "Вычислить контрольные суммы MD5, SHA1 и SHA256 для выбранного образа"
t MSG_273 "Изменить язык приложения"
t MSG_274 "Обнаружен ISOHybrid-образ"
t MSG_275 "Выбранный образ является 'ISOHybrid' образом. Это означает, что образ можно записать "
@ -12398,7 +12398,7 @@ t MSG_268 "Používanie Windows obrazu..."
t MSG_269 "Zachovať časové značky"
t MSG_270 "USB ladenie"
t MSG_271 "Prebieha výpočet kontrolného súčtu: %0.1f%% hotových"
t MSG_272 "Vypočítať SHA1 a MD5 kontrolný súčet pre vybraný obraz"
t MSG_272 "Vypočítať MD5, SHA1 a SHA256 kontrolný súčet pre vybraný obraz"
t MSG_273 "Zmeniť jazyk programu"
t MSG_274 "Bol zistený hybridný ISO obraz"
t MSG_275 "Tento obraz bol označený ako 'Hybridný ISO obraz'. To znamená, že môže byť zapísaný iba v "
@ -12834,7 +12834,7 @@ t MSG_268 "Nameščam sliko za Windows…"
t MSG_269 "Ohranjanje časov datotek"
t MSG_270 "Razhroščevanje USB"
t MSG_271 "Računam kontrolni vsoti: %0.1f%%"
t MSG_272 "Izračuna kontrolni vsoti SHA1 in MD5 za izbrano sliko"
t MSG_272 "Izračuna kontrolni vsoti MD5, SHA1 in SHA256 za izbrano sliko"
t MSG_273 "Spremeni jezik aplikacije"
t MSG_274 "Zaznana je bila slika ISOHybrid"
t MSG_275 "Slika, ki ste jo izbrali, je vrste \"ISOHybrid\". To pomeni, da jo lahko zapišete kot "
@ -13298,7 +13298,7 @@ t MSG_268 "Aplicando imagen Windows..."
t MSG_269 "Mantener la información de tiempo"
t MSG_270 "Depuración USB"
t MSG_271 "Calculando checksums de la imagen: %0.1f%% completado"
t MSG_272 "Calcular los checksums SHA1 y MD5 para la imagen seleccionada"
t MSG_272 "Calcular los checksums MD5, SHA1 y SHA256 para la imagen seleccionada"
t MSG_273 "Cambiar idioma"
t MSG_274 "Imagen ISOHybrid detectada"
t MSG_275 "La imágen que ha seleccionado es una imagen de tipo 'ISOHybrid', esto significa que puede ser escrita tanto en modo "
@ -13758,7 +13758,7 @@ t MSG_268 "Tillämpar Windows-avbild..."
t MSG_269 "Bevara datum och tid är"
t MSG_270 "USB-felsökning är"
t MSG_271 "Beräknar kontrollsummor för avbilden: %0.1f%% klart"
t MSG_272 "Beräkna SHA1- och MD5-kontrollsummor för den valda avbilden"
t MSG_272 "Beräkna MD5-, SHA1- och SHA256-kontrollsummor för den valda avbilden"
t MSG_273 "Ändra programspråk"
t MSG_274 "Avbilden är av typen ISOHybrid"
t MSG_275 "Avbilden du har valt är en 'ISOHybrid'. Detta innebär att den kan skrivas i både "
@ -14232,7 +14232,7 @@ t MSG_268 "Windows yansıması uygulanıyor..."
t MSG_269 "Zaman damgalarını koruma"
t MSG_270 "USB Hata Ayıklama"
t MSG_271 "Yansıma sağlaması hesaplanıyor: %0.1f%% tamamlandı"
t MSG_272 "Seçilen yansıma için SHA1 ve MD5 sağlamasını hesapla"
t MSG_272 "Seçilen yansıma için MD5, SHA1 ve SHA256 sağlamasını hesapla"
t MSG_273 "Uygulama dilini değiştir"
t MSG_274 "ISOHybrid yansıma algılandı"
t MSG_275 "Seçtiğiniz yansıma bir 'ISOHybrid' yansımasıdır. Bu da yansımanın ya %s (dosya kopyalama) modunda "
@ -14682,7 +14682,7 @@ t MSG_268 "Застосування Windows-образа..."
t MSG_269 "Зберігати мітки"
t MSG_270 "Режим USB-налагодження"
t MSG_271 "Обчислення контрольних сум: %0.1f%% завершено"
t MSG_272 "Обчислити контрольні суми SHA1 ті MD5 для обраного образа"
t MSG_272 "Обчислити контрольні суми MD5, SHA1 ті SHA256 для обраного образа"
t MSG_273 "Змінити мову додатка"
t MSG_274 "Виявлений образ ISOHybrid"
t MSG_275 "Обраний образ є образом 'ISOHybrid'. Це означає, що образ можна записати "
@ -15133,7 +15133,7 @@ t MSG_268 "Đang áp dụng ảnh Windows..."
t MSG_269 "Giữ dấu thời gian"
t MSG_270 "Gỡ rối USB"
t MSG_271 "Đang tính toán kiểm tổng ảnh: đã hoàn thành %0.1f%%"
t MSG_272 "Tính toán giá trị tổng kiểm tra SHA1 và MD5 với ảnh đã chọn"
t MSG_272 "Tính toán giá trị tổng kiểm tra MD5, SHA1 và SHA256 với ảnh đã chọn"
t MSG_273 "Thay đổi ngôn ngữ ứng dụng"
t MSG_274 "Đã phát hiện ảnh ISOHybrid"
t MSG_275 "Ảnh bạn đã chọn là một ảnh 'ISOHybrid'. Điều này có nghĩa nó có thể được ghi trong "

View file

@ -3,6 +3,7 @@
* Message-Digest algorithms (sha1sum, md5sum)
* Copyright © 1998-2001 Free Software Foundation, Inc.
* Copyright © 2004 g10 Code GmbH
* Copyright © 2006-2012 Brad Conte <brad@bradconte.com>
* Copyright © 2015 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
@ -22,6 +23,9 @@
/*
* SHA-1 code taken from GnuPG, as per copyrights above.
*
* SHA-256 code modified from crypto-algorithms by Brad Conte:
* https://github.com/B-Con/crypto-algorithms - Public Domain
*
* MD5 code from various public domain sources sharing the following
* copyright declaration:
*
@ -55,7 +59,7 @@
#undef BIG_ENDIAN_HOST
/* Globals */
char sha1str[41], md5str[33];
char sha1str[41], sha256str[65], md5str[33];
#if defined(__GNUC__)
#define ALIGNED(m) __attribute__ ((__aligned__(m)))
@ -86,36 +90,68 @@ static __inline uint32_t rol(uint32_t x, int n)
#define rol(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) )
#endif
// For SHA-256
static const uint32_t k[64] = {
0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,
0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,
0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,
0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967,
0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,
0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,
0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,
0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2
};
typedef struct ALIGNED(8) {
unsigned char buf[64];
uint32_t h0, h1, h2, h3, h4;
uint32_t state[5];
uint32_t count;
uint64_t nblocks;
} SHA1_CONTEXT;
typedef struct ALIGNED(8) {
unsigned char buf[64];
uint32_t h0, h1, h2, h3;
uint32_t state[8];
uint32_t datalen;
uint64_t bitlen;
} SHA256_CONTEXT;
typedef struct ALIGNED(8) {
unsigned char buf[64];
uint32_t state[4];
uint64_t bitcount;
} MD5_CONTEXT;
void sha1_init(SHA1_CONTEXT *ctx)
static void sha1_init(SHA1_CONTEXT *ctx)
{
memset(ctx, 0, sizeof(*ctx));
ctx->h0 = 0x67452301;
ctx->h1 = 0xefcdab89;
ctx->h2 = 0x98badcfe;
ctx->h3 = 0x10325476;
ctx->h4 = 0xc3d2e1f0;
ctx->state[0] = 0x67452301;
ctx->state[1] = 0xefcdab89;
ctx->state[2] = 0x98badcfe;
ctx->state[3] = 0x10325476;
ctx->state[4] = 0xc3d2e1f0;
}
void md5_init(MD5_CONTEXT *ctx)
static void sha256_init(SHA256_CONTEXT *ctx)
{
memset(ctx, 0, sizeof(*ctx));
ctx->h0 = 0x67452301;
ctx->h1 = 0xefcdab89;
ctx->h2 = 0x98badcfe;
ctx->h3 = 0x10325476;
ctx->state[0] = 0x6a09e667;
ctx->state[1] = 0xbb67ae85;
ctx->state[2] = 0x3c6ef372;
ctx->state[3] = 0xa54ff53a;
ctx->state[4] = 0x510e527f;
ctx->state[5] = 0x9b05688c;
ctx->state[6] = 0x1f83d9ab;
ctx->state[7] = 0x5be0cd19;
}
static void md5_init(MD5_CONTEXT *ctx)
{
memset(ctx, 0, sizeof(*ctx));
ctx->state[0] = 0x67452301;
ctx->state[1] = 0xefcdab89;
ctx->state[2] = 0x98badcfe;
ctx->state[3] = 0x10325476;
}
/* Transform the message X which consists of 16 32-bit-words (SHA-1) */
@ -125,11 +161,11 @@ static void sha1_transform(SHA1_CONTEXT *ctx, const unsigned char *data)
uint32_t x[16];
/* get values from the chaining vars */
a = ctx->h0;
b = ctx->h1;
c = ctx->h2;
d = ctx->h3;
e = ctx->h4;
a = ctx->state[0];
b = ctx->state[1];
c = ctx->state[2];
d = ctx->state[3];
e = ctx->state[4];
#ifdef BIG_ENDIAN_HOST
memcpy(x, data, sizeof(x));
@ -246,11 +282,75 @@ static void sha1_transform(SHA1_CONTEXT *ctx, const unsigned char *data)
#undef F4
/* Update chaining vars */
ctx->h0 += a;
ctx->h1 += b;
ctx->h2 += c;
ctx->h3 += d;
ctx->h4 += e;
ctx->state[0] += a;
ctx->state[1] += b;
ctx->state[2] += c;
ctx->state[3] += d;
ctx->state[4] += e;
}
static void sha256_transform(SHA256_CONTEXT *ctx, const unsigned char *data)
{
uint32_t a, b, c, d, e, f, g, h, i, t1, t2, m[64];
a = ctx->state[0];
b = ctx->state[1];
c = ctx->state[2];
d = ctx->state[3];
e = ctx->state[4];
f = ctx->state[5];
g = ctx->state[6];
h = ctx->state[7];
#define ROTLEFT(a,b) (((a) << (b)) | ((a) >> (32-(b))))
#define ROTRIGHT(a,b) (((a) >> (b)) | ((a) << (32-(b))))
#define CH(x,y,z) (((x) & (y)) ^ (~(x) & (z)))
#define MAJ(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
#define EP0(x) (ROTRIGHT(x,2) ^ ROTRIGHT(x,13) ^ ROTRIGHT(x,22))
#define EP1(x) (ROTRIGHT(x,6) ^ ROTRIGHT(x,11) ^ ROTRIGHT(x,25))
#define SIG0(x) (ROTRIGHT(x,7) ^ ROTRIGHT(x,18) ^ ((x) >> 3))
#define SIG1(x) (ROTRIGHT(x,17) ^ ROTRIGHT(x,19) ^ ((x) >> 10))
#ifdef BIG_ENDIAN_HOST
memcpy(m, data, sizeof(m));
#else
{
unsigned char *p2;
for (i = 0, p2 = (unsigned char*)m; i < 16; i++, p2 += 4) {
p2[3] = *data++;
p2[2] = *data++;
p2[1] = *data++;
p2[0] = *data++;
}
}
#endif
for (i = 16; i < 64; ++i)
m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
for (i = 0; i < 64; ++i) {
t1 = h + EP1(e) + CH(e, f, g) + k[i] + m[i];
t2 = EP0(a) + MAJ(a, b, c);
h = g;
g = f;
f = e;
e = d + t1;
d = c;
c = b;
b = a;
a = t1 + t2;
}
ctx->state[0] += a;
ctx->state[1] += b;
ctx->state[2] += c;
ctx->state[3] += d;
ctx->state[4] += e;
ctx->state[5] += f;
ctx->state[6] += g;
ctx->state[7] += h;
}
/* Transform the message X which consists of 16 32-bit-words (MD5) */
@ -259,10 +359,10 @@ static void md5_transform(MD5_CONTEXT *ctx, const unsigned char *data)
uint32_t a, b, c, d;
uint32_t x[16];
a = ctx->h0;
b = ctx->h1;
c = ctx->h2;
d = ctx->h3;
a = ctx->state[0];
b = ctx->state[1];
c = ctx->state[2];
d = ctx->state[3];
#ifndef BIG_ENDIAN_HOST
memcpy(x, data, sizeof(x));
@ -361,10 +461,10 @@ static void md5_transform(MD5_CONTEXT *ctx, const unsigned char *data)
#undef F4
/* Update chaining vars */
ctx->h0 += a;
ctx->h1 += b;
ctx->h2 += c;
ctx->h3 += d;
ctx->state[0] += a;
ctx->state[1] += b;
ctx->state[2] += c;
ctx->state[3] += d;
}
/* Update the message digest with the contents of the buffer (SHA-1) */
@ -396,8 +496,23 @@ static void sha1_write(SHA1_CONTEXT *ctx, const unsigned char *buf, size_t len)
ctx->buf[ctx->count++] = *buf++;
}
static void sha256_write(SHA256_CONTEXT *ctx, const unsigned char *buf, size_t len)
{
uint32_t i;
for (i = 0; i < len; ++i) {
ctx->buf[ctx->datalen] = buf[i];
ctx->datalen++;
if (ctx->datalen == 64) {
sha256_transform(ctx, ctx->buf);
ctx->bitlen += 512;
ctx->datalen = 0;
}
}
}
/* Update the message digest with the contents of the buffer (MD5) */
void md5_write(MD5_CONTEXT *ctx, const unsigned char *buf, size_t len)
static void md5_write(MD5_CONTEXT *ctx, const unsigned char *buf, size_t len)
{
uint32_t t;
@ -469,10 +584,10 @@ static void sha1_final(SHA1_CONTEXT *ctx)
p = ctx->buf;
#ifdef BIG_ENDIAN_HOST
#define X(a) do { *(uint32_t*)p = ctx->h##a ; p += 4; } while(0)
#define X(a) do { *(uint32_t*)p = ctx->state[a]; p += 4; } while(0)
#else /* little endian */
#define X(a) do { *p++ = (unsigned char) (ctx->h##a >> 24); *p++ = (unsigned char) (ctx->h##a >> 16); \
*p++ = (unsigned char) (ctx->h##a >> 8); *p++ = (unsigned char) ctx->h##a; } while(0)
#define X(a) do { *p++ = (unsigned char) (ctx->state[a] >> 24); *p++ = (unsigned char) (ctx->state[a] >> 16); \
*p++ = (unsigned char) (ctx->state[a] >> 8); *p++ = (unsigned char) ctx->state[a]; } while(0)
#endif
X(0);
X(1);
@ -482,6 +597,58 @@ static void sha1_final(SHA1_CONTEXT *ctx)
#undef X
}
static void sha256_final(SHA256_CONTEXT *ctx)
{
uint32_t i;
unsigned char *p;
i = ctx->datalen;
// Pad whatever data is left in the buffer.
if (ctx->datalen < 56) {
ctx->buf[i++] = 0x80;
while (i < 56)
ctx->buf[i++] = 0x00;
}
else {
ctx->buf[i++] = 0x80;
while (i < 64)
ctx->buf[i++] = 0x00;
sha256_transform(ctx, ctx->buf);
memset(ctx->buf, 0, 56);
}
// Append to the padding the total message's length in bits and transform.
ctx->bitlen += ctx->datalen * 8;
ctx->buf[63] = (unsigned char) (ctx->bitlen);
ctx->buf[62] = (unsigned char) (ctx->bitlen >> 8);
ctx->buf[61] = (unsigned char) (ctx->bitlen >> 16);
ctx->buf[60] = (unsigned char) (ctx->bitlen >> 24);
ctx->buf[59] = (unsigned char) (ctx->bitlen >> 32);
ctx->buf[58] = (unsigned char) (ctx->bitlen >> 40);
ctx->buf[57] = (unsigned char) (ctx->bitlen >> 48);
ctx->buf[56] = (unsigned char) (ctx->bitlen >> 56);
sha256_transform(ctx, ctx->buf);
p = ctx->buf;
#ifdef BIG_ENDIAN_HOST
#define X(a) do { *(uint32_t*)p = ctx->state[a]; p += 4; } while(0)
#else /* little endian */
#define X(a) do { *p++ = (unsigned char) (ctx->state[a] >> 24); *p++ = (unsigned char) (ctx->state[a] >> 16); \
*p++ = (unsigned char) (ctx->state[a] >> 8); *p++ = (unsigned char) ctx->state[a]; } while(0)
#endif
X(0);
X(1);
X(2);
X(3);
X(4);
X(5);
X(6);
X(7);
#undef X
}
/* The routine final terminates the computation and returns the digest (MD5) */
static void md5_final(MD5_CONTEXT *ctx)
{
@ -527,10 +694,10 @@ static void md5_final(MD5_CONTEXT *ctx)
p = ctx->buf;
#ifdef BIG_ENDIAN_HOST
#define X(a) do { *p++ = (unsigned char) (ctx->h##a >> 24); *p++ = (unsigned char) (ctx->h##a >> 16); \
*p++ = (unsigned char) (ctx->h##a >> 8); *p++ = (unsigned char) ctx->h##a; } while(0)
#define X(a) do { *p++ = (unsigned char) (ctx->state[a] >> 24); *p++ = (unsigned char) (ctx->state[a] >> 16); \
*p++ = (unsigned char) (ctx->state[a] >> 8); *p++ = (unsigned char) ctx->state[a]; } while(0)
#else /* little endian */
#define X(a) do { *(uint32_t*)p = ctx->h##a ; p += 4; } while(0)
#define X(a) do { *(uint32_t*)p = ctx->state[a]; p += 4; } while(0)
#endif
X(0);
X(1);
@ -556,25 +723,33 @@ INT_PTR CALLBACK ChecksumCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM
hFont = CreateFontA(-MulDiv(9, GetDeviceCaps(hDC, LOGPIXELSY), 72),
0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
0, 0, PROOF_QUALITY, 0, "Courier New");
if (hDC != NULL)
ReleaseDC(hDlg, hDC);
safe_release_dc(hDlg, hDC);
SendDlgItemMessageA(hDlg, IDC_MD5, WM_SETFONT, (WPARAM)hFont, TRUE);
SendDlgItemMessageA(hDlg, IDC_SHA1, WM_SETFONT, (WPARAM)hFont, TRUE);
SendDlgItemMessageA(hDlg, IDC_SHA256, WM_SETFONT, (WPARAM)hFont, TRUE);
SetWindowTextA(GetDlgItem(hDlg, IDC_MD5), md5str);
SetWindowTextA(GetDlgItem(hDlg, IDC_SHA1), sha1str);
SetWindowTextA(GetDlgItem(hDlg, IDC_SHA256), sha256str);
// Move/Resize the controls as needed to fit our text
hDC = GetDC(GetDlgItem(hDlg, IDC_SHA1));
hDC = GetDC(GetDlgItem(hDlg, IDC_MD5));
SelectFont(hDC, hFont); // Yes, you *MUST* reapply the font to the DC, even after SetWindowText!
GetWindowRect(GetDlgItem(hDlg, IDC_MD5), &rect);
dw = rect.right - rect.left;
DrawTextU(hDC, md5str, -1, &rect, DT_CALCRECT);
dw = rect.right - rect.left - dw + 12; // Ideally we'd compute the field borders from the system, but hey...
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_SHA256), 0, 0, dw, 0, 1.0f);
GetWindowRect(GetDlgItem(hDlg, IDC_SHA1), &rect);
dw = rect.right - rect.left;
DrawTextU(hDC, sha1str, -1, &rect, DT_CALCRECT);
if (hDC != NULL)
ReleaseDC(GetDlgItem(hDlg, IDC_SHA1), hDC);
dw = rect.right - rect.left - dw + 12; // Ideally we'd compute the field borders from the system, but hey...
dw = rect.right - rect.left - dw + 12;
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_MD5), 0, 0, dw, 0, 1.0f);
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_SHA1), 0, 0, dw, 0, 1.0f);
safe_release_dc(GetDlgItem(hDlg, IDC_MD5), hDC);
for (i=(int)safe_strlen(image_path); (i>0)&&(image_path[i]!='\\'); i--);
if (image_path != NULL) // VS code analysis has a false positive on this one
SetWindowTextU(hDlg, &image_path[i+1]);
@ -604,6 +779,7 @@ DWORD WINAPI SumThread(void* param)
uint64_t rb;
char buffer[4096];
SHA1_CONTEXT sha1_ctx;
SHA256_CONTEXT sha256_ctx;
MD5_CONTEXT md5_ctx;
int i, r = -1;
float format_percent = 0.0f;
@ -621,6 +797,7 @@ DWORD WINAPI SumThread(void* param)
}
sha1_init(&sha1_ctx);
sha256_init(&sha256_ctx);
md5_init(&md5_ctx);
for (rb = 0; ; rb += rSize) {
@ -640,18 +817,23 @@ DWORD WINAPI SumThread(void* param)
if (rSize == 0)
break;
sha1_write(&sha1_ctx, buffer, (size_t)rSize);
sha256_write(&sha256_ctx, buffer, (size_t)rSize);
md5_write(&md5_ctx, buffer, (size_t)rSize);
}
sha1_final(&sha1_ctx);
sha256_final(&sha256_ctx);
md5_final(&md5_ctx);
for (i = 0; i < 16; i++)
safe_sprintf(&md5str[2 * i], sizeof(md5str) - 2 * i, "%02x", md5_ctx.buf[i]);
uprintf(" MD5:\t%s", md5str);
safe_sprintf(&md5str[2*i], sizeof(md5str) - 2*i, "%02x", md5_ctx.buf[i]);
uprintf(" MD5:\t %s", md5str);
for (i = 0; i < 20; i++)
safe_sprintf(&sha1str[2*i], sizeof(sha1str) - 2*i, "%02x", sha1_ctx.buf[i]);
uprintf(" SHA1:\t%s", sha1str);
uprintf(" SHA1:\t %s", sha1str);
for (i = 0; i < 32; i++)
safe_sprintf(&sha256str[2*i], sizeof(sha256str) - 2*i, "%02x", sha256_ctx.buf[i]);
uprintf(" SHA256: %s", sha256str);
r = 0;
out:

View file

@ -108,6 +108,10 @@ const char* additional_copyrights =
"https://www.gnupg.org\\line\n"
"GNU General Public License (GPL) v3 or later\\line\n"
"\\line\n"
"SHA-256 checksum from Brad Conte's crypto-algorithms:\\line\n"
"https://github.com/B-Con/crypto-algorithms\\line\n"
"Public Domain\\line\n"
"\\line\n"
"About and License dialogs inspired by WinSCP by Martin Prikryl\\line\n"
"http://winscp.net\\line\n"
"GNU General Public License (GPL) v3 or later\\line\n"

View file

@ -90,6 +90,7 @@ const loc_control_id control_id[] = {
LOC_CTRL(IDC_DOWNLOAD_URL),
LOC_CTRL(IDC_MD5),
LOC_CTRL(IDC_SHA1),
LOC_CTRL(IDC_SHA256),
LOC_CTRL(IDC_SELECTION_ICON),
LOC_CTRL(IDC_SELECTION_TEXT),
LOC_CTRL(IDC_SELECTION_LINE),

View file

@ -128,11 +128,12 @@
#define IDC_DOWNLOAD_URL 1070
#define IDC_MD5 1071
#define IDC_SHA1 1072
#define IDC_SELECTION_ICON 1073
#define IDC_SELECTION_TEXT 1074
#define IDC_SELECTION_LINE 1075
#define IDC_SELECTION_CHOICE1 1076
#define IDC_SELECTION_CHOICE2 1077
#define IDC_SHA256 1073
#define IDC_SELECTION_ICON 1074
#define IDC_SELECTION_TEXT 1075
#define IDC_SELECTION_LINE 1076
#define IDC_SELECTION_CHOICE1 1077
#define IDC_SELECTION_CHOICE2 1078
#define IDS_DEVICE_TXT 2000
#define IDS_PARTITION_TYPE_TXT 2001
#define IDS_FILESYSTEM_TXT 2002
@ -437,7 +438,7 @@
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 505
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1078
#define _APS_NEXT_CONTROL_VALUE 1079
#define _APS_NEXT_SYMED_VALUE 4000
#endif
#endif

View file

@ -98,6 +98,7 @@
#define safe_strnicmp(str1, str2, count) _strnicmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2), count)
#define safe_closehandle(h) do {if ((h != INVALID_HANDLE_VALUE) && (h != NULL)) {CloseHandle(h); h = INVALID_HANDLE_VALUE;}} while(0)
#define safe_unlockclose(h) do {if ((h != INVALID_HANDLE_VALUE) && (h != NULL)) {UnlockDrive(h); CloseHandle(h); h = INVALID_HANDLE_VALUE;}} while(0)
#define safe_release_dc(hDlg, hDC) do {if ((hDC != INVALID_HANDLE_VALUE) && (hDC != NULL)) {ReleaseDC(hDlg, hDC); hDC = NULL;}} while(0)
#define safe_sprintf(dst, count, ...) do {_snprintf(dst, count, __VA_ARGS__); (dst)[(count)-1] = 0; } while(0)
#define static_sprintf(dst, ...) safe_sprintf(dst, sizeof(dst), __VA_ARGS__)
#define safe_strlen(str) ((((char*)str)==NULL)?0:strlen(str))

View file

@ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 242, 376
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Rufus 2.4.758"
CAPTION "Rufus 2.4.759"
FONT 8, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8
@ -86,16 +86,18 @@ BEGIN
DEFPUSHBUTTON "OK",IDOK,251,215,50,14,WS_GROUP
END
IDD_CHECKSUM DIALOGEX 0, 0, 301, 63
IDD_CHECKSUM DIALOGEX 0, 0, 301, 67
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Checksums"
FONT 8, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "MD5:",IDC_STATIC,11,10,18,8
EDITTEXT IDC_MD5,38,9,197,12,ES_LOWERCASE | ES_AUTOHSCROLL | ES_READONLY
LTEXT "SHA1:",IDC_STATIC,11,26,20,8
EDITTEXT IDC_SHA1,38,25,197,12,ES_LOWERCASE | ES_AUTOHSCROLL | ES_READONLY
DEFPUSHBUTTON "OK",IDOK,243,43,50,14,WS_GROUP
LTEXT "MD5:",IDC_STATIC,9,10,18,8
EDITTEXT IDC_MD5,40,9,197,12,ES_LOWERCASE | ES_AUTOHSCROLL | ES_READONLY
LTEXT "SHA1:",IDC_STATIC,9,26,20,8
EDITTEXT IDC_SHA1,40,25,197,12,ES_LOWERCASE | ES_AUTOHSCROLL | ES_READONLY
LTEXT "SHA256:",IDC_STATIC,9,42,27,8
EDITTEXT IDC_SHA256,40,41,197,19,ES_MULTILINE | ES_LOWERCASE | ES_READONLY
DEFPUSHBUTTON "OK",IDOK,243,46,50,14,WS_GROUP
END
IDD_LICENSE DIALOGEX 0, 0, 335, 205
@ -154,7 +156,7 @@ FONT 8, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
ICON IDI_ICON,IDC_ABOUT_ICON,11,8,20,20
DEFPUSHBUTTON "Close",IDCANCEL,221,172,50,14,WS_GROUP
CONTROL "",IDC_POLICY,"RichEdit20W",ES_MULTILINE | ES_READONLY | WS_VSCROLL | WS_TABSTOP,46,8,235,132,WS_EX_STATICEDGE
CONTROL "",IDC_POLICY,"RichEdit20W",WS_VSCROLL | WS_TABSTOP | 0x804,46,8,235,132,WS_EX_STATICEDGE
GROUPBOX "Settings",IDS_UPDATE_SETTINGS_GRP,45,145,165,46
LTEXT "Check for updates",IDS_UPDATE_FREQUENCY_TXT,51,159,76,11
COMBOBOX IDC_UPDATE_FREQUENCY,133,155,66,12,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
@ -317,8 +319,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,4,758,0
PRODUCTVERSION 2,4,758,0
FILEVERSION 2,4,759,0
PRODUCTVERSION 2,4,759,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -335,13 +337,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "2.4.758"
VALUE "FileVersion", "2.4.759"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2015 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "2.4.758"
VALUE "ProductVersion", "2.4.759"
END
END
BLOCK "VarFileInfo"