author | Claus Gittinger <cg@exept.de> |
Wed, 26 Jun 2019 22:06:12 +0200 | |
changeset 24369 | e796791ea838 |
parent 23955 | 65bb2eee0144 |
permissions | -rw-r--r-- |
23938 | 1 |
"{ Encoding: utf8 }" |
2 |
||
6864 | 3 |
" |
4 |
COPYRIGHT (c) 1999 by eXept Software AG |
|
5 |
All Rights Reserved |
|
6 |
||
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
7041 | 14 |
"{ Package: 'stx:libbasic' }" |
15 |
||
19608 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
6864 | 18 |
HashStream subclass:#MD5Stream |
19 |
instanceVariableNames:'hashContext' |
|
20 |
classVariableNames:'HashSize ContextSize' |
|
21 |
poolDictionaries:'' |
|
12419 | 22 |
category:'System-Crypt-Hashing' |
6864 | 23 |
! |
24 |
||
25 |
!MD5Stream primitiveDefinitions! |
|
26 |
%{ |
|
27 |
||
28 |
/* |
|
29 |
* includes, defines, structure definitions |
|
30 |
* and typedefs come here. |
|
31 |
*/ |
|
32 |
||
33 |
#include "md5.h" |
|
34 |
||
35 |
%} |
|
36 |
! ! |
|
37 |
||
38 |
!MD5Stream class methodsFor:'documentation'! |
|
39 |
||
40 |
copyright |
|
41 |
" |
|
42 |
COPYRIGHT (c) 1999 by eXept Software AG |
|
43 |
All Rights Reserved |
|
44 |
||
45 |
This software is furnished under a license and may be used |
|
46 |
only in accordance with the terms of that license and with the |
|
47 |
inclusion of the above copyright notice. This software may not |
|
48 |
be provided or otherwise made available to, or used by, any |
|
49 |
other person. No title to or ownership of the software is |
|
50 |
hereby transferred. |
|
51 |
" |
|
52 |
||
53 |
||
54 |
! |
|
55 |
||
56 |
documentation |
|
57 |
" |
|
58 |
Generate a MD5 hash value as defined in RFC 1321. |
|
12756 | 59 |
|
60 |
Note: |
|
14787 | 61 |
in August 2004, some researchers have found a way to generate full collisions for MD5. |
62 |
Therefore, for new applications, it may be wise to choose another hash function for security stuff. |
|
63 |
See a hash-collision example in the examples method. |
|
6864 | 64 |
|
23938 | 65 |
The MD5 algorithm has severe weaknesses, for example it is easy to compute two messages yielding |
14787 | 66 |
the same hash (collision attack). |
67 |
The use of this algorithm is only justified for non-cryptographic application. |
|
13932 | 68 |
|
69 |
||
12265 | 70 |
performance: roughly |
21153 | 71 |
150 Mb/s on a 2007 MAC Powerbook (2.6Ghz I7-Duo) |
14787 | 72 |
104000 Kb/s on a 2.5Ghz 64X2 Athlon 4800+ (64bit) |
73 |
80000 Kb/s on a 2Ghz Duo |
|
74 |
27200 Kb/s on a 1.2Ghz Athlon |
|
75 |
12600 Kb/s on a 400Mhz PIII |
|
76 |
9150 Kb/s on a 300Mhz Sparc. |
|
77 |
performance is almost completely limited by the speed of the md5-routine, which is the reference |
|
78 |
implementation in C from md5lib. |
|
12756 | 79 |
|
6864 | 80 |
[author:] |
14787 | 81 |
Stefan Vogel |
6864 | 82 |
|
19608 | 83 |
[references:] |
84 |
* Ronald L. Rivest, http://www.roxen.com/rfc/rfc1321.html |
|
85 |
''The MD5 Message-Digest Algorithm'', IETF RFC-1321 (informational). |
|
86 |
* Bruce Schneier, Section 18.5 MD5, ''Applied Cryptography, 2nd edition'', John Wiley & Sons, 1996 |
|
87 |
||
6864 | 88 |
[see also:] |
14787 | 89 |
SHA1Stream |
90 |
SHA256Stream SHA512Stream (in libcrypt) |
|
6864 | 91 |
|
92 |
[class variables:] |
|
14787 | 93 |
HashSize size of returned hash value |
94 |
ContextSize (implementation) size of hash context |
|
6864 | 95 |
|
96 |
[instance variables:] |
|
14787 | 97 |
hashContext (implementation) |
98 |
internal buffer for computation of the hash value |
|
6864 | 99 |
" |
100 |
! |
|
101 |
||
102 |
examples |
|
103 |
" |
|
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
104 |
[exBegin] |
10782 | 105 |
Test Vectors (from FIPS PUB 180-1); results are: |
7041 | 106 |
|
10782 | 107 |
'abc' |
108 |
-> #[90 1 50 98 3C D2 4F B0 D6 96 3F 7D 28 E1 7F 72] |
|
6864 | 109 |
|
10782 | 110 |
'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq' |
111 |
-> #[82 15 EF 7 96 A2 B CA AA E1 16 D3 87 6C 66 4A] |
|
7041 | 112 |
|
10782 | 113 |
A million repetitions of 'a' |
114 |
-> #[77 7 D6 AE 4E 2 7C 70 EE A2 A9 35 C2 29 6F 21] |
|
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
115 |
[exEnd] |
6864 | 116 |
|
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
117 |
[exBegin] |
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
118 |
Transcript showCR:(MD5Stream hashValueOf:'abc') hexPrintString |
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
119 |
[exEnd] |
13001 | 120 |
|
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
121 |
[exBegin] |
12265 | 122 |
(MD5Stream hashValueOf:'abc') |
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
123 |
printOn:Transcript base:16. |
10782 | 124 |
Transcript cr. |
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
125 |
[exEnd] |
6864 | 126 |
|
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
127 |
[exBegin] |
12265 | 128 |
(MD5Stream hashValueOfStream:('abc' readStream)) |
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
129 |
printOn:Transcript base:16. |
10782 | 130 |
Transcript cr. |
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
131 |
[exEnd] |
6864 | 132 |
|
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
133 |
[exBegin] |
6864 | 134 |
|hashStream| |
135 |
||
136 |
hashStream := MD5Stream new. |
|
137 |
hashStream nextPut:'abc'. |
|
138 |
hashStream hashValue printOn:Transcript base:16. Transcript cr. |
|
139 |
hashStream nextPut:'dbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'. |
|
140 |
hashStream hashValue printOn:Transcript base:16. Transcript cr. |
|
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
141 |
[exEnd] |
6864 | 142 |
|
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
143 |
[exBegin] |
6864 | 144 |
|hashStream| |
145 |
||
146 |
hashStream := MD5Stream new. |
|
7041 | 147 |
hashStream nextPut:'a' asByteArray. |
148 |
hashStream nextPut:'bc' asByteArray. |
|
6864 | 149 |
hashStream hashValue printOn:Transcript base:16. Transcript cr. |
150 |
hashStream nextPut:'dbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq' asByteArray. |
|
151 |
hashStream hashValue printOn:Transcript base:16. Transcript cr. |
|
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
152 |
[exEnd] |
6864 | 153 |
|
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
154 |
[exBegin] |
6864 | 155 |
|hashStream| |
156 |
||
157 |
hashStream := MD5Stream new. |
|
158 |
1000000 timesRepeat:[ hashStream nextPut:$a ]. |
|
159 |
hashStream hashValue printOn:Transcript base:16. Transcript cr. |
|
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
160 |
[exEnd] |
6864 | 161 |
|
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
162 |
[exBegin] |
6864 | 163 |
|hashStream| |
164 |
||
165 |
hashStream := MD5Stream new. |
|
166 |
hashStream nextPut:'a'. |
|
167 |
hashStream hashValue printOn:Transcript base:16. Transcript cr. |
|
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
168 |
[exEnd] |
6864 | 169 |
|
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
170 |
[exBegin] |
6864 | 171 |
|hashStream| |
172 |
||
173 |
hashStream := MD5Stream new. |
|
174 |
hashStream nextPut:$a. |
|
175 |
hashStream hashValue printOn:Transcript base:16. Transcript cr. |
|
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
176 |
[exEnd] |
6864 | 177 |
|
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
178 |
[exBegin] |
6864 | 179 |
|hashStream| |
180 |
||
181 |
hashStream := MD5Stream new. |
|
182 |
hashStream nextPut:'abc'. |
|
183 |
hashStream hashValue printOn:Transcript base:16. Transcript cr. |
|
184 |
hashStream reset. |
|
185 |
hashStream nextPut:'abc'. |
|
186 |
hashStream hashValue printOn:Transcript base:16. Transcript cr. |
|
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
187 |
[exEnd] |
6864 | 188 |
|
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
189 |
a collision: |
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
190 |
[exBegin] |
13896 | 191 |
|hashStream| |
192 |
||
193 |
hashStream := MD5Stream new. |
|
194 |
hashStream nextPut:(ByteArray fromHexStringWithSeparators:' |
|
195 |
d131dd02c5e6eec4693d9a0698aff95c 2fcab58712467eab4004583eb8fb7f89 |
|
196 |
55ad340609f4b30283e488832571415a 085125e8f7cdc99fd91dbdf280373c5b |
|
197 |
d8823e3156348f5bae6dacd436c919c6 dd53e2b487da03fd02396306d248cda0 |
|
198 |
e99f33420f577ee8ce54b67080a80d1e c69821bcb6a8839396f9652b6ff72a70'). |
|
199 |
hashStream hashValue printOn:Transcript base:16. Transcript cr. |
|
200 |
hashStream reset. |
|
201 |
||
202 |
hashStream nextPut:(ByteArray fromHexStringWithSeparators:' |
|
203 |
d131dd02c5e6eec4693d9a0698aff95c 2fcab50712467eab4004583eb8fb7f89 |
|
204 |
55ad340609f4b30283e4888325f1415a 085125e8f7cdc99fd91dbd7280373c5b |
|
205 |
d8823e3156348f5bae6dacd436c919c6 dd53e23487da03fd02396306d248cda0 |
|
206 |
e99f33420f577ee8ce54b67080280d1e c69821bcb6a8839396f965ab6ff72a70'). |
|
207 |
hashStream hashValue printOn:Transcript base:16. Transcript cr. |
|
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
208 |
[exEnd] |
13896 | 209 |
|
6864 | 210 |
timing throughput: |
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
211 |
[exBegin] |
6864 | 212 |
|hashStream n t| |
213 |
||
214 |
hashStream := MD5Stream new. |
|
215 |
n := 1000000. |
|
216 |
t := Time millisecondsToRun:[ |
|
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
217 |
n timesRepeat:[ |
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
218 |
hashStream nextPutAll:'12345678901234567890123456789012345678901234567890'. |
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
219 |
]. |
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
220 |
]. |
6864 | 221 |
t := (t / 1000) asFloat. |
222 |
Transcript show:t; show:' seconds for '; show:(50*n/1024) asFloat; showCR:' Kb'. |
|
223 |
Transcript show:(n*50/1024 / t); showCR:' Kb/s' |
|
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13932
diff
changeset
|
224 |
[exEnd] |
7041 | 225 |
" |
6864 | 226 |
! ! |
227 |
||
228 |
!MD5Stream class methodsFor:'initialization'! |
|
229 |
||
230 |
initialize |
|
231 |
|ctxSize| |
|
232 |
||
233 |
%{ |
|
8913 | 234 |
ctxSize = __mkSmallInteger(sizeof(MD5_CTX)); |
6864 | 235 |
%}. |
236 |
ContextSize := ctxSize. |
|
237 |
HashSize := 16. |
|
238 |
||
239 |
" |
|
240 |
self initialize |
|
241 |
" |
|
242 |
||
243 |
||
244 |
||
245 |
! ! |
|
246 |
||
247 |
!MD5Stream class methodsFor:'queries'! |
|
248 |
||
15624
11ce1e9cf098
Rename #blockSize to #hashBlockSize
Stefan Vogel <sv@exept.de>
parents:
14787
diff
changeset
|
249 |
hashBlockSize |
6864 | 250 |
"return the block size used internally by the compression function" |
15624
11ce1e9cf098
Rename #blockSize to #hashBlockSize
Stefan Vogel <sv@exept.de>
parents:
14787
diff
changeset
|
251 |
|
6864 | 252 |
^ 64 |
253 |
||
254 |
"Created: / 18.3.1999 / 08:36:44 / stefan" |
|
255 |
! |
|
256 |
||
257 |
hashSize |
|
258 |
"return the size of the hashvalue returned by instances of this class" |
|
259 |
||
260 |
^ HashSize |
|
261 |
||
262 |
"Created: / 18.3.1999 / 08:02:16 / stefan" |
|
263 |
! ! |
|
264 |
||
265 |
!MD5Stream methodsFor:'initialization'! |
|
266 |
||
267 |
initialize |
|
268 |
||
269 |
hashContext := ByteArray new:ContextSize. |
|
270 |
self reset. |
|
271 |
||
272 |
"Modified: / 18.3.1999 / 08:03:42 / stefan" |
|
273 |
! ! |
|
274 |
||
275 |
!MD5Stream methodsFor:'positioning'! |
|
276 |
||
277 |
reset |
|
278 |
"reset the stream in order to compute a new hash value" |
|
279 |
||
280 |
%{ |
|
14723 | 281 |
if (__isByteArray(__INST(hashContext)) && |
6864 | 282 |
__byteArraySize(__INST(hashContext)) == sizeof(MD5_CTX) |
283 |
) { |
|
14723 | 284 |
MD5_CTX *ctx = (MD5_CTX *)__ByteArrayInstPtr(__INST(hashContext))->ba_element; |
6864 | 285 |
|
286 |
MD5Init(ctx); |
|
287 |
RETURN(self); |
|
288 |
} |
|
289 |
%}. |
|
290 |
^ self primitiveFailed |
|
291 |
||
292 |
||
293 |
||
294 |
! ! |
|
295 |
||
296 |
!MD5Stream methodsFor:'queries'! |
|
297 |
||
298 |
hashValue |
|
299 |
"Get the value hashed so far. |
|
300 |
The context is kept, so that more objects may be hashed after |
|
301 |
retrieving a hash value" |
|
302 |
||
303 |
||
304 |
|digest| |
|
305 |
||
306 |
digest := ByteArray new:HashSize. |
|
307 |
||
308 |
%{ |
|
14723 | 309 |
if (__isByteArray(__INST(hashContext)) && |
6864 | 310 |
__byteArraySize(__INST(hashContext)) == sizeof(MD5_CTX) && |
14723 | 311 |
__isByteArray(digest) && |
6864 | 312 |
__byteArraySize(digest) == 16 |
313 |
) { |
|
14723 | 314 |
MD5_CTX *ctx = (MD5_CTX *)__ByteArrayInstPtr(__INST(hashContext))->ba_element; |
6864 | 315 |
MD5_CTX copyContext; |
316 |
||
317 |
memcpy(©Context, ctx, sizeof(copyContext)); |
|
318 |
MD5Final(__ByteArrayInstPtr(digest)->ba_element, ©Context); |
|
319 |
RETURN(digest); |
|
320 |
} |
|
321 |
%}. |
|
322 |
||
12265 | 323 |
^ self primitiveFailed |
6864 | 324 |
! ! |
325 |
||
326 |
!MD5Stream methodsFor:'writing'! |
|
327 |
||
7042 | 328 |
nextPutBytes:count from:anObject startingAt:start |
329 |
"update the hash value with count bytes from an object starting at index start. |
|
12265 | 330 |
The object must have non-pointer indexed instvars |
7042 | 331 |
(i.e. be a ByteArray, String, Float- or DoubleArray), |
332 |
or an externalBytes object (with known size)" |
|
333 |
||
334 |
%{ |
|
14723 | 335 |
INT len, offs; |
336 |
INT objSize; |
|
15988 | 337 |
int nInstBytes; |
7042 | 338 |
char *extPtr; |
23955 | 339 |
OBJ _hashContext = __INST(hashContext); |
7042 | 340 |
|
23955 | 341 |
// convert first, check later |
342 |
len = __intVal(count); |
|
343 |
offs = __intVal(start) - 1; |
|
344 |
||
345 |
if (__isByteArray(_hashContext) |
|
346 |
&& __byteArraySize(_hashContext) == sizeof(MD5_CTX) |
|
7042 | 347 |
&& __bothSmallInteger(count, start) |
7197
a68adb223592
also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents:
7042
diff
changeset
|
348 |
) { |
23955 | 349 |
MD5_CTX *ctx = (MD5_CTX *)__byteArrayVal(_hashContext); |
7042 | 350 |
|
23955 | 351 |
if (__isByteArrayLike(anObject)) { |
352 |
extPtr = (char *)__byteArrayVal(anObject); |
|
353 |
objSize = __byteArraySize(anObject); |
|
354 |
} else if (__isStringLike(anObject)) { |
|
355 |
extPtr = (char *)__stringVal(anObject); |
|
356 |
objSize = __stringSize(anObject); |
|
357 |
} else if (__isExternalBytesLike(anObject)) { |
|
15988 | 358 |
OBJ sz; |
7042 | 359 |
|
15988 | 360 |
nInstBytes = 0; |
361 |
extPtr = (char *)__externalBytesAddress(anObject); |
|
362 |
if (extPtr == (char *)0) goto bad; |
|
363 |
sz = __externalBytesSize(anObject); |
|
364 |
if (__isSmallInteger(sz)) { |
|
365 |
objSize = __intVal(sz); |
|
366 |
} else { |
|
367 |
objSize = 0; /* unknown */ |
|
368 |
} |
|
369 |
} else { |
|
370 |
OBJ oClass = __Class(anObject); |
|
371 |
int nInstVars = __intVal(__ClassInstPtr(oClass)->c_ninstvars); |
|
7197
a68adb223592
also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents:
7042
diff
changeset
|
372 |
|
16003 | 373 |
nInstBytes = OHDR_SIZE + __OBJS2BYTES__(nInstVars); |
15988 | 374 |
switch (__intVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) { |
375 |
case BYTEARRAY: |
|
376 |
case WORDARRAY: |
|
377 |
case LONGARRAY: |
|
378 |
case SWORDARRAY: |
|
379 |
case SLONGARRAY: |
|
380 |
case FLOATARRAY: |
|
15992 | 381 |
break; |
15988 | 382 |
case DOUBLEARRAY: |
383 |
#ifdef __NEED_DOUBLE_ALIGN |
|
384 |
nInstBytes = (nInstBytes-1+__DOUBLE_ALIGN) &~ (__DOUBLE_ALIGN-1); |
|
385 |
#endif |
|
386 |
break; |
|
387 |
case LONGLONGARRAY: |
|
388 |
case SLONGLONGARRAY: |
|
389 |
#ifdef __NEED_LONGLONG_ALIGN |
|
390 |
nInstBytes = (nInstBytes-1+__LONGLONG_ALIGN) &~ (__LONGLONG_ALIGN-1); |
|
391 |
#endif |
|
15992 | 392 |
break; |
15988 | 393 |
default: |
394 |
goto bad; |
|
395 |
} |
|
396 |
// nInstBytes is the number of bytes occupied by pointer instance variables |
|
397 |
// subtract from size and add to byte-pointer |
|
16003 | 398 |
objSize = __Size(anObject) - nInstBytes; |
16008 | 399 |
extPtr = (char *)anObject + nInstBytes; |
15988 | 400 |
} |
401 |
if ((offs >= 0) && (len >= 0) && (objSize >= (len + offs))) { |
|
402 |
MD5Update(ctx, extPtr+offs, len); |
|
403 |
RETURN (count); |
|
404 |
} |
|
7042 | 405 |
} |
406 |
bad: ; |
|
407 |
%}. |
|
408 |
||
409 |
^ self primitiveFailed |
|
23955 | 410 |
|
411 |
"Modified: / 23-03-2019 / 15:16:34 / Claus Gittinger" |
|
6864 | 412 |
! ! |
413 |
||
414 |
!MD5Stream class methodsFor:'documentation'! |
|
415 |
||
416 |
version |
|
19608 | 417 |
^ '$Header$' |
12204 | 418 |
! |
419 |
||
420 |
version_CVS |
|
19608 | 421 |
^ '$Header$' |
6864 | 422 |
! ! |
423 |
||
14716 | 424 |
|
6864 | 425 |
MD5Stream initialize! |