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

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

rel 4.2.0

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