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

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

fix tree

File size: 7.5 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; {{BLOCK-LENGTH}} : {{positive-fixnum}} ; default {{4}}
66
67* The primitive's accumulator length in bytes.
68
69; {{NAME}} : {{(or symbol string)}} ; default {{uninterned-symbol}}.
70
71* Identifies the message digest algorithm. The suggested form is
72{{<algorithm>-primitive}}, {{'md5-primitive}} for example.
73
74; {{INIT}} : {{(CONTEXT -> void))}}
75
76* sets up the {{CONTEXT}}.
77
78; {{UPDATE}} : {{(CONTEXT SOURCE COUNT -> void))}}.
79
80* Must accumulate the {{SOURCE}}, beginning at {{0}}, for {{COUNT}} bytes.
81Will be called zero or more times. {{SOURCE}} is usually a {{(or blob
82string)}} object.
83
84* {{COUNT}} is the actual number of bytes in the {{SOURCE}}. Only the first
85{{COUNT}} bytes in the {{SOURCE}} are valid. {{COUNT}} is a
86{{positive-fixnum}}.
87
88; {{RAW-UPDATE}} : {{(CONTEXT POINTER COUNT -> void))}}.
89
90* Must accumulate the memory at {{POINTER}}, beginning at {{0}}, for {{COUNT}}
91bytes. Will be called zero or more times.
92
93* {{COUNT}} is the actual number of bytes in the {{SOURCE}}. Only the first
94{{COUNT}} bytes in the memory at {{POINTER}} are valid. {{COUNT}} is a
95{{positive-fixnum}}, limited by {{(message-digest-chunk-size)}}.
96
97; {{FINAL}} : {{(CONTEXT DESTINATION -> void))}}.
98
99* Must build the message-digest result in the supplied result {{DESTINATION}},
100which will have a byte-count of at least {{DIGEST-SIZE}}. {{DESTINATION}} is
101usually a {{(or blob string)}} object.
102
103=== make-message-digest-primitive-context
104
105<procedure>(make-message-digest-primitive-context PRIM) -> *
106
107Returns a {{message-digest-primitive-context}} object, used by a message digest
108algorithm.
109
110
111== Requirements
112
113[[check-errors]]
114
115
116== Author
117
118[[/users/kon-lovett|Kon Lovett]]
119
120
121== Version history
122
123; 4.1.0 : Fix {{make-message-digest-primitive-context}} argument.
124; 4.0.0 : CHICKEN 5 release as ''own'' egg.
125; 3.9.0 : Add types.
126; 3.8.0 : Fix {{message-digest-primitive?}}; accept {{*}}.
127; 3.7.1 :
128; 3.7.0 : Add {{message-digest-object!}}, {{message-digest-file!}}, and {{message-digest-port!}}.
129; 3.6.0 : Add {{START}} and/or {{END}} optional arguments.
130; 3.5.0 : Add {{finalize-message-digest!}}.
131; 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}}.
132; 3.3.0 : Deprecate {{message-digest-default-result-type}}. Add {{message-digest-result-form}}.
133; 3.2.0 : Add {{message-digest-default-result-type}}. {{message-digest-chunk-*}} are parameters.
134; 3.1.1 : Fix {{check-u8vector}} import.
135; 3.1.0 : Added optional {{message-digest-primitive-block-length}}.
136; 3.0.5 : Reverted 64 bit support.
137; 3.0.4 : Removed 64 bit support.
138; 3.0.3 :
139; 3.0.2 : Use of compiled setup-helper.
140; 3.0.1 :
141; 3.0.0 : Removed deprecated procedures to own module. Removed integer packing procedures. Split into many modules. Deprecated some procedures.
142; 2.3.8 : Treat integers as unsigned. (Ticket #534) Uses blob for finalization result buffer.
143; 2.3.7 : Remove no checks optimization compier options.
144; 2.3.6 : Deprecated close-output-digest. Restricted no checks optimization compier option.
145; 2.3.5 : The {{'u8vector}} {{RESULT-FORM}} is slightly faster. Revert to allocated context memory.
146; 2.3.4 : Try w/o C-level memory allocation so no finalizer needed.
147; 2.3.3 : The {{'blob}} {{RESULT-FORM}} is slightly faster.
148; 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.
149; 2.3.1 : Moved some utility routines into own egg(s).
150; 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.
151; 2.2.0 : Added [[Byte Packing]] API. Downgraded {{message-digest-chunk-read-maker}}, {{message-digest-chunk-size}} & {{message-digest-chunk-converter}} from {{parameter}}.
152; 2.1.1 : Bug fix for hexstring: must use lowercase.
153; 2.1.0 : Added message digest "phase" and port APIs. Deprecated old API.
154; 2.0.1 : Bug fix for {{(message-digest-chunk-converter)}} use by {{make-binary-message-digest}}.
155; 2.0.0 : Release for Chicken 4 [From a diff provided by Christian Kellermann]
156
157
158== License
159
160  Copyright (C) 2006-2018 Kon Lovett.  All rights reserved.
161
162  Permission is hereby granted, free of charge, to any person obtaining a
163  copy of this software and associated documentation files (the Software),
164  to deal in the Software without restriction, including without limitation
165  the rights to use, copy, modify, merge, publish, distribute, sublicense,
166  and/or sell copies of the Software, and to permit persons to whom the
167  Software is furnished to do so, subject to the following conditions:
168
169  The above copyright notice and this permission notice shall be included
170  in all copies or substantial portions of the Software.
171
172  THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
173  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
174  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
175  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
176  OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
177  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
178  OTHER DEALINGS IN THE SOFTWARE.
Note: See TracBrowser for help on using the repository browser.