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

(make-message-digest-primitive CONTEXT-INFO DIGEST-SIZE INIT! UPDATE! FINAL! [BLOCK-LENGTH] [NAME] [RAW-UPDATE!]) -> 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.
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.
INIT!
(CONTEXT -> void))
  • sets up the CONTEXT.
UPDATE!
(CONTEXT SOURCE COUNT -> void)).
  • Must accumulate the SOURCE, beginning at 0, for COUNT bytes. Will be called zero or more times. SOURCE is usually an (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.
RAW-UPDATE!
(CONTEXT POINTER COUNT -> void)).
  • 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, limited by (message-digest-chunk-size).
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 an (or blob string) object.