home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume41 / mdigest / part03 < prev    next >
Internet Message Format  |  1994-03-24  |  49KB

  1. From: M.Gream@uts.edu.au (Matthew Gream)
  2. Newsgroups: comp.sources.misc
  3. Subject: v41i139: mdigest - message digest library, Part03/03
  4. Date: 28 Feb 1994 18:26:19 -0000
  5. Sender: aem@aber.ac.uk
  6. Approved: aem@aber.ac.uk
  7. Message-ID: <2ktd0b$107@uk-usenet.uk.sun.com>
  8. X-Md4-Signature: 0909afb00f2d22cd68dad338323acceb
  9.  
  10. Submitted-by: M.Gream@uts.edu.au (Matthew Gream)
  11. Posting-number: Volume 41, Issue 139
  12. Archive-name: mdigest/part03
  13. Environment: C
  14.  
  15. #! /bin/sh
  16. # into a shell via "sh file" or similar.  To overwrite existing files,
  17. # type "sh file -c".
  18. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  19. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  20. # Contents:  CHECKSUMS Makefile haval-if.c haval.h license.txt md4-if.c
  21. #   md4.h md5-if.c md5.h mdigest.h shs-if.c shs.h utility.c
  22. # Wrapped by alecm@uk-usenet on Thu Feb 24 09:36:44 1994
  23. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  24. echo If this archive is complete, you will see the following message:
  25. echo '          "shar: End of archive 3 (of 3)."'
  26. if test -f 'CHECKSUMS' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'CHECKSUMS'\"
  28. else
  29.   echo shar: Extracting \"'CHECKSUMS'\" \(4908 characters\)
  30.   sed "s/^X//" >'CHECKSUMS' <<'END_OF_FILE'
  31. XEXPORT : 97 bytes
  32. X  md4      : 3ac4f1f5f90b8b1f50416125729f1baa
  33. X  shs      : e4c0e82642034a2e1fb1ea8052ca72fd4243165d
  34. X  md5      : 151cbda69cfd23e6120ee4f65fb7dd8d
  35. X  haval    : be77c00fc6ba285d78d2e2c4918f7358
  36. XMakefile : 598 bytes
  37. X  md4      : b7189b9e9dd45996a6eb64e1ff56d487
  38. X  shs      : b08571682e27ba4a502ad7d556a75af0fd35ceb4
  39. X  md5      : d9f729f47f134cad9da76e5757e9fedb
  40. X  haval    : 5d0f1e5c45462d4e6573e8d917a20813
  41. XREADME : 10157 bytes
  42. X  md4      : e3c49ed13ddd7e06c60c54a6b4787366
  43. X  shs      : 06c1c80b4e18a7512b36eb2c30faf24a7b5eaf48
  44. X  md5      : 06dc11c849fadf75b9a279f5fe6582f5
  45. X  haval    : e3b2445af1096d6d41abfb444d23a917
  46. Xhaval-if.c : 3024 bytes
  47. X  md4      : 53cab1c8835daeb44d157e889cae8542
  48. X  shs      : 6ae9ce9504342fec2298004b77cd1d71210a5d2d
  49. X  md5      : 77aea8bc4f32f6e87826957713ee3ec8
  50. X  haval    : 7722a0f85bff94f7838b33632d30f728
  51. Xhaval.c : 26139 bytes
  52. X  md4      : e317891d8b9480b9a1446f779ea6ba7a
  53. X  shs      : 3051aec69d62d2d912e961d765bc3b2834d0a172
  54. X  md5      : 8eed73ca3a388848aad8d713ec37a101
  55. X  haval    : 411dbdbde75d51143333789f7724cce4
  56. Xhaval.h : 2980 bytes
  57. X  md4      : f3b035277bd40d67791c140029f5fca6
  58. X  shs      : da13bca519d71a25c666f11461c43c5d896dac5a
  59. X  md5      : 153c94e7dcbab4660a6ccb916ede4781
  60. X  haval    : 28b33bf339aefa4543d441c7e217fcb9
  61. Xlicense.txt : 3733 bytes
  62. X  md4      : 741462d6ce28e1cd0b9c32a9173fb4e4
  63. X  shs      : 3de46d78eabeac4c1f87149a5b0085ef2ec11024
  64. X  md5      : 33386c167d8f012b437e70c3c0f98a94
  65. X  haval    : c38ae05ca51511935ae867442f0f8ee7
  66. Xmd4-if.c : 2963 bytes
  67. X  md4      : eb51bbba579f6156b33917a5fc812e31
  68. X  shs      : 53799be5b79bda841fde3bc20582e00fd80b8b1a
  69. X  md5      : 0825b96ab0428ccd00d2f976a7b152da
  70. X  haval    : 6067cc0ea94e504e457da42007d58b72
  71. Xmd4.c : 8249 bytes
  72. X  md4      : dcd9c022b19bd3046b8460a2c243491b
  73. X  shs      : ac634f340ceb8bb3f1323002af85411cc7cb9811
  74. X  md5      : 1587b45eb7339f13dec1a5b4ea923746
  75. X  haval    : 8e05626384ec85374ec7c84849659ff8
  76. Xmd4.h : 1885 bytes
  77. X  md4      : 44ac5f61de4ff311b28f2cfcc4dbab99
  78. X  shs      : dafdf2f0db16aafc1448cc85c72e17ccac95bb23
  79. X  md5      : 86cc0bcbd18a73f1b4123437b9769f0f
  80. X  haval    : 58b4bc1b974069f1030759926b705dfa
  81. Xmd5-if.c : 2964 bytes
  82. X  md4      : c06567cc83c254b77e86bd3d7a32fd40
  83. X  shs      : 92925a403ca84a11654ced4074fee2188a32e458
  84. X  md5      : be9119aee609c6375046a3df1d75492e
  85. X  haval    : e37ca5c533d46dcc7eec78dc2f16f233
  86. Xmd5.c : 9847 bytes
  87. X  md4      : d84c616028ea36c08c26441c922ee4e0
  88. X  shs      : 28c779bf5821d147e4cb43bfd1b52dfed138decd
  89. X  md5      : 394d19028b0774e842372ce6cfb971ea
  90. X  haval    : 330dbb5ff4efc6c92492b1067ba52943
  91. Xmd5.h : 1885 bytes
  92. X  md4      : 759872f325c96abce82e408e7f7153f8
  93. X  shs      : f9978e289707aa2b8fe7d9ef3e5a3227a7db3018
  94. X  md5      : d7fa2167486edc450e7a1c73ae1eaada
  95. X  haval    : 038ecea7854a1d024a55441633b240aa
  96. Xmdigest.c : 10961 bytes
  97. X  md4      : 36d674aea8350948bfe1bb8051efd4ff
  98. X  shs      : 3ed687237403187b77f25e4102fdf4b70cff8862
  99. X  md5      : fc43047ad2b642f845acecfdc88975bb
  100. X  haval    : 4967a23bda802f8acf739dfa2c2bc6cb
  101. Xmdigest.h : 8184 bytes
  102. X  md4      : bcde76cbc21787d133f3f255bf07344e
  103. X  shs      : 6bdb9a733ada0e07d871193992462962c69b9750
  104. X  md5      : ffb96e9124d0e69741bd6475d566a51d
  105. X  haval    : 8326ad6425ab95d13a13836251e70e97
  106. Xmfile.c : 8644 bytes
  107. X  md4      : e6000a5b552dda4103679b1fede5690d
  108. X  shs      : 20cfcd4c1efe86702891d60c2926fce32a5e8e18
  109. X  md5      : 8d4ace4e886820e123fd779e9253f66b
  110. X  haval    : d43cb7cf0172a494d3f7a58e15511464
  111. Xmtest.c : 11052 bytes
  112. X  md4      : 972ce79b66abf9b4d762318f9bfb40ce
  113. X  shs      : c43195c45cb0f79c5cf95d3c6615d94e06e803df
  114. X  md5      : 0f7a7e2c5671f000b1d4e6d2b9ecf2b5
  115. X  haval    : 5db33ece31d35e3526b294f67e5434b1
  116. Xshs-if.c : 3568 bytes
  117. X  md4      : ca050edf795ef0a5d6db2f4df6ac2ccd
  118. X  shs      : 5d05654a1bb62ec8308b815c454fe2e6ac8d8014
  119. X  md5      : f817be75acb95e6f06b013cf47f44761
  120. X  haval    : c11cd17aad8024745957cb55f487f9f0
  121. Xshs-old.c : 8625 bytes
  122. X  md4      : d7371df64f71187475ab94ee45a24c1f
  123. X  shs      : e5c6a9d78f4d137a3cdfada467fa7fe28c6e1c55
  124. X  md5      : e69390167a9e3351a8126334a27eaf68
  125. X  haval    : aabebccdd08e2b7d9e67cf1a069f9648
  126. Xshs-old.h : 1237 bytes
  127. X  md4      : b5622e691981b7f2ea5b1fe8aa9c0ef5
  128. X  shs      : 3004e0f2462db45d5fd2a4b5ff5520644a16f27a
  129. X  md5      : 2edf211dd753cedb1c0c9824eaab716d
  130. X  haval    : 4a59a814c90a8180ce86c0c01a493f9b
  131. Xshs.c : 12355 bytes
  132. X  md4      : 51b876be3c89e403877e589a2c1eb4fe
  133. X  shs      : 86906cc236a78cb35f225b578a44c25ea91b3f57
  134. X  md5      : a90364e8128b70875ef5f199528c1025
  135. X  haval    : 02dcaf11d501af82dbd93163853928a8
  136. Xshs.h : 1619 bytes
  137. X  md4      : 7f5331a02c3fe9923901218e198dd691
  138. X  shs      : 7a4182de7198c93466ed46f56afa229f2cd26e44
  139. X  md5      : 4a1d9b2cd015186d0848a52fbda0ed32
  140. X  haval    : b2ebd0355313ceb85842491f82c2c4ee
  141. Xutility.c : 3574 bytes
  142. X  md4      : 9eea7d930f09212c6353de51c5b031c0
  143. X  shs      : bb100d514f8658b5451109a9b80f6d4a87608d4d
  144. X  md5      : 37d0e42deb7a9bccd13ebb3ab8707610
  145. X  haval    : 5ef3fc0c3940395122754acab320875a
  146. END_OF_FILE
  147.   if test 4908 -ne `wc -c <'CHECKSUMS'`; then
  148.     echo shar: \"'CHECKSUMS'\" unpacked with wrong size!
  149.   fi
  150.   # end of 'CHECKSUMS'
  151. fi
  152. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  153.   echo shar: Will not clobber existing file \"'Makefile'\"
  154. else
  155.   echo shar: Extracting \"'Makefile'\" \(598 characters\)
  156.   sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  157. X
  158. XCC      = cc
  159. XAR    = ar
  160. XRANLIB    = ranlib
  161. X
  162. XCFLAGS  = -I. -O4 #-Wall
  163. XLDFLAGS = $(CFLAGS) -s
  164. XARFLAGS = rc
  165. X
  166. XLIB     = mdigest.a
  167. XLIB_OBJS= mdigest.o utility.o \
  168. X      md4.o md4-if.o \
  169. X      md5.o md5-if.o \
  170. X      shs.o shs-if.o \
  171. X      haval.o haval-if.o
  172. X
  173. X# ---
  174. X
  175. Xall: $(LIB) mfile mtest
  176. X
  177. X# ---
  178. X
  179. X$(LIB): $(LIB_OBJS)
  180. X    rm -f $(LIB)
  181. X    $(AR) $(ARFLAGS) $(LIB) $(LIB_OBJS)
  182. X    $(RANLIB) $(LIB)
  183. X
  184. Xmfile: $(LIB) mfile.o
  185. X    $(CC) $(LDFLAGS) -o mfile mfile.o $(LIB)
  186. X
  187. Xmtest: $(LIB) mtest.o
  188. X    $(CC) $(LDFLAGS) -o mtest mtest.o $(LIB)
  189. X
  190. X# ---
  191. X
  192. Xclean:
  193. X    rm -f $(LIB_OBJS) mfile.o mtest.o a.out core
  194. X
  195. Xclobber: clean
  196. X    rm -f $(LIB) mfile mtest
  197. X
  198. END_OF_FILE
  199.   if test 598 -ne `wc -c <'Makefile'`; then
  200.     echo shar: \"'Makefile'\" unpacked with wrong size!
  201.   fi
  202.   # end of 'Makefile'
  203. fi
  204. if test -f 'haval-if.c' -a "${1}" != "-c" ; then 
  205.   echo shar: Will not clobber existing file \"'haval-if.c'\"
  206. else
  207.   echo shar: Extracting \"'haval-if.c'\" \(3024 characters\)
  208.   sed "s/^X//" >'haval-if.c' <<'END_OF_FILE'
  209. X
  210. X/* -------------------------------------------------------------------- */
  211. X/*                                                                      */
  212. X/*  Secure Asyncronous Communications Subsystem (SACS)                  */
  213. X/*  (C) 1994 Matthew Gream <M.Gream@uts.edu.au>                         */
  214. X/*                                                                      */
  215. X/*  You have been given a limited license to use and distribute this    */
  216. X/*  library. You should have received this license with the original    */
  217. X/*  release package of this library, named "license.txt" and entitled   */
  218. X/*  "SACS SOFTWARE LICENSE". In the event that you have not read or     */
  219. X/*  understood this license, regardless of reason, you may do nothing   */
  220. X/*  with this library other than read it for self-awareness.            */
  221. X/*                                                                      */
  222. X/* -------------------------------------------------------------------- */
  223. X
  224. X/* $Id: haval-if.c%v 0.90 1994/02/22 20:37:24 matt Exp $
  225. X */
  226. X
  227. X/*
  228. X *  File:         haval-if.c
  229. X *  Description:  interface to haval message digest
  230. X */
  231. X
  232. X#include <mdigest.h>
  233. X#include "haval.h"
  234. X
  235. X
  236. X/* -------------------------------------------------------------------- */
  237. X/* function    : HAVAL_CREATE                                           */
  238. X/* description : individually setup a haval context                     */
  239. X/* -------------------------------------------------------------------- */
  240. XSTATIC err_code
  241. XHAVAL_CREATE (ctx)
  242. X    md_ctx*         ctx;            /* context to setup                 */
  243. X{
  244. X    if (ctx->priv == NULL)
  245. X      ((haval_state*)ctx->priv) = (haval_state*)mem_get (sizeof(haval_state), MEMOPT_CLEAR);
  246. X
  247. X    return (err_ok);
  248. X}
  249. X
  250. X
  251. X/* -------------------------------------------------------------------- */
  252. X/* function    : HAVAL_DESTROY                                          */
  253. X/* description : shutdown a previously allocated context                */
  254. X/* -------------------------------------------------------------------- */
  255. XSTATIC err_code
  256. XHAVAL_DESTROY (ctx)
  257. X    md_ctx*         ctx;            /* context to deallocate            */
  258. X{
  259. X    if (ctx->priv != NULL)
  260. X      mem_free (ctx->priv);
  261. X
  262. X    ctx->priv = NULL;
  263. X    return (err_ok);
  264. X}
  265. X
  266. X
  267. X/* -------------------------------------------------------------------- */
  268. X/* function    : HAVAL_REGISTER                                         */
  269. X/* description : register and setup haval info structure                */
  270. X/* -------------------------------------------------------------------- */
  271. XGLOBAL err_code
  272. XHAVAL_REGISTER (m)
  273. X    md_info*        m;              /* info structure to fill out       */
  274. X{
  275. X    m->block_sz     = 128;
  276. X    m->hash_sz      = FPTLEN >> 3;
  277. X
  278. X    m->create       = HAVAL_CREATE;
  279. X    m->destroy      = HAVAL_DESTROY;
  280. X    m->deregister   = NULL;
  281. X
  282. X    m->init         = haval_start;
  283. X    m->update       = haval_hash;
  284. X    m->final        = haval_end;
  285. X
  286. X    return (err_ok);
  287. X}
  288. X
  289. X/* -------------------------------------------------------------------- */
  290. X
  291. END_OF_FILE
  292.   if test 3024 -ne `wc -c <'haval-if.c'`; then
  293.     echo shar: \"'haval-if.c'\" unpacked with wrong size!
  294.   fi
  295.   # end of 'haval-if.c'
  296. fi
  297. if test -f 'haval.h' -a "${1}" != "-c" ; then 
  298.   echo shar: Will not clobber existing file \"'haval.h'\"
  299. else
  300.   echo shar: Extracting \"'haval.h'\" \(2980 characters\)
  301.   sed "s/^X//" >'haval.h' <<'END_OF_FILE'
  302. X
  303. X/*  -- derived from original havalapp.h and haval.h
  304. X *  -- mgream: endian definitions not needed, they are computed run time
  305. X *  -- mgream: changed prototypes from ansi (for compat)
  306. X *
  307. X *  havalapp.h:  specifies the following three constants needed to
  308. X *               compile the HAVAL hashing library:
  309. X *                     LITTLE_ENDIAN, PASS and FPTLEN
  310. X *
  311. X *  Descriptions:
  312. X *
  313. X *   LITTLE_ENDIAN  define this only if your machine is little-endian
  314. X *                  (such as 80X86 family). 
  315. X *
  316. X *         Note:
  317. X *            1. In general, HAVAL is faster on a little endian
  318. X *               machine than on a big endian one.
  319. X *
  320. X *            2. The test program "havaltest.c" provides an option
  321. X *               for testing the endianity of your machine.
  322. X *
  323. X *            3. The speed of HAVAL is even more remarkable on a
  324. X *               machine that has a large number of internal registers.
  325. X *
  326. X *   PASS     define the number of passes        (3, 4, or 5)
  327. X *   FPTLEN   define the length of a fingerprint (128, 160, 192, 224 or 256)
  328. X */
  329. X
  330. X/*#define LITTLE_ENDIAN*/
  331. X
  332. X#ifndef PASS
  333. X#define PASS       3        /* 3, 4, or 5 */
  334. X#endif
  335. X
  336. X#ifndef FPTLEN  
  337. X#define FPTLEN     128      /* 128, 160, 192, 224 or 256 */
  338. X#endif
  339. X
  340. X/*
  341. X *  haval.h:  specifies the interface to the HAVAL (V.1) hashing library.
  342. X *
  343. X *      HAVAL is a one-way hashing algorithm with the following
  344. X *      collision-resistant property:
  345. X *             It is computationally infeasible to find two or more
  346. X *             messages that are hashed into the same fingerprint.
  347. X *
  348. X *  Reference:
  349. X *       Y. Zheng, J. Pieprzyk and J. Seberry:
  350. X *       ``HAVAL --- a one-way hashing algorithm with variable
  351. X *       length of output'', Advances in Cryptology --- AUSCRYPT'92,
  352. X *       Lecture Notes in Computer Science, Springer-Verlag, 1993.
  353. X *
  354. X *      This library provides routines to hash
  355. X *        -  a string,
  356. X *        -  a file,
  357. X *        -  input from the standard input device,
  358. X *        -  a 32-word block, and
  359. X *        -  a string of specified length.
  360. X *
  361. X *  Author:     Yuliang Zheng
  362. X *              Department of Computer Science
  363. X *              University of Wollongong
  364. X *              Wollongong, NSW 2522, Australia
  365. X *              Email: yuliang@cs.uow.edu.au
  366. X *              Voice: +61 42 21 4331 (office)
  367. X *
  368. X *  Date:       June 1993
  369. X *
  370. X *      Copyright (C) 1993 by C^3SR. All rights reserved. 
  371. X *      This program may not be sold or used as inducement to
  372. X *      buy a product without the written permission of C^3SR.
  373. X */
  374. X
  375. Xtypedef unsigned long int haval_word; /* a HAVAL word = 32 bits */
  376. X
  377. Xtypedef struct {
  378. X  haval_word    count[2];                /* number of bits in a message */
  379. X  haval_word    fingerprint[8];          /* current state of fingerprint */    
  380. X  haval_word    block[32];               /* buffer for a 32-word block */ 
  381. X  unsigned char remainder[32*4];         /* unhashed chars (No.<128) */   
  382. X} haval_state;
  383. X
  384. Xvoid haval_start ();
  385. Xvoid haval_hash ();
  386. Xvoid haval_end ();
  387. X
  388. END_OF_FILE
  389.   if test 2980 -ne `wc -c <'haval.h'`; then
  390.     echo shar: \"'haval.h'\" unpacked with wrong size!
  391.   fi
  392.   # end of 'haval.h'
  393. fi
  394. if test -f 'license.txt' -a "${1}" != "-c" ; then 
  395.   echo shar: Will not clobber existing file \"'license.txt'\"
  396. else
  397.   echo shar: Extracting \"'license.txt'\" \(3733 characters\)
  398.   sed "s/^X//" >'license.txt' <<'END_OF_FILE'
  399. X
  400. XSACS LIBRARY SOFTWARE LICENSE
  401. X
  402. X
  403. XMatthew Gream
  404. XM.Gream@uts.edu.au
  405. X+61-2-821-2043
  406. XMarch 1994
  407. X
  408. X
  409. X-- BEGIN LICENCE --
  410. X
  411. XUnless specifically authorized in writing by the author of this
  412. Xlibrary, you are given a limited license to use and distributed
  413. Xthis library and software incorporating elements of this library
  414. Xin accordance with the following conditions:
  415. X
  416. X  1. WARRANTIES AND SUITABILITY TO TASK
  417. X
  418. X  This library comes with no warranties at all, either expressed
  419. X  or implied. This includes such warranties as merchantability
  420. X  or fitness for a particular purpose. There is no guarantee
  421. X  whatsoever that this library will perform as per expected and
  422. X  described operation.
  423. X
  424. X  2. COST RECOVERY
  425. X
  426. X  Except to recover reasonable costs for media and distribution
  427. X  purposes, monies or payment in any form whatsoever for this
  428. X  library or creations incorporating any element of this library
  429. X  may not be made.
  430. X
  431. X  3. MODIFICATION AND/OR DISTRIBUTION
  432. X
  433. X  You many not modify and/or distribute modified copies of this
  434. X  library or provide mechanisms for creating modified versions
  435. X  of this library without prior consent of the author. You may,
  436. X  however, for the purposes of integration and development of
  437. X  software using elements of this library make minimal and
  438. X  reasonable changes to ensure this library will compile on an
  439. X  otherwise incompatible operating system. These modifications
  440. X  must not change the functionality of the library and must
  441. X  interoperate with existing unmodified versions of this
  442. X  library.
  443. X
  444. X  4. COPYRIGHT AND CREATION NOTICES
  445. X
  446. X  Any software incorporating or using elements of this library
  447. X  must ensure that notice is placed in such software or
  448. X  accompanying documentation so as to give credit to the
  449. X  authorship, copyright ownership and current version of this
  450. X  library.
  451. X
  452. X  5. NOTIFICATION OF USE
  453. X
  454. X  Reasonable attempts must be made to notify the author of this
  455. X  library of the existence and generation of any software that
  456. X  incorporates elements of this library. Further, reasonable
  457. X  attempts must be made to provide the author with a copy of
  458. X  such software.
  459. X
  460. X
  461. X-- END LICENSE --
  462. X
  463. X
  464. XA rough english-speak translation of the above is as such (this
  465. Xdoes not constitute part of the license, but merely attempts to
  466. Xexplain it):
  467. X
  468. X  Unless I specifically say so, all the following holds. Which
  469. X  means I may of course relax any or all of the following
  470. X  restrictions or modify them on request.
  471. X
  472. X  This library is free, and you are allowed to use it for free
  473. X  providing you or someone isn't going to make any money out of
  474. X  it. Shareware or commercial use maybe considered upon
  475. X  application to the author. At the same time, this library is
  476. X  centrally controlled in terms of modifications and future
  477. X  revisions. This means that only I as the author can release
  478. X  new versions of any form, though you are welcome to submit
  479. X  patches or improvements to me. This means you are not allowed
  480. X  to distribute modified copies of this library or software to
  481. X  generate modified copies of this library.
  482. X
  483. X  I do this to prevent splinters in the source tree, and to
  484. X  maintain compatibility. I do allow the distribution of patches
  485. X  that fix existing bugs or incompatibilities with particular
  486. X  operating systems, provided the patches don't change the way
  487. X  the library operates and don't stop it interoperating with
  488. X  unmodified versions of the library.
  489. X
  490. X  I also ask that you make best efforts to send me, or notify me
  491. X  about how to retrieve a copy of any software which uses this
  492. X  library. The reason I ask this is that feedback of this sort
  493. X  is important in determining modifications and future
  494. X  directions of the library. By the same token, I welcome any
  495. X  _constructive_ criticisms, comments and suggestions.
  496. X
  497. X
  498. X
  499. END_OF_FILE
  500.   if test 3733 -ne `wc -c <'license.txt'`; then
  501.     echo shar: \"'license.txt'\" unpacked with wrong size!
  502.   fi
  503.   # end of 'license.txt'
  504. fi
  505. if test -f 'md4-if.c' -a "${1}" != "-c" ; then 
  506.   echo shar: Will not clobber existing file \"'md4-if.c'\"
  507. else
  508.   echo shar: Extracting \"'md4-if.c'\" \(2963 characters\)
  509.   sed "s/^X//" >'md4-if.c' <<'END_OF_FILE'
  510. X
  511. X/* -------------------------------------------------------------------- */
  512. X/*                                                                      */
  513. X/*  Secure Asyncronous Communications Subsystem (SACS)                  */
  514. X/*  (C) 1994 Matthew Gream <M.Gream@uts.edu.au>                         */
  515. X/*                                                                      */
  516. X/*  You have been given a limited license to use and distribute this    */
  517. X/*  library. You should have received this license with the original    */
  518. X/*  release package of this library, named "license.txt" and entitled   */
  519. X/*  "SACS SOFTWARE LICENSE". In the event that you have not read or     */
  520. X/*  understood this license, regardless of reason, you may do nothing   */
  521. X/*  with this library other than read it for self-awareness.            */
  522. X/*                                                                      */
  523. X/* -------------------------------------------------------------------- */
  524. X
  525. X/* $Id: md4-if.c%v 0.90 1994/02/22 20:37:24 matt Exp $
  526. X */
  527. X
  528. X/*
  529. X *  File:         md4-if.c
  530. X *  Description:  interface to md4
  531. X */
  532. X
  533. X#include <mdigest.h>
  534. X#include "md4.h"
  535. X
  536. X
  537. X/* -------------------------------------------------------------------- */
  538. X/* function    : MD4_CREATE                                             */
  539. X/* description : individually setup a md4 context                       */
  540. X/* -------------------------------------------------------------------- */
  541. XSTATIC err_code
  542. XMD4_CREATE (ctx)
  543. X    md_ctx*         ctx;            /* context to setup                 */
  544. X{
  545. X    if (ctx->priv == NULL)
  546. X      ((MD4_CTX*)ctx->priv) = (MD4_CTX*)mem_get (sizeof(MD4_CTX), MEMOPT_CLEAR);
  547. X
  548. X    return (err_ok);
  549. X}
  550. X
  551. X
  552. X/* -------------------------------------------------------------------- */
  553. X/* function    : MD4_DESTROY                                            */
  554. X/* description : shutdown a previously allocated context                */
  555. X/* -------------------------------------------------------------------- */
  556. XSTATIC err_code
  557. XMD4_DESTROY (ctx)
  558. X    md_ctx*         ctx;            /* context to deallocate            */
  559. X{
  560. X    if (ctx->priv != NULL)
  561. X      mem_free (ctx->priv);
  562. X
  563. X    ctx->priv = NULL;
  564. X    return (err_ok);
  565. X}
  566. X
  567. X
  568. X/* -------------------------------------------------------------------- */
  569. X/* function    : MD4_REGISTER                                           */
  570. X/* description : register and setup md4 info structure                  */
  571. X/* -------------------------------------------------------------------- */
  572. XGLOBAL err_code
  573. XMD4_REGISTER (m)
  574. X    md_info*        m;              /* info structure to fill out       */
  575. X{
  576. X    m->block_sz     = 64;
  577. X    m->hash_sz      = 16;
  578. X
  579. X    m->create       = MD4_CREATE;
  580. X    m->destroy      = MD4_DESTROY;
  581. X    m->deregister   = NULL;
  582. X
  583. X    m->init         = MD4Init;
  584. X    m->update       = MD4Update;
  585. X    m->final        = MD4Final;
  586. X
  587. X    return (err_ok);
  588. X}
  589. X
  590. X/* -------------------------------------------------------------------- */
  591. X
  592. END_OF_FILE
  593.   if test 2963 -ne `wc -c <'md4-if.c'`; then
  594.     echo shar: \"'md4-if.c'\" unpacked with wrong size!
  595.   fi
  596.   # end of 'md4-if.c'
  597. fi
  598. if test -f 'md4.h' -a "${1}" != "-c" ; then 
  599.   echo shar: Will not clobber existing file \"'md4.h'\"
  600. else
  601.   echo shar: Extracting \"'md4.h'\" \(1885 characters\)
  602.   sed "s/^X//" >'md4.h' <<'END_OF_FILE'
  603. X
  604. X/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
  605. X   rights reserved.
  606. X
  607. X   License to copy and use this software is granted provided that it
  608. X   is identified as the "RSA Data Security, Inc. MD4 Message-Digest
  609. X   Algorithm" in all material mentioning or referencing this software
  610. X   or this function.
  611. X
  612. X   License is also granted to make and use derivative works provided
  613. X   that such works are identified as "derived from the RSA Data
  614. X   Security, Inc. MD4 Message-Digest Algorithm" in all material
  615. X   mentioning or referencing the derived work.
  616. X
  617. X   RSA Data Security, Inc. makes no representations concerning either
  618. X   the merchantability of this software or the suitability of this
  619. X   software for any particular purpose. It is provided "as is"
  620. X   without express or implied warranty of any kind.
  621. X
  622. X   These notices must be retained in any copies of any part of this
  623. X   documentation and/or software.
  624. X */
  625. X
  626. X#ifndef PROTOTYPES
  627. X#define PROTOTYPES 0
  628. X#endif
  629. X
  630. X/* POINTER defines a generic pointer type */
  631. Xtypedef unsigned char *POINTER;
  632. X
  633. X/* UINT2 defines a two byte word */
  634. Xtypedef unsigned short int UINT2;
  635. X
  636. X/* UINT4 defines a four byte word */
  637. Xtypedef unsigned long int UINT4;
  638. X
  639. X/* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
  640. X   If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
  641. X     returns an empty list.
  642. X */
  643. X
  644. X#if PROTOTYPES
  645. X#define PROTO_LIST(list) list
  646. X#else
  647. X#define PROTO_LIST(list) ()
  648. X#endif
  649. X
  650. X/* MD4 context. */
  651. Xtypedef struct {
  652. X  UINT4 state[4];                                   /* state (ABCD) */
  653. X  UINT4 count[2];        /* number of bits, modulo 2^64 (lsb first) */
  654. X  unsigned char buffer[64];                         /* input buffer */
  655. X} MD4_CTX;
  656. X
  657. Xvoid MD4Init PROTO_LIST ((MD4_CTX *));
  658. Xvoid MD4Update PROTO_LIST ((MD4_CTX *, unsigned char *, unsigned int));
  659. Xvoid MD4Final PROTO_LIST ((MD4_CTX*, unsigned char [16]));
  660. X
  661. END_OF_FILE
  662.   if test 1885 -ne `wc -c <'md4.h'`; then
  663.     echo shar: \"'md4.h'\" unpacked with wrong size!
  664.   fi
  665.   # end of 'md4.h'
  666. fi
  667. if test -f 'md5-if.c' -a "${1}" != "-c" ; then 
  668.   echo shar: Will not clobber existing file \"'md5-if.c'\"
  669. else
  670.   echo shar: Extracting \"'md5-if.c'\" \(2964 characters\)
  671.   sed "s/^X//" >'md5-if.c' <<'END_OF_FILE'
  672. X
  673. X/* -------------------------------------------------------------------- */
  674. X/*                                                                      */
  675. X/*  Secure Asyncronous Communications Subsystem (SACS)                  */
  676. X/*  (C) 1994 Matthew Gream <M.Gream@uts.edu.au>                         */
  677. X/*                                                                      */
  678. X/*  You have been given a limited license to use and distribute this    */
  679. X/*  library. You should have received this license with the original    */
  680. X/*  release package of this library, named "license.txt" and entitled   */
  681. X/*  "SACS SOFTWARE LICENSE". In the event that you have not read or     */
  682. X/*  understood this license, regardless of reason, you may do nothing   */
  683. X/*  with this library other than read it for self-awareness.            */
  684. X/*                                                                      */
  685. X/* -------------------------------------------------------------------- */
  686. X
  687. X/* $Id: md5-if.c%v 0.90 1994/02/22 20:37:24 matt Exp $
  688. X */
  689. X
  690. X/*
  691. X *  File:         md5-if.c
  692. X *  Description:  interface to md5
  693. X */
  694. X
  695. X#include <mdigest.h>
  696. X#include "md5.h"
  697. X
  698. X
  699. X/* -------------------------------------------------------------------- */
  700. X/* function    : MD5_CREATE                                             */
  701. X/* description : individually setup a md5 context                       */
  702. X/* -------------------------------------------------------------------- */
  703. XSTATIC err_code
  704. XMD5_CREATE (ctx)
  705. X    md_ctx*         ctx;            /* context to setup                 */
  706. X{
  707. X    if (ctx->priv == NULL)
  708. X      ((MD5_CTX*)ctx->priv) = (MD5_CTX*)mem_get (sizeof(MD5_CTX), MEMOPT_CLEAR);
  709. X
  710. X    return (err_ok);
  711. X}
  712. X
  713. X
  714. X/* -------------------------------------------------------------------- */
  715. X/* function    : MD5_DESTROY                                            */
  716. X/* description : shutdown a previously allocated context                */
  717. X/* -------------------------------------------------------------------- */
  718. XSTATIC err_code
  719. XMD5_DESTROY (ctx)
  720. X    md_ctx*         ctx;            /* context to deallocate            */
  721. X{
  722. X    if (ctx->priv != NULL)
  723. X      mem_free (ctx->priv);
  724. X
  725. X    ctx->priv = NULL;
  726. X    return (err_ok);
  727. X}
  728. X
  729. X
  730. X/* -------------------------------------------------------------------- */
  731. X/* function    : MD5_REGISTER                                           */
  732. X/* description : register and setup md5 info structure                  */
  733. X/* -------------------------------------------------------------------- */
  734. XGLOBAL err_code
  735. XMD5_REGISTER (m)
  736. X    md_info*        m;              /* info structure to fill out       */
  737. X{
  738. X    m->block_sz     = 64;
  739. X    m->hash_sz      = 16;
  740. X
  741. X    m->create       = MD5_CREATE;
  742. X    m->destroy      = MD5_DESTROY;
  743. X    m->deregister   = NULL;
  744. X
  745. X    m->init         = MD5Init;
  746. X    m->update       = MD5Update;
  747. X    m->final        = MD5Final;
  748. X
  749. X    return (err_ok);
  750. X}
  751. X
  752. X
  753. X/* -------------------------------------------------------------------- */
  754. X
  755. END_OF_FILE
  756.   if test 2964 -ne `wc -c <'md5-if.c'`; then
  757.     echo shar: \"'md5-if.c'\" unpacked with wrong size!
  758.   fi
  759.   # end of 'md5-if.c'
  760. fi
  761. if test -f 'md5.h' -a "${1}" != "-c" ; then 
  762.   echo shar: Will not clobber existing file \"'md5.h'\"
  763. else
  764.   echo shar: Extracting \"'md5.h'\" \(1885 characters\)
  765.   sed "s/^X//" >'md5.h' <<'END_OF_FILE'
  766. X
  767. X/* derived from: MD5.H - header file for MD5C.C
  768. X */
  769. X
  770. X/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
  771. Xrights reserved.
  772. X
  773. XLicense to copy and use this software is granted provided that it
  774. Xis identified as the "RSA Data Security, Inc. MD5 Message-Digest
  775. XAlgorithm" in all material mentioning or referencing this software
  776. Xor this function.
  777. X
  778. XLicense is also granted to make and use derivative works provided
  779. Xthat such works are identified as "derived from the RSA Data
  780. XSecurity, Inc. MD5 Message-Digest Algorithm" in all material
  781. Xmentioning or referencing the derived work.
  782. X
  783. XRSA Data Security, Inc. makes no representations concerning either
  784. Xthe merchantability of this software or the suitability of this
  785. Xsoftware for any particular purpose. It is provided "as is"
  786. Xwithout express or implied warranty of any kind.
  787. XThese notices must be retained in any copies of any part of this
  788. Xdocumentation and/or software.
  789. X */
  790. X
  791. X#ifndef PROTOTYPES
  792. X#define PROTOTYPES 0
  793. X#endif
  794. X
  795. X/* POINTER defines a generic pointer type */
  796. Xtypedef unsigned char *POINTER;
  797. X
  798. X/* UINT2 defines a two byte word */
  799. Xtypedef unsigned short int UINT2;
  800. X
  801. X/* UINT4 defines a four byte word */
  802. Xtypedef unsigned long int UINT4;
  803. X
  804. X/* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
  805. XIf using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
  806. X  returns an empty list.
  807. X */
  808. X#if PROTOTYPES
  809. X#define PROTO_LIST(list) list
  810. X#else
  811. X#define PROTO_LIST(list) ()
  812. X#endif
  813. X
  814. X/* MD5 context. */
  815. Xtypedef struct {
  816. X  UINT4 state[4];                                   /* state (ABCD) */
  817. X  UINT4 count[2];        /* number of bits, modulo 2^64 (lsb first) */
  818. X  unsigned char buffer[64];                         /* input buffer */
  819. X} MD5_CTX;
  820. X
  821. Xvoid MD5Init PROTO_LIST ((MD5_CTX *));
  822. Xvoid MD5Update PROTO_LIST ((MD5_CTX *, unsigned char *, unsigned int));
  823. Xvoid MD5Final PROTO_LIST ((MD5_CTX*, unsigned char [16]));
  824. X
  825. END_OF_FILE
  826.   if test 1885 -ne `wc -c <'md5.h'`; then
  827.     echo shar: \"'md5.h'\" unpacked with wrong size!
  828.   fi
  829.   # end of 'md5.h'
  830. fi
  831. if test -f 'mdigest.h' -a "${1}" != "-c" ; then 
  832.   echo shar: Will not clobber existing file \"'mdigest.h'\"
  833. else
  834.   echo shar: Extracting \"'mdigest.h'\" \(8184 characters\)
  835.   sed "s/^X//" >'mdigest.h' <<'END_OF_FILE'
  836. X
  837. X/* -------------------------------------------------------------------- */
  838. X/*                                                                      */
  839. X/*  Secure Asyncronous Communications Subsystem (SACS)                  */
  840. X/*  (C) 1994 Matthew Gream <M.Gream@uts.edu.au>                         */
  841. X/*                                                                      */
  842. X/*  You have been given a limited license to use and distribute this    */
  843. X/*  library. You should have received this license with the original    */
  844. X/*  release package of this library, named "license.txt" and entitled   */
  845. X/*  "SACS SOFTWARE LICENSE". In the event that you have not read or     */
  846. X/*  understood this license, regardless of reason, you may do nothing   */
  847. X/*  with this library other than read it for self-awareness.            */
  848. X/*                                                                      */
  849. X/* -------------------------------------------------------------------- */
  850. X
  851. X/* $Id: mdigest.h%v 0.90 1994/02/22 20:37:24 matt Exp $
  852. X */
  853. X
  854. X/*
  855. X *  File:         mdigest.h
  856. X *  Description:  Message digest header file
  857. X */
  858. X
  859. X#ifndef _MDIGEST_H_
  860. X#define _MDIGEST_H_
  861. X
  862. X/* -------------------------------------------------------------------- */
  863. X/* header files                                                         */
  864. X/* -------------------------------------------------------------------- */
  865. X
  866. X#include <stdio.h>
  867. X#include <strings.h>
  868. X#include <stdlib.h>
  869. X#include <unistd.h>
  870. X
  871. X/* -------------------------------------------------------------------- */
  872. X/* usual low level type castings                                        */
  873. X/* -------------------------------------------------------------------- */
  874. X
  875. Xtypedef unsigned char   word8;      /* defined as per bit size          */
  876. Xtypedef unsigned short  word16;
  877. Xtypedef unsigned long   word32;
  878. X
  879. Xtypedef int             word;       /* ''generic'' integer              */
  880. X
  881. Xtypedef unsigned char*  opaque;     /* arbitrary data segments          */
  882. Xtypedef char*           string;     /* character strings                */
  883. X
  884. Xtypedef void            (*handler)();   /* void function handler        */
  885. X
  886. X/* -------------------------------------------------------------------- */
  887. X/* nearly all functions return error codes as defined below             */
  888. X/* -------------------------------------------------------------------- */
  889. X
  890. Xtypedef enum
  891. X  {
  892. X    err_ok              = 0,        /* no error occured                 */
  893. X    err_no_memory       = 1,        /* memory allocation failed         */
  894. X    err_invalid_params  = 2,        /* invalid parameters passed        */
  895. X    err_file_not_found  = 3,        /* can't find a requested filename  */
  896. X    err_cant_open_file  = 4,        /* can't open a requested filename  */
  897. X    err_invalid_alg     = 5,        /* unknown algorithm from somewhere */
  898. X    err_already_exist   = 6,        /* something already exists         */
  899. X    err_no_space        = 7,        /* internal table/etc is full       */
  900. X    err_not_found       = 8,        /* something was not found          */
  901. X    err_no_more         = 9,        /* no more is available             */
  902. X    err_not_init        = 10,       /* not initialised                  */
  903. X    err_unknown         = 255,      /* unknown error                    */
  904. X  } err_code;
  905. X
  906. Xtypedef err_code        (*function)();  /* general function handler     */
  907. X
  908. X
  909. X/* -------------------------------------------------------------------- */
  910. X/* macros for general purpose use                                       */
  911. X/* -------------------------------------------------------------------- */
  912. X
  913. X#ifndef min
  914. X# define min(a, b)      ( ((a) <= (b)) ? (a) : (b) )
  915. X# define max(a, b)      ( ((a) >= (b)) ? (a) : (b) )
  916. X#endif
  917. X
  918. X#ifndef TRUE
  919. X# define TRUE           (1)
  920. X# define FALSE          (0)
  921. X#endif
  922. X
  923. X#define BIT_POS(x)      (1L<<(x))   /* specific bit position            */
  924. X#define ident_sz        (16)        /* identifer sizes in the system    */
  925. X
  926. X#define GLOBAL                      /* functions for rest of the world  */
  927. X#define STATIC          static      /* local to specific file           */
  928. X#define reg             register    /* quick defn for register vars     */
  929. X
  930. X
  931. X/* -------------------------------------------------------------------- */
  932. X/* simple bitstring class and operators                                 */
  933. X/* -------------------------------------------------------------------- */
  934. X
  935. Xtypedef word32          bitstring;
  936. X
  937. X#define bit_max         (sizeof(bitstring)<<3)
  938. X#define bit_set(s, b)   ((s) |= (1L<<(b))
  939. X#define bit_clr(s, b)   ((s) &= ~(1L<<(b))
  940. X#define bit_zero(s)     (s) = ((bitstring)0L)
  941. X#define bit_inv(s)      (s) ^= ((bitstring)0xffffffff)
  942. X#define bit_chk(s, b)   ((((s) &= ~(1L<<(b))) == 0) ? FALSE : TRUE)
  943. X
  944. X#define bit_pos(b)      (1L<<(b))
  945. X#define bit_empty       (0L)
  946. X
  947. X
  948. X/* -------------------------------------------------------------------- */
  949. X/* debug facilities                                                     */
  950. X/* -------------------------------------------------------------------- */
  951. X
  952. X#define DEBUG_FUNCTION_ENTER(f)
  953. X
  954. X
  955. X/* -------------------------------------------------------------------- */
  956. X/* memory.c requirements                                                */
  957. X/* -------------------------------------------------------------------- */
  958. X
  959. X#define MEMOPT_NONE     bit_empty   /* no options                       */
  960. X#define MEMOPT_CLEAR    bit_pos(0)  /* clear segment before use         */
  961. X
  962. X
  963. X/* -------------------------------------------------------------------- */
  964. X/* max number of registerable hash functions                            */
  965. X/* -------------------------------------------------------------------- */
  966. X
  967. X#define md_max_reg          (8)
  968. X
  969. X
  970. X/* -------------------------------------------------------------------- */
  971. X/* at registration, each algorithm provides function handlers and other */
  972. X/* information                                                          */
  973. X/* -------------------------------------------------------------------- */
  974. X
  975. Xtypedef struct
  976. X  {
  977. X    char                ident[ident_sz+1];  /* id string                */
  978. X
  979. X    word                block_sz;   /* input block size in bytes        */
  980. X    word                hash_sz;    /* output has size in bytes         */
  981. X
  982. X    function            create;     /* creation handler                 */
  983. X    function            destroy;    /* destruction                      */
  984. X    function            deregister; /* deregistration                   */
  985. X
  986. X    handler             init;       /* init for start of hash           */
  987. X    handler             update;     /* update for hash                  */
  988. X    handler             final;      /* final and calc digest            */
  989. X
  990. X  } md_info;
  991. X
  992. X/* -------------------------------------------------------------------- */
  993. X/* each association with the module uses its own context:               */
  994. X/* -------------------------------------------------------------------- */
  995. X
  996. Xtypedef struct
  997. X  {
  998. X    md_info             *info;      /* ptr to above info block          */
  999. X    opaque              priv;       /* private structure                */
  1000. X
  1001. X  } md_ctx;
  1002. X
  1003. X
  1004. X#define md_create(c)        (*((c)->info->create))(c)   /* not for user */
  1005. X#define md_destroy(c)       (*((c)->info->destroy))(c)  /* not for user */
  1006. X
  1007. X#define md_init(c)          (*((c)->info->init))((c)->priv)       /* u  */
  1008. X#define md_update(c,d,l)    (*((c)->info->update))((c)->priv,d,l) /* u  */
  1009. X#define md_final(c,o)       (*((c)->info->final))((c)->priv,o)    /* u  */
  1010. X
  1011. X#define md_hash_sz(c)       ((c)->info->hash_sz)
  1012. X#define md_block_sz(c)      ((c)->info->block_sz)
  1013. X#define md_id(c)            ((c)->info->ident)
  1014. X
  1015. X
  1016. X/* -------------------------------------------------------------------- */
  1017. X/* prototypes -- k'n'r */
  1018. X
  1019. Xopaque      mem_get ();
  1020. Xvoid        mem_free ();
  1021. Xstring      sacs_err_msg ();
  1022. Xmd_info*    md_lookup_id ();
  1023. Xerr_code    md_register ();
  1024. Xerr_code    md_deregister ();
  1025. Xerr_code    md_mod_open ();
  1026. Xerr_code    md_mod_close ();
  1027. Xerr_code    md_open ();
  1028. Xerr_code    md_close ();
  1029. Xerr_code    md_list_init ();
  1030. Xerr_code    md_list_next ();
  1031. X
  1032. X/* -------------------------------------------------------------------- */
  1033. X#endif /*_MDIGEST_H_*/
  1034. X
  1035. END_OF_FILE
  1036.   if test 8184 -ne `wc -c <'mdigest.h'`; then
  1037.     echo shar: \"'mdigest.h'\" unpacked with wrong size!
  1038.   fi
  1039.   # end of 'mdigest.h'
  1040. fi
  1041. if test -f 'shs-if.c' -a "${1}" != "-c" ; then 
  1042.   echo shar: Will not clobber existing file \"'shs-if.c'\"
  1043. else
  1044.   echo shar: Extracting \"'shs-if.c'\" \(3568 characters\)
  1045.   sed "s/^X//" >'shs-if.c' <<'END_OF_FILE'
  1046. X
  1047. X/* -------------------------------------------------------------------- */
  1048. X/*                                                                      */
  1049. X/*  Secure Asyncronous Communications Subsystem (SACS)                  */
  1050. X/*  (C) 1994 Matthew Gream <M.Gream@uts.edu.au>                         */
  1051. X/*                                                                      */
  1052. X/*  You have been given a limited license to use and distribute this    */
  1053. X/*  library. You should have received this license with the original    */
  1054. X/*  release package of this library, named "license.txt" and entitled   */
  1055. X/*  "SACS SOFTWARE LICENSE". In the event that you have not read or     */
  1056. X/*  understood this license, regardless of reason, you may do nothing   */
  1057. X/*  with this library other than read it for self-awareness.            */
  1058. X/*                                                                      */
  1059. X/* -------------------------------------------------------------------- */
  1060. X
  1061. X/* $Id: shs-if.c%v 0.90 1994/02/22 20:37:24 matt Exp $
  1062. X */
  1063. X
  1064. X/*
  1065. X *  File:         shs-if.c
  1066. X *  Description:  interface to nist shs
  1067. X */
  1068. X
  1069. X#include <mdigest.h>
  1070. X#include "shs.h"
  1071. X
  1072. X
  1073. X/* -------------------------------------------------------------------- */
  1074. X/* function    : SHS_FINAL                                              */
  1075. X/* description : perform the final operation, so as to copy in digest   */
  1076. X/* -------------------------------------------------------------------- */
  1077. XSTATIC void
  1078. XSHS_FINAL (shsInfo, digest)
  1079. X    SHS_INFO*       shsInfo;        /* private shsinfo structure        */
  1080. X    opaque          digest;         /* where to place digest            */
  1081. X{
  1082. X    shsFinal (shsInfo);
  1083. X    memcpy (digest, shsInfo->digest, SHS_DIGESTSIZE);
  1084. X}
  1085. X
  1086. X/* -------------------------------------------------------------------- */
  1087. X/* function    : SHS_CREATE                                             */
  1088. X/* description : individually setup a SHS context                       */
  1089. X/* -------------------------------------------------------------------- */
  1090. XSTATIC err_code
  1091. XSHS_CREATE (ctx)
  1092. X    md_ctx*         ctx;            /* context to setup                 */
  1093. X{
  1094. X    if (ctx->priv == NULL)
  1095. X      ((SHS_INFO*)ctx->priv) = (SHS_INFO*)mem_get (sizeof(SHS_INFO), MEMOPT_CLEAR);
  1096. X
  1097. X    return (err_ok);
  1098. X}
  1099. X
  1100. X
  1101. X/* -------------------------------------------------------------------- */
  1102. X/* function    : SHS_DESTROY                                            */
  1103. X/* description : shutdown a previously allocated context                */
  1104. X/* -------------------------------------------------------------------- */
  1105. XSTATIC err_code
  1106. XSHS_DESTROY (ctx)
  1107. X    md_ctx*         ctx;            /* context to deallocate            */
  1108. X{
  1109. X    if (ctx->priv != NULL)
  1110. X      mem_free (ctx->priv);
  1111. X
  1112. X    ctx->priv = NULL;
  1113. X    return (err_ok);
  1114. X}
  1115. X
  1116. X
  1117. X/* -------------------------------------------------------------------- */
  1118. X/* function    : SHS_REGISTER                                           */
  1119. X/* description : register and setup SHS info structure                  */
  1120. X/* -------------------------------------------------------------------- */
  1121. XGLOBAL err_code
  1122. XSHS_REGISTER (m)
  1123. X    md_info*        m;              /* info structure to fill out       */
  1124. X{
  1125. X    m->block_sz     = SHS_BLOCKSIZE;
  1126. X    m->hash_sz      = SHS_DIGESTSIZE;
  1127. X
  1128. X    m->create       = SHS_CREATE;
  1129. X    m->destroy      = SHS_DESTROY;
  1130. X    m->deregister   = NULL;
  1131. X
  1132. X    m->init         = shsInit;
  1133. X    m->update       = shsUpdate;
  1134. X    m->final        = SHS_FINAL;
  1135. X
  1136. X    return (err_ok);
  1137. X}
  1138. X
  1139. X/* -------------------------------------------------------------------- */
  1140. X
  1141. END_OF_FILE
  1142.   if test 3568 -ne `wc -c <'shs-if.c'`; then
  1143.     echo shar: \"'shs-if.c'\" unpacked with wrong size!
  1144.   fi
  1145.   # end of 'shs-if.c'
  1146. fi
  1147. if test -f 'shs.h' -a "${1}" != "-c" ; then 
  1148.   echo shar: Will not clobber existing file \"'shs.h'\"
  1149. else
  1150.   echo shar: Extracting \"'shs.h'\" \(1619 characters\)
  1151.   sed "s/^X//" >'shs.h' <<'END_OF_FILE'
  1152. X/* --------------------------------- SHS.H ------------------------------- */
  1153. X/* NIST proposed Secure Hash Standard.
  1154. X   Written 2 September 1992, Peter C. Gutmann.
  1155. X   This implementation placed in the public domain.
  1156. X
  1157. X   Modified 1 June 1993, Colin Plumb.
  1158. X   These modifications placed in the public domain.
  1159. X
  1160. X   mgream: feb/94, changed from ANSI to KNR args/protos for compat.
  1161. X   mgream: added runtime endian check
  1162. X
  1163. X   Comments to pgut1@cs.aukuni.ac.nz */
  1164. X/* Useful defines/typedefs */
  1165. Xtypedef unsigned char    BYTE;
  1166. X
  1167. X/* Since 64-bit machines are the wave of the future, we may as well
  1168. X   support them directly. */
  1169. X
  1170. X#ifdef FORCE32
  1171. X
  1172. X#undef HAVE64
  1173. X
  1174. X#else    /* !FORCE32 */
  1175. X
  1176. X#if __alpha    /* Or other machines? */
  1177. X#define HAVE64 1
  1178. Xtypedef unsigned long WORD64;
  1179. X#endif
  1180. X
  1181. X#if __GNUC__
  1182. X#define HAVE64 1
  1183. Xtypedef unsigned long long WORD64;
  1184. X#endif
  1185. X
  1186. X#endif    /* !FORCE32 */
  1187. X
  1188. X#ifdef HAVE64
  1189. Xtypedef unsigned int WORD32;
  1190. X#else
  1191. Xtypedef unsigned long WORD32;
  1192. X#endif
  1193. X/* The SHS block size and message digest sizes, in bytes */
  1194. X#define SHS_BLOCKSIZE    64
  1195. X#define SHS_DIGESTSIZE    20
  1196. X/* The structure for storing SHS info
  1197. X   data[] is placed first in case offsets of 0 are faster
  1198. X   for some reason; it's the most often accessed field. */
  1199. Xtypedef struct {
  1200. X    WORD32 data[ 16 ];        /* SHS data buffer */
  1201. X    WORD32 digest[ 5 ];        /* Message digest */
  1202. X#ifdef HAVE64
  1203. X    WORD64 count;
  1204. X#else
  1205. X    WORD32 countHi, countLo;    /* 64-bit bit count */
  1206. X#endif
  1207. X} SHS_INFO;
  1208. X/* Whether the machine is little-endian or not */
  1209. X/*#define LITTLE_ENDIAN   -- obselete (mgream) */
  1210. X
  1211. X/* shs.c */
  1212. Xvoid shsInit();
  1213. Xvoid shsTransform();
  1214. Xvoid shsUpdate();
  1215. Xvoid shsFinal();
  1216. X
  1217. END_OF_FILE
  1218.   if test 1619 -ne `wc -c <'shs.h'`; then
  1219.     echo shar: \"'shs.h'\" unpacked with wrong size!
  1220.   fi
  1221.   # end of 'shs.h'
  1222. fi
  1223. if test -f 'utility.c' -a "${1}" != "-c" ; then 
  1224.   echo shar: Will not clobber existing file \"'utility.c'\"
  1225. else
  1226.   echo shar: Extracting \"'utility.c'\" \(3574 characters\)
  1227.   sed "s/^X//" >'utility.c' <<'END_OF_FILE'
  1228. X
  1229. X/* -------------------------------------------------------------------- */
  1230. X/*                                                                      */
  1231. X/*  Secure Asyncronous Communications Subsystem (SACS)                  */
  1232. X/*  (C) 1994 Matthew Gream <M.Gream@uts.edu.au>                         */
  1233. X/*                                                                      */
  1234. X/*  You have been given a limited license to use and distribute this    */
  1235. X/*  library. You should have received this license with the original    */
  1236. X/*  release package of this library, named "license.txt" and entitled   */
  1237. X/*  "SACS SOFTWARE LICENSE". In the event that you have not read or     */
  1238. X/*  understood this license, regardless of reason, you may do nothing   */
  1239. X/*  with this library other than read it for self-awareness.            */
  1240. X/*                                                                      */
  1241. X/* -------------------------------------------------------------------- */
  1242. X
  1243. X/* $Id: memory.c%v 0.81 1994/02/12 10:08:43 matt Exp $
  1244. X */
  1245. X
  1246. X/*
  1247. X *  File:         utility.c
  1248. X *  Description:  misc utility stuff
  1249. X */
  1250. X
  1251. X#include <mdigest.h>
  1252. X
  1253. X
  1254. X/* -------------------------------------------------------------------- */
  1255. X/* function    : mem_get                                                */
  1256. X/* description : allocate and return 'req_size' bytes of memory, clear  */
  1257. X/*               if MEMOPT_CLEAR flag is present. Failures are hard.    */
  1258. X/* -------------------------------------------------------------------- */
  1259. XGLOBAL opaque
  1260. Xmem_get (req_size, req_options)
  1261. X    word            req_size;           /* size of memory requested     */
  1262. X    bitstring       req_options;        /* options for allocated mem    */
  1263. X{
  1264. X    opaque          seg_addr;
  1265. X
  1266. X    DEBUG_FUNCTION_ENTER("mem_get");
  1267. X
  1268. X    /* ---------------------------------------------------------------- */
  1269. X    /* code should never request zero size segments -- deal with it by  */
  1270. X    /* returning NULL pointer.                                          */
  1271. X    /* ---------------------------------------------------------------- */
  1272. X
  1273. X    if (req_size == 0)
  1274. X      return ((opaque)NULL);
  1275. X
  1276. X    /* ---------------------------------------------------------------- */
  1277. X    /* if allocation request fails, call error handler and indicate a   */
  1278. X    /* fatal error with appropriate error code                          */
  1279. X    /* ---------------------------------------------------------------- */
  1280. X
  1281. X    seg_addr = (opaque)malloc (req_size);
  1282. X    if (seg_addr == NULL)
  1283. X      {
  1284. X        /*sacs_hard_error (err_no_memory);*/
  1285. X        fprintf (stderr, "malloc failed.\n");
  1286. X        exit (1);
  1287. X        /* not reached */
  1288. X      }
  1289. X
  1290. X    /* ---------------------------------------------------------------- */
  1291. X    /* clear segment if we were specifically asked to do so             */
  1292. X    /* ---------------------------------------------------------------- */
  1293. X
  1294. X    if (bit_chk (req_options, MEMOPT_CLEAR) == TRUE)
  1295. X      memset (seg_addr, '\0', req_size);
  1296. X
  1297. X    return (seg_addr);
  1298. X}
  1299. X
  1300. X
  1301. X/* -------------------------------------------------------------------- */
  1302. X/* function    : mem_free                                               */
  1303. X/* description : release memory segment previously allocated            */
  1304. X/* -------------------------------------------------------------------- */
  1305. XGLOBAL void
  1306. Xmem_free (seg_addr)
  1307. X    opaque          seg_addr;           /* address of mem segment       */
  1308. X{
  1309. X    DEBUG_FUNCTION_ENTER("mem_free");
  1310. X
  1311. X    if (seg_addr != NULL)
  1312. X      free (seg_addr);
  1313. X}
  1314. X
  1315. X/* -------------------------------------------------------------------- */
  1316. X
  1317. END_OF_FILE
  1318.   if test 3574 -ne `wc -c <'utility.c'`; then
  1319.     echo shar: \"'utility.c'\" unpacked with wrong size!
  1320.   fi
  1321.   # end of 'utility.c'
  1322. fi
  1323. echo shar: End of archive 3 \(of 3\).
  1324. cp /dev/null ark3isdone
  1325. MISSING=""
  1326. for I in 1 2 3 ; do
  1327.     if test ! -f ark${I}isdone ; then
  1328.     MISSING="${MISSING} ${I}"
  1329.     fi
  1330. done
  1331. if test "${MISSING}" = "" ; then
  1332.     echo You have unpacked all 3 archives.
  1333.     rm -f ark[1-9]isdone
  1334. else
  1335.     echo You still must unpack the following archives:
  1336.     echo "        " ${MISSING}
  1337. fi
  1338. exit 0
  1339. exit 0 # Just in case...
  1340.