source: project/wiki/eggref/5/message-digest-primitive @ 38977

Last change on this file since 38977 was 38977, checked in by Kon Lovett, 8 weeks ago

rel 4.2.0

File size: 7.7 KB
Line 
1[[tags: egg]]
2
3
4== message-digest-primitive
5
6[[toc:]]
7
8
9== Documentation
10
11The Message Digest Primitive Type; reification of a message digest algorithm.
12
13=== Usage
14
15<enscript highlight=scheme>
16(import message-digest-primitive)
17</enscript>
18
19=== Common Argument Definitions
20
21{{PRIM}} is a {{message-digest-primitive}}
22
23=== message-digest-primitive?
24
25<procedure>(message-digest-primitive? OBJ) --> boolean</procedure>
26<procedure>(check-message-digest-primitive LOC OBJ [NAM])</procedure>
27<procedure>(error-message-digest-primitive LOC OBJ [NAM])</procedure>
28
29=== message-digest-primitive Accessors
30
31<procedure>(message-digest-primitive-context-info PRIM) --> *</procedure>
32<procedure>(message-digest-primitive-digest-length PRIM) --> fixnum</procedure>
33<procedure>(message-digest-primitive-init PRIM) --> procedure</procedure>
34<procedure>(message-digest-primitive-update PRIM) --> procedure</procedure>
35<procedure>(message-digest-primitive-raw-update PRIM) --> (or #f procedure)</procedure>
36<procedure>(message-digest-primitive-final PRIM) --> procedure</procedure>
37<procedure>(message-digest-primitive-block-length PRIM) --> fixnum</procedure>
38<procedure>(message-digest-primitive-name PRIM) --> symbol</procedure>
39
40=== make-message-digest-primitive
41
42<procedure>(make-message-digest-primitive CONTEXT-INFO DIGEST-SIZE INIT UPDATE FINAL [block-length 4] [name 'mdp] [raw-update #f]) -> message-digest-primitive</procedure>
43
44Create a {{message-digest-primitive}} object, defining a message digest
45algorithm.
46
47The processing of a message digest is split into three phases: initialization,
48update, & finalization. These are represented by procedures: {{INIT}},
49{{UPDATE}} | {{RAW-UPDATE}}, & {{FINAL}}, respectively.
50
51; {{CONTEXT-INFO}} : {{(or (CONTEXT-INFO -> context-object) positive-fixnum)}}
52
53* {{(CONTEXT-INFO -> CONTEXT)}} ; returns the {{context-object}}, which should
54be unique. At least the object cannot be shared with another ''activated''
55primitive.
56
57* {{positive-fixnum}} : a memory-block of length {{CONTEXT-INFO}} bytes is
58allocated; the memory is automatically free'ed. The {{context-object}} here is
59a {pointer}} to a block of uninitialized memory.
60
61; {{DIGEST-SIZE}} : {{positive-fixnum}}
62
63* The count of bytes in the result.
64
65; {{INIT}} : {{(CONTEXT -> void))}}
66
67* sets up the {{CONTEXT}}.
68
69; {{UPDATE}} : {{#f}} or {{(CONTEXT SOURCE COUNT -> void))}}
70
71* Must accumulate the {{SOURCE}}, beginning at {{0}}, for {{COUNT}} bytes.
72Will be called zero or more times. {{SOURCE}} is usually a {{(or blob
73string)}} object.
74
75* {{COUNT}} is the actual number of bytes in the {{SOURCE}}. Only the first
76{{COUNT}} bytes in the {{SOURCE}} are valid. {{COUNT}} is a
77{{positive-fixnum}}.
78
79* when {{#f}} & {{RAW-UPDATE}} then an {{UPDATE}} is built, otherwise an
80error.
81
82; {{FINAL}} : {{(CONTEXT DESTINATION -> void))}}.
83
84* Must build the message-digest result in the supplied result {{DESTINATION}},
85which will have a byte-count of at least {{DIGEST-SIZE}}. {{DESTINATION}} is
86usually a {{(or blob string)}} object.
87
88; {{RAW-UPDATE}} : {{(CONTEXT POINTER COUNT -> void))}}.
89
90* When {{UPDATE}} is {{#f}} {{RAW-UPDATE}} must be defined.
91
92* Must accumulate the memory at {{POINTER}}, beginning at {{0}}, for {{COUNT}}
93bytes. Will be called zero or more times.
94
95* {{COUNT}} is the actual number of bytes in the {{SOURCE}}. Only the first
96{{COUNT}} bytes in the memory at {{POINTER}} are valid. {{COUNT}} is a
97{{positive-fixnum}}.
98
99; {{BLOCK-LENGTH}} : {{positive-fixnum}} ; default {{4}}
100
101* The primitive's accumulator length in bytes.
102
103; {{NAME}} : {{(or symbol string)}} ; default {{uninterned-symbol}}.
104
105* Identifies the message digest algorithm. The suggested form is
106{{<algorithm>-primitive}}, {{'md5-primitive}} for example.
107
108=== make-message-digest-primitive-context
109
110<procedure>(make-message-digest-primitive-context PRIM) -> *</procedure>
111
112Returns a {{message-digest-primitive-context}} object, used by a message digest
113algorithm.
114
115
116== Requirements
117
118[[check-errors]]
119
120
121== Author
122
123[[/users/kon-lovett|Kon Lovett]]
124
125
126== Version history
127
128; 4.3.0 : Add {{message-digest-primitive.types.scm}}.
129; 4.2.1 : .
130; 4.2.0 : Add make missing update procedure from raw-update procedure argument.
131; 4.1.0 : Fix {{make-message-digest-primitive-context}} argument.
132; 4.0.0 : CHICKEN 5 release as ''own'' egg.
133; 3.9.0 : Add types.
134; 3.8.0 : Fix {{message-digest-primitive?}}; accept {{*}}.
135; 3.7.1 :
136; 3.7.0 : Add {{message-digest-object!}}, {{message-digest-file!}}, and {{message-digest-port!}}.
137; 3.6.0 : Add {{START}} and/or {{END}} optional arguments.
138; 3.5.0 : Add {{finalize-message-digest!}}.
139; 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}}.
140; 3.3.0 : Deprecate {{message-digest-default-result-type}}. Add {{message-digest-result-form}}.
141; 3.2.0 : Add {{message-digest-default-result-type}}. {{message-digest-chunk-*}} are parameters.
142; 3.1.1 : Fix {{check-u8vector}} import.
143; 3.1.0 : Added optional {{message-digest-primitive-block-length}}.
144; 3.0.5 : Reverted 64 bit support.
145; 3.0.4 : Removed 64 bit support.
146; 3.0.3 :
147; 3.0.2 : Use of compiled setup-helper.
148; 3.0.1 :
149; 3.0.0 : Removed deprecated procedures to own module. Removed integer packing procedures. Split into many modules. Deprecated some procedures.
150; 2.3.8 : Treat integers as unsigned. (Ticket #534) Uses blob for finalization result buffer.
151; 2.3.7 : Remove no checks optimization compier options.
152; 2.3.6 : Deprecated close-output-digest. Restricted no checks optimization compier option.
153; 2.3.5 : The {{'u8vector}} {{RESULT-FORM}} is slightly faster. Revert to allocated context memory.
154; 2.3.4 : Try w/o C-level memory allocation so no finalizer needed.
155; 2.3.3 : The {{'blob}} {{RESULT-FORM}} is slightly faster.
156; 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.
157; 2.3.1 : Moved some utility routines into own egg(s).
158; 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.
159; 2.2.0 : Added [[Byte Packing]] API. Downgraded {{message-digest-chunk-read-maker}}, {{message-digest-chunk-size}} & {{message-digest-chunk-converter}} from {{parameter}}.
160; 2.1.1 : Bug fix for hexstring: must use lowercase.
161; 2.1.0 : Added message digest "phase" and port APIs. Deprecated old API.
162; 2.0.1 : Bug fix for {{(message-digest-chunk-converter)}} use by {{make-binary-message-digest}}.
163; 2.0.0 : Release for Chicken 4 [From a diff provided by Christian Kellermann]
164
165== License
166
167  Copyright (C) 2006-2020 Kon Lovett.  All rights reserved.
168
169  Permission is hereby granted, free of charge, to any person obtaining a
170  copy of this software and associated documentation files (the Software),
171  to deal in the Software without restriction, including without limitation
172  the rights to use, copy, modify, merge, publish, distribute, sublicense,
173  and/or sell copies of the Software, and to permit persons to whom the
174  Software is furnished to do so, subject to the following conditions:
175
176  The above copyright notice and this permission notice shall be included
177  in all copies or substantial portions of the Software.
178
179  THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
180  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
181  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
182  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
183  OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
184  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
185  OTHER DEALINGS IN THE SOFTWARE.
Note: See TracBrowser for help on using the repository browser.