chickadee » message-digest-primitive » make-message-digest-primitive

(make-message-digest-primitive CONTEXT-INFO DIGEST-SIZE INIT UPDATE FINAL [block-length 4] [name 'mdp] [raw-update #f]) -> message-digest-primitiveprocedure

Create a message-digest-primitive object, defining a message digest algorithm.

The processing of a message digest is split into three phases: initialization, update, & finalization. These are represented by procedures: INIT, UPDATE | RAW-UPDATE, & FINAL, respectively.

CONTEXT-INFO
(or (CONTEXT-INFO -> context-object) positive-fixnum)
  • (CONTEXT-INFO -> CONTEXT) ; returns the context-object, which should be unique. At least the object cannot be shared with another activated primitive.
  • positive-fixnum : a memory-block of length CONTEXT-INFO bytes is allocated; the memory is automatically free'ed. The context-object here is a {pointer}} to a block of uninitialized memory.
DIGEST-SIZE
positive-fixnum
  • The count of bytes in the result.
INIT
(CONTEXT -> void))
  • sets up the CONTEXT.
UPDATE
#f or (CONTEXT SOURCE COUNT -> void))
  • Must accumulate the SOURCE, beginning at 0, for COUNT bytes. Will be called zero or more times. SOURCE is usually a (or blob string) object.
  • COUNT is the actual number of bytes in the SOURCE. Only the first COUNT bytes in the SOURCE are valid. COUNT is a positive-fixnum.
  • when #f & RAW-UPDATE then an UPDATE is built, otherwise an error.
FINAL
(CONTEXT DESTINATION -> void)).
  • Must build the message-digest result in the supplied result DESTINATION, which will have a byte-count of at least DIGEST-SIZE. DESTINATION is usually a (or blob string) object.
RAW-UPDATE
(CONTEXT POINTER COUNT -> void)).
  • When UPDATE is #f RAW-UPDATE must be defined.
  • Must accumulate the memory at POINTER, beginning at 0, for COUNT bytes. Will be called zero or more times.
  • COUNT is the actual number of bytes in the SOURCE. Only the first COUNT bytes in the memory at POINTER are valid. COUNT is a positive-fixnum.
BLOCK-LENGTH
positive-fixnum ; default 4
  • The primitive's accumulator length in bytes.
NAME
(or symbol string) ; default uninterned-symbol.
  • Identifies the message digest algorithm. The suggested form is <algorithm>-primitive, 'md5-primitive for example.