message-digest

  1. message-digest
  2. Documentation
    1. Usage
    2. Common Argument Definitions
    3. message-digest-result-form
    4. initialize-message-digest
    5. message-digest?
    6. message-digest-algorithm
    7. finalize-message-digest
    8. finalize-message-digest!
    9. setup-message-digest-buffer!
  3. Requirements
  4. Author
  5. Version history
  6. License

Documentation

The Message Digest Type provides support for an active message digest primitive.

Usage

(use message-digest-type)

Common Argument Definitions

RESULT-FORM is a message-digest-result-form, one of:

'byte-string 'string
the result bytes as a string; these are raw bytes, not characters!
'blob
the result bytes as a blob.
'u8vector
the result bytes as a u8vector.
'hex-string 'hex 'hexstring
the result bytes encoded as a string of lower-case hexadecimal digits.

DIGEST is a message-digest.

ENDIAN is one of 'big-endian, 'little-endian.

SOURCE is a Scheme object.

The buffer argument for the update phase is translated as:

string
buffer is SOURCE.
blob
buffer is SOURCE.
srfi-4-vector
buffer from (...vector->blob/shared SOURCE).
procedure
updates with buffer from (procedure) until #f.
input-port
like procedure above but from ((message-digest-chunk-read-maker) SOURCE).
pointer
buffer is SOURCE, thru the digest primitive raw-update usually.
*
buffer from (message-digest-chunk-converter SOURCE).

Should none of the above interpretations be available then an error is signaled.

A byte-source is one of string, blob, or srfi-4-vector.

message-digest-result-type is (or blob string u8vector)

message-digest-result-form

[parameter] (message-digest-result-form [RESULT-FORM]) -> symbol

The initial RESULT-FORM value is 'hex-string.

A RESULT-FORM of #f resets to the initial value.

initialize-message-digest

[procedure] (initialize-message-digest PRIM) -> message-digest

Returns a new, initialized, message-digest for the supplied algorithm PRIM.

Initialized here means the intialization phase is completed.

message-digest?

[procedure] (message-digest? OBJ) -> boolean
[procedure] (check-message-digest LOC OBJ [NAM])
[procedure] (error-message-digest LOC OBJ [NAM])

message-digest-algorithm

[procedure] (message-digest-algorithm DIGEST) -> message-digest-primitive

Returns the message digest algorithm used by this DIGEST.

Mostly for use when developing an update operation.

Do not mess with this object!

finalize-message-digest

[procedure] (finalize-message-digest DIGEST [RESULT-FORM]) -> message-digest-result-type

Finalize the DIGEST and return the result in the RESULT-FORM.

RESULT-FORM
message-digest-result-form ; default (message-digest-result-form).

Finalize here means the finalization phase is completed. The DIGEST is not in a useful state.

finalize-message-digest!

[procedure] (finalize-message-digest! DIGEST BUFFER) -> message-digest-result-type

Finalize the DIGEST and return the result in the BUFFER.

The BUFFER must be a string, blob, or u8vector of sufficient size; checked at runtime. Does not perform any initialization of the BUFFER.

The result starts at the beginning of the BUFFER, and runs for (message-digest-primitive-digest-length (message-digest-algorithm DIGEST)) bytes. Result is binary only.

Finalize here means the finalization phase is completed. The DIGEST is not in a useful state.

setup-message-digest-buffer!

[procedure] (setup-message-digest-buffer! DIGEST SIZE)

Ensure the DIGEST has a buffer of at least SIZE bytes.

Requirements

check-errors blob-utils string-utils

Author

Kon Lovett

Version history

4.0.1
Add tests & type checking.
4.0.0
CHICKEN 5 release as own egg.
3.9.0
Add types.
3.8.0
Fix message-digest-primitive?; accept *.
3.7.1
3.7.0
Add message-digest-object!, message-digest-file!, and message-digest-port!.
3.6.0
Add START and/or END optional arguments.
3.5.0
Add finalize-message-digest!.
3.4.0
Deprecate message-digest-chunk-read-maker. Add message-digest-chunk-port-read-maker, message-digest-chunk-fileno-read-maker. Add message-digest-primitive-raw-update.
3.3.0
Deprecate message-digest-default-result-type. Add message-digest-result-form.
3.2.0
Add message-digest-default-result-type. message-digest-chunk-* are parameters.
3.1.1
Fix check-u8vector import.
3.1.0
Added optional message-digest-primitive-block-length.
3.0.5
Reverted 64 bit support.
3.0.4
Removed 64 bit support.
3.0.3
3.0.2
Use of compiled setup-helper.
3.0.1
3.0.0
Removed deprecated procedures to own module. Removed integer packing procedures. Split into many modules. Deprecated some procedures.
2.3.8
Treat integers as unsigned. (Ticket #534) Uses blob for finalization result buffer.
2.3.7
Remove no checks optimization compier options.
2.3.6
Deprecated close-output-digest. Restricted no checks optimization compier option.
2.3.5
The 'u8vector RESULT-FORM is slightly faster. Revert to allocated context memory.
2.3.4
Try w/o C-level memory allocation so no finalizer needed.
2.3.3
The 'blob RESULT-FORM is slightly faster.
2.3.2
Deprecated byte-string->hexadecimal. Deprecated string->hex, use string-utils string-hexadecimal#string->hex. Fix for the default message-digest-chunk-read-maker, blob was always chunk-size.
2.3.1
Moved some utility routines into own egg(s).
2.3.0
Added message-digest-update-char-u8, message-digest-update-char-be, and message-digest-update-char-le. message-digest-update-char now treats the actual bit-width of char correctly.
2.2.0
Added Byte Packing API. Downgraded message-digest-chunk-read-maker, message-digest-chunk-size & message-digest-chunk-converter from parameter.
2.1.1
Bug fix for hexstring: must use lowercase.
2.1.0
Added message digest "phase" and port APIs. Deprecated old API.
2.0.1
Bug fix for (message-digest-chunk-converter) use by make-binary-message-digest.
2.0.0
Release for Chicken 4 [From a diff provided by Christian Kellermann]

License

 Copyright (C) 2006-2018 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.