https://bugzilla.redhat.com/show_bug.cgi?id=1175759
Bug ID: 1175759 Summary: Checksum validation in PowerShell is wrong Product: Fedora Documentation Version: devel Component: install-guide Assignee: pbokoc@redhat.com Reporter: gliverma@westga.edu QA Contact: docs-qa@lists.fedoraproject.org CC: pbokoc@redhat.com, zach@oglesby.co
Description of problem: I tried to use the info at http://docs.fedoraproject.org/en-US/Fedora/21/html/Installation_Guide/sect-v... and found that the commands did not work due to missing quotes and case sensitivity.
Version-Release number of selected component (if applicable): Fedora 21
How reproducible: Every time for me.
Steps to Reproduce: 1. Download ISO 2. Download checksum file 3. Use code on http://docs.fedoraproject.org/en-US/Fedora/21/html/Installation_Guide/sect-v...
Actual results: PS D:\Downloads> $image = "Fedora-Live-Workstation-x86_64-21-5.iso" PS D:\Downloads> $checksum_file = "Fedora-Workstation-21-x86_64-CHECKSUM.md5" PS D:\Downloads> $sha256 = New-Object -TypeName System.Security.Cryptography.sha256CryptoSer viceProvider PS D:\Downloads> $exepected_checksum = ((Get-Content $checksum_file | Select-String -Pattern $image) -split " ")[0] PS D:\Downloads> $download_checksum = [System.BitConverter]::ToString($sha256.ComputeHash([S ystem.IO.File]::ReadAllBytes($PWD$image))) At line:1 char:109 + ... adAllBytes($PWD$image))) + ~ Missing ')' in method call. At line:1 char:109 + ... adAllBytes($PWD$image))) + ~~~~~~~ Unexpected token '$image' in expression or statement. At line:1 char:116 + ... tes($PWD$image))) + ~ Unexpected token ')' in expression or statement. At line:1 char:117 + ... es($PWD$image))) + ~ Unexpected token ')' in expression or statement. At line:1 char:118 + ... s($PWD$image))) + ~ Unexpected token ')' in expression or statement. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : MissingEndParenthesisInMethodCall
Expected results: No errors in console
Additional info: I fixed the code and made the output more readable. Below is what I think should be posted on that page of the docs:
$image = "Fedora-Live-Workstation-x86_64-21-5.iso" $checksum_file = "Fedora-Workstation-21-x86_64-CHECKSUM" $sha256 = New-Object -TypeName System.Security.Cryptography.sha256CryptoServiceProvider $expected_checksum = ((Get-Content $checksum_file | Select-String -Pattern $image) -split " ")[0].ToLower() $download_checksum = [System.BitConverter]::ToString($sha256.ComputeHash([System.IO.File]::ReadAllBytes("$PWD$image"))).ToLower() -replace '-', '' if ( "$download_checksum" -eq "$expected_checksum" ) { echo "Checksum test passed!" } else { echo "Checksum test failed." } echo "Download Checksum: $download_checksum" echo "Expected Checksum: $expected_checksum"
https://bugzilla.redhat.com/show_bug.cgi?id=1175759
--- Comment #1 from Zach Oglesby zach@oglesby.co --- Trying this on a Windows 7 Pro Service Pack 1 provides the same results. gliverma's version provides the expected result.
https://bugzilla.redhat.com/show_bug.cgi?id=1175759
Pete Travis me@petetravis.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |me@petetravis.com QA Contact|docs-qa@lists.fedoraproject |me@petetravis.com |.org |
https://bugzilla.redhat.com/show_bug.cgi?id=1175759
Bugzilla account termination pnt-expunge@redhat.com changed:
What |Removed |Added ---------------------------------------------------------------------------- QA Contact|cspicer@redhat.com |docs-qa@lists.fedoraproject | |.org
https://bugzilla.redhat.com/show_bug.cgi?id=1175759
Richard Hrkach Jr rickhrkachjr@yahoo.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |rickhrkachjr@yahoo.com
--- Comment #29 from Richard Hrkach Jr rickhrkachjr@yahoo.com --- PS C:\Users\Richard\Downloads\Fedora> $image = 'Fedora-Server-dvd-x86_64-29-1.2.iso' PS C:\Users\Richard\Downloads\Fedora> $checksum_file = 'Fedora-Server-29-Checksum' PS C:\Users\Richard\Downloads\Fedora> $sha256 = New-Object Security.Cryptography.SHA256Managed PS C:\Users\Richard\Downloads\Fedora> $stream = (Get-Item "$PWD$image").OpenRead() PS C:\Users\Richard\Downloads\Fedora> $download_checksum = [BitConverter]::ToString($sha256.ComputeHash($stream)).ToLowe r() -replace '-' PS C:\Users\Richard\Downloads\Fedora> $stream.Close() PS C:\Users\Richard\Downloads\Fedora> $expected_checksum = ((Get-Content $checksum_file) -match [regex]::Escape($image) -split ' += +')[1].ToLower() PS C:\Users\Richard\Downloads\Fedora> echo "Download Checksum: $download_checksum" Download Checksum: 129d131a55e5bd518f593f0eacdce095f7c795fe7ccbef1f3f6aeb2ff9f99f35 PS C:\Users\Richard\Downloads\Fedora> echo "Expected Checksum: $expected_checksum" Expected Checksum: sha256 (fedora-server-dvd-x86_64-29-1.2.iso) PS C:\Users\Richard\Downloads\Fedora>
Problem is with the second last line there is no checksum to compare, ran on windows 8.1 for Fedora 29 Server
docs-qa@lists.fedoraproject.org