Expunge revision histories in files.
[u/mdw/catacomb] / tlsprf.c
index d45eb43..dafc247 100644 (file)
--- a/tlsprf.c
+++ b/tlsprf.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: tlsprf.c,v 1.2 2001/04/06 22:05:53 mdw Exp $
+ * $Id: tlsprf.c,v 1.3 2004/04/08 01:36:15 mdw Exp $
  *
  * The TLS pseudo-random function
  *
  * MA 02111-1307, USA.
  */
 
-/*----- Revision history --------------------------------------------------* 
- *
- * $Log: tlsprf.c,v $
- * Revision 1.2  2001/04/06 22:05:53  mdw
- * Change dummy names in grand objects so that they say what sort of thing
- * they are.
- *
- * Revision 1.1  2001/04/04 20:10:52  mdw
- * Add support for the TLS pseudo-random function.
- *
- */
-
 /*----- Header files ------------------------------------------------------*/
 
 #include <mLib/alloc.h>
 void tlsdx_init(tlsdx_ctx *c, gmac *m, const void *sd, size_t sdsz)
 {
   c->k = m;
-  c->hashsz = c->k->ops->c->hashsz;
+  c->hashsz = GM_CLASS(c->k)->hashsz;
   c->sd = sd; c->sdsz = sdsz;
 
-  c->i = c->k->ops->init(c->k);
-  c->i->ops->hash(c->i, sd, sdsz);
-  c->ai = c->i->ops->done(c->i, 0);
-  c->o = c->k->ops->init(c->k);
-  c->o->ops->hash(c->o, c->ai, c->hashsz);
-  c->o->ops->hash(c->o, sd, sdsz);
-  c->p = c->o->ops->done(c->o, 0);
+  c->i = GM_INIT(c->k);
+  GH_HASH(c->i, sd, sdsz);
+  c->ai = GH_DONE(c->i, 0);
+  c->o = GM_INIT(c->k);
+  GH_HASH(c->o, c->ai, c->hashsz);
+  GH_HASH(c->o, sd, sdsz);
+  c->p = GH_DONE(c->o, 0);
   c->sz = c->hashsz;
 }
 
@@ -111,16 +99,16 @@ void tlsdx_encrypt(tlsdx_ctx *c, const void *src, void *dest, size_t sz)
     if (c->sz)
       n = c->sz;
     else {
-      h = c->k->ops->init(c->k);
-      h->ops->hash(h, c->ai, c->hashsz);
-      c->ai = h->ops->done(h, 0);
-      c->i->ops->destroy(c->i);
+      h = GM_INIT(c->k);
+      GH_HASH(h, c->ai, c->hashsz);
+      c->ai = GH_DONE(h, 0);
+      GH_DESTROY(c->i);
       c->i = h;
-      c->o->ops->destroy(c->o);
-      h = c->o = c->k->ops->init(c->k);
-      h->ops->hash(h, c->ai, c->hashsz);
-      h->ops->hash(h, c->sd, c->sdsz);
-      c->p = h->ops->done(h, 0);
+      GH_DESTROY(c->o);
+      h = c->o = GM_INIT(c->k);
+      GH_HASH(h, c->ai, c->hashsz);
+      GH_HASH(h, c->sd, c->sdsz);
+      c->p = GH_DONE(h, 0);
       c->sz = n = c->hashsz;
     }
     if (n > sz)
@@ -151,8 +139,8 @@ void tlsdx_encrypt(tlsdx_ctx *c, const void *src, void *dest, size_t sz)
 
 void tlsdx_free(tlsdx_ctx *c)
 {
-  c->i->ops->destroy(c->i);
-  c->o->ops->destroy(c->o);
+  GH_DESTROY(c->i);
+  GH_DESTROY(c->o);
 }
 
 /* --- Generic random number generator --- */
@@ -284,7 +272,7 @@ grand *tlsdx_rand(const gcmac *mc, const void *k, size_t ksz,
 {
   dx_grctx *g = S_CREATE(dx_grctx);
   dstr d = DSTR_INIT;
-  gmac *m = mc->key(k, ksz);
+  gmac *m = GM_KEY(mc, k, ksz);
   octet *q = xmalloc(sdsz);
   memcpy(q, sd, sdsz);
   dstr_putf(&d, "tlsdx(%s)", mc->name);