home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / unix / volume27 / fngrprnt / part01 < prev    next >
Encoding:
Text File  |  1993-11-01  |  74.3 KB  |  2,886 lines

  1. Newsgroups: comp.sources.unix
  2. From: djb@silverton.berkeley.edu (D. J. Bernstein)
  3. Subject: v27i079: fingerprint-0.60 - a universal hash/checksum package, Part01/02
  4. Message-id: <1.752229646.7906@gw.home.vix.com>
  5. Sender: unix-sources-moderator@gw.home.vix.com
  6. Approved: vixie@gw.home.vix.com
  7.  
  8. Submitted-By: djb@silverton.berkeley.edu (D. J. Bernstein)
  9. Posting-Number: Volume 27, Issue 79
  10. Archive-Name: fingerprint/part01
  11.  
  12.     fingerprint 0.60: the universal hash/checksum package
  13.     931101
  14.     Daniel J. Bernstein, djb@silverton.berkeley.edu
  15.  
  16.     Do you want a powerful, uniform interface to MD5, a standard CRC-32,
  17.     Snefru-8, and a combined universal fingerprint, in highly efficient
  18.     library form or as easy-to-use programs? That's what this package
  19.     provides. The code is freely reusable so you can distribute it along
  20.     with your own applications. Have fun.
  21.  
  22. #! /bin/sh
  23. # This is a shell archive.  Remove anything before this line, then unpack
  24. # it by saving it into a file and typing "sh file".  To overwrite existing
  25. # files, type "sh file -c".  You can also feed this as standard input via
  26. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  27. # will see the following message at the end:
  28. #        "End of archive 1 (of 2)."
  29. # Contents:  BINARIES BLURB FILES FORMLETTER MANIFEST Makefile OBJECTS
  30. #   README TIMINGS cksum.1 cksum.c cksum.tests crc32file.3 crc32file.c
  31. #   crc32file.h fingerprint.1 fingerprint.c fingerprint.tests
  32. #   fprintfile.3 fprintfile.c fprintfile.h fprintfmt.c fptocksum.c
  33. #   fptomd5.c fptosnefru.c getopt.c getopt.h md5.1 md5.c md5.tests
  34. #   md5file.3 md5file.c md5file.h snefru.1 snefru.c snefru.tests
  35. #   snefru512.3 snefru512.h snefrufile.3 snefrufile.c snefrufile.h
  36. #   summain.1 summain.c
  37. # Wrapped by vixie@gw.home.vix.com on Tue Nov  2 00:39:49 1993
  38. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  39. if test -f 'BINARIES' -a "${1}" != "-c" ; then 
  40.   echo shar: Will not clobber existing file \"'BINARIES'\"
  41. else
  42. echo shar: Extracting \"'BINARIES'\" \(58 characters\)
  43. sed "s/^X//" >'BINARIES' <<'END_OF_FILE'
  44. Xcksum
  45. Xfingerprint
  46. Xfptocksum
  47. Xfptomd5
  48. Xfptosnefru
  49. Xmd5
  50. Xsnefru
  51. END_OF_FILE
  52. if test 58 -ne `wc -c <'BINARIES'`; then
  53.     echo shar: \"'BINARIES'\" unpacked with wrong size!
  54. fi
  55. # end of 'BINARIES'
  56. fi
  57. if test -f 'BLURB' -a "${1}" != "-c" ; then 
  58.   echo shar: Will not clobber existing file \"'BLURB'\"
  59. else
  60. echo shar: Extracting \"'BLURB'\" \(420 characters\)
  61. sed "s/^X//" >'BLURB' <<'END_OF_FILE'
  62. Xfingerprint 0.60: the universal hash/checksum package
  63. X931101
  64. XDaniel J. Bernstein, djb@silverton.berkeley.edu
  65. X
  66. XDo you want a powerful, uniform interface to MD5, a standard CRC-32,
  67. XSnefru-8, and a combined universal fingerprint, in highly efficient
  68. Xlibrary form or as easy-to-use programs? That's what this package
  69. Xprovides. The code is freely reusable so you can distribute it along
  70. Xwith your own applications. Have fun.
  71. END_OF_FILE
  72. if test 420 -ne `wc -c <'BLURB'`; then
  73.     echo shar: \"'BLURB'\" unpacked with wrong size!
  74. fi
  75. # end of 'BLURB'
  76. fi
  77. if test -f 'FILES' -a "${1}" != "-c" ; then 
  78.   echo shar: Will not clobber existing file \"'FILES'\"
  79. else
  80. echo shar: Extracting \"'FILES'\" \(456 characters\)
  81. sed "s/^X//" >'FILES' <<'END_OF_FILE'
  82. XBLURB
  83. XREADME
  84. XFORMLETTER
  85. XFILES
  86. XOBJECTS
  87. XBINARIES
  88. XMakefile
  89. Xfprintfile.3
  90. Xfprintfile.h
  91. Xfprintfile.c
  92. Xfprintfmt.c
  93. Xcrc32file.3
  94. Xcrc32file.h
  95. Xcrc32file.c
  96. Xmd5file.3
  97. Xmd5file.h
  98. Xmd5file.c
  99. Xsnefrufile.3
  100. Xsnefrufile.h
  101. Xsnefrufile.c
  102. Xsnefru512.3
  103. Xsnefru512.h
  104. Xsnefru512.c
  105. Xsnefru.1
  106. Xsnefru.c
  107. Xmd5.1
  108. Xmd5.c
  109. Xcksum.1
  110. Xcksum.c
  111. Xfptocksum.c
  112. Xfptomd5.c
  113. Xfptosnefru.c
  114. Xfingerprint.1
  115. Xfingerprint.c
  116. Xsummain.1
  117. Xsummain.c
  118. Xgetopt.h
  119. Xgetopt.c
  120. XTIMINGS
  121. Xfingerprint.tests
  122. Xmd5.tests
  123. Xsnefru.tests
  124. Xcksum.tests
  125. END_OF_FILE
  126. if test 456 -ne `wc -c <'FILES'`; then
  127.     echo shar: \"'FILES'\" unpacked with wrong size!
  128. fi
  129. # end of 'FILES'
  130. fi
  131. if test -f 'FORMLETTER' -a "${1}" != "-c" ; then 
  132.   echo shar: Will not clobber existing file \"'FORMLETTER'\"
  133. else
  134. echo shar: Extracting \"'FORMLETTER'\" \(817 characters\)
  135. sed "s/^X//" >'FORMLETTER' <<'END_OF_FILE'
  136. XTo: djb@silverton.berkeley.edu (Dan Bernstein)
  137. XFrom: 
  138. XDate: 
  139. XSubject: fingerprint 0.60 FORMLETTER
  140. X
  141. XPackage: fingerprint 0.60, gamma, 931101 release
  142. XObtained from (e.g., uunet.uu.net): 
  143. XObtained by (e.g., ftp): 
  144. X
  145. X1. Machine architecture (e.g., Sun 4/280): 
  146. X2. Operating system (e.g., SunOS 4.1): 
  147. X3. OS vendor (e.g., Sun): 
  148. X4. Does fingerprint work on your machine so far (yes/no)?
  149. X5. What's CC in your Makefile?
  150. X   CC=
  151. X
  152. X6. Describe any problems you've had with fingerprint.
  153. X
  154. X
  155. X
  156. X7. If you've timed the programs (make speedtest), how fast were they?
  157. X
  158. X
  159. X
  160. X8. Do you have any suggestions for a standard fingerprint library
  161. X   organization? Should all the library routines be in -lfprint?
  162. X   Or should they be split among -lfprint, -lmd5, -lsnefru, -lcrc?
  163. X
  164. X
  165. X
  166. X9. Any further questions, comments, or suggestions?
  167. X
  168. X
  169. X
  170. XYour name:
  171. END_OF_FILE
  172. if test 817 -ne `wc -c <'FORMLETTER'`; then
  173.     echo shar: \"'FORMLETTER'\" unpacked with wrong size!
  174. fi
  175. # end of 'FORMLETTER'
  176. fi
  177. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  178.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  179. else
  180. echo shar: Extracting \"'MANIFEST'\" \(1478 characters\)
  181. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  182. X   File Name        Archive #    Description
  183. X-----------------------------------------------------------
  184. X BINARIES                   1    
  185. X BLURB                      1    
  186. X FILES                      1    
  187. X FORMLETTER                 1    
  188. X MANIFEST                   1    This shipping list
  189. X Makefile                   1    
  190. X OBJECTS                    1    
  191. X README                     1    
  192. X TIMINGS                    1    
  193. X cksum.1                    1    
  194. X cksum.c                    1    
  195. X cksum.tests                1    
  196. X crc32file.3                1    
  197. X crc32file.c                1    
  198. X crc32file.h                1    
  199. X fingerprint.1              1    
  200. X fingerprint.c              1    
  201. X fingerprint.tests          1    
  202. X fprintfile.3               1    
  203. X fprintfile.c               1    
  204. X fprintfile.h               1    
  205. X fprintfmt.c                1    
  206. X fptocksum.c                1    
  207. X fptomd5.c                  1    
  208. X fptosnefru.c               1    
  209. X getopt.c                   1    
  210. X getopt.h                   1    
  211. X md5.1                      1    
  212. X md5.c                      1    
  213. X md5.tests                  1    
  214. X md5file.3                  1    
  215. X md5file.c                  1    
  216. X md5file.h                  1    
  217. X snefru.1                   1    
  218. X snefru.c                   1    
  219. X snefru.tests               1    
  220. X snefru512.3                1    
  221. X snefru512.c                2    
  222. X snefru512.h                1    
  223. X snefrufile.3               1    
  224. X snefrufile.c               1    
  225. X snefrufile.h               1    
  226. X summain.1                  1    
  227. X summain.c                  1    
  228. END_OF_FILE
  229. if test 1478 -ne `wc -c <'MANIFEST'`; then
  230.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  231. fi
  232. # end of 'MANIFEST'
  233. fi
  234. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  235.   echo shar: Will not clobber existing file \"'Makefile'\"
  236. else
  237. echo shar: Extracting \"'Makefile'\" \(3064 characters\)
  238. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  239. XCC=cc -O
  240. XTIME=time
  241. XCOMPRESS=compress
  242. X
  243. Xall: fingerprint fptocksum fptosnefru fptomd5 snefru md5 cksum
  244. X
  245. Xsnefru: snefru.o snefrufile.o snefru512.o summain.o getopt.o
  246. X    $(CC) -o snefru snefru.o snefrufile.o snefru512.o summain.o getopt.o
  247. X
  248. Xcksum: cksum.o crc32file.o summain.o getopt.o
  249. X    $(CC) -o cksum cksum.o crc32file.o summain.o getopt.o
  250. X
  251. Xmd5: md5.o md5file.o summain.o getopt.o
  252. X    $(CC) -o md5 md5.o md5file.o summain.o getopt.o
  253. X
  254. Xfptosnefru: fptosnefru.o fprintfmt.o
  255. X    $(CC) -o fptosnefru fptosnefru.o fprintfmt.o
  256. X
  257. Xfptomd5: fptomd5.o fprintfmt.o
  258. X    $(CC) -o fptomd5 fptomd5.o fprintfmt.o
  259. X
  260. Xfptocksum: fptocksum.o fprintfmt.o
  261. X    $(CC) -o fptocksum fptocksum.o fprintfmt.o
  262. X
  263. Xfingerprint: fingerprint.o crc32file.o md5file.o snefrufile.o \
  264. Xsnefru512.o fprintfile.o fprintfmt.o getopt.o summain.o
  265. X    $(CC) -o fingerprint fingerprint.o crc32file.o md5file.o \
  266. X    snefrufile.o snefru512.o fprintfile.o fprintfmt.o getopt.o summain.o
  267. X
  268. Xfptosnefru.o: fptosnefru.c
  269. X    $(CC) -c fptosnefru.c
  270. X
  271. Xfptomd5.o: fptomd5.c
  272. X    $(CC) -c fptomd5.c
  273. X
  274. Xfptocksum.o: fptocksum.c
  275. X    $(CC) -c fptocksum.c
  276. X
  277. Xcksum.o: cksum.c crc32file.h
  278. X    $(CC) -c cksum.c
  279. X
  280. Xmd5.o: md5.c md5file.h
  281. X    $(CC) -c md5.c
  282. X
  283. Xsnefru.o: snefru.c snefrufile.h
  284. X    $(CC) -c snefru.c
  285. X
  286. Xfprintfmt.o: fprintfmt.c fprintfile.h
  287. X    $(CC) -c fprintfmt.c
  288. X
  289. Xfprintfile.o: fprintfile.c fprintfile.h
  290. X    $(CC) -c fprintfile.c
  291. X
  292. Xcrc32file.o: crc32file.c crc32file.h
  293. X    $(CC) -c crc32file.c
  294. X
  295. Xmd5file.o: md5file.c md5file.h
  296. X    $(CC) -c md5file.c
  297. X
  298. Xsnefrufile.o: snefrufile.c snefrufile.h snefru512.h
  299. X    @echo You should get three warnings for snefrufile.c.
  300. X    @echo This is my reminder that the code there is not portable.
  301. X    $(CC) -c snefrufile.c
  302. X
  303. Xsnefru512.o: snefru512.c snefru512.h
  304. X    $(CC) -c snefru512.c
  305. X
  306. Xfingerprint.o: fingerprint.c crc32file.h md5file.h snefrufile.h \
  307. Xfprintfile.h getopt.h
  308. X    $(CC) -c fingerprint.c
  309. X
  310. Xsummain.o: summain.c getopt.h
  311. X    $(CC) -c summain.c
  312. X
  313. Xgetopt.o: getopt.c getopt.h
  314. X    $(CC) -c getopt.c
  315. X
  316. Xtest:
  317. X    @echo 'Trying canned tests... No output (other than seven ./commands) if successful.'
  318. X    ./fingerprint -c < fingerprint.tests
  319. X    ./snefru -c < snefru.tests
  320. X    ./md5 -c < md5.tests
  321. X    ./cksum -c < cksum.tests
  322. X    ./fptosnefru < fingerprint.tests | cmp - snefru.tests
  323. X    ./fptomd5 < fingerprint.tests | cmp - md5.tests
  324. X    ./fptocksum < fingerprint.tests | cmp - cksum.tests
  325. X
  326. Xshar:
  327. X    shar `cat FILES` > fingerprint.shar
  328. X    chmod 400 fingerprint.shar
  329. X
  330. Xclean: OBJECTS BINARIES
  331. X    rm -f `cat OBJECTS BINARIES`
  332. X
  333. Xspeedtest.1M:
  334. X    @echo 'Making a one-megabyte file for speed tests...'
  335. X    cat `cat FILES` > speedtest.tmp
  336. X    dd bs=8k count=8 < speedtest.tmp > speedtest.64k
  337. X    cat speedtest.64k speedtest.64k speedtest.64k speedtest.64k > speedtest.256k
  338. X    cat speedtest.256k speedtest.256k speedtest.256k speedtest.256k > speedtest.1M
  339. X    rm -f speedtest.tmp speedtest.64k speedtest.256k
  340. X
  341. Xspeedtest: speedtest.1M fingerprint snefru md5 cksum
  342. X    @echo 'Trying speed tests...'
  343. X    $(TIME) ./fingerprint < speedtest.1M > /dev/null
  344. X    $(TIME) ./snefru < speedtest.1M > /dev/null
  345. X    $(TIME) ./md5 < speedtest.1M > /dev/null
  346. X    $(TIME) ./cksum < speedtest.1M > /dev/null
  347. X    $(TIME) $(COMPRESS) < speedtest.1M > /dev/null
  348. END_OF_FILE
  349. if test 3064 -ne `wc -c <'Makefile'`; then
  350.     echo shar: \"'Makefile'\" unpacked with wrong size!
  351. fi
  352. # end of 'Makefile'
  353. fi
  354. if test -f 'OBJECTS' -a "${1}" != "-c" ; then 
  355.   echo shar: Will not clobber existing file \"'OBJECTS'\"
  356. else
  357. echo shar: Extracting \"'OBJECTS'\" \(176 characters\)
  358. sed "s/^X//" >'OBJECTS' <<'END_OF_FILE'
  359. Xcksum.o
  360. Xcrc32file.o
  361. Xfingerprint.o
  362. Xfprintfile.o
  363. Xfprintfmt.o
  364. Xfptocksum.o
  365. Xfptomd5.o
  366. Xfptosnefru.o
  367. Xgetopt.o
  368. Xmd5.o
  369. Xmd5file.o
  370. Xsnefru.o
  371. Xsnefru512.o
  372. Xsnefrufile.o
  373. Xsummain.o
  374. Xspeedtest.1M
  375. END_OF_FILE
  376. if test 176 -ne `wc -c <'OBJECTS'`; then
  377.     echo shar: \"'OBJECTS'\" unpacked with wrong size!
  378. fi
  379. # end of 'OBJECTS'
  380. fi
  381. if test -f 'README' -a "${1}" != "-c" ; then 
  382.   echo shar: Will not clobber existing file \"'README'\"
  383. else
  384. echo shar: Extracting \"'README'\" \(2629 characters\)
  385. sed "s/^X//" >'README' <<'END_OF_FILE'
  386. XThis is the fingerprint 0.60 package, gamma.
  387. X931101
  388. XDaniel J. Bernstein, djb@silverton.berkeley.edu.
  389. X
  390. XThe fingerprint program produces a base-64-sanely-encoded fingerprint of
  391. Xits input. I imagine this fingerprint as something universal and
  392. Xpermanent, which people will use forever. If the fingerprint is ever
  393. Xbroken, I'd rather make an entirely new version than try to extend this
  394. Xone.
  395. X
  396. XA fingerprint is 76 characters long. What does it contain? Here's a list:
  397. X
  398. X1. A Snefru-8 (version 2.5, 8 passes, 512->256) hash.
  399. X   (Code derived from the Xerox Secure Hash Function.)
  400. X2. An MD5 hash, as per RFC 1321.
  401. X   (Code derived from the RSADSI MD5 Message-Digest Algorithm.)
  402. X3. A CRC checksum, as in the new cksum utility.
  403. X4. Length modulo 2^40.
  404. X
  405. XThe output format is not expected to be compatible with anything.
  406. XHowever, I have helper utilities which take a fingerprint and produce 
  407. Xthe purported output of Merkle's snefru program (fptosnefru), the 
  408. Xpurported output of RSADSI's mddriver -x (fptomd5), or the purported 
  409. Xoutput of the POSIX cksum program (fptocksum).
  410. X
  411. XAlso included: (1) a clone of the snefru program, with some extra 
  412. Xfeatures; (2) a cksum implementation; (3) an md5 driver; (4) libraries
  413. Xwith a uniform interface for calculating these hashes; (5) some 
  414. Xdocumentation.
  415. X
  416. XTo compile, just make. To try a few simple tests, make test. To see how
  417. Xfast the various hash functions can handle a megabyte of data on your
  418. Xmachine, make speedtest.
  419. X
  420. XI've written this because I want to set up a global database which maps
  421. Xfingerprints to network locations. Thanks to the tripwire authors for
  422. Xunknowingly giving this project a push, and thanks of course to the
  423. Xhash function designers and implementors.
  424. X
  425. XThanks to the alpha testers for their comments and criticism:
  426. X
  427. X  Eric Backus <ericb@lsid.hp.com>
  428. X  Alan Barrett <barrett@daisy.ee.und.ac.za>
  429. X  Paul Haahr <haahr@mv.us.adobe.com>
  430. X  Mark C. Henderson <mch@wimsey.bc.ca>
  431. X  Stephan Neuhaus <neuhaus@informatik.uni-kl.de>
  432. X  Danny Padwa <padwad@gs.com>
  433. X  Eric Rescorla <ekr@eitech.com>
  434. X  Icarus Sparry <I.Sparry@ss1.bath.ac.uk>
  435. X
  436. XNo thanks to the beta testers---there weren't any, as far as I can tell.
  437. XThis package is essentially unchanged since beta version 0.50, which I
  438. Xposted to alt.sources in early August 1993.
  439. X
  440. XContinuing worries: I still have to make sure I'm giving all appropriate
  441. Xcredit here. Also, I haven't tested *_addn properly. I'm not too happy
  442. Xwith the man pages, which were to a large extent mechanically produced;
  443. XI'd appreciate any suggestions for improvement.
  444. X
  445. Xecho hi | fingerprint:
  446. XJoXEhdflGxZdS89tDd5zpFx0JRJyX0k67EH0Jod7aet4hIjB.hGhon0veN0BZRfi058HZQ06U0JD    
  447. END_OF_FILE
  448. if test 2629 -ne `wc -c <'README'`; then
  449.     echo shar: \"'README'\" unpacked with wrong size!
  450. fi
  451. # end of 'README'
  452. fi
  453. if test -f 'TIMINGS' -a "${1}" != "-c" ; then 
  454.   echo shar: Will not clobber existing file \"'TIMINGS'\"
  455. else
  456. echo shar: Extracting \"'TIMINGS'\" \(1319 characters\)
  457. sed "s/^X//" >'TIMINGS' <<'END_OF_FILE'
  458. XTimings are based on a few trials. More accurate timings would be nice.
  459. X
  460. X386/40, BSDI 1.0, cc -O, 64k (?) cache
  461. Xfingerprint: 38.9K/sec
  462. Xsnefru: 51.6K/sec
  463. Xmd5: 323.7K/sec
  464. Xcksum: 589.7K/sec
  465. X/usr/ucb/compress: 104.5K/sec
  466. X
  467. XSPARC, Sun 4, SunOS 4.1.3, cc -O4, ? cache
  468. Xfingerprint: 127K/sec
  469. Xsnefru: 139K/sec
  470. Xmd5: 2304K/sec
  471. Xcksum: 3585K/sec
  472. X/usr/ucb/compress: 190K/sec
  473. X
  474. XSPARC, Sun 4, SunOS 4.1.3, gcc -O, ? cache
  475. Xfingerprint: 138K/sec
  476. Xsnefru: 150K/sec
  477. Xmd5: 2300K/sec
  478. Xcksum: 4600K/sec
  479. X/usr/ucb/compress: 190K/sec
  480. X
  481. XSPARC, Sun 4, SunOS 4.1.1, cc -O4, ? cache
  482. Xfingerprint: 95K/sec
  483. Xsnefru: 115K/sec
  484. Xmd5: 913K/sec
  485. Xcksum: 1644K/sec
  486. X/usr/ucb/compress: 153K/sec
  487. X
  488. Xvangogh (HP?), cc -O
  489. Xfingerprint: 61.6K/sec
  490. Xsnefru: 72.5K/sec
  491. Xmd5: 580K/sec
  492. Xcksum: 1200K/sec
  493. X/usr/bin/compress: 99.5K/sec
  494. X
  495. XSGI, ?, cc -O2 -cckr
  496. Xfingerprint: 157K/sec
  497. Xsnefru: 188K/sec
  498. Xmd5: 1309K/sec
  499. Xcksum: 2216K/sec
  500. X/usr/bsd/compress: 139.4K/sec
  501. X
  502. XNeXT, ?, cc -O
  503. Xfingerprint: 60.5K/sec
  504. Xsnefru: 72.3K/sec
  505. Xmd5: 528K/sec
  506. Xcksum: 1300K/sec
  507. X/usr/ucb/compress: 130K/sec
  508. X
  509. XMIPS, DECstation 5000, Ultrix 4.2A (47), cc -O2, ? cache
  510. Xfingerprint: 121K/sec
  511. Xsnefru: 148K/sec
  512. Xmd5: 1128K/sec
  513. Xcksum: 1812K/sec
  514. X/usr/ucb/compress: 157K/sec
  515. X
  516. XMIPS, DECstation 5000, Ultrix 4.2A (47), gcc -O, ? cache
  517. Xfingerprint: 110K/sec
  518. Xsnefru: 144K/sec
  519. Xmd5: 927K/sec
  520. Xcksum: 2098K/sec
  521. X/usr/ucb/compress: 157K/sec
  522. END_OF_FILE
  523. if test 1319 -ne `wc -c <'TIMINGS'`; then
  524.     echo shar: \"'TIMINGS'\" unpacked with wrong size!
  525. fi
  526. # end of 'TIMINGS'
  527. fi
  528. if test -f 'cksum.1' -a "${1}" != "-c" ; then 
  529.   echo shar: Will not clobber existing file \"'cksum.1'\"
  530. else
  531. echo shar: Extracting \"'cksum.1'\" \(622 characters\)
  532. sed "s/^X//" >'cksum.1' <<'END_OF_FILE'
  533. X.TH cksum 1
  534. X.SH NAME
  535. Xcksum \- calculate a CRC-32 of the input
  536. X.SH SYNTAX
  537. X.B cksum
  538. X.SH DESCRIPTION
  539. X.B cksum
  540. Xcalculates a CRC-32 checksum of its input.
  541. X
  542. X.B cksum
  543. Xconforms to the
  544. X.I summain
  545. Xinterface.
  546. XSee
  547. X.B summain(1)
  548. Xfor a description of
  549. X.B cksum\fP's
  550. Xoptions.
  551. X.SH COMPATIBILITY
  552. XThis program is intended to
  553. Xbe backwards compatible with
  554. Xthe POSIX
  555. X.B cksum
  556. Xprogram.
  557. X.SH VERSION
  558. Xcksum 1.0, 13 July 1993.
  559. X.SH AUTHOR
  560. XMost of the work is done in
  561. Xthe
  562. X.B crc32file
  563. Xlibrary,
  564. Xwhich is
  565. Xprimarily code written by
  566. XGary S. Brown.
  567. XWrapper code
  568. Xplaced into the public domain by Daniel J. Bernstein.
  569. X.SH "SEE ALSO"
  570. Xsummain(1),
  571. Xcrc32file(3)
  572. END_OF_FILE
  573. if test 622 -ne `wc -c <'cksum.1'`; then
  574.     echo shar: \"'cksum.1'\" unpacked with wrong size!
  575. fi
  576. # end of 'cksum.1'
  577. fi
  578. if test -f 'cksum.c' -a "${1}" != "-c" ; then 
  579.   echo shar: Will not clobber existing file \"'cksum.c'\"
  580. else
  581. echo shar: Extracting \"'cksum.c'\" \(457 characters\)
  582. sed "s/^X//" >'cksum.c' <<'END_OF_FILE'
  583. X#include <stdio.h>
  584. X#include "crc32file.h"
  585. X
  586. Xstatic unsigned char h[CRC32FILE_HASHLEN];
  587. Xstatic unsigned char input[1024];
  588. X
  589. Xvoid sum(fi,out)
  590. XFILE *fi;
  591. Xchar *out;
  592. X{
  593. X crc32file s;
  594. X int i;
  595. X int len;
  596. X
  597. X crc32file_clear(&s);
  598. X len = 0;
  599. X while (i = fread(input,1,sizeof(input),fi))
  600. X  {
  601. X   crc32file_addn(&s,input,i);
  602. X   len += i;
  603. X  }
  604. X crc32file_hash(&s,h);
  605. X
  606. X sprintf(out,"%10lu %8lu"
  607. X   ,h[0] + 256 * (h[1] + 256 * (h[2] + 256 * (unsigned long) h[3]))
  608. X   ,len
  609. X   );
  610. X}
  611. END_OF_FILE
  612. if test 457 -ne `wc -c <'cksum.c'`; then
  613.     echo shar: \"'cksum.c'\" unpacked with wrong size!
  614. fi
  615. # end of 'cksum.c'
  616. fi
  617. if test -f 'cksum.tests' -a "${1}" != "-c" ; then 
  618.   echo shar: Will not clobber existing file \"'cksum.tests'\"
  619. else
  620. echo shar: Extracting \"'cksum.tests'\" \(32 characters\)
  621. sed "s/^X//" >'cksum.tests' <<'END_OF_FILE'
  622. X3188261980    60030    snefru512.c
  623. END_OF_FILE
  624. if test 32 -ne `wc -c <'cksum.tests'`; then
  625.     echo shar: \"'cksum.tests'\" unpacked with wrong size!
  626. fi
  627. # end of 'cksum.tests'
  628. fi
  629. if test -f 'crc32file.3' -a "${1}" != "-c" ; then 
  630.   echo shar: Will not clobber existing file \"'crc32file.3'\"
  631. else
  632. echo shar: Extracting \"'crc32file.3'\" \(1527 characters\)
  633. sed "s/^X//" >'crc32file.3' <<'END_OF_FILE'
  634. X.TH crc32file 3
  635. X.SH NAME
  636. Xcrc32file \- apply the standard CRC-32 hash function to a stream
  637. X.SH SYNTAX
  638. X.B #include <crc32file.h>
  639. X
  640. Xvoid \fBcrc32file_clear(\fIm\fB)\fR;
  641. X.br
  642. Xvoid \fBcrc32file_add(\fIm,c\fB)\fR;
  643. X.br
  644. Xvoid \fBcrc32file_addn(\fIm,b,len\fB)\fR;
  645. X.br
  646. Xvoid \fBcrc32file_hash(\fIm,h\fB)\fR;
  647. X
  648. Xcrc32file *\fIm\fP;
  649. X.br
  650. Xunsigned char \fIc\fP;
  651. X.br
  652. Xunsigned char \fIh\fP[CRC32FILE_HASHLEN];
  653. X.br
  654. Xunsigned char *\fIb\fP;
  655. X.br
  656. Xint \fIlen\fR;
  657. X.SH DESCRIPTION
  658. X.B crc32file
  659. Xapplies the standard CRC-32 hash function
  660. Xto a stream of unsigned characters.
  661. X
  662. X.I m
  663. Xpoints to an crc32file structure,
  664. Xwhich accumulates the hash as
  665. Xdata is fed in.
  666. XBefore feeding in any data you must
  667. Xcall
  668. X.B crc32file_clear(\fIm\fB)\fR.
  669. XThen, for each unsigned character
  670. X.I c
  671. Xfrom the stream,
  672. Xcall
  673. X.B crc32file_add(\fIm\fB,\fIc\fB)\fR.
  674. X
  675. XTo process an array
  676. X.I b
  677. Xof
  678. X.I len
  679. Xunsigned characters,
  680. Xcall
  681. X.B crc32file_addn(\fIm\fB,\fIb\fB,\fIlen\fB)\fR.
  682. XThis is faster than calling
  683. X.B crc32file_add
  684. Xon each character in turn.
  685. X
  686. X.B crc32file_hash(\fIm\fB,\fIh\fB)\fR
  687. Xplaces the resulting hash into
  688. X.I h\fP,
  689. Xan array of bytes of
  690. Xlength CRC32FILE_HASHLEN.
  691. XYou may not use
  692. X.I m
  693. Xafter that without
  694. Xagain calling
  695. X.B crc32file_clear(\fIm\fB)\fR.
  696. X
  697. XCRC32FILE_HASHLEN equals 4.
  698. X.SH COMPATIBILITY
  699. XThe
  700. X.B crc32file
  701. Xlibrary was designed for compatibility with
  702. XBSD 4.4
  703. X.B cksum\fR.
  704. X.SH DEFINITION
  705. XSee the POSIX specification for
  706. X.B cksum\fR.
  707. X.SH VERSION
  708. Xcrc32file 0.95, 8 July 1993.
  709. X.SH AUTHOR
  710. XInterface by Daniel J. Bernstein
  711. Xto code written by Gary S. Brown.
  712. X.SH "SEE ALSO"
  713. Xcksum(1)
  714. END_OF_FILE
  715. if test 1527 -ne `wc -c <'crc32file.3'`; then
  716.     echo shar: \"'crc32file.3'\" unpacked with wrong size!
  717. fi
  718. # end of 'crc32file.3'
  719. fi
  720. if test -f 'crc32file.c' -a "${1}" != "-c" ; then 
  721.   echo shar: Will not clobber existing file \"'crc32file.c'\"
  722. else
  723. echo shar: Extracting \"'crc32file.c'\" \(5058 characters\)
  724. sed "s/^X//" >'crc32file.c' <<'END_OF_FILE'
  725. X/* a few improvements by DJB 930708 */
  726. X/* nonreverse table included by DJB 930622 */
  727. X/* interface mods by DJB 930529 */
  728. X  /*  COPYRIGHT (C) 1986 Gary S. Brown.  You may use this program, or       */
  729. X  /*  code or tables extracted from it, as desired without restriction.     */
  730. X  /*  X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0   */
  731. X  /*      polynomial $edb88320                                              */
  732. X
  733. X#include "crc32file.h"
  734. X
  735. Xstatic unsigned long crc_32_tab[] = {
  736. X    0x0,
  737. X    0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
  738. X    0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6,
  739. X    0x2b4bcb61, 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd,
  740. X    0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9, 0x5f15adac,
  741. X    0x5bd4b01b, 0x569796c2, 0x52568b75, 0x6a1936c8, 0x6ed82b7f,
  742. X    0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3, 0x709f7b7a,
  743. X    0x745e66cd, 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039,
  744. X    0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, 0xbe2b5b58,
  745. X    0xbaea46ef, 0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033,
  746. X    0xa4ad16ea, 0xa06c0b5d, 0xd4326d90, 0xd0f37027, 0xddb056fe,
  747. X    0xd9714b49, 0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95,
  748. X    0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, 0xe13ef6f4,
  749. X    0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, 0x34867077, 0x30476dc0,
  750. X    0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5,
  751. X    0x2ac12072, 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16,
  752. X    0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca, 0x7897ab07,
  753. X    0x7c56b6b0, 0x71159069, 0x75d48dde, 0x6b93dddb, 0x6f52c06c,
  754. X    0x6211e6b5, 0x66d0fb02, 0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1,
  755. X    0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba,
  756. X    0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b,
  757. X    0xbb60adfc, 0xb6238b25, 0xb2e29692, 0x8aad2b2f, 0x8e6c3698,
  758. X    0x832f1041, 0x87ee0df6, 0x99a95df3, 0x9d684044, 0x902b669d,
  759. X    0x94ea7b2a, 0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e,
  760. X    0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2, 0xc6bcf05f,
  761. X    0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34,
  762. X    0xdc3abded, 0xd8fba05a, 0x690ce0ee, 0x6dcdfd59, 0x608edb80,
  763. X    0x644fc637, 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb,
  764. X    0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f, 0x5c007b8a,
  765. X    0x58c1663d, 0x558240e4, 0x51435d53, 0x251d3b9e, 0x21dc2629,
  766. X    0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5, 0x3f9b762c,
  767. X    0x3b5a6b9b, 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff,
  768. X    0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, 0xf12f560e,
  769. X    0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65,
  770. X    0xeba91bbc, 0xef68060b, 0xd727bbb6, 0xd3e6a601, 0xdea580d8,
  771. X    0xda649d6f, 0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3,
  772. X    0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, 0xae3afba2,
  773. X    0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, 0x9b3660c6, 0x9ff77d71,
  774. X    0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74,
  775. X    0x857130c3, 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640,
  776. X    0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c, 0x7b827d21,
  777. X    0x7f436096, 0x7200464f, 0x76c15bf8, 0x68860bfd, 0x6c47164a,
  778. X    0x61043093, 0x65c52d24, 0x119b4be9, 0x155a565e, 0x18197087,
  779. X    0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec,
  780. X    0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d,
  781. X    0x2056cd3a, 0x2d15ebe3, 0x29d4f654, 0xc5a92679, 0xc1683bce,
  782. X    0xcc2b1d17, 0xc8ea00a0, 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb,
  783. X    0xdbee767c, 0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18,
  784. X    0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4, 0x89b8fd09,
  785. X    0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662,
  786. X    0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf,
  787. X    0xa2f33668, 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
  788. X};
  789. X
  790. Xvoid crc32file_clear(c)
  791. Xcrc32file *c;
  792. X{
  793. X c->c = 0;
  794. X c->len[0] = c->len[1] = c->len[2] = c->len[3] =
  795. X c->len[4] = c->len[5] = c->len[6] = c->len[7] = 0;
  796. X}
  797. X
  798. Xvoid crc32file_addn(c,s,n)
  799. Xcrc32file *c;
  800. Xregister unsigned char *s;
  801. Xint n;
  802. X{
  803. X register unsigned long x;
  804. X unsigned char newc;
  805. X register int i;
  806. X
  807. X i = n;
  808. X while (i >= 256)
  809. X  {
  810. X   if (!++c->len[1]) if (!++c->len[2]) if (!++c->len[3])
  811. X   if (!++c->len[4]) if (!++c->len[5]) if (!++c->len[6]) if (!++c->len[7])
  812. X     ;
  813. X   i -= 256;
  814. X  }
  815. X newc = i;
  816. X if ((c->len[0] += newc) < newc)
  817. X   if (!++c->len[1]) if (!++c->len[2]) if (!++c->len[3])
  818. X   if (!++c->len[4]) if (!++c->len[5]) if (!++c->len[6]) if (!++c->len[7])
  819. X     ;
  820. X i = n;
  821. X x = c->c;
  822. X while (i--)
  823. X   x = crc_32_tab[(int) ((x >> 24) ^ *s++) & 0xff] ^ (x << 8);
  824. X c->c = x;
  825. X}
  826. X
  827. Xvoid crc32file_add(c,ch)
  828. Xcrc32file *c;
  829. Xunsigned char ch;
  830. X{
  831. X register unsigned long x;
  832. X
  833. X x = c->c;
  834. X c->c = crc_32_tab[(int) ((x >> 24) ^ ch) & 0xff] ^ (x << 8);
  835. X if (!++c->len[0]) if (!++c->len[1]) if (!++c->len[2]) if (!++c->len[3])
  836. X if (!++c->len[4]) if (!++c->len[5]) if (!++c->len[6]) if (!++c->len[7])
  837. X   ;
  838. X}
  839. X
  840. Xvoid crc32file_hash(c,h)
  841. Xcrc32file *c;
  842. Xunsigned char *h;
  843. X{
  844. X register unsigned long x;
  845. X unsigned char len[8];
  846. X int i;
  847. X
  848. X for (i = 0;i < 8;++i) len[i] = c->len[i];
  849. X for (i = 7;i >= 0;--i) if (len[i]) break;
  850. X crc32file_addn(c,len,i + 1);
  851. X
  852. X x = ~c->c;
  853. X h[0] = x & 255; x /= 256;
  854. X h[1] = x & 255; x /= 256;
  855. X h[2] = x & 255; x /= 256;
  856. X h[3] = x & 255;
  857. X}
  858. END_OF_FILE
  859. if test 5058 -ne `wc -c <'crc32file.c'`; then
  860.     echo shar: \"'crc32file.c'\" unpacked with wrong size!
  861. fi
  862. # end of 'crc32file.c'
  863. fi
  864. if test -f 'crc32file.h' -a "${1}" != "-c" ; then 
  865.   echo shar: Will not clobber existing file \"'crc32file.h'\"
  866. else
  867. echo shar: Extracting \"'crc32file.h'\" \(268 characters\)
  868. sed "s/^X//" >'crc32file.h' <<'END_OF_FILE'
  869. X#ifndef CRC32FILE_H
  870. X#define CRC32FILE_H
  871. X
  872. Xtypedef struct { unsigned long c; unsigned char len[8]; } crc32file;
  873. X
  874. X#define CRC32FILE_HASHLEN 4
  875. X
  876. Xextern void crc32file_clear();
  877. Xextern void crc32file_add();
  878. Xextern void crc32file_addn();
  879. Xextern void crc32file_hash();
  880. X
  881. X#endif
  882. END_OF_FILE
  883. if test 268 -ne `wc -c <'crc32file.h'`; then
  884.     echo shar: \"'crc32file.h'\" unpacked with wrong size!
  885. fi
  886. # end of 'crc32file.h'
  887. fi
  888. if test -f 'fingerprint.1' -a "${1}" != "-c" ; then 
  889.   echo shar: Will not clobber existing file \"'fingerprint.1'\"
  890. else
  891. echo shar: Extracting \"'fingerprint.1'\" \(388 characters\)
  892. sed "s/^X//" >'fingerprint.1' <<'END_OF_FILE'
  893. X.TH fingerprint 1
  894. X.SH NAME
  895. Xfingerprint \- the universal fingerprint program
  896. X.SH SYNTAX
  897. X.B fingerprint
  898. X.SH DESCRIPTION
  899. X.B fingerprint
  900. Xcalculates a cryptographically strong one-way hash of its input.
  901. X
  902. X.B fingerprint
  903. Xconforms to the
  904. X.I summain
  905. Xinterface.
  906. XSee
  907. X.B summain(1)
  908. Xfor a description of
  909. X.B fingerprint\fP's
  910. Xoptions.
  911. X.SH VERSION
  912. Xfingerprint 1.0, 7 July 1993.
  913. X.SH "SEE ALSO"
  914. Xsummain(1)
  915. END_OF_FILE
  916. if test 388 -ne `wc -c <'fingerprint.1'`; then
  917.     echo shar: \"'fingerprint.1'\" unpacked with wrong size!
  918. fi
  919. # end of 'fingerprint.1'
  920. fi
  921. if test -f 'fingerprint.c' -a "${1}" != "-c" ; then 
  922.   echo shar: Will not clobber existing file \"'fingerprint.c'\"
  923. else
  924. echo shar: Extracting \"'fingerprint.c'\" \(377 characters\)
  925. sed "s/^X//" >'fingerprint.c' <<'END_OF_FILE'
  926. X#include <stdio.h>
  927. X#include "fprintfile.h"
  928. X
  929. Xstatic unsigned char h[FINGERPRINTFILE_HASHLEN];
  930. Xstatic unsigned char input[1024];
  931. X
  932. Xvoid sum(fi,out)
  933. XFILE *fi;
  934. Xchar *out;
  935. X{
  936. X fingerprintfile f;
  937. X int i;
  938. X
  939. X fingerprintfile_clear(&f);
  940. X while (i = fread(input,1,sizeof(input),fi))
  941. X   fingerprintfile_addn(&f,input,i);
  942. X fingerprintfile_hash(&f,h);
  943. X
  944. X out[fingerprintfile_fmt(out,h)] = 0;
  945. X}
  946. END_OF_FILE
  947. if test 377 -ne `wc -c <'fingerprint.c'`; then
  948.     echo shar: \"'fingerprint.c'\" unpacked with wrong size!
  949. fi
  950. # end of 'fingerprint.c'
  951. fi
  952. if test -f 'fingerprint.tests' -a "${1}" != "-c" ; then 
  953.   echo shar: Will not clobber existing file \"'fingerprint.tests'\"
  954. else
  955. echo shar: Extracting \"'fingerprint.tests'\" \(89 characters\)
  956. sed "s/^X//" >'fingerprint.tests' <<'END_OF_FILE'
  957. X9hX04ha9c7F23oV5wWEtGIVWUt:pH07srkl0QOfGsxbensg6BNEd:g8VQIDhn:QZ00VtVu05Kipu    snefru512.c
  958. END_OF_FILE
  959. if test 89 -ne `wc -c <'fingerprint.tests'`; then
  960.     echo shar: \"'fingerprint.tests'\" unpacked with wrong size!
  961. fi
  962. # end of 'fingerprint.tests'
  963. fi
  964. if test -f 'fprintfile.3' -a "${1}" != "-c" ; then 
  965.   echo shar: Will not clobber existing file \"'fprintfile.3'\"
  966. else
  967. echo shar: Extracting \"'fprintfile.3'\" \(2826 characters\)
  968. sed "s/^X//" >'fprintfile.3' <<'END_OF_FILE'
  969. X.TH fingerprintfile 3
  970. X.SH NAME
  971. Xfingerprintfile \- compute the fingerprint of a stream
  972. X.SH SYNTAX
  973. X.B #include <fprintfile.h>
  974. X
  975. Xvoid \fBfingerprintfile_clear(\fIf\fB)\fR;
  976. X.br
  977. Xvoid \fBfingerprintfile_addn(\fIm,b,len\fB)\fR;
  978. X.br
  979. Xvoid \fBfingerprintfile_add(\fIf\fB,\fIc\fB)\fR;
  980. X.br
  981. Xvoid \fBfingerprintfile_hash(\fIf\fB,\fIh\fB)\fR;
  982. X
  983. Xunsigned int \fBfingerprintfile_fmt(\fIs\fB,\fIh\fB)\fR;
  984. X.br
  985. Xunsigned int \fBfingerprintfile_scan(\fIs\fB,\fIh\fB)\fR;
  986. X
  987. Xfingerprintfile *\fIf\fP;
  988. X.br
  989. Xunsigned char \fIc\fP;
  990. X.br
  991. Xunsigned char \fIh\fP[FINGERPRINTFILE_HASHLEN];
  992. X.br
  993. Xunsigned char *\fIb\fP;
  994. X.br
  995. Xint \fIlen\fR;
  996. X
  997. Xchar *\fIs\fP;
  998. X.SH DESCRIPTION
  999. X.B fingerprintfile
  1000. Xcomputes the fingerprint
  1001. Xof a stream of unsigned characters.
  1002. X
  1003. XNobody knows how to create two files with the same fingerprint.
  1004. X
  1005. X.I f
  1006. Xpoints to an fingerprintfile structure,
  1007. Xwhich accumulates the fingerprint as
  1008. Xdata is fed in.
  1009. XBefore feeding in any data you must
  1010. Xcall
  1011. X.B fingerprintfile_clear(\fIf\fB)\fR.
  1012. XThen, for each unsigned character
  1013. X.I c
  1014. Xfrom the stream,
  1015. Xcall
  1016. X.B fingerprintfile_add(\fIf\fB,\fIc\fB)\fR.
  1017. X
  1018. XTo process an array
  1019. X.I b
  1020. Xof
  1021. X.I len
  1022. Xunsigned characters,
  1023. Xcall
  1024. X.B fingerprintfile_addn(\fIm\fB,\fIb\fB,\fIlen\fB)\fR.
  1025. XThis is faster than calling
  1026. X.B fingerprintfile_add
  1027. Xon each character in turn.
  1028. X
  1029. X.B fingerprintfile_hash(\fIf\fB,\fIh\fB)\fR
  1030. Xplaces the resulting fingerprint into
  1031. X.I h\fP,
  1032. Xan array of bytes of
  1033. Xlength FINGERPRINTFILE_HASHLEN.
  1034. XYou may not use
  1035. X.I f
  1036. Xafter that without
  1037. Xagain calling
  1038. X.B fingerprintfile_clear(\fIf\fB)\fR.
  1039. X
  1040. XFINGERPRINTFILE_HASHLEN equals 57.
  1041. X
  1042. X.B fingerprintfile_fmt(\fIs\fB,\fIh\fB)\fR
  1043. Xplaces a readable version of the hash
  1044. X.I h
  1045. Xinto the character array
  1046. X.I s\fP.
  1047. XIt returns the number of characters written.
  1048. XIf
  1049. X.I s
  1050. Xis zero,
  1051. X.B fingerprintfile_fmt
  1052. Xwill not write anything,
  1053. Xbut it will return the number of characters it would have written.
  1054. X
  1055. X.B fingerprintfile_scan(\fIs\fB,\fIh\fB)\fR
  1056. Xattempts to decipher a readable hash
  1057. Xappearing in the character array
  1058. X.I s\fP.
  1059. XIf it fails it returns 0.
  1060. XIf it succeeds it places the hash
  1061. Xinto
  1062. X.I h\fP,
  1063. Xand returns the number of characters read
  1064. Xfrom
  1065. X.I s\fP.
  1066. X
  1067. XThe readable version of a hash
  1068. Xtakes up exactly 76 characters.
  1069. X.SH VERSION
  1070. Xfingerprintfile 0.95, 8 July 1993.
  1071. X.SH DEFINITION
  1072. XThe fingerprint contains four pieces of information:
  1073. Xthe result of
  1074. X.B snefrufile\fR,
  1075. Xwhich
  1076. X(through
  1077. X.B snefru512\fR)
  1078. Xcomputes the Snefru-8 function
  1079. Xwith code derived from the Xerox Secure Hash Function;
  1080. Xthe result of
  1081. X.B md5file\fR,
  1082. Xwhich computes the
  1083. XRSADSI MD5 Message-Digest Algorithm;
  1084. Xthe result of
  1085. X.B crc32file\fR,
  1086. Xwhich computes a standard CRC-32;
  1087. Xand the number of bytes of the stream, modulo terabytes.
  1088. X.SH AUTHOR
  1089. XPlaced into the public domain by Daniel J. Bernstein.
  1090. XNote that the libraries used by
  1091. X.B fingerprintfile
  1092. Xare not public-domain.
  1093. X.SH "SEE ALSO"
  1094. Xfingerprint(1),
  1095. Xcrc32file(3),
  1096. Xmd5file(3),
  1097. Xsnefrufile(3)
  1098. END_OF_FILE
  1099. if test 2826 -ne `wc -c <'fprintfile.3'`; then
  1100.     echo shar: \"'fprintfile.3'\" unpacked with wrong size!
  1101. fi
  1102. # end of 'fprintfile.3'
  1103. fi
  1104. if test -f 'fprintfile.c' -a "${1}" != "-c" ; then 
  1105.   echo shar: Will not clobber existing file \"'fprintfile.c'\"
  1106. else
  1107. echo shar: Extracting \"'fprintfile.c'\" \(1507 characters\)
  1108. sed "s/^X//" >'fprintfile.c' <<'END_OF_FILE'
  1109. X/* fprintfile.c, fprintfmt.c, fprintfile.h: fingerprint library
  1110. XDaniel J. Bernstein, brnstnd@nyu.edu.
  1111. XDepends on snefrufile.h, md5file.h, crc32file.h.
  1112. XNo environment requirements.
  1113. X930708: fprintfile 0.95. Public domain.
  1114. X930708: Added fingerprintfile_addn.
  1115. X930622: Split off fprintfmt.c.
  1116. X930601: Baseline, fprintfile 0.8. Public domain.
  1117. XNo known patent problems.
  1118. X
  1119. XDocumentation in fprintfile.3.
  1120. X*/
  1121. X
  1122. X#include "fprintfile.h"
  1123. X
  1124. Xvoid fingerprintfile_clear(f)
  1125. Xfingerprintfile *f;
  1126. X{
  1127. X snefrufile_clear(&f->s);
  1128. X md5file_clear(&f->m);
  1129. X crc32file_clear(&f->c);
  1130. X f->len[0] = f->len[1] = f->len[2] = f->len[3] = f->len[4] = 0;
  1131. X}
  1132. X
  1133. Xvoid fingerprintfile_addn(f,s,n)
  1134. Xfingerprintfile *f;
  1135. Xunsigned char *s;
  1136. Xint n;
  1137. X{
  1138. X unsigned char newlen;
  1139. X
  1140. X snefrufile_addn(&f->s,s,n);
  1141. X md5file_addn(&f->m,s,n);
  1142. X crc32file_addn(&f->c,s,n);
  1143. X while (n >= 256)
  1144. X  {
  1145. X   if(!++f->len[1])if(!++f->len[2])if(!++f->len[3])++f->len[4];
  1146. X   n -= 256;
  1147. X  }
  1148. X newlen = n;
  1149. X if ((f->len[0] += newlen) < newlen)
  1150. X   if(!++f->len[1])if(!++f->len[2])if(!++f->len[3])++f->len[4];
  1151. X}
  1152. X
  1153. Xvoid fingerprintfile_add(f,c)
  1154. Xfingerprintfile *f;
  1155. Xunsigned char c;
  1156. X{
  1157. X snefrufile_add(&f->s,c);
  1158. X md5file_add(&f->m,c);
  1159. X crc32file_add(&f->c,c);
  1160. X if(!++f->len[0])if(!++f->len[1])if(!++f->len[2])if(!++f->len[3])++f->len[4];
  1161. X}
  1162. X
  1163. Xvoid fingerprintfile_hash(f,h)
  1164. Xfingerprintfile *f;
  1165. Xunsigned char h[57];
  1166. X{
  1167. X snefrufile_hash(&f->s,h);
  1168. X md5file_hash(&f->m,h + 32);
  1169. X crc32file_hash(&f->c,h + 48);
  1170. X h[52] = f->len[0]; h[53] = f->len[1]; h[54] = f->len[2];
  1171. X h[55] = f->len[3]; h[56] = f->len[4];
  1172. X}
  1173. END_OF_FILE
  1174. if test 1507 -ne `wc -c <'fprintfile.c'`; then
  1175.     echo shar: \"'fprintfile.c'\" unpacked with wrong size!
  1176. fi
  1177. # end of 'fprintfile.c'
  1178. fi
  1179. if test -f 'fprintfile.h' -a "${1}" != "-c" ; then 
  1180.   echo shar: Will not clobber existing file \"'fprintfile.h'\"
  1181. else
  1182. echo shar: Extracting \"'fprintfile.h'\" \(504 characters\)
  1183. sed "s/^X//" >'fprintfile.h' <<'END_OF_FILE'
  1184. X#ifndef FINGERPRINTFILE_H
  1185. X#define FINGERPRINTFILE_H
  1186. X
  1187. X#include "snefrufile.h"
  1188. X#include "md5file.h"
  1189. X#include "crc32file.h"
  1190. X
  1191. Xtypedef struct
  1192. X {
  1193. X  snefrufile s;
  1194. X  md5file m;
  1195. X  crc32file c;
  1196. X  unsigned char len[5];
  1197. X }
  1198. Xfingerprintfile;
  1199. X
  1200. X#define FINGERPRINTFILE_HASHLEN 57
  1201. X
  1202. Xextern void fingerprintfile_clear();
  1203. Xextern void fingerprintfile_add();
  1204. Xextern void fingerprintfile_addn();
  1205. Xextern void fingerprintfile_hash();
  1206. Xextern unsigned int fingerprintfile_fmt();
  1207. Xextern unsigned int fingerprintfile_scan();
  1208. X
  1209. X#endif
  1210. END_OF_FILE
  1211. if test 504 -ne `wc -c <'fprintfile.h'`; then
  1212.     echo shar: \"'fprintfile.h'\" unpacked with wrong size!
  1213. fi
  1214. # end of 'fprintfile.h'
  1215. fi
  1216. if test -f 'fprintfmt.c' -a "${1}" != "-c" ; then 
  1217.   echo shar: Will not clobber existing file \"'fprintfmt.c'\"
  1218. else
  1219. echo shar: Extracting \"'fprintfmt.c'\" \(1660 characters\)
  1220. sed "s/^X//" >'fprintfmt.c' <<'END_OF_FILE'
  1221. X/* fprintfile.c, fprintfmt.c, fprintfile.h: fingerprint library
  1222. XDaniel J. Bernstein, brnstnd@nyu.edu.
  1223. XDepends on snefrufile.h, md5file.h, crc32file.h.
  1224. XNo environment requirements.
  1225. X930708: fprintfile 0.95. Public domain.
  1226. X930708: Changed slash to colon in base64sane.
  1227. X930622: Split off fprintfmt.c.
  1228. X930601: Baseline, fprintfile 0.8. Public domain.
  1229. XNo known patent problems.
  1230. X
  1231. XDocumentation in fprintfile.3.
  1232. X*/
  1233. X
  1234. X#include "fprintfile.h"
  1235. X
  1236. Xstatic char base64sane[]
  1237. X= "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ:.";
  1238. X
  1239. Xunsigned int fingerprintfile_fmt(s,h)
  1240. Xchar *s;
  1241. Xunsigned char *h;
  1242. X{
  1243. X if (s)
  1244. X  {
  1245. X   int i;
  1246. X   unsigned long x;
  1247. X
  1248. X   for (i = 0;i < 19;++i)
  1249. X    {
  1250. X     x = h[3 * i] + 256 * (h[3 * i + 1] + 256 * (long) h[3 * i + 2]);
  1251. X     s[(12 * i) % 76] = base64sane[x & 63]; x /= 64;
  1252. X     s[(12 * i + 41) % 76] = base64sane[x & 63]; x /= 64;
  1253. X     s[(12 * i + 6) % 76] = base64sane[x & 63]; x /= 64;
  1254. X     s[(12 * i + 47) % 76] = base64sane[x & 63];
  1255. X    }
  1256. X  }
  1257. X return 76;
  1258. X}
  1259. X
  1260. Xstatic int unbase64(c)
  1261. Xchar c;
  1262. X{
  1263. X int i;
  1264. X
  1265. X /* XXX: efficiency? */
  1266. X
  1267. X for (i = 0;i < 64;++i)
  1268. X   if (base64sane[i] == c)
  1269. X     return i;
  1270. X return -1;
  1271. X}
  1272. X
  1273. Xunsigned int fingerprintfile_scan(s,h)
  1274. Xchar *s;
  1275. Xunsigned char h[57];
  1276. X{
  1277. X int i;
  1278. X unsigned long x;
  1279. X
  1280. X for (i = 0;i < 76;++i)
  1281. X   if (unbase64(s[i]) == -1) /* XXX: great, calling it twice! */
  1282. X     return 0;
  1283. X for (i = 0;i < 19;++i)
  1284. X  {
  1285. X   x = unbase64(s[(12 * i + 47) % 76]); x *= 64;
  1286. X   x += unbase64(s[(12 * i + 6) % 76]); x *= 64;
  1287. X   x += unbase64(s[(12 * i + 41) % 76]); x *= 64;
  1288. X   x += unbase64(s[(12 * i) % 76]);
  1289. X   h[3 * i] = x & 255; x = x / 256;
  1290. X   h[3 * i + 1] = x & 255; x = x / 256;
  1291. X   h[3 * i + 2] = x;
  1292. X  }
  1293. X return 76;
  1294. X}
  1295. END_OF_FILE
  1296. if test 1660 -ne `wc -c <'fprintfmt.c'`; then
  1297.     echo shar: \"'fprintfmt.c'\" unpacked with wrong size!
  1298. fi
  1299. # end of 'fprintfmt.c'
  1300. fi
  1301. if test -f 'fptocksum.c' -a "${1}" != "-c" ; then 
  1302.   echo shar: Will not clobber existing file \"'fptocksum.c'\"
  1303. else
  1304. echo shar: Extracting \"'fptocksum.c'\" \(478 characters\)
  1305. sed "s/^X//" >'fptocksum.c' <<'END_OF_FILE'
  1306. X#include <stdio.h>
  1307. X#include "fprintfile.h"
  1308. X
  1309. Xchar line[200];
  1310. Xunsigned char h[57];
  1311. X
  1312. Xmain()
  1313. X{
  1314. X int i;
  1315. X
  1316. X while (fgets(line,sizeof(line),stdin))
  1317. X  {
  1318. X   if (!(i = fingerprintfile_scan(line,h)))
  1319. X     printf("bad fingerprint\n");
  1320. X   else
  1321. X     printf("%10lu %8lu%s"
  1322. X       ,h[48] + 256 * (h[49] + 256 * (h[50] + 256 * (unsigned long) h[51]))
  1323. X       ,h[52] + 256 * (h[53] + 256 * (h[54] +
  1324. X          256 * (h[55] + 256 * (unsigned long) h[56])))
  1325. X       ,line + i
  1326. X       );
  1327. X  }
  1328. X exit(0);
  1329. X}
  1330. END_OF_FILE
  1331. if test 478 -ne `wc -c <'fptocksum.c'`; then
  1332.     echo shar: \"'fptocksum.c'\" unpacked with wrong size!
  1333. fi
  1334. # end of 'fptocksum.c'
  1335. fi
  1336. if test -f 'fptomd5.c' -a "${1}" != "-c" ; then 
  1337.   echo shar: Will not clobber existing file \"'fptomd5.c'\"
  1338. else
  1339. echo shar: Extracting \"'fptomd5.c'\" \(356 characters\)
  1340. sed "s/^X//" >'fptomd5.c' <<'END_OF_FILE'
  1341. X#include <stdio.h>
  1342. X#include "fprintfile.h"
  1343. X
  1344. Xchar line[200];
  1345. Xunsigned char h[57];
  1346. X
  1347. Xmain()
  1348. X{
  1349. X int i;
  1350. X int len;
  1351. X
  1352. X while (fgets(line,sizeof(line),stdin))
  1353. X  {
  1354. X   if (!(len = fingerprintfile_scan(line,h)))
  1355. X     printf("bad fingerprint\n");
  1356. X   else
  1357. X    {
  1358. X     for (i = 32;i < 48;++i) printf("%02x",(int) h[i]);
  1359. X     printf("%s",line + len);
  1360. X    }
  1361. X  }
  1362. X exit(0);
  1363. X}
  1364. END_OF_FILE
  1365. if test 356 -ne `wc -c <'fptomd5.c'`; then
  1366.     echo shar: \"'fptomd5.c'\" unpacked with wrong size!
  1367. fi
  1368. # end of 'fptomd5.c'
  1369. fi
  1370. if test -f 'fptosnefru.c' -a "${1}" != "-c" ; then 
  1371.   echo shar: Will not clobber existing file \"'fptosnefru.c'\"
  1372. else
  1373. echo shar: Extracting \"'fptosnefru.c'\" \(374 characters\)
  1374. sed "s/^X//" >'fptosnefru.c' <<'END_OF_FILE'
  1375. X#include <stdio.h>
  1376. X#include "fprintfile.h"
  1377. X
  1378. Xchar line[200];
  1379. Xunsigned char h[57];
  1380. X
  1381. Xmain()
  1382. X{
  1383. X int i;
  1384. X int len;
  1385. X
  1386. X while (fgets(line,sizeof(line),stdin))
  1387. X  {
  1388. X   if (!(len = fingerprintfile_scan(line,h)))
  1389. X     printf("bad fingerprint\n");
  1390. X   else
  1391. X    {
  1392. X     for(i=0;i<32;++i){if(!(i&3))printf(" "); printf("%02x",(int) h[i]);}
  1393. X     printf("%s",line + len);
  1394. X    }
  1395. X  }
  1396. X exit(0);
  1397. X}
  1398. END_OF_FILE
  1399. if test 374 -ne `wc -c <'fptosnefru.c'`; then
  1400.     echo shar: \"'fptosnefru.c'\" unpacked with wrong size!
  1401. fi
  1402. # end of 'fptosnefru.c'
  1403. fi
  1404. if test -f 'getopt.c' -a "${1}" != "-c" ; then 
  1405.   echo shar: Will not clobber existing file \"'getopt.c'\"
  1406. else
  1407. echo shar: Extracting \"'getopt.c'\" \(3276 characters\)
  1408. sed "s/^X//" >'getopt.c' <<'END_OF_FILE'
  1409. X/* getopt.c, getopt.h: (yet another) improved getopt clone
  1410. XDaniel J. Bernstein, brnstnd@nyu.edu.
  1411. XNo dependencies.
  1412. XRequires stdio.
  1413. X10/20/91: Removed -DGETOPT_SHUT_UP. [sigh]
  1414. X8/26/91: Added -DGETOPT_SHUT_UP.
  1415. X8/25/91: Changed getopt to not skip blank arguments.
  1416. X7/6/91: Baseline. getopt 1.0, public domain.
  1417. XNo known patent problems.
  1418. X
  1419. XThis is a clone of the usual getopt() functions. It includes opterr so
  1420. Xthat you can turn off error handling, optpos so that you can find out
  1421. Xexactly where the processing is up to (instead of just which argument),
  1422. Xoptproblem so that you can accurately diagnose errors yourself, and
  1423. Xoptprogname so that you can set the program name for getopt-generated
  1424. Xerrors. getopt() takes much more care to ensure that all the variables
  1425. Xstill make sense upon errors and EOF. (optproblem is a character. If
  1426. Xargv[optind] is 0, the problem is a missing argument; otherwise it's an
  1427. Xillegal option character.) Unless you define GETOPTORIGDEF, the header
  1428. Xfile redefines all names so that you don't have to worry about conflicts
  1429. Xwith libc. Finally, the code is public-domain, so you should feel free
  1430. Xto use these extra features in your own programs and just attach a copy
  1431. Xof this.
  1432. X
  1433. XNote that optind and optpos can be read (or set) any time, but the
  1434. Xofficial getopt interface only defines optind when getopt() returns EOF.
  1435. XWe define optproblem only when getopt() returns '?', optarg all the
  1436. Xtime, and optprogram only after getopt() has been called at least once.
  1437. X
  1438. X*/
  1439. X
  1440. X#include <stdio.h> /* for EOF and stderr---talk about immodularity! */
  1441. X#include "getopt.h"
  1442. X
  1443. Xint optind = 1;
  1444. Xint optpos = 0;
  1445. Xint opterr = 1;
  1446. Xchar *optarg = 0;
  1447. Xint optproblem = 0;
  1448. Xchar *optprogname = 0;
  1449. Xint opteof = EOF;
  1450. X
  1451. Xint getopt(argc,argv,opts)
  1452. Xint argc;
  1453. Xchar **argv;
  1454. Xchar *opts;
  1455. X{
  1456. X int c;
  1457. X char *s;
  1458. X
  1459. X optarg = 0;
  1460. X if (!optprogname)
  1461. X  {
  1462. X   optprogname = *argv;
  1463. X   if (!optprogname) /* oh boy */
  1464. X     optprogname = ""; /*XXX*/
  1465. X   for (s = optprogname;*s;++s)
  1466. X     if (*s == '/')
  1467. X       optprogname = s + 1;
  1468. X  }
  1469. X if (!argv || (optind >= argc) || !argv[optind])
  1470. X   return opteof;
  1471. X while (optpos && !argv[optind][optpos])
  1472. X  {
  1473. X   /* we simply skip blank arguments... not any more */
  1474. X   ++optind;
  1475. X   optpos = 0;
  1476. X   if ((optind >= argc) || !argv[optind])
  1477. X     return opteof;
  1478. X  }
  1479. X if (!optpos)
  1480. X  {
  1481. X   if (argv[optind][0] != '-')
  1482. X     return opteof;
  1483. X   ++optpos;
  1484. X   c = argv[optind][1];
  1485. X   if ((c == '-') || (c == 0))
  1486. X    {
  1487. X     /* XXX: this behavior of "-" is stupid */
  1488. X     if (c)
  1489. X       ++optind;
  1490. X     optpos = 0;
  1491. X     return opteof;
  1492. X    }
  1493. X   /* otherwise c is reassigned below */
  1494. X  }
  1495. X c = argv[optind][optpos];
  1496. X ++optpos;
  1497. X s = opts;
  1498. X while (*s)
  1499. X  {
  1500. X   if (c == *s)
  1501. X    {
  1502. X     if (s[1] == ':')
  1503. X      {
  1504. X       optarg = argv[optind] + optpos;
  1505. X       ++optind;
  1506. X       optpos = 0;
  1507. X       if (!*optarg)
  1508. X        {
  1509. X         optarg = argv[optind];
  1510. X         if ((optind >= argc) || !optarg) /* argument past end */
  1511. X          {
  1512. X           optproblem = c;
  1513. X           if (opterr)
  1514. X             fprintf(stderr,"%s: option requires an argument -- %c\n"
  1515. X               ,optprogname,c);
  1516. X           return '?';
  1517. X          }
  1518. X     ++optind;
  1519. X        }
  1520. X      }
  1521. X     return c;
  1522. X    }
  1523. X   ++s;
  1524. X   if (*s == ':')
  1525. X     ++s;
  1526. X  }
  1527. X optproblem = c;
  1528. X if (opterr)
  1529. X   fprintf(stderr,"%s: illegal option -- %c\n",optprogname,c);
  1530. X return '?';
  1531. X}
  1532. END_OF_FILE
  1533. if test 3276 -ne `wc -c <'getopt.c'`; then
  1534.     echo shar: \"'getopt.c'\" unpacked with wrong size!
  1535. fi
  1536. # end of 'getopt.c'
  1537. fi
  1538. if test -f 'getopt.h' -a "${1}" != "-c" ; then 
  1539.   echo shar: Will not clobber existing file \"'getopt.h'\"
  1540. else
  1541. echo shar: Extracting \"'getopt.h'\" \(459 characters\)
  1542. sed "s/^X//" >'getopt.h' <<'END_OF_FILE'
  1543. X#ifndef GETOPT_H
  1544. X#define GETOPT_H
  1545. X
  1546. X#ifndef GETOPTORIGDEF
  1547. X#define getopt getoptmine
  1548. X#define optarg getoptarg
  1549. X#define optind getoptind
  1550. X#define opterr getopterr
  1551. X#define optpos getoptpos
  1552. X#define optproblem getoptproblem
  1553. X#define optprogname getoptprogname
  1554. X#define opteof getopteof
  1555. X#endif
  1556. X
  1557. Xextern int getopt();
  1558. Xextern char *optarg;
  1559. Xextern int optind;
  1560. Xextern int opterr;
  1561. Xextern int optpos;
  1562. Xextern int optproblem;
  1563. Xextern char *optprogname;
  1564. Xextern int opteof;
  1565. X
  1566. X#endif
  1567. END_OF_FILE
  1568. if test 459 -ne `wc -c <'getopt.h'`; then
  1569.     echo shar: \"'getopt.h'\" unpacked with wrong size!
  1570. fi
  1571. # end of 'getopt.h'
  1572. fi
  1573. if test -f 'md5.1' -a "${1}" != "-c" ; then 
  1574.   echo shar: Will not clobber existing file \"'md5.1'\"
  1575. else
  1576. echo shar: Extracting \"'md5.1'\" \(566 characters\)
  1577. sed "s/^X//" >'md5.1' <<'END_OF_FILE'
  1578. X.TH md5 1
  1579. X.SH NAME
  1580. Xmd5 \- the RSADSI MD5 Message-Digest Algorithm
  1581. X.SH SYNTAX
  1582. X.B md5
  1583. X.SH DESCRIPTION
  1584. X.B md5
  1585. Xcalculates a cryptographically strong one-way hash of its input.
  1586. X
  1587. X.B md5
  1588. Xconforms to the
  1589. X.I summain
  1590. Xinterface.
  1591. XSee
  1592. X.B summain(1)
  1593. Xfor a description of
  1594. X.B md5\fP's
  1595. Xoptions.
  1596. X.SH VERSION
  1597. Xmd5 1.0, 7 July 1993.
  1598. X.SH AUTHOR
  1599. XMost of the work is done in
  1600. Xthe
  1601. X.B md5file
  1602. Xlibrary,
  1603. Xwhich is derived from the
  1604. XRSADSI MD5 Message-Digest Algorithm
  1605. Xdesigned by
  1606. XRon Rivest.
  1607. XWrapper code
  1608. Xplaced into the public domain by Daniel J. Bernstein.
  1609. X.SH "SEE ALSO"
  1610. Xsummain(1),
  1611. Xmd5file(3)
  1612. END_OF_FILE
  1613. if test 566 -ne `wc -c <'md5.1'`; then
  1614.     echo shar: \"'md5.1'\" unpacked with wrong size!
  1615. fi
  1616. # end of 'md5.1'
  1617. fi
  1618. if test -f 'md5.c' -a "${1}" != "-c" ; then 
  1619.   echo shar: Will not clobber existing file \"'md5.c'\"
  1620. else
  1621. echo shar: Extracting \"'md5.c'\" \(422 characters\)
  1622. sed "s/^X//" >'md5.c' <<'END_OF_FILE'
  1623. X#include <stdio.h>
  1624. X#include "md5file.h"
  1625. X
  1626. Xstatic unsigned char h[MD5FILE_HASHLEN];
  1627. Xstatic unsigned char input[1024];
  1628. X
  1629. Xvoid sum(fi,out)
  1630. XFILE *fi;
  1631. Xchar *out;
  1632. X{
  1633. X md5file s;
  1634. X int i;
  1635. X char *x;
  1636. X
  1637. X md5file_clear(&s);
  1638. X while (i = fread(input,1,sizeof(input),fi))
  1639. X   md5file_addn(&s,input,i);
  1640. X md5file_hash(&s,h);
  1641. X
  1642. X x = out;
  1643. X for (i = 0;i < MD5FILE_HASHLEN;++i)
  1644. X  {
  1645. X   sprintf(x,"%02x",(int) h[i]);
  1646. X   x += strlen(x);
  1647. X  }
  1648. X *x = 0;
  1649. X}
  1650. END_OF_FILE
  1651. if test 422 -ne `wc -c <'md5.c'`; then
  1652.     echo shar: \"'md5.c'\" unpacked with wrong size!
  1653. fi
  1654. # end of 'md5.c'
  1655. fi
  1656. if test -f 'md5.tests' -a "${1}" != "-c" ; then 
  1657.   echo shar: Will not clobber existing file \"'md5.tests'\"
  1658. else
  1659. echo shar: Extracting \"'md5.tests'\" \(45 characters\)
  1660. sed "s/^X//" >'md5.tests' <<'END_OF_FILE'
  1661. X16344b673995a9049736209bf7ab5779    snefru512.c
  1662. END_OF_FILE
  1663. if test 45 -ne `wc -c <'md5.tests'`; then
  1664.     echo shar: \"'md5.tests'\" unpacked with wrong size!
  1665. fi
  1666. # end of 'md5.tests'
  1667. fi
  1668. if test -f 'md5file.3' -a "${1}" != "-c" ; then 
  1669.   echo shar: Will not clobber existing file \"'md5file.3'\"
  1670. else
  1671. echo shar: Extracting \"'md5file.3'\" \(1557 characters\)
  1672. sed "s/^X//" >'md5file.3' <<'END_OF_FILE'
  1673. X.TH md5file 3
  1674. X.SH NAME
  1675. Xmd5file \- apply the RSADSI MD5 Message-Digest Algorithm to a stream
  1676. X.SH SYNTAX
  1677. X.B #include <md5file.h>
  1678. X
  1679. Xvoid \fBmd5file_clear(\fIm\fB)\fR;
  1680. X.br
  1681. Xvoid \fBmd5file_add(\fIm,c\fB)\fR;
  1682. X.br
  1683. Xvoid \fBmd5file_addn(\fIm,b,len\fB)\fR;
  1684. X.br
  1685. Xvoid \fBmd5file_hash(\fIm,h\fB)\fR;
  1686. X
  1687. Xmd5file *\fIm\fP;
  1688. X.br
  1689. Xunsigned char \fIc\fP;
  1690. X.br
  1691. Xunsigned char \fIh\fP[MD5FILE_HASHLEN];
  1692. X.br
  1693. Xunsigned char *\fIb\fP;
  1694. X.br
  1695. Xint \fIlen\fR;
  1696. X.SH DESCRIPTION
  1697. X.B md5file
  1698. Xapplies the MD5 hash function
  1699. Xto a stream of unsigned characters.
  1700. X
  1701. X.I m
  1702. Xpoints to an md5file structure,
  1703. Xwhich accumulates the hash as
  1704. Xdata is fed in.
  1705. XBefore feeding in any data you must
  1706. Xcall
  1707. X.B md5file_clear(\fIm\fB)\fR.
  1708. XThen, for each unsigned character
  1709. X.I c
  1710. Xfrom the stream,
  1711. Xcall
  1712. X.B md5file_add(\fIm\fB,\fIc\fB)\fR.
  1713. X
  1714. XTo process an array
  1715. X.I b
  1716. Xof
  1717. X.I len
  1718. Xunsigned characters,
  1719. Xcall
  1720. X.B md5file_addn(\fIm\fB,\fIb\fB,\fIlen\fB)\fR.
  1721. XThis is faster than calling
  1722. X.B md5file_add
  1723. Xon each character in turn.
  1724. X
  1725. X.B md5file_hash(\fIm\fB,\fIh\fB)\fR
  1726. Xplaces the resulting hash into
  1727. X.I h\fP,
  1728. Xan array of bytes of
  1729. Xlength MD5FILE_HASHLEN.
  1730. XYou may not use
  1731. X.I m
  1732. Xafter that without
  1733. Xagain calling
  1734. X.B md5file_clear(\fIm\fB)\fR.
  1735. X
  1736. XMD5FILE_HASHLEN equals 16.
  1737. X.SH COMPATIBILITY
  1738. XExcept for minor interface differences
  1739. Xthis should be completely compatible
  1740. Xwith Rivest's MD5 library.
  1741. X.SH DEFINITION
  1742. XSee RFC 1321.
  1743. X.SH VERSION
  1744. Xmd5file 0.95, 8 July 1993.
  1745. X.SH AUTHOR
  1746. XDerived from the RSA Data Security Incorporated
  1747. XMD5 Message-Digest Function,
  1748. Xdesigned by Ron Rivest.
  1749. XThis adaptation created by Daniel J. Bernstein.
  1750. X.SH "SEE ALSO"
  1751. Xmddriver(1)
  1752. END_OF_FILE
  1753. if test 1557 -ne `wc -c <'md5file.3'`; then
  1754.     echo shar: \"'md5file.3'\" unpacked with wrong size!
  1755. fi
  1756. # end of 'md5file.3'
  1757. fi
  1758. if test -f 'md5file.c' -a "${1}" != "-c" ; then 
  1759.   echo shar: Will not clobber existing file \"'md5file.c'\"
  1760. else
  1761. echo shar: Extracting \"'md5file.c'\" \(10262 characters\)
  1762. sed "s/^X//" >'md5file.c' <<'END_OF_FILE'
  1763. X/* derived from RSADSI MD5 Message-Digest Algorithm */
  1764. X
  1765. X/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
  1766. Xrights reserved.
  1767. X
  1768. XLicense to copy and use this software is granted provided that it
  1769. Xis identified as the "RSA Data Security, Inc. MD5 Message-Digest
  1770. XAlgorithm" in all material mentioning or referencing this software
  1771. Xor this function.
  1772. X
  1773. XLicense is also granted to make and use derivative works provided
  1774. Xthat such works are identified as "derived from the RSA Data
  1775. XSecurity, Inc. MD5 Message-Digest Algorithm" in all material
  1776. Xmentioning or referencing the derived work.
  1777. X
  1778. XRSA Data Security, Inc. makes no representations concerning either
  1779. Xthe merchantability of this software or the suitability of this
  1780. Xsoftware for any particular purpose. It is provided "as is"
  1781. Xwithout express or implied warranty of any kind.
  1782. X
  1783. XThese notices must be retained in any copies of any part of this
  1784. Xdocumentation and/or software.
  1785. X */
  1786. X
  1787. X#include "md5file.h"
  1788. X
  1789. Xtypedef unsigned char *POINTER;
  1790. X
  1791. X/* Constants for MD5Transform routine.
  1792. X */
  1793. X
  1794. X#define S11 7
  1795. X#define S12 12
  1796. X#define S13 17
  1797. X#define S14 22
  1798. X#define S21 5
  1799. X#define S22 9
  1800. X#define S23 14
  1801. X#define S24 20
  1802. X#define S31 4
  1803. X#define S32 11
  1804. X#define S33 16
  1805. X#define S34 23
  1806. X#define S41 6
  1807. X#define S42 10
  1808. X#define S43 15
  1809. X#define S44 21
  1810. X
  1811. Xstatic void MD5Transform ();
  1812. Xstatic void Encode ();
  1813. Xstatic void Decode ();
  1814. Xstatic void MD5_memcpy ();
  1815. Xstatic void MD5_memset ();
  1816. X
  1817. Xstatic unsigned char PADDING[64] = {
  1818. X  0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  1819. X  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  1820. X  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  1821. X};
  1822. X
  1823. X/* F, G, H and I are basic MD5 functions.
  1824. X */
  1825. X#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
  1826. X#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
  1827. X#define H(x, y, z) ((x) ^ (y) ^ (z))
  1828. X#define I(x, y, z) ((y) ^ ((x) | (~z)))
  1829. X
  1830. X/* ROTATE_LEFT rotates x left n bits.
  1831. X */
  1832. X#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
  1833. X
  1834. X/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
  1835. XRotation is separate from addition to prevent recomputation.
  1836. X */
  1837. X#define FF(a, b, c, d, x, s, ac) { \
  1838. X (a) += F ((b), (c), (d)) + (x) + (md5file_word)(ac); \
  1839. X (a) = ROTATE_LEFT ((a), (s)); \
  1840. X (a) += (b); \
  1841. X  }
  1842. X#define GG(a, b, c, d, x, s, ac) { \
  1843. X (a) += G ((b), (c), (d)) + (x) + (md5file_word)(ac); \
  1844. X (a) = ROTATE_LEFT ((a), (s)); \
  1845. X (a) += (b); \
  1846. X  }
  1847. X#define HH(a, b, c, d, x, s, ac) { \
  1848. X (a) += H ((b), (c), (d)) + (x) + (md5file_word)(ac); \
  1849. X (a) = ROTATE_LEFT ((a), (s)); \
  1850. X (a) += (b); \
  1851. X  }
  1852. X#define II(a, b, c, d, x, s, ac) { \
  1853. X (a) += I ((b), (c), (d)) + (x) + (md5file_word)(ac); \
  1854. X (a) = ROTATE_LEFT ((a), (s)); \
  1855. X (a) += (b); \
  1856. X  }
  1857. X
  1858. X/* MD5 initialization. Begins an MD5 operation, writing a new context.
  1859. X */
  1860. Xvoid md5file_clear (context)
  1861. Xmd5file *context;
  1862. X{
  1863. X  context->count[0] = context->count[1] = 0;
  1864. X  /* Load magic initialization constants.  */
  1865. X  context->state[0] = 0x67452301;
  1866. X  context->state[1] = 0xefcdab89;
  1867. X  context->state[2] = 0x98badcfe;
  1868. X  context->state[3] = 0x10325476;
  1869. X}
  1870. X
  1871. X/* MD5 block update operation. Continues an MD5 message-digest
  1872. X  operation, processing another message block, and updating the
  1873. X  context.
  1874. X */
  1875. Xvoid md5file_addn (context, input, inputLen)
  1876. Xmd5file *context;
  1877. Xunsigned char *input;                                /* input block */
  1878. Xint inputLen;                     /* length of input block */
  1879. X{
  1880. X  unsigned int i, index, partLen;
  1881. X
  1882. X  /* Compute number of bytes mod 64 */
  1883. X  index = (unsigned int)((context->count[0] >> 3) & 0x3F);
  1884. X
  1885. X  /* Update number of bits */
  1886. X  if ((context->count[0] += ((md5file_word)inputLen << 3))
  1887. X   < ((md5file_word)inputLen << 3))
  1888. X context->count[1]++;
  1889. X  context->count[1] += ((md5file_word)inputLen >> 29);
  1890. X
  1891. X  partLen = 64 - index;
  1892. X
  1893. X  /* Transform as many times as possible.
  1894. X*/
  1895. X  if (inputLen >= partLen) {
  1896. X MD5_memcpy
  1897. X   ((POINTER)&context->buffer[index], (POINTER)input, partLen);
  1898. X MD5Transform (context->state, context->buffer);
  1899. X
  1900. X for (i = partLen; i + 63 < inputLen; i += 64)
  1901. X   MD5Transform (context->state, &input[i]);
  1902. X
  1903. X index = 0;
  1904. X  }
  1905. X  else
  1906. X i = 0;
  1907. X
  1908. X  /* Buffer remaining input */
  1909. X  MD5_memcpy
  1910. X ((POINTER)&context->buffer[index], (POINTER)&input[i],
  1911. X  inputLen-i);
  1912. X}
  1913. X
  1914. Xvoid md5file_add(context,c)
  1915. Xmd5file *context;
  1916. Xunsigned char c;
  1917. X{
  1918. X md5file_addn(context,&c,1);
  1919. X}
  1920. X
  1921. X/* MD5 finalization. Ends an MD5 message-digest operation, writing
  1922. X  the message digest and zeroizing the context.
  1923. X */
  1924. Xvoid md5file_hash (context,digest)
  1925. Xmd5file *context;
  1926. Xunsigned char digest[16];                         /* message digest */
  1927. X{
  1928. X  unsigned char bits[8];
  1929. X  unsigned int index, padLen;
  1930. X
  1931. X  /* Save number of bits */
  1932. X  Encode (bits, context->count, 8);
  1933. X
  1934. X  /* Pad out to 56 mod 64.  */
  1935. X  index = (unsigned int)((context->count[0] >> 3) & 0x3f);
  1936. X  padLen = (index < 56) ? (56 - index) : (120 - index);
  1937. X  md5file_addn (context, PADDING, padLen);
  1938. X
  1939. X  /* Append length (before padding) */
  1940. X  md5file_addn (context, bits, 8);
  1941. X  /* Store state in digest */
  1942. X  Encode (digest, context->state, 16);
  1943. X
  1944. X  /* Zeroize sensitive information.  */
  1945. X  MD5_memset ((POINTER)context, 0, sizeof (*context));
  1946. X}
  1947. X
  1948. X/* MD5 basic transformation. Transforms state based on block.
  1949. X */
  1950. Xstatic void MD5Transform (state, block)
  1951. Xmd5file_word state[4];
  1952. Xunsigned char block[64];
  1953. X{
  1954. X  md5file_word a = state[0], b = state[1], c = state[2], d = state[3], x[16];
  1955. X
  1956. X  Decode (x, block, 64);
  1957. X
  1958. X  /* Round 1 */
  1959. X  FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
  1960. X  FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
  1961. X  FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
  1962. X  FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
  1963. X  FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
  1964. X  FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
  1965. X  FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
  1966. X  FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
  1967. X  FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
  1968. X  FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
  1969. X  FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
  1970. X  FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
  1971. X  FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
  1972. X  FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
  1973. X  FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
  1974. X  FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
  1975. X
  1976. X /* Round 2 */
  1977. X  GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
  1978. X  GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
  1979. X  GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
  1980. X  GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
  1981. X  GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
  1982. X  GG (d, a, b, c, x[10], S22,  0x2441453); /* 22 */
  1983. X  GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
  1984. X  GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
  1985. X  GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
  1986. X  GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
  1987. X  GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
  1988. X  GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
  1989. X  GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
  1990. X  GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
  1991. X  GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
  1992. X  GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
  1993. X
  1994. X  /* Round 3 */
  1995. X  HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
  1996. X  HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
  1997. X  HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
  1998. X  HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
  1999. X  HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
  2000. X  HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
  2001. X  HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
  2002. X  HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
  2003. X  HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
  2004. X  HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
  2005. X  HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
  2006. X  HH (b, c, d, a, x[ 6], S34,  0x4881d05); /* 44 */
  2007. X  HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
  2008. X  HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
  2009. X  HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
  2010. X  HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
  2011. X
  2012. X  /* Round 4 */
  2013. X  II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
  2014. X  II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
  2015. X  II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
  2016. X  II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
  2017. X  II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
  2018. X  II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
  2019. X  II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
  2020. X  II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
  2021. X  II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
  2022. X  II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
  2023. X  II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
  2024. X  II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
  2025. X  II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
  2026. X  II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
  2027. X  II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
  2028. X  II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
  2029. X
  2030. X  state[0] += a;
  2031. X  state[1] += b;
  2032. X  state[2] += c;
  2033. X  state[3] += d;
  2034. X
  2035. X  /* Zeroize sensitive information.
  2036. X*/
  2037. X  MD5_memset ((POINTER)x, 0, sizeof (x));
  2038. X}
  2039. X
  2040. X/* Encodes input (md5file_word) into output (unsigned char). Assumes len is
  2041. X  a multiple of 4.
  2042. X */
  2043. Xstatic void Encode (output, input, len)
  2044. Xunsigned char *output;
  2045. Xmd5file_word *input;
  2046. Xunsigned int len;
  2047. X{
  2048. X  unsigned int i, j;
  2049. X
  2050. X  for (i = 0, j = 0; j < len; i++, j += 4) {
  2051. X output[j] = (unsigned char)(input[i] & 0xff);
  2052. X output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
  2053. X output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
  2054. X output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
  2055. X  }
  2056. X}
  2057. X
  2058. X/* Decodes input (unsigned char) into output (md5file_word). Assumes len is
  2059. X  a multiple of 4.
  2060. X */
  2061. Xstatic void Decode (output, input, len)
  2062. Xmd5file_word *output;
  2063. Xunsigned char *input;
  2064. Xunsigned int len;
  2065. X{
  2066. X  unsigned int i, j;
  2067. X
  2068. X  for (i = 0, j = 0; j < len; i++, j += 4)
  2069. X output[i] = ((md5file_word)input[j]) | (((md5file_word)input[j+1]) << 8) |
  2070. X   (((md5file_word)input[j+2]) << 16) | (((md5file_word)input[j+3]) << 24);
  2071. X}
  2072. X
  2073. X/* Note: Replace "for loop" with standard memcpy if possible.
  2074. X */
  2075. X
  2076. Xstatic void MD5_memcpy (output, input, len)
  2077. XPOINTER output;
  2078. XPOINTER input;
  2079. Xunsigned int len;
  2080. X{
  2081. X  unsigned int i;
  2082. X
  2083. X  for (i = 0; i < len; i++)
  2084. X output[i] = input[i];
  2085. X}
  2086. X
  2087. X/* Note: Replace "for loop" with standard memset if possible.
  2088. X */
  2089. Xstatic void MD5_memset (output, value, len)
  2090. XPOINTER output;
  2091. Xint value;
  2092. Xunsigned int len;
  2093. X{
  2094. X  unsigned int i;
  2095. X
  2096. X  for (i = 0; i < len; i++)
  2097. X ((char *)output)[i] = (char)value;
  2098. X}
  2099. END_OF_FILE
  2100. if test 10262 -ne `wc -c <'md5file.c'`; then
  2101.     echo shar: \"'md5file.c'\" unpacked with wrong size!
  2102. fi
  2103. # end of 'md5file.c'
  2104. fi
  2105. if test -f 'md5file.h' -a "${1}" != "-c" ; then 
  2106.   echo shar: Will not clobber existing file \"'md5file.h'\"
  2107. else
  2108. echo shar: Extracting \"'md5file.h'\" \(339 characters\)
  2109. sed "s/^X//" >'md5file.h' <<'END_OF_FILE'
  2110. X#ifndef MD5FILE_H
  2111. X#define MD5FILE_H
  2112. X
  2113. Xtypedef unsigned long md5file_word;
  2114. X
  2115. Xtypedef struct md5file
  2116. X {
  2117. X  md5file_word state[4];
  2118. X  md5file_word count[2];
  2119. X  unsigned char buffer[64];
  2120. X }
  2121. Xmd5file;
  2122. X
  2123. X#define MD5FILE_HASHLEN 16
  2124. X
  2125. Xextern void md5file_clear();
  2126. Xextern void md5file_add();
  2127. Xextern void md5file_addn();
  2128. Xextern void md5file_hash();
  2129. X
  2130. X#endif
  2131. END_OF_FILE
  2132. if test 339 -ne `wc -c <'md5file.h'`; then
  2133.     echo shar: \"'md5file.h'\" unpacked with wrong size!
  2134. fi
  2135. # end of 'md5file.h'
  2136. fi
  2137. if test -f 'snefru.1' -a "${1}" != "-c" ; then 
  2138.   echo shar: Will not clobber existing file \"'snefru.1'\"
  2139. else
  2140. echo shar: Extracting \"'snefru.1'\" \(865 characters\)
  2141. sed "s/^X//" >'snefru.1' <<'END_OF_FILE'
  2142. X.TH snefru 1
  2143. X.SH NAME
  2144. Xsnefru \- the Xerox Secure Hash Function, version 2.5a
  2145. X.SH SYNTAX
  2146. X.B snefru
  2147. X.SH DESCRIPTION
  2148. X.B snefru
  2149. Xcalculates a cryptographically strong one-way hash of its input.
  2150. X
  2151. X.B snefru
  2152. Xconforms to the
  2153. X.I summain
  2154. Xinterface.
  2155. XSee
  2156. X.B summain(1)
  2157. Xfor a description of
  2158. X.B snefru\fP's
  2159. Xoptions.
  2160. X.SH COMPATIBILITY
  2161. XThis is a clone of
  2162. XRalph Merkle's
  2163. X.B snefru
  2164. Xprogram.
  2165. XIf you find two inputs which produce the same output,
  2166. Xplease
  2167. Xverify first that
  2168. XMerkle's version produces the same output,
  2169. Xand then contact
  2170. Xhim at
  2171. Xmerkle@parc.xerox.com.
  2172. X.SH VERSION
  2173. Xsnefru 1.2, 7 July 1993.
  2174. X.SH AUTHOR
  2175. XMost of the work is done in
  2176. Xthe
  2177. X.B snefrufile
  2178. Xand
  2179. X.B snefru512
  2180. Xlibraries,
  2181. Xwhich are
  2182. Xderived from the Xerox Secure Hash Function
  2183. Xas implemented by Merkle.
  2184. XWrapper code
  2185. Xplaced into the public domain by Daniel J. Bernstein.
  2186. X.SH "SEE ALSO"
  2187. Xsummain(1),
  2188. Xsnefrufile(3),
  2189. Xsnefru512(3)
  2190. END_OF_FILE
  2191. if test 865 -ne `wc -c <'snefru.1'`; then
  2192.     echo shar: \"'snefru.1'\" unpacked with wrong size!
  2193. fi
  2194. # end of 'snefru.1'
  2195. fi
  2196. if test -f 'snefru.c' -a "${1}" != "-c" ; then 
  2197.   echo shar: Will not clobber existing file \"'snefru.c'\"
  2198. else
  2199. echo shar: Extracting \"'snefru.c'\" \(477 characters\)
  2200. sed "s/^X//" >'snefru.c' <<'END_OF_FILE'
  2201. X#include <stdio.h>
  2202. X#include "snefrufile.h"
  2203. X
  2204. Xstatic unsigned char h[SNEFRUFILE_HASHLEN];
  2205. Xstatic unsigned char input[1024];
  2206. X
  2207. Xvoid sum(fi,out)
  2208. XFILE *fi;
  2209. Xchar *out;
  2210. X{
  2211. X snefrufile s;
  2212. X int i;
  2213. X char *x;
  2214. X
  2215. X snefrufile_clear(&s);
  2216. X while (i = fread(input,1,sizeof(input),fi))
  2217. X   snefrufile_addn(&s,input,i);
  2218. X snefrufile_hash(&s,h);
  2219. X
  2220. X x = out;
  2221. X for (i = 0;i < SNEFRUFILE_HASHLEN;++i)
  2222. X  {
  2223. X   if (!(i & 3))
  2224. X     *x++ = ' ';
  2225. X   sprintf(x,"%02x",(int) h[i]);
  2226. X   x += strlen(x);
  2227. X  }
  2228. X *x = 0;
  2229. X}
  2230. END_OF_FILE
  2231. if test 477 -ne `wc -c <'snefru.c'`; then
  2232.     echo shar: \"'snefru.c'\" unpacked with wrong size!
  2233. fi
  2234. # end of 'snefru.c'
  2235. fi
  2236. if test -f 'snefru.tests' -a "${1}" != "-c" ; then 
  2237.   echo shar: Will not clobber existing file \"'snefru.tests'\"
  2238. else
  2239. echo shar: Extracting \"'snefru.tests'\" \(85 characters\)
  2240. sed "s/^X//" >'snefru.tests' <<'END_OF_FILE'
  2241. X 49a81803 84463870 1474b424 25867457 9773aebc 3b4c9ce7 aaef779b f400d781    snefru512.c
  2242. END_OF_FILE
  2243. if test 85 -ne `wc -c <'snefru.tests'`; then
  2244.     echo shar: \"'snefru.tests'\" unpacked with wrong size!
  2245. fi
  2246. # end of 'snefru.tests'
  2247. fi
  2248. if test -f 'snefru512.3' -a "${1}" != "-c" ; then 
  2249.   echo shar: Will not clobber existing file \"'snefru512.3'\"
  2250. else
  2251. echo shar: Extracting \"'snefru512.3'\" \(1580 characters\)
  2252. sed "s/^X//" >'snefru512.3' <<'END_OF_FILE'
  2253. X.TH snefru512 3
  2254. X.SH NAME
  2255. Xsnefru512 \- apply the Xerox Secure Hash Function to a 512-bit block
  2256. X.SH SYNTAX
  2257. X.B #include <snefru512.h>
  2258. X
  2259. Xvoid \fBsnefru512_setup()\fR;
  2260. X
  2261. Xvoid \fBsnefru512(\fIout\fB,\fIin\fB,\fIlev\fB)\fR;
  2262. X
  2263. Xsnefru512_word \fIout\fP[8];
  2264. X.br
  2265. Xsnefru512_word \fIin\fP[16];
  2266. X.br
  2267. Xint \fIlev\fP;
  2268. X.SH DESCRIPTION
  2269. X.B snefru512
  2270. Xis derived from the Xerox Secure Hash Function.
  2271. XIt hashes a 512-bit block
  2272. X.I in
  2273. Xinto a 256-bit block
  2274. X.I out\fP.
  2275. XThe hash function is cryptographically strong.
  2276. X
  2277. XTo hash
  2278. X.I in
  2279. Xinto
  2280. X.I out\fP,
  2281. Xcall
  2282. X.B snefru512(\fIout\fB,\fIin\fB,\fIlev\fB)\fR.
  2283. X.I out
  2284. Xand
  2285. X.I in
  2286. Xare arrays of
  2287. X8 and 16
  2288. Xsnefru512_words respectively.
  2289. Xsnefru512_word
  2290. Xis a 32-bit unsigned integer type.
  2291. X
  2292. X.I lev
  2293. Xis the Snefru security level,
  2294. Xany number from 2 through 8.
  2295. XSnefru-2 is fast but insecure.
  2296. XSnefru-4 might not be safe against
  2297. Xattacks by powerful future computers.
  2298. XSnefru-8 is very strong and not too slow for most applications.
  2299. X
  2300. XBefore calling
  2301. X.B snefru512
  2302. Xyou must call
  2303. X.B snefru512_setup()\fR.
  2304. XYou may call
  2305. X.B snefru512_setup()
  2306. Xany number of times.
  2307. X
  2308. XThe
  2309. XSnefru algorithm
  2310. Xwas designed by Ralph C. Merkle.
  2311. XIt is named after a Pharaoh of ancient Egypt.
  2312. XMerkle is offering a large cash reward to anyone who
  2313. Xcan break Snefru-4.
  2314. X.SH DEFINITION
  2315. XSee Ralph C. Merkle,
  2316. X.I A Fast Software One-Way Hash Function\fP.
  2317. X.SH VERSION
  2318. Xsnefru512 1.0, 1 June 1993.
  2319. X.SH AUTHOR
  2320. XThis code is essentially the same as
  2321. XMerkle's reference Snefru 2.0 implementation,
  2322. Xas modified by Rich Salz,
  2323. Xtogether with the Snefru 2.5 S boxes.
  2324. XThis adaptation was created by Daniel J. Bernstein.
  2325. X.SH "SEE ALSO"
  2326. Xsnefrufile(3)
  2327. END_OF_FILE
  2328. if test 1580 -ne `wc -c <'snefru512.3'`; then
  2329.     echo shar: \"'snefru512.3'\" unpacked with wrong size!
  2330. fi
  2331. # end of 'snefru512.3'
  2332. fi
  2333. if test -f 'snefru512.h' -a "${1}" != "-c" ; then 
  2334.   echo shar: Will not clobber existing file \"'snefru512.h'\"
  2335. else
  2336. echo shar: Extracting \"'snefru512.h'\" \(247 characters\)
  2337. sed "s/^X//" >'snefru512.h' <<'END_OF_FILE'
  2338. X#ifndef SNEFRU512_H
  2339. X#define SNEFRU512_H
  2340. X
  2341. Xtypedef unsigned long snefru512_word;
  2342. X
  2343. Xextern snefru512_word snefru512_sboxes[16][256];
  2344. Xextern snefru512_word snefru512_rotated[4][16][256];
  2345. X
  2346. Xextern void snefru512_setup();
  2347. Xextern void snefru512();
  2348. X
  2349. X#endif
  2350. END_OF_FILE
  2351. if test 247 -ne `wc -c <'snefru512.h'`; then
  2352.     echo shar: \"'snefru512.h'\" unpacked with wrong size!
  2353. fi
  2354. # end of 'snefru512.h'
  2355. fi
  2356. if test -f 'snefrufile.3' -a "${1}" != "-c" ; then 
  2357.   echo shar: Will not clobber existing file \"'snefrufile.3'\"
  2358. else
  2359. echo shar: Extracting \"'snefrufile.3'\" \(1638 characters\)
  2360. sed "s/^X//" >'snefrufile.3' <<'END_OF_FILE'
  2361. X.TH snefrufile 3
  2362. X.SH NAME
  2363. Xsnefrufile \- apply the Xerox Secure Hash Function to a stream
  2364. X.SH SYNTAX
  2365. X.B #include <snefrufile.h>
  2366. X
  2367. Xvoid \fBsnefrufile_clear(\fIs\fB)\fR;
  2368. X.br
  2369. Xvoid \fBsnefrufile_add(\fIs,c\fB)\fR;
  2370. X.br
  2371. Xvoid \fBsnefrufile_addn(\fIm,b,len\fB)\fR;
  2372. X.br
  2373. Xvoid \fBsnefrufile_hash(\fIs,h\fB)\fR;
  2374. X
  2375. Xsnefrufile *\fIs\fP;
  2376. X.br
  2377. Xunsigned char \fIc\fP;
  2378. X.br
  2379. Xunsigned char \fIh\fP[SNEFRUFILE_HASHLEN];
  2380. X.br
  2381. Xunsigned char *\fIb\fP;
  2382. X.br
  2383. Xint \fIlen\fR;
  2384. X.SH DESCRIPTION
  2385. X.B snefrufile
  2386. Xprovides a standard way to apply
  2387. XMerkle's
  2388. XSnefru-8 hash function
  2389. Xto a stream of unsigned characters.
  2390. X
  2391. X.I s
  2392. Xpoints to a snefrufile structure,
  2393. Xwhich accumulates the hash as
  2394. Xdata is fed in.
  2395. XBefore feeding in any data you must
  2396. Xcall
  2397. X.B snefrufile_clear(\fIs\fB)\fR.
  2398. XThen, for each unsigned character
  2399. X.I c
  2400. Xfrom the stream,
  2401. Xcall
  2402. X.B snefrufile_add(\fIs\fB,\fIc\fB)\fR.
  2403. X
  2404. XTo process an array
  2405. X.I b
  2406. Xof
  2407. X.I len
  2408. Xunsigned characters,
  2409. Xcall
  2410. X.B snefrufile_addn(\fIm\fB,\fIb\fB,\fIlen\fB)\fR.
  2411. XThis is faster than calling
  2412. X.B snefrufile_add
  2413. Xon each character in turn.
  2414. X
  2415. X.B snefrufile_hash(\fIs\fB,\fIh\fB)\fR
  2416. Xplaces the resulting hash into
  2417. X.I h\fP,
  2418. Xan array of bytes of
  2419. Xlength SNEFRUFILE_HASHLEN.
  2420. XYou may not use
  2421. X.I s
  2422. Xafter that without
  2423. Xagain calling
  2424. X.B snefrufile_clear(\fIs\fB)\fR.
  2425. X
  2426. XSNEFRUFILE_HASHLEN equals 32.
  2427. X.SH COMPATIBILITY
  2428. XThe
  2429. X.B snefrufile
  2430. Xlibrary
  2431. Xwas designed for compatibility
  2432. Xwith Merkle's original
  2433. X.B snefru
  2434. Xutility.
  2435. X.SH VERSION
  2436. Xsnefrufile 0.95, 8 July 1993.
  2437. X.SH AUTHOR
  2438. XPlaced into the public domain by Daniel J. Bernstein.
  2439. X.B snefrufile
  2440. Xis simply a wrapper around
  2441. X.B snefru512\fR,
  2442. Xwhich is derived from the Xerox Secure Hash Function.
  2443. X.SH "SEE ALSO"
  2444. Xsnefru(1),
  2445. Xsnefru512(3)
  2446. END_OF_FILE
  2447. if test 1638 -ne `wc -c <'snefrufile.3'`; then
  2448.     echo shar: \"'snefrufile.3'\" unpacked with wrong size!
  2449. fi
  2450. # end of 'snefrufile.3'
  2451. fi
  2452. if test -f 'snefrufile.c' -a "${1}" != "-c" ; then 
  2453.   echo shar: Will not clobber existing file \"'snefrufile.c'\"
  2454. else
  2455. echo shar: Extracting \"'snefrufile.c'\" \(2639 characters\)
  2456. sed "s/^X//" >'snefrufile.c' <<'END_OF_FILE'
  2457. X/* snefrufile.c, snefrufile.h: Snefru stream hashing library
  2458. XDaniel J. Bernstein, brnstnd@nyu.edu.
  2459. XDepends on snefru512.h.
  2460. XNo environment requirements.
  2461. X930708: snefrufile 0.95. Public domain.
  2462. X930708: Added snefrufile_addn.
  2463. X930708: Moved wm, wl, ctr out to static globals.
  2464. X930601: Baseline, snefrufile 0.8. Public domain.
  2465. XNo known patent problems.
  2466. X
  2467. XDocumentation in snefrufile.3.
  2468. X*/
  2469. X
  2470. X#include "snefru512.h"
  2471. X#include "snefrufile.h"
  2472. X
  2473. Xstatic snefru512_word tr[16] =
  2474. X/* backwards, for compatibility with Merkle's implementation */
  2475. X {
  2476. X  66051, 67438087, 134810123, 202182159, 269554195, 336926231,
  2477. X  404298267, 471670303, 539042339, 606414375, 673786411, 741158447,
  2478. X  808530483, 875902519, 943274555, 1010646591
  2479. X } ;
  2480. X
  2481. Xvoid snefrufile_clear(s)
  2482. Xsnefrufile *s;
  2483. X{
  2484. X int i;
  2485. X
  2486. X snefru512_setup(); /* XXX: called multiple times unnecessarily */
  2487. X
  2488. X for (i = 0;i < 64;++i) s->c[i] = 0;
  2489. X for (i = 0;i < 8;++i) s->len[i] = 0;
  2490. X s->n = 32;
  2491. X}
  2492. X
  2493. Xstatic unsigned char l[64];
  2494. Xstatic unsigned char m[32];
  2495. Xstatic snefru512_word *wm = &m[0];
  2496. Xstatic snefru512_word *wl = &l[0];
  2497. Xstatic unsigned char *ctr = &tr[0];
  2498. X
  2499. Xvoid snefrufile_addn(s,t,len)
  2500. Xsnefrufile *s;
  2501. Xregister unsigned char *t;
  2502. Xint len;
  2503. X{
  2504. X register int n;
  2505. X register int i;
  2506. X unsigned char newlen;
  2507. X
  2508. X i = len;
  2509. X while (i >= 32)
  2510. X  {
  2511. X   if (!++s->len[1]) if (!++s->len[2]) if (!++s->len[3]) if (!++s->len[4])
  2512. X   if (!++s->len[5]) if (!++s->len[6]) if (!++s->len[7]) ; /* too bad */
  2513. X   i -= 32;
  2514. X  }
  2515. X newlen = i << 3;
  2516. X if ((s->len[0] += newlen) < newlen)
  2517. X   if (!++s->len[1]) if (!++s->len[2]) if (!++s->len[3]) if (!++s->len[4])
  2518. X   if (!++s->len[5]) if (!++s->len[6]) if (!++s->len[7]) ; /* too bad */
  2519. X n = s->n;
  2520. X while (len--)
  2521. X  {
  2522. X   s->c[n++] = *t++;
  2523. X   if (n == 64)
  2524. X    {
  2525. X     for (i = 0;i < 64;++i) l[ctr[i]] = s->c[i];
  2526. X     snefru512(wm,wl,8);
  2527. X     for (i = 0;i < 32;++i) s->c[i] = m[ctr[i]];
  2528. X     n = 32;
  2529. X    }
  2530. X  }
  2531. X s->n = n;
  2532. X}
  2533. X
  2534. Xvoid snefrufile_add(s,c)
  2535. Xsnefrufile *s;
  2536. Xunsigned char c;
  2537. X{
  2538. X int n;
  2539. X register int i;
  2540. X
  2541. X n = s->n;
  2542. X s->c[n++] = c;
  2543. X if (!(s->len[0] += 8))
  2544. X   if (!++s->len[1]) if (!++s->len[2]) if (!++s->len[3]) if (!++s->len[4])
  2545. X   if (!++s->len[5]) if (!++s->len[6]) if (!++s->len[7]) ; /* too bad */
  2546. X if (n == 64)
  2547. X  {
  2548. X   for (i = 0;i < 64;++i) l[ctr[i]] = s->c[i];
  2549. X   snefru512(wm,wl,8);
  2550. X   for (i = 0;i < 32;++i) s->c[i] = m[ctr[i]];
  2551. X   n = 32;
  2552. X  }
  2553. X s->n = n;
  2554. X}
  2555. X
  2556. Xvoid snefrufile_hash(s,h)
  2557. Xsnefrufile *s;
  2558. Xunsigned char *h;
  2559. X{
  2560. X int len[8];
  2561. X int i;
  2562. X
  2563. X for (i = 0;i < 8;++i) len[i] = s->len[i];
  2564. X while (s->n != 32) snefrufile_add(s,(unsigned char) 0);
  2565. X while (s->n != 56) snefrufile_add(s,(unsigned char) 0);
  2566. X for (i = 0;i < 8;++i) snefrufile_add(s,len[7 - i]);
  2567. X for (i = 0;i < 32;++i) h[i] = s->c[i];
  2568. X}
  2569. END_OF_FILE
  2570. if test 2639 -ne `wc -c <'snefrufile.c'`; then
  2571.     echo shar: \"'snefrufile.c'\" unpacked with wrong size!
  2572. fi
  2573. # end of 'snefrufile.c'
  2574. fi
  2575. if test -f 'snefrufile.h' -a "${1}" != "-c" ; then 
  2576.   echo shar: Will not clobber existing file \"'snefrufile.h'\"
  2577. else
  2578. echo shar: Extracting \"'snefrufile.h'\" \(307 characters\)
  2579. sed "s/^X//" >'snefrufile.h' <<'END_OF_FILE'
  2580. X#ifndef SNEFRUFILE_H
  2581. X#define SNEFRUFILE_H
  2582. X
  2583. Xtypedef struct snefrufile
  2584. X {
  2585. X  unsigned char c[64];
  2586. X  int n;
  2587. X  unsigned char len[8];
  2588. X }
  2589. Xsnefrufile;
  2590. X
  2591. X#define SNEFRUFILE_HASHLEN 32
  2592. X
  2593. Xextern void snefrufile_clear();
  2594. Xextern void snefrufile_add();
  2595. Xextern void snefrufile_addn();
  2596. Xextern void snefrufile_hash();
  2597. X
  2598. X#endif
  2599. END_OF_FILE
  2600. if test 307 -ne `wc -c <'snefrufile.h'`; then
  2601.     echo shar: \"'snefrufile.h'\" unpacked with wrong size!
  2602. fi
  2603. # end of 'snefrufile.h'
  2604. fi
  2605. if test -f 'summain.1' -a "${1}" != "-c" ; then 
  2606.   echo shar: Will not clobber existing file \"'summain.1'\"
  2607. else
  2608. echo shar: Extracting \"'summain.1'\" \(2354 characters\)
  2609. sed "s/^X//" >'summain.1' <<'END_OF_FILE'
  2610. X.TH summain 1
  2611. X.SH NAME
  2612. Xsummain \- generic checksum program interface
  2613. X.SH SYNTAX
  2614. X.I summain
  2615. X[
  2616. X\fB\-cgfFiIbB\fP
  2617. X] [
  2618. X\fIfile ...\fP
  2619. X]
  2620. X.SH DESCRIPTION
  2621. X.I summain
  2622. Xis a generic interface for programs which compute checksums.
  2623. XThere is no actual
  2624. X.B summain
  2625. Xprogram.
  2626. XInstead, several other programs,
  2627. Xsuch as
  2628. X.B cksum
  2629. Xand
  2630. X.B fingerprint\fP,
  2631. Xall conform to
  2632. Xthe
  2633. X.I summain
  2634. Xinterface.
  2635. X
  2636. X.I summain
  2637. Xcomputes checksums for some number of files.
  2638. XNormally it takes the filenames as arguments,
  2639. Xopens the files in binary mode,
  2640. Xcomputes their checksums,
  2641. Xand prints the checksums (with filenames) on standard output.
  2642. X
  2643. XA checksum never contains the characters tab, space, newline, or null.
  2644. XOther features of a checksum depend on the particular program.
  2645. X
  2646. X.I summain
  2647. Xfollows the
  2648. X.B getopt
  2649. Xstandard.
  2650. XIts options are summarized here.
  2651. X.TP
  2652. X.B \-b
  2653. XOpen files in binary mode (default).
  2654. X.TP
  2655. X.B \-B
  2656. XOpen files in text mode.
  2657. X.TP
  2658. X.B \-i
  2659. XRead filenames from input, and ignore any filename arguments.
  2660. X.TP
  2661. X.B \-I
  2662. XUse arguments as filenames (default).
  2663. XIf no arguments are given,
  2664. X.I summain
  2665. Xreads the standard input as a file.
  2666. XOtherwise it ignores
  2667. Xthe input.
  2668. X.TP
  2669. X.B \-f
  2670. XWhen the
  2671. X.B \-i
  2672. Xoption is in effect,
  2673. Xread input lines with the
  2674. Xsame format as the usual output
  2675. Xof
  2676. X.I summain\fP.
  2677. XIn other words, look for the first tab on each input line,
  2678. Xand use the filename following that tab.
  2679. X.TP
  2680. X.B \-F
  2681. XWhen the
  2682. X.B \-i
  2683. Xoption is in effect,
  2684. Xread filenames as entire input lines (default).
  2685. X.TP
  2686. X.B \-g
  2687. XGenerate checksums (default).
  2688. X.I summain
  2689. Xwill print each checksum, followed by a tab and the
  2690. Xname of the file,
  2691. Xas a separate line on standard output.
  2692. XThe checksum of the standard input is printed with a tab
  2693. Xbut no filename.
  2694. X.TP
  2695. X.B \-c
  2696. XCheck checksums.
  2697. XThis option forces
  2698. X.B \-fi\fP.
  2699. X.I summain
  2700. Xwill read any number of input lines,
  2701. Xeach containing a purported checksum, a tab, and a filename.
  2702. X.I summain
  2703. Xwill open each file, compute its checksum, and compare the
  2704. Xchecksum to the purported checksum.
  2705. X.SH "EXIT VALUE"
  2706. X0 normally.
  2707. X1 for usage messages.
  2708. X2 if a file could not be opened for reading.
  2709. X3 with option
  2710. X.B \-c
  2711. Xif any checksums failed to match.
  2712. X(Exit value 3 overrides exit value 2.)
  2713. X.SH BUGS
  2714. XNone known.
  2715. X.SH VERSION
  2716. Xsummain version 0.9, 13 July 1993.
  2717. X.SH AUTHOR
  2718. XPlaced into the public domain by Daniel J. Bernstein.
  2719. X.SH "SEE ALSO"
  2720. X.B cksum(1)\fP,
  2721. X.B fingerprint(1)\fP,
  2722. X.B md5(1)\fP,
  2723. X.B snefru(1)\fP
  2724. END_OF_FILE
  2725. if test 2354 -ne `wc -c <'summain.1'`; then
  2726.     echo shar: \"'summain.1'\" unpacked with wrong size!
  2727. fi
  2728. # end of 'summain.1'
  2729. fi
  2730. if test -f 'summain.c' -a "${1}" != "-c" ; then 
  2731.   echo shar: Will not clobber existing file \"'summain.c'\"
  2732. else
  2733. echo shar: Extracting \"'summain.c'\" \(2101 characters\)
  2734. sed "s/^X//" >'summain.c' <<'END_OF_FILE'
  2735. X#include <stdio.h>
  2736. X#include <errno.h>
  2737. Xextern int errno;
  2738. X#include "getopt.h"
  2739. X
  2740. X#define TAB '    ' /*XXX*/
  2741. X
  2742. Xint flagcheck = 0;
  2743. Xint flagin = 0;
  2744. Xint flaghin = 0;
  2745. Xint flagbinary = 1;
  2746. X
  2747. Xint flagallmatch = 1;
  2748. Xint flagreaderr = 0;
  2749. X
  2750. Xchar *oldhash; /* defined for the duration of doit, if flagcheck */
  2751. X
  2752. Xvoid doit(fi,fn)
  2753. XFILE *fi;
  2754. Xchar *fn;
  2755. X{
  2756. X static char out[100];
  2757. X
  2758. X sum(fi,out);
  2759. X
  2760. X if (flagcheck)
  2761. X  {
  2762. X   if (strcmp(oldhash,out))
  2763. X    {
  2764. X     fprintf(stderr,"%s: warning: %s hash does not match\n"
  2765. X       ,optprogname,fn);
  2766. X     flagallmatch = 0;
  2767. X    }
  2768. X  }
  2769. X else
  2770. X  {
  2771. X   fputs(out,stdout);
  2772. X   putchar(TAB);
  2773. X   puts(fn);
  2774. X  }
  2775. X}
  2776. X
  2777. Xvoid handle(x)
  2778. Xchar *x;
  2779. X{
  2780. X FILE *fi;
  2781. X
  2782. X fi = fopen(x,flagbinary ? "rb" : "r");
  2783. X if (!fi)
  2784. X  {
  2785. X   int errnobak;
  2786. X   errnobak = errno;
  2787. X   fprintf(stderr,"%s: warning: cannot open %s for "
  2788. X     ,optprogname,x);
  2789. X   errno = errnobak;
  2790. X   perror("reading");
  2791. X   flagreaderr = 1;
  2792. X  }
  2793. X else
  2794. X  {
  2795. X   doit(fi,x);
  2796. X   fclose(fi);
  2797. X  }
  2798. X}
  2799. X
  2800. Xchar line[1000];
  2801. X
  2802. Xmain(argc,argv)
  2803. Xint argc;
  2804. Xchar **argv;
  2805. X{
  2806. X int opt;
  2807. X
  2808. X while ((opt = getopt(argc,argv,"cgfFiIbB")) != opteof)
  2809. X   switch(opt)
  2810. X    {
  2811. X     case 'c': flagcheck = 1; break;
  2812. X     case 'g': flagcheck = 0; break;
  2813. X     case 'f': flaghin = 0; break;
  2814. X     case 'F': flaghin = 1; break;
  2815. X     case 'i': flagin = 1; break;
  2816. X     case 'I': flagin = 0; break;
  2817. X     case 'b': flagbinary = 1; break;
  2818. X     case 'B': flagbinary = 0; break;
  2819. X     case '?': default: exit(1);
  2820. X    }
  2821. X argc -= optind;
  2822. X argv += optind;
  2823. X
  2824. X if (flagcheck)
  2825. X   flagin = flaghin = 1;
  2826. X
  2827. X if (flagin)
  2828. X   while (fgets(line,sizeof(line),stdin))
  2829. X    {
  2830. X     char *x;
  2831. X     int len;
  2832. X     x = line;
  2833. X     if (flaghin)
  2834. X      {
  2835. X       while (*x && (*x != '\n') && (*x != TAB)) ++x;
  2836. X       if (*x == TAB) *x++ = 0;
  2837. X      }
  2838. X     if (!*x) continue; /*XXX*/
  2839. X     len = strlen(x);
  2840. X     if (x[len - 1] == '\n') x[len - 1] = 0;
  2841. X     if (!*x) continue; /*XXX*/
  2842. X     if (flagcheck)
  2843. X       oldhash = line;
  2844. X     handle(x);
  2845. X    }
  2846. X else
  2847. X   if (*argv)
  2848. X     while (*argv)
  2849. X      {
  2850. X       handle(*argv);
  2851. X       ++argv;
  2852. X      }
  2853. X   else
  2854. X     doit(stdin,""); /*XXX*/
  2855. X
  2856. X if (!flagallmatch)
  2857. X   exit(3);
  2858. X if (flagreaderr)
  2859. X   exit(2);
  2860. X exit(0);
  2861. X}
  2862. END_OF_FILE
  2863. if test 2101 -ne `wc -c <'summain.c'`; then
  2864.     echo shar: \"'summain.c'\" unpacked with wrong size!
  2865. fi
  2866. # end of 'summain.c'
  2867. fi
  2868. echo shar: End of archive 1 \(of 2\).
  2869. cp /dev/null ark1isdone
  2870. MISSING=""
  2871. for I in 1 2 ; do
  2872.     if test ! -f ark${I}isdone ; then
  2873.     MISSING="${MISSING} ${I}"
  2874.     fi
  2875. done
  2876. if test "${MISSING}" = "" ; then
  2877.     echo You have unpacked both archives.
  2878.     rm -f ark[1-9]isdone
  2879. else
  2880.     echo You still need to unpack the following archives:
  2881.     echo "        " ${MISSING}
  2882. fi
  2883. ##  End of shell archive.
  2884. exit 0
  2885.