chiark / gitweb /
all compiles again. more pat to do.
[chiark-tcl.git] / hbytes / hbytes.h
index c6fe050b8d675f29a6a6bfb8162391c2e08518d5..a545edeae9f4cd949516d78dc09ef55034417724 100644 (file)
  *
  *  hbytes pkcs5 pa|ua VAR ALG                   => worked?  (always 1 for p)
  *  hbytes pkcs5 pn|un VAR BLOCKSIZE             => worked?  (always 1 for p)
- *  hbytes blockcipher e|d VAR ALG MODE [IV]     => IV
+ *  hbytes blockcipher d|e VAR ALG MODE [IV]     => IV
  *
- *  hbytes hash ALG VALUE                        => hash
- *  hbytes hmac ALG VALUE KEY [MACLENGTH]        => mac
+ *  hbytes hash ALG MESSAGE                      => hash
+ *  hbytes hmac ALG MESSAGE KEY [MACLENGTH]      => mac
  *
  * Refs: HMAC: RFC2104
  */
@@ -43,14 +43,25 @@ extern Tcl_ObjType hbytes_type;
 int staticerr(Tcl_Interp *ip, const char *m);
 void objfreeir(Tcl_Obj *o);
 
-Tcl_Obj *hbytes_set(Tcl_Obj *overwrite, const Byte *array, int l);
+void hbytes_set(HBytes_Value *upd, const Byte *array, int l);
+Tcl_Obj *hbytes_set_obj(Tcl_Obj *overwrite, const Byte *array, int l);
+
+/* from parse.c */
+
+typedef struct {
+  HBytes_Value *hb;
+  Tcl_Obj *obj, *var;
+} HBytes_Var;
+
+void fini_hbv(Tcl_Interp *ip, int rc, HBytes_Var *agg);
 
 /* from enum.c */
 
 extern Tcl_ObjType enum_nearlytype;
+extern Tcl_ObjType enum1_nearlytype;
 
 const void *enum_lookup_cached_func(Tcl_Interp *ip, Tcl_Obj *o,
-                                   size_t entrysize, const void *firstentry,
+                                   const void *firstentry, size_t entrysize,
                                    const char *what);
 #define enum_lookup_cached(ip,o,table,what)                    \
     (enum_lookup_cached_func((ip),(o),                         \
@@ -63,10 +74,28 @@ const void *enum_lookup_cached_func(Tcl_Interp *ip, Tcl_Obj *o,
    * set to the error message.
    */
 
+int enum1_lookup_cached_func(Tcl_Interp *ip, Tcl_Obj *o,
+                            const char *opts, const char *what);
+  /* -1 => error */
+
+/* from crypto.c */
+
+typedef struct {
+  int blocksize, hashsize;
+} HashAlgInfo;
+
+typedef struct {
+  int blocksize;
+} BlockCipherAlgInfo;
+
+typedef struct {
+  int dummy;
+} BlockCipherModeInfo;
+
 /* useful macros */
 
-#define HBYTES(o) ((HBytes_Value*)&(o)->internalRep.twoPtrValue)
-#define HBYTES_LEN(o) (HBYTES((o))->end - HBYTES((o))->start)
+#define HBYTES(o) (*(HBytes_Value*)&(o)->internalRep.twoPtrValue)
+#define HBYTES_LEN(hb) ((hb).end - (hb).start)
 
 #define TALLOC(s) ((void*)Tcl_Alloc((s)))
 #define TFREE(f) (Tcl_Free((void*)(f)))