1. Introduction
  2. Usage
  3. Documentation
    1. make-binary-message-digest
    2. make-message-digest
    3. message-digest-primitive
    4. message-digest-primitive-apply
    5. Auxillary Procedures
    6. message-digest-chunk-size
      1. byte-string->substring-list
      2. byte-string->substring-list/shared
      3. string->hexadecimal
      4. string->substring-list ; DEPRECATED
      5. string->substring-list/shared ; DEPRECATED
      6. ->byte-vector ; DEPRECATED
      7. ->blob
  4. Examples
  5. Notes
  6. Bugs and Limitations
  7. Author
  8. License
  9. Requirements
  10. Version history

= message-digest

Introduction

Message Digest provides support for message digest primitives. A message-digest is a function taking arbitrary-length byte-block binary input and returning a fixed-length hash.

Usage

(require-extension message-digest)

Documentation

make-binary-message-digest

[procedure] (make-binary-message-digest OBJECT CONTEXT-INFO DIGEST-LENGTH INIT UPDATE FINAL [ID])

Returns the message-digest for OBJECT as a binary string. ID is the symbol for the calling context.

Acceptable objects are string, input-port, blob, or anything that can be converted into a blob. Lists, vectors, and homogeneous-vectors can be converted. Lists and vectors should only be composed of characters, fixnums, or booleans. A boolean is treated as #f = 0 and #t = 1.

An input-port is not closed, but is read to end-of-file.

CONTEXT-INFO is either a procedure that returns an object, or a positive fixnum. When a fixnum a block of memory of length CONTEXT-INFO is allocated (and automatically free'ed). The CONTEXT can be a pointer object or any other Scheme object.

DIGEST-LENGTH The fixnum count of bytes in the result string.

The phase procedures:

[procedure] ({{INIT}} CONTEXT)

Initialization phase procedure. Sets up the CONTEXT, if necessary. The result is ignored.

[procedure] ({{UPDATE}} CONTEXT BYTES COUNT)

Accumulation phase procedure. Must accumulate the COUNT BYTES. BYTES is a Scheme non-immediate object. Will be called one or more times. The result is ignored.

See message-digest-chunk-size to set the number of bytes read per update invocation.

[procedure] ({{FINAL}} CONTEXT RESULT)

Finalization phase procedure. Must build the resulting message-digest in the supplied RESULT string. The result is ignored.

The optional ID is for identification. If not supplied a unique id will be generated.

make-message-digest

[procedure] (make-message-digest OBJECT CONTEXT-INFO DIGEST-LENGTH INIT UPDATE FINAL [ID])

Exactly as above but returns the message-digest for OBJECT as a hexadecimal encoded string of length 2 * DIGEST-LENGTH.

message-digest-primitive

 [record] (message-digest-primitive CONTEXT-INFO DIGEST-LENGTH INIT UPDATE FINAL ID)

The meaning of the fields are exactly as above.

[procedure] message-digest?
[procedure] message-digest-context-info
[procedure] message-digest-digest-length
[procedure] message-digest-init
[procedure] message-digest-update
[procedure] message-digest-final
[procedure] message-digest-name

message-digest-primitive-apply

[procedure] (message-digest-primitive-apply MESSAGE-DIGEST-PRIMITIVE OBJECT [ID])

Returns a binary-message-digest of OBJECT using MESSAGE-DIGEST-PRIMITIVE.

Auxillary Procedures

message-digest-chunk-size

[parameter] (message-digest-chunk-size [SIZE])

The number of bytes to read during the message-digest update phase. SIZE is a positive fixnum, default 1024.

byte-string->substring-list

[procedure] (byte-string->substring-list STRING CHUNK-SIZE [START [END]])

Returns a list of CHUNK-SIZE substrings of STRING, on the interval [START END). Defaults are [0 string-length). Any remaining substring less than chunk-size is appended to the list.

byte-string->substring-list/shared

[procedure] (byte-string->substring-list/shared STRING CHUNK-SIZE [START [END]])

Returns a list of CHUNK-SIZE substrings of STRING, on the interval [START END). Defaults are [0 string-length). Any remaining substring less than chunk-size is appended to the list.

The substrings share storage with the STRING!

string->hexadecimal

[procedure] (string->hexadecimal STRING [LENGTH])

Returns the STRING as a hex-encoded string. When LENGTH missing string-length is used. The returned string is 2 * string-length.

string->substring-list ; DEPRECATED

[procedure] (string->substring-list STRING CHUNK-SIZE [START [END]])

Returns a list of CHUNK-SIZE substrings of STRING, on the interval [START END). Defaults are [0 string-length). Any remaining substring less than chunk-size is appended to the list.

Byte Oriented!

string->substring-list/shared ; DEPRECATED

[procedure] (string->substring-list/shared STRING CHUNK-SIZE [START [END]])

Returns a list of CHUNK-SIZE substrings of STRING, on the interval [START END). Defaults are [0 string-length). Any remaining substring less than chunk-size is appended to the list.

The substrings share storage with the STRING!

Byte Oriented!

->byte-vector ; DEPRECATED

[procedure] (->byte-vector OBJECT)

Converts the OBJECT into a byte-vector.

->blob

[procedure] (->blob OBJECT)

Converts the OBJECT into a blob.

Examples

Notes

Bugs and Limitations

Author

Kon Lovett

License

Copyright (c) 2006, 2007 Kon Lovett. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Requirements

Version history

1.7
Deprecated byte-vector & string stuff, added blob & byte-string stuff, added chunk parameter
1.6
Better fixnum coercion
1.5
Exports
1.4
Removed ->integer
1.3
Added name field to primitive record
1.2
Added Auxiallary Procedures
1.1
Added un-managed context object support
1.0
Initial release