message-digest-type

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

Documentation

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

Usage

(import message-digest-type)

Common Argument Definitions

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

'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.
'string 'byte-string
DEPRECATED - the result bytes as a string; these are raw bytes, not necessarily characters!

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.

initialize-message-digest!

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

Returns a new, initialized, message-digest for the supplied message-digest-primitive-context CTX.

Initialized here means the intialization phase is completed.

ensure-message-digest-buffer!

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

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

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.

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 object representation used by this DIGEST.

Mostly for use when developing an update operation.

message-digest-context

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

Returns the message-digest algorithm object opaque-data object used by this DIGEST.

Mostly for use when developing an update operation.

Requirements

check-errors blob-utils string-utils

Author

Kon Lovett

Version history

4.1.0
Add initialize-message-digest!, fix message-digest-result-form.
4.0.1
Add tests & type checking.
4.0.0
CHICKEN 5 release as own egg.

License

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