chiark / gitweb /
magic.h, etc.: Rename the transform capability bits.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 29 Apr 2017 12:55:40 +0000 (13:55 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 25 Sep 2019 12:46:43 +0000 (13:46 +0100)
Mostly mechanical, with the following rune:

git grep -zil TRANSFORMNUM | xargs -0r sed -i '
s/TRANSFORMNUM/BIT/g
s/transformnum/bit/g
s/BIT_ANCIENT/&TRANSFORM/g'

But I renamed the `capab_transformnum' member of `struct msg' back by
hand, because it's referring specifically to a selected
transform.  (This will make sense later.)

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
magic.h
secnet.h
site.c
transform-cbcmac.c
transform-common.h
transform-eax.c

diff --git a/magic.h b/magic.h
index 4389d54..5b0407e 100644 (file)
--- a/magic.h
+++ b/magic.h
  * number actually chosen by the MSG3 sender.
  *
  * Aside from that, an empty bitmask is treated the same as
- *  1u<<CAPAB_TRANSFORMNUM_ANCIENT
+ *  1u<<CAPAB_BIT_ANCIENTTRANSFORM
  */
 
 /* bit indices, 0 is ls bit */
-#define CAPAB_TRANSFORMNUM_USER_MIN              0
-#define CAPAB_TRANSFORMNUM_USER_MAX              7
-#define CAPAB_TRANSFORMNUM_SERPENT256CBC         8
-#define CAPAB_TRANSFORMNUM_EAXSERPENT            9
-#define CAPAB_TRANSFORMNUM_MAX                  15
+#define CAPAB_BIT_USER_MIN              0
+#define CAPAB_BIT_USER_MAX              7
+#define CAPAB_BIT_SERPENT256CBC         8
+#define CAPAB_BIT_EAXSERPENT            9
+#define CAPAB_BIT_MAX                  15
 
-#define CAPAB_TRANSFORMNUM_ANCIENT CAPAB_TRANSFORMNUM_SERPENT256CBC
+#define CAPAB_BIT_ANCIENTTRANSFORM CAPAB_BIT_SERPENT256CBC
 
 #endif /* magic_h */
index 818e946..f2840db 100644 (file)
--- a/secnet.h
+++ b/secnet.h
@@ -574,7 +574,7 @@ struct transform_inst_if {
 
 struct transform_if {
     void *st;
-    int capab_transformnum;
+    int capab_bit;
     int32_t keylen; /* <<< INT_MAX */
     transform_createinstance_fn *create;
 };
diff --git a/site.c b/site.c
index d0dd909..478ce4d 100644 (file)
--- a/site.c
+++ b/site.c
@@ -575,7 +575,7 @@ static _Bool set_new_transform(struct site *st, char *pk)
 
     slog(st,LOG_SETUP_INIT,"key exchange negotiated transform"
         " %d (capabilities ours=%#"PRIx32" theirs=%#"PRIx32")",
-        st->chosen_transform->capab_transformnum,
+        st->chosen_transform->capab_bit,
         st->local_capabilities, st->remote_capabilities);
     return True;
 }
@@ -643,7 +643,7 @@ static bool_t generate_msg(struct site *st, uint32_t type, cstring_t what)
     if (hacky_par_mid_failnow()) return False;
 
     if (type==LABEL_MSG3BIS)
-       buf_append_uint8(&st->buffer,st->chosen_transform->capab_transformnum);
+       buf_append_uint8(&st->buffer,st->chosen_transform->capab_bit);
 
     dhpub=st->dh->makepublic(st->dh->st,st->dhsecret,st->dh->len);
     buf_append_string(&st->buffer,dhpub);
@@ -717,7 +717,7 @@ static bool_t unpick_msg(struct site *st, uint32_t type,
        CHECK_AVAIL(msg,1);
        m->capab_transformnum = buf_unprepend_uint8(msg);
     } else {
-       m->capab_transformnum = CAPAB_TRANSFORMNUM_ANCIENT;
+       m->capab_transformnum = CAPAB_BIT_ANCIENTTRANSFORM;
     }
     CHECK_AVAIL(msg,2);
     m->pklen=buf_unprepend_uint16(msg);
@@ -827,13 +827,13 @@ static bool_t process_msg2(struct site *st, struct buffer_if *msg2,
     uint32_t remote_transforms = st->remote_capabilities & CAPAB_TRANSFORM_MASK;
     if (!remote_transforms)
        /* old secnets only had this one transform */
-       remote_transforms = 1UL << CAPAB_TRANSFORMNUM_ANCIENT;
+       remote_transforms = 1UL << CAPAB_BIT_ANCIENTTRANSFORM;
 
     struct transform_if *ti;
     int i;
     for (i=0; i<st->ntransforms; i++) {
        ti=st->transforms[i];
-       if ((1UL << ti->capab_transformnum) & remote_transforms)
+       if ((1UL << ti->capab_bit) & remote_transforms)
            goto transform_found;
     }
     slog(st,LOG_ERROR,"no transforms in common"
@@ -910,7 +910,7 @@ static bool_t process_msg3(struct site *st, struct buffer_if *msg3,
     int i;
     for (i=0; i<st->ntransforms; i++) {
        ti=st->transforms[i];
-       if (ti->capab_transformnum == m.capab_transformnum)
+       if (ti->capab_bit == m.capab_transformnum)
            goto transform_found;
     }
     slog(st,LOG_SEC,"peer chose unknown-to-us transform %d!",
@@ -2230,10 +2230,10 @@ static list_t *site_apply(closure_t *self, struct cloc loc, dict_t *context,
 
     for (i=0; i<st->ntransforms; i++) {
        struct transform_if *ti=st->transforms[i];
-       uint32_t capbit = 1UL << ti->capab_transformnum;
+       uint32_t capbit = 1UL << ti->capab_bit;
        if (st->local_capabilities & capbit)
-           slog(st,LOG_ERROR,"transformnum capability bit"
-                " %d (%#"PRIx32") reused", ti->capab_transformnum, capbit);
+           slog(st,LOG_ERROR,"bit capability bit"
+                " %d (%#"PRIx32") reused", ti->capab_bit, capbit);
        st->local_capabilities |= capbit;
     }
 
index ad9e901..b481346 100644 (file)
@@ -298,7 +298,7 @@ static list_t *transform_apply(closure_t *self, struct cloc loc,
 
     SEQNUM_PARAMS_INIT(dict,&st->p,"serpent-cbc256",loc);
 
-    SET_CAPAB_TRANSFORMNUM(CAPAB_TRANSFORMNUM_SERPENT256CBC);
+    SET_CAPAB_BIT(CAPAB_BIT_SERPENT256CBC);
 
     return new_closure(&st->cl);
 }
index 74e08ea..4351ce8 100644 (file)
@@ -88,12 +88,12 @@ typedef uint32_t recvbitmap_type;
        free(st);                                       \
     }
 
-#define SET_CAPAB_TRANSFORMNUM(def) do{                                        \
-        st->ops.capab_transformnum=dict_read_number(dict, "capab-num", \
+#define SET_CAPAB_BIT(def) do{                                         \
+        st->ops.capab_bit=dict_read_number(dict, "capab-num",          \
                                      False, "transform", loc, (def));  \
-        if (st->ops.capab_transformnum > CAPAB_TRANSFORMNUM_MAX)       \
+        if (st->ops.capab_bit > CAPAB_BIT_MAX)                         \
            cfgfatal(loc,"transform","capab-num out of range 0..%d\n",  \
-                    CAPAB_TRANSFORMNUM_MAX);                           \
+                    CAPAB_BIT_MAX);                                    \
     }while(0)
 
 #define TRANSFORM_CREATE_CORE                          \
index c6da1d3..04cd0e6 100644 (file)
@@ -290,7 +290,7 @@ static list_t *transform_apply(closure_t *self, struct cloc loc,
        cfgfatal(loc,"eax-serpent","parameter must be a dictionary\n");
     dict=item->data.dict;
 
-    SET_CAPAB_TRANSFORMNUM(CAPAB_TRANSFORMNUM_EAXSERPENT);
+    SET_CAPAB_BIT(CAPAB_BIT_EAXSERPENT);
 
     SEQNUM_PARAMS_INIT(dict,&st->p,"eax-serpent",loc);