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

Last change on this file since 36747 was 36747, checked in by kon, 6 months ago

fix raw-update doc

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.2.0 : Add make missing update procedure from raw-update procedure argument.
129; 4.1.0 : Fix {{make-message-digest-primitive-context}} argument.
130; 4.0.0 : CHICKEN 5 release as ''own'' egg.
131; 3.9.0 : Add types.
132; 3.8.0 : Fix {{message-digest-primitive?}}; accept {{*}}.
133; 3.7.1 :
134; 3.7.0 : Add {{message-digest-object!}}, {{message-digest-file!}}, and {{message-digest-port!}}.
135; 3.6.0 : Add {{START}} and/or {{END}} optional arguments.
136; 3.5.0 : Add {{finalize-message-digest!}}.
137; 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}}.
138; 3.3.0 : Deprecate {{message-digest-default-result-type}}. Add {{message-digest-result-form}}.
139; 3.2.0 : Add {{message-digest-default-result-type}}. {{message-digest-chunk-*}} are parameters.
140; 3.1.1 : Fix {{check-u8vector}} import.
141; 3.1.0 : Added optional {{message-digest-primitive-block-length}}.
142; 3.0.5 : Reverted 64 bit support.
143; 3.0.4 : Removed 64 bit support.
144; 3.0.3 :
145; 3.0.2 : Use of compiled setup-helper.
146; 3.0.1 :
147; 3.0.0 : Removed deprecated procedures to own module. Removed integer packing procedures. Split into many modules. Deprecated some procedures.
148; 2.3.8 : Treat integers as unsigned. (Ticket #534) Uses blob for finalization result buffer.
149; 2.3.7 : Remove no checks optimization compier options.
150; 2.3.6 : Deprecated close-output-digest. Restricted no checks optimization compier option.
151; 2.3.5 : The {{'u8vector}} {{RESULT-FORM}} is slightly faster. Revert to allocated context memory.
152; 2.3.4 : Try w/o C-level memory allocation so no finalizer needed.
153; 2.3.3 : The {{'blob}} {{RESULT-FORM}} is slightly faster.
154; 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.
155; 2.3.1 : Moved some utility routines into own egg(s).
156; 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.
157; 2.2.0 : Added [[Byte Packing]] API. Downgraded {{message-digest-chunk-read-maker}}, {{message-digest-chunk-size}} & {{message-digest-chunk-converter}} from {{parameter}}.
158; 2.1.1 : Bug fix for hexstring: must use lowercase.
159; 2.1.0 : Added message digest "phase" and port APIs. Deprecated old API.
160; 2.0.1 : Bug fix for {{(message-digest-chunk-converter)}} use by {{make-binary-message-digest}}.
161; 2.0.0 : Release for Chicken 4 [From a diff provided by Christian Kellermann]
162
163
164== License
165
166  Copyright (C) 2006-2018 Kon Lovett.  All rights reserved.
167
168  Permission is hereby granted, free of charge, to any person obtaining a
169  copy of this software and associated documentation files (the Software),
170  to deal in the Software without restriction, including without limitation
171  the rights to use, copy, modify, merge, publish, distribute, sublicense,
172  and/or sell copies of the Software, and to permit persons to whom the
173  Software is furnished to do so, subject to the following conditions:
174
175  The above copyright notice and this permission notice shall be included
176  in all copies or substantial portions of the Software.
177
178  THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
179  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
180  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
181  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
182  OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
183  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
184  OTHER DEALINGS IN THE SOFTWARE.
Note: See TracBrowser for help on using the repository browser.