Updater Application Block 2.0 and hash validation

Topics: Updater Application Block
Apr 14, 2005 at 3:23 AM
originally posted by: MIlchQ_m

Hello!

I've problems with the Updater Application Block (version 2.0) and hash validation.

What is the correct value of the "source" attribute in the manifest (ActivationProcessors.ValidateHashProcessor) ? If i fill it with the given filename from the files section it validates but give me a invalid argument error.

Has anyone a working example with hash validation?


Thanks, Daniel
Apr 15, 2005 at 2:31 AM
originally posted by: AnuragRastogi

Hi

The source attribute in the manifest is a reference to a downloaded file .

you can have a look on the AutoInproc QuickStart shipped with application block.
Apr 16, 2005 at 12:27 AM
originally posted by: MIlchQ_m

Thanks but without an activation processor (its not included in the exmaple manifest of AutoInproc) it not validates anything. when i add the activation processor like this

---snip---
<task type="Microsoft.ApplicationBlocks.Updater.ActivationProcessors.ValidateHashProcessor,
Microsoft.ApplicationBlocks.Updater.ActivationProcessors, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=null" name="MachVali" source="Muh.jpg" />
---snap---

it alwas say that the hash dont match (but it is the same file and nor corrupt).
Apr 27, 2005 at 6:49 AM
originally posted by: chriscb33

This is apparently a bug in the ValidateHashProcessor, which I submitted to the bug tracker last week. Here's the info from my bug entry which also tells you what changes you need to make to the ValidateHashProcessor to make it work correctly:

=== Opened by chriscb33 @ 4/21/2005 10:31:32 AM ===
The ValidateHashProcessor included in the 2.0 release is not correctly computing the hash key when validating the hash key in the manifest against the computed value of a downloaded file. The result, of course, is the the ValidateHashProcessor will always error out regardless of whether or not the downloaded file is correct.

Cause: Termination character should be stripped after reading the file into memory, before the call to Cryptographer.CompareHash in Execute(). (as is done in the Manifest Manager's FileHashHelper).

Resolution: replace the TRY block in Execute() with the following:
Try
'MOD CCAMPBELL 04-20-05
'Dim fileBytes(fs.Length) As Byte
'fs.Read(fileBytes, 0, fileBytes.Length)
Dim i As Integer
Dim iLen As Integer

iLen = fs.Length

Dim fileBytesTemp(iLen) As Byte
Dim fileBytes(iLen - 1) As Byte

fs.Read(fileBytesTemp, 0, iLen)

'copy everything but last character <---THIS WAS MISSING IN RELEASED VERSION
For i = 0 To iLen - 1
fileBytes(i) = fileBytesTemp(i)
Next i

If Not Cryptographer.CompareHash(task.Manifest.Files.HashProvider, fileBytes, Convert.FromBase64String(targetHash)) Then
Throw New ValidateHashException(sourceFile + " " + targetHash)

End If
Finally
fs.Close()
fs = Nothing
End Try