[squeak-dev] The Trunk: System-ar.267.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Feb 25 22:45:38 UTC 2010

Andreas Raab uploaded a new version of System to project The Trunk:

==================== Summary ====================

Name: System-ar.267
Author: ar
Time: 25 February 2010, 11:42:28.601 pm
UUID: e956ceab-fd27-bc4a-aa14-dc4d9cb052b4
Ancestors: System-laza.266

Fix SecureHashAlgorithm raising an error upon empty input instead of computing the correct result.

=============== Diff against System-laza.266 ===============

Item was changed:
  ----- Method: SecureHashAlgorithm>>hashStream: (in category 'public') -----
  hashStream: aPositionableStream
  	"Hash the contents of the given stream from the current position to the end using the Secure Hash Algorithm. The SHA algorithm is defined in FIPS PUB 180-1. It is also described on p. 442 of 'Applied Cryptography: Protocols, Algorithms, and Source Code in C' by Bruce Scheier, Wiley, 1996."
  	"SecureHashAlgorithm new hashStream: (ReadStream on: 'foo')"
  	| startPosition buf bitLength |
  	self initializeTotals.
+ 	"(SecureHashAlgorithm new hashMessage: '') radix: 16 	
+ 	=> 'DA39A3EE5E6B4B0D3255BFEF95601890AFD80709'"
+ 	aPositionableStream atEnd ifTrue: [self processFinalBuffer: #() bitLength: 0].
- 	aPositionableStream atEnd ifTrue: [self error: 'empty stream'].
  	startPosition := aPositionableStream position.
  	[aPositionableStream atEnd] whileFalse: [
  		buf := aPositionableStream next: 64.
  		(aPositionableStream atEnd not and: [buf size = 64])
  			ifTrue: [self processBuffer: buf]
  			ifFalse: [
  				bitLength := (aPositionableStream position - startPosition) * 8.
  				self processFinalBuffer: buf bitLength: bitLength]].
  	^ self finalHash

More information about the Squeak-dev mailing list