author | Claus Gittinger <cg@exept.de> |
Fri, 22 Mar 2019 13:48:12 +0100 | |
changeset 23952 | 59e081dd12dc |
parent 23937 | 76632065b720 |
child 23953 | 43aef89d0166 |
permissions | -rw-r--r-- |
22563 | 1 |
"{ Encoding: utf8 }" |
2 |
||
4426 | 3 |
" |
15038 | 4 |
COPYRIGHT (c) 1999-2013 by eXept Software AG |
15907
b6a05f7d463f
use int32 instead of long (for 64bit machines)
Claus Gittinger <cg@exept.de>
parents:
15623
diff
changeset
|
5 |
All Rights Reserved |
4426 | 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 |
" |
|
9369
b7f43a51c4ed
Moved SHA1Stream from exept:libcrypt to stx:libbasic
Stefan Vogel <sv@exept.de>
parents:
7824
diff
changeset
|
14 |
"{ Package: 'stx:libbasic' }" |
4051 | 15 |
|
19160 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
4051 | 18 |
HashStream subclass:#SHA1Stream |
19 |
instanceVariableNames:'hashContext' |
|
20 |
classVariableNames:'HashSize ContextSize' |
|
21 |
poolDictionaries:'' |
|
12420 | 22 |
category:'System-Crypt-Hashing' |
4051 | 23 |
! |
24 |
||
25 |
!SHA1Stream primitiveDefinitions! |
|
26 |
%{ |
|
27 |
||
28 |
#if defined(__LSBFIRST) |
|
7824 | 29 |
# ifndef LITTLE_ENDIAN |
30 |
# define LITTLE_ENDIAN /* This should be #define'd if true. */ |
|
31 |
# endif |
|
4051 | 32 |
#endif |
33 |
||
5056 | 34 |
#define SHA1HANDSOFF /* Copies data before messing with it. */ |
4051 | 35 |
|
22491 | 36 |
#ifndef _STDIO_H_INCLUDED_ |
37 |
# include <stdio.h> |
|
38 |
# define _STDIO_H_INCLUDED_ |
|
39 |
#endif |
|
40 |
||
41 |
#ifndef _STRING_H_INCLUDED_ |
|
42 |
# include <string.h> |
|
43 |
# define _STRING_H_INCLUDED_ |
|
44 |
#endif |
|
4051 | 45 |
|
46 |
typedef struct { |
|
15025
552103f2ae6e
64bit (mac) fix: long is not an int32 here
Claus Gittinger <cg@exept.de>
parents:
14791
diff
changeset
|
47 |
unsigned int32 state[5]; |
552103f2ae6e
64bit (mac) fix: long is not an int32 here
Claus Gittinger <cg@exept.de>
parents:
14791
diff
changeset
|
48 |
unsigned int32 count[2]; |
4051 | 49 |
unsigned char buffer[64]; |
50 |
} SHA1_CTX; |
|
51 |
||
23952 | 52 |
#if defined(__GNUC__) || defined(__CLANG__) |
53 |
# define STATIC_INLINE static inline |
|
54 |
#endif |
|
55 |
||
7824 | 56 |
#if USE_ANSI_C |
23952 | 57 |
|
15907
b6a05f7d463f
use int32 instead of long (for 64bit machines)
Claus Gittinger <cg@exept.de>
parents:
15623
diff
changeset
|
58 |
void SHA1Transform(unsigned int32 /* long */ state[5], unsigned char buffer[64]); |
23952 | 59 |
STATIC_INLINE void SHA1Init(SHA1_CTX* context); |
7824 | 60 |
void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int len); |
61 |
void SHA1Final(unsigned char digest[20], SHA1_CTX* context); |
|
23952 | 62 |
|
7824 | 63 |
#else /* general: compiles everywhere */ |
23952 | 64 |
|
7824 | 65 |
# define SHA1Init __SHA1Init |
66 |
# define SHA1Update __SHA1Update |
|
67 |
# define SHA1Final __SHA2Final |
|
4051 | 68 |
|
23952 | 69 |
STATIC_INLINE void SHA1Init(); |
7824 | 70 |
void SHA1Update(); |
71 |
void SHA1Final(); |
|
23952 | 72 |
|
7824 | 73 |
#endif /* USE_ANSI_C */ |
23952 | 74 |
|
4051 | 75 |
%} |
76 |
! ! |
|
77 |
||
78 |
!SHA1Stream primitiveFunctions! |
|
23952 | 79 |
void SHA1Init(); |
80 |
void SHA1Update(); |
|
81 |
void SHA1Final(); |
|
4051 | 82 |
|
23952 | 83 |
#endif /* USE_ANSI_C */ |
4051 | 84 |
|
85 |
%} |
|
86 |
! ! |
|
87 |
||
88 |
!SHA1Stream class methodsFor:'documentation'! |
|
89 |
||
4426 | 90 |
copyright |
91 |
" |
|
15038 | 92 |
COPYRIGHT (c) 1999-2013 by eXept Software AG |
15907
b6a05f7d463f
use int32 instead of long (for 64bit machines)
Claus Gittinger <cg@exept.de>
parents:
15623
diff
changeset
|
93 |
All Rights Reserved |
4426 | 94 |
|
95 |
This software is furnished under a license and may be used |
|
96 |
only in accordance with the terms of that license and with the |
|
97 |
inclusion of the above copyright notice. This software may not |
|
98 |
be provided or otherwise made available to, or used by, any |
|
99 |
other person. No title to or ownership of the software is |
|
100 |
hereby transferred. |
|
101 |
" |
|
102 |
! |
|
103 |
||
4051 | 104 |
documentation |
105 |
" |
|
106 |
Generate a SHA-1 hash value as defined in |
|
107 |
NIST, FIPS PUB 180-1: Secure Hash Standard, April 1995. |
|
13933 | 108 |
|
13935 | 109 |
Notice (2005): |
21152 | 110 |
Be aware that SHA-1 is considered broken and may not be appropriate in some applications. |
111 |
Especially it should no longer be used for security stuff. |
|
4051 | 112 |
|
12265 | 113 |
performance: roughly |
23952 | 114 |
200 Mb/s on a 2012 MAC Powerbook (2.6Ghz I7) |
115 |
150 Mb/s on a 2007 MAC Powerbook (2.6Ghz Duo) |
|
23937 | 116 |
120 Mb/s on a 2.5Ghz 64X2 Athlon 4800+ (64bit) |
21152 | 117 |
47400 Kb/s on a 2Ghz Duo (old measure) |
118 |
9580 Kb/s on a 400Mhz PIII |
|
119 |
3970 Kb/s on a 300Mhz Sparc |
|
4916
df965a3448b9
added throughput test example
Claus Gittinger <cg@exept.de>
parents:
4798
diff
changeset
|
120 |
|
4051 | 121 |
[author:] |
21152 | 122 |
Stefan Vogel |
4051 | 123 |
|
124 |
[see also:] |
|
21152 | 125 |
MD5Stream |
126 |
SHA256Stream SHA512Stream (in libcrypt) |
|
4051 | 127 |
|
128 |
[class variables:] |
|
21152 | 129 |
HashSize size of returned hash value |
130 |
ContextSize (implementation) size of hash context |
|
4051 | 131 |
|
132 |
[instance variables:] |
|
21152 | 133 |
hashContext (implementation) |
134 |
internal buffer for computation of the hash value |
|
4051 | 135 |
" |
136 |
! |
|
137 |
||
138 |
examples |
|
139 |
" |
|
10781 | 140 |
Test Vectors (from FIPS PUB 180-1); results are: |
7824 | 141 |
|
19160 | 142 |
[exBegin] |
4051 | 143 |
|hashStream| |
144 |
||
4798 | 145 |
hashStream := SHA1Stream new. |
4051 | 146 |
hashStream nextPut:'abc'. |
147 |
hashStream hashValue printOn:Transcript base:16. Transcript cr. |
|
148 |
hashStream nextPut:'dbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'. |
|
149 |
hashStream hashValue printOn:Transcript base:16. Transcript cr. |
|
19160 | 150 |
[exEnd] |
151 |
||
152 |
[exBegin] |
|
153 |
|hashValue| |
|
7042 | 154 |
|
19160 | 155 |
hashValue := SHA1Stream hashValueOf:'hello world'. |
156 |
self assert:(hashValue hexPrintString = '2AAE6C35C94FCFB415DBE95F408B9CE91EE846ED') |
|
157 |
[exEnd] |
|
158 |
||
159 |
[exBegin] |
|
7042 | 160 |
|hashValue| |
4051 | 161 |
|
15038 | 162 |
hashValue := SHA1Stream hashValueOf:'abc'. |
7042 | 163 |
hashValue printOn:Transcript base:16. Transcript cr. |
19160 | 164 |
[exEnd] |
7042 | 165 |
|
19160 | 166 |
[exBegin] |
4051 | 167 |
|hashStream| |
168 |
||
4798 | 169 |
hashStream := SHA1Stream new. |
4051 | 170 |
hashStream nextPut:'abc' asByteArray. |
171 |
hashStream hashValue printOn:Transcript base:16. Transcript cr. |
|
172 |
hashStream nextPut:'dbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq' asByteArray. |
|
173 |
hashStream hashValue printOn:Transcript base:16. Transcript cr. |
|
174 |
||
19160 | 175 |
[exEnd] |
4051 | 176 |
|
19160 | 177 |
[exBegin] |
4051 | 178 |
|hashStream| |
179 |
||
4798 | 180 |
hashStream := SHA1Stream new. |
4051 | 181 |
1000000 timesRepeat:[ hashStream nextPut:$a ]. |
182 |
hashStream hashValue printOn:Transcript base:16. Transcript cr. |
|
19160 | 183 |
[exEnd] |
4051 | 184 |
|
19160 | 185 |
[exBegin] |
4051 | 186 |
|hashStream| |
187 |
||
4798 | 188 |
hashStream := SHA1Stream new. |
4051 | 189 |
hashStream nextPut:'a'. |
190 |
hashStream hashValue printOn:Transcript base:16. Transcript cr. |
|
19160 | 191 |
[exEnd] |
4051 | 192 |
|
19160 | 193 |
[exBegin] |
4051 | 194 |
|hashStream| |
195 |
||
4798 | 196 |
hashStream := SHA1Stream new. |
4051 | 197 |
hashStream nextPut:$a. |
198 |
hashStream hashValue printOn:Transcript base:16. Transcript cr. |
|
19160 | 199 |
[exEnd] |
4916
df965a3448b9
added throughput test example
Claus Gittinger <cg@exept.de>
parents:
4798
diff
changeset
|
200 |
|
df965a3448b9
added throughput test example
Claus Gittinger <cg@exept.de>
parents:
4798
diff
changeset
|
201 |
timing throughput: |
19160 | 202 |
[exBegin] |
4916
df965a3448b9
added throughput test example
Claus Gittinger <cg@exept.de>
parents:
4798
diff
changeset
|
203 |
|hashStream n t| |
df965a3448b9
added throughput test example
Claus Gittinger <cg@exept.de>
parents:
4798
diff
changeset
|
204 |
|
df965a3448b9
added throughput test example
Claus Gittinger <cg@exept.de>
parents:
4798
diff
changeset
|
205 |
hashStream := SHA1Stream new. |
df965a3448b9
added throughput test example
Claus Gittinger <cg@exept.de>
parents:
4798
diff
changeset
|
206 |
n := 1000000. |
df965a3448b9
added throughput test example
Claus Gittinger <cg@exept.de>
parents:
4798
diff
changeset
|
207 |
t := Time millisecondsToRun:[ |
19160 | 208 |
n timesRepeat:[ |
209 |
hashStream nextPutAll:'12345678901234567890123456789012345678901234567890'. |
|
210 |
]. |
|
211 |
]. |
|
4916
df965a3448b9
added throughput test example
Claus Gittinger <cg@exept.de>
parents:
4798
diff
changeset
|
212 |
t := (t / 1000) asFloat. |
df965a3448b9
added throughput test example
Claus Gittinger <cg@exept.de>
parents:
4798
diff
changeset
|
213 |
Transcript show:t; show:' seconds for '; show:(50*n/1024) asFloat; showCR:' Kb'. |
df965a3448b9
added throughput test example
Claus Gittinger <cg@exept.de>
parents:
4798
diff
changeset
|
214 |
Transcript show:(n*50/1024 / t); showCR:' Kb/s' |
19160 | 215 |
[exEnd] |
4051 | 216 |
" |
19143 | 217 |
! |
218 |
||
219 |
performance |
|
220 |
" |
|
23952 | 221 |
CPU cc algo mb/sec |
19143 | 222 |
|
23952 | 223 |
MAC (2010 macbook; 2.7Ghz Duo) clang -O2 slow 128.5 |
224 |
132 |
|
225 |
MAC (2012 macbook; 2.6Ghz I7) clang -O2 203.5 |
|
226 |
||
19143 | 227 |
|
228 |
||
229 |
||
230 |
timing throughput: |
|
23952 | 231 |
[exBegin] |
19143 | 232 |
|hashStream n t| |
233 |
||
234 |
hashStream := SHA1Stream new. |
|
235 |
n := 1000000. |
|
236 |
t := Time millisecondsToRun:[ |
|
23952 | 237 |
n timesRepeat:[ |
238 |
hashStream nextPutAll:'12345678901234567890123456789012345678901234567890'. |
|
239 |
]. |
|
240 |
]. |
|
19143 | 241 |
t := (t / 1000) asFloat. |
242 |
Transcript show:t; show:' seconds for '; show:(50*n/1024) asFloat; showCR:' Kb'. |
|
243 |
Transcript show:(n*50/1024 / t); showCR:' Kb/s' |
|
23952 | 244 |
[exEnd] |
19143 | 245 |
" |
4051 | 246 |
! ! |
247 |
||
248 |
!SHA1Stream class methodsFor:'initialization'! |
|
249 |
||
250 |
initialize |
|
251 |
|ctxSize| |
|
252 |
||
253 |
%{ |
|
254 |
ctxSize = __MKSMALLINT(sizeof(SHA1_CTX)); |
|
255 |
%}. |
|
256 |
ContextSize := ctxSize. |
|
257 |
HashSize := 20. |
|
258 |
||
259 |
" |
|
5056 | 260 |
self initialize |
4051 | 261 |
" |
262 |
! ! |
|
263 |
||
264 |
!SHA1Stream class methodsFor:'queries'! |
|
265 |
||
15623
1c229b466d52
Rename #blockSize to #hashBlockSize
Stefan Vogel <sv@exept.de>
parents:
15038
diff
changeset
|
266 |
hashBlockSize |
4051 | 267 |
"return the block size used internally by the compression function" |
15907
b6a05f7d463f
use int32 instead of long (for 64bit machines)
Claus Gittinger <cg@exept.de>
parents:
15623
diff
changeset
|
268 |
|
4051 | 269 |
^ 64 |
270 |
||
271 |
"Created: / 18.3.1999 / 08:37:10 / stefan" |
|
272 |
! |
|
273 |
||
274 |
hashSize |
|
275 |
"return the size of the hashvalue returned by instances of this class" |
|
276 |
||
277 |
^ HashSize |
|
278 |
||
279 |
"Modified: / 18.3.1999 / 07:54:22 / stefan" |
|
280 |
! ! |
|
281 |
||
282 |
!SHA1Stream methodsFor:'initialization'! |
|
283 |
||
284 |
initialize |
|
285 |
||
286 |
hashContext := ByteArray new:ContextSize. |
|
287 |
self reset |
|
288 |
||
289 |
"Created: / 17.3.1999 / 16:11:37 / stefan" |
|
290 |
"Modified: / 18.3.1999 / 07:56:46 / stefan" |
|
291 |
! ! |
|
292 |
||
293 |
!SHA1Stream methodsFor:'positioning'! |
|
294 |
||
295 |
reset |
|
296 |
"reset the stream in order to compute a new hash value" |
|
297 |
||
298 |
%{ |
|
14669 | 299 |
if (__isByteArray(__INST(hashContext)) && |
4051 | 300 |
__byteArraySize(__INST(hashContext)) == sizeof(SHA1_CTX) |
301 |
) { |
|
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13935
diff
changeset
|
302 |
SHA1_CTX *ctx = (SHA1_CTX *)__ByteArrayInstPtr(__INST(hashContext))->ba_element; |
4051 | 303 |
|
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13935
diff
changeset
|
304 |
SHA1Init(ctx); |
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13935
diff
changeset
|
305 |
RETURN(self); |
4051 | 306 |
} |
307 |
%}. |
|
308 |
^ self primitiveFailed |
|
309 |
||
13930 | 310 |
"Created: / 18-03-1999 / 07:59:02 / stefan" |
311 |
"Modified: / 12-01-2012 / 12:21:23 / cg" |
|
22563 | 312 |
! |
313 |
||
314 |
seedWith:fiveWordVector |
|
315 |
"seed the stream with 5*16 (for testing)" |
|
316 |
||
317 |
|seedA seedB seedC seedD seedE| |
|
318 |
||
319 |
seedA := fiveWordVector at:1. |
|
320 |
seedB := fiveWordVector at:1. |
|
321 |
seedC := fiveWordVector at:1. |
|
322 |
seedD := fiveWordVector at:1. |
|
323 |
seedE := fiveWordVector at:1. |
|
324 |
self reset. |
|
325 |
%{ |
|
326 |
if (__isByteArray(__INST(hashContext)) |
|
327 |
&& (__byteArraySize(__INST(hashContext)) == sizeof(SHA1_CTX)) |
|
328 |
&& __isSmallInteger(seedA) |
|
329 |
&& __isSmallInteger(seedB) |
|
330 |
&& __isSmallInteger(seedC) |
|
331 |
&& __isSmallInteger(seedD) |
|
332 |
&& __isSmallInteger(seedE) |
|
333 |
) { |
|
334 |
SHA1_CTX *ctx = (SHA1_CTX *)__ByteArrayInstPtr(__INST(hashContext))->ba_element; |
|
335 |
||
336 |
ctx->state[0] = __intVal(seedA); |
|
337 |
ctx->state[1] = __intVal(seedB); |
|
338 |
ctx->state[2] = __intVal(seedC); |
|
339 |
ctx->state[3] = __intVal(seedD); |
|
340 |
ctx->state[4] = __intVal(seedE); |
|
341 |
RETURN(self); |
|
342 |
} |
|
343 |
%}. |
|
344 |
^ self primitiveFailed |
|
4051 | 345 |
! ! |
346 |
||
347 |
!SHA1Stream methodsFor:'queries'! |
|
348 |
||
349 |
hashValue |
|
350 |
"Get the value hashed so far. |
|
351 |
The context is kept, so that more objects may be hashed after |
|
352 |
retrieving a hash value" |
|
353 |
||
354 |
||
355 |
|digest| |
|
356 |
||
357 |
digest := ByteArray new:HashSize. |
|
358 |
||
359 |
%{ |
|
14791 | 360 |
OBJ hcon; |
361 |
||
362 |
hcon = __INST(hashContext); |
|
363 |
if (__isByteArray(hcon) && |
|
364 |
__byteArraySize(hcon) == sizeof(SHA1_CTX) && |
|
14669 | 365 |
__isByteArray(digest) && |
5056 | 366 |
__byteArraySize(digest) == 20 |
4051 | 367 |
) { |
14791 | 368 |
SHA1_CTX *ctx = (SHA1_CTX *)(__ByteArrayInstPtr(hcon)->ba_element); |
5056 | 369 |
SHA1_CTX copyContext; |
14723 | 370 |
|
14791 | 371 |
memcpy(©Context, ctx, sizeof(SHA1_CTX)); |
5056 | 372 |
SHA1Final(__ByteArrayInstPtr(digest)->ba_element, ©Context); |
373 |
RETURN(digest); |
|
4051 | 374 |
} |
375 |
%}. |
|
376 |
||
377 |
^ self primitiveFailed |
|
378 |
||
379 |
"Created: / 17.3.1999 / 16:13:12 / stefan" |
|
380 |
"Modified: / 18.3.1999 / 08:00:54 / stefan" |
|
381 |
! ! |
|
382 |
||
383 |
!SHA1Stream methodsFor:'writing'! |
|
384 |
||
19400 | 385 |
nextPutByte:anInteger |
386 |
"update the hash value with anInteger <= 255." |
|
387 |
||
388 |
%{ |
|
389 |
if (__isSmallInteger(anInteger) && __intVal(anInteger) <= 255 |
|
390 |
&& __isByteArray(__INST(hashContext)) |
|
391 |
&& __byteArraySize(__INST(hashContext)) == sizeof(SHA1_CTX) |
|
392 |
) { |
|
393 |
SHA1_CTX *ctx = (SHA1_CTX *)__ByteArrayInstPtr(__INST(hashContext))->ba_element; |
|
394 |
unsigned char value = __intVal(anInteger); |
|
395 |
||
396 |
SHA1Update(ctx, &value, 1); |
|
397 |
RETURN(self); |
|
398 |
} |
|
399 |
bad: ; |
|
400 |
%}. |
|
401 |
||
402 |
^ self primitiveFailed |
|
403 |
! |
|
404 |
||
7042 | 405 |
nextPutBytes:count from:anObject startingAt:start |
406 |
"update the hash value with count bytes from an object starting at index start. |
|
9369
b7f43a51c4ed
Moved SHA1Stream from exept:libcrypt to stx:libbasic
Stefan Vogel <sv@exept.de>
parents:
7824
diff
changeset
|
407 |
The object must have non-pointer indexed instvars |
7042 | 408 |
(i.e. be a ByteArray, String, Float- or DoubleArray), |
409 |
or an externalBytes object (with known size)" |
|
410 |
||
411 |
%{ |
|
14667
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13935
diff
changeset
|
412 |
INT len, offs; |
f6a830b971f3
care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents:
13935
diff
changeset
|
413 |
INT objSize; |
15989 | 414 |
int nInstBytes; |
7042 | 415 |
char *extPtr; |
416 |
||
14669 | 417 |
if (__isByteArray(__INST(hashContext)) |
7042 | 418 |
&& __byteArraySize(__INST(hashContext)) == sizeof(SHA1_CTX) |
419 |
&& __bothSmallInteger(count, start) |
|
420 |
) { |
|
19143 | 421 |
SHA1_CTX *ctx = (SHA1_CTX *)__ByteArrayInstPtr(__INST(hashContext))->ba_element; |
7042 | 422 |
|
19143 | 423 |
len = __intVal(count); |
424 |
offs = __intVal(start) - 1; |
|
7042 | 425 |
|
19143 | 426 |
if (__isExternalBytesLike(anObject)) { |
427 |
OBJ sz; |
|
7042 | 428 |
|
19143 | 429 |
nInstBytes = 0; |
430 |
extPtr = (char *)__externalBytesAddress(anObject); |
|
431 |
if (extPtr == NULL) goto bad; |
|
432 |
sz = __externalBytesSize(anObject); |
|
433 |
if (__isSmallInteger(sz)) { |
|
434 |
objSize = __intVal(sz); |
|
435 |
} else { |
|
436 |
objSize = 0; /* unknown */ |
|
437 |
} |
|
438 |
} else { |
|
439 |
OBJ oClass = __Class(anObject); |
|
440 |
int nInstVars = __intVal(__ClassInstPtr(oClass)->c_ninstvars); |
|
14723 | 441 |
|
19143 | 442 |
nInstBytes = OHDR_SIZE + __OBJS2BYTES__(nInstVars); |
443 |
switch (__intVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) { |
|
444 |
case BYTEARRAY: |
|
445 |
case WORDARRAY: |
|
446 |
case LONGARRAY: |
|
447 |
case SWORDARRAY: |
|
448 |
case SLONGARRAY: |
|
449 |
case FLOATARRAY: |
|
450 |
break; |
|
451 |
case DOUBLEARRAY: |
|
15989 | 452 |
#ifdef __NEED_DOUBLE_ALIGN |
19143 | 453 |
nInstBytes = (nInstBytes-1+__DOUBLE_ALIGN) &~ (__DOUBLE_ALIGN-1); |
15989 | 454 |
#endif |
19143 | 455 |
break; |
456 |
case LONGLONGARRAY: |
|
457 |
case SLONGLONGARRAY: |
|
15989 | 458 |
#ifdef __NEED_LONGLONG_ALIGN |
19143 | 459 |
nInstBytes = (nInstBytes-1+__LONGLONG_ALIGN) &~ (__LONGLONG_ALIGN-1); |
15989 | 460 |
#endif |
19143 | 461 |
break; |
462 |
default: |
|
463 |
goto bad; |
|
464 |
} |
|
465 |
// nInstBytes is the number of bytes occupied by pointer instance variables |
|
466 |
// subtract from size and add to byte-pointer |
|
467 |
objSize = __Size(anObject) - nInstBytes; |
|
468 |
extPtr = (char *)anObject + nInstBytes; |
|
469 |
} |
|
470 |
if ((offs >= 0) && (len >= 0) && (objSize >= (len + offs))) { |
|
471 |
SHA1Update(ctx, extPtr+offs, (unsigned int)len); |
|
472 |
RETURN (count); |
|
473 |
} |
|
7042 | 474 |
} |
475 |
bad: ; |
|
476 |
%}. |
|
477 |
||
478 |
^ self primitiveFailed |
|
4051 | 479 |
! ! |
480 |
||
481 |
!SHA1Stream class methodsFor:'documentation'! |
|
482 |
||
483 |
version |
|
19143 | 484 |
^ '$Header$' |
12205 | 485 |
! |
486 |
||
487 |
version_CVS |
|
19143 | 488 |
^ '$Header$' |
4051 | 489 |
! ! |
7042 | 490 |
|
14715 | 491 |
|
4051 | 492 |
SHA1Stream initialize! |