Oberon || Library || Module Index || Search Engine || Definition || Module
TYPE Hash = POINTER TO HashRec; TYPE HashRec = RECORD (Services.ObjectRec) END; TYPE Value = POINTER TO ValueRec; TYPE ValueRec = RECORD (PersistentDisciplines.ObjectRec) END; TYPE GenerateProc = PROCEDURE (hash: Hash; message: Streams.Stream; VAR value: Value); TYPE BitlengthProc = PROCEDURE (hash: Hash): LONGINT; TYPE Interface = POINTER TO InterfaceRec; TYPE InterfaceRec = RECORD (Objects.ObjectRec) generate: GenerateProc; bitlength: BitlengthProc; END; TYPE GeneratorProc = PROCEDURE (value: Value): Hash; TYPE EqualProc = PROCEDURE (value1, value2: Value): BOOLEAN; TYPE CreateStreamProc = PROCEDURE (value: Value; VAR stream: Streams.Stream); TYPE ValueInterface = POINTER TO ValueInterfaceRec; TYPE ValueInterfaceRec = RECORD (Objects.ObjectRec) generator: GeneratorProc; equal: EqualProc; createStream: CreateStreamProc; END;
PROCEDURE Init(hash: Hash; if: Interface); PROCEDURE InitValue(value: Value; if: ValueInterface); PROCEDURE Generate(hash: Hash; message: Streams.Stream; VAR value: Value); PROCEDURE Bitlength(hash: Hash): LONGINT; PROCEDURE Generator(value: Value): Hash; PROCEDURE Equal(value1, value2: Value): BOOLEAN; PROCEDURE CreateStream(value: Value; VAR stream: Streams.Stream);
The interface procedures of hashes should meet the specifications following:
Moreover, interface procedures of hash values are specified as follows:
Init is to be called by implementations of OneWayHashes and connects the interface if to hash. Note that Services.Init must of course be called as well.
InitValue connects values with their OneWayHashes interface. Note that PersistentObjects.Init is supposed to have been called before.
Generate uses the one-way hash function specified by hash to compute a hash value out of given message and stores the result in value. Bitlength returns the fixed bit length of hash values created by the one-way hash function specified by hash.
Generator returns the hash that created a given value. Equal returns TRUE if two values generated by the same hash are equal. By definition, this is a strong hint that the original messages were equal as well. Note that comparing values of different hash functions does not make sense and is in fact illegal.
CreateStream opens the memory area of a hash value as a stream for reading.
revised by Martin Hasch
Oberon || Library || Module Index || Search Engine || Definition || Module