chiark / gitweb /
site: Remove pointless check from decrypt_msg0
[secnet.git] / transform.c
index b13c2dd9e88cfd3de573972a038ac7218df15fd0..f55aa447dfd41c1c64c3dfc6b658010057b77d55 100644 (file)
@@ -72,8 +72,8 @@ static void transform_delkey(void *sst)
 {
     struct transform_inst *ti=sst;
 
-    memset(&ti->cryptkey,0,sizeof(ti->cryptkey));
-    memset(&ti->mackey,0,sizeof(ti->mackey));
+    FILLZERO(ti->cryptkey);
+    FILLZERO(ti->mackey);
     ti->keyed=False;
 }
 
@@ -171,6 +171,10 @@ static uint32_t transform_reverse(void *sst, struct buffer_if *buf,
        return 1;
     }
 
+    if (buf->size < 4 + 16 + 16) {
+       *errmsg="msg too short";
+       return 1;
+    }
 
     /* CBC */
     memset(iv,0,16);
@@ -181,6 +185,7 @@ static uint32_t transform_reverse(void *sst, struct buffer_if *buf,
     /* Assert bufsize is multiple of blocksize */
     if (buf->size&0xf) {
        *errmsg="msg not multiple of cipher blocksize";
+       return 1;
     }
     serpent_encrypt(&ti->cryptkey,iv,iv);
     for (n=buf->start; n<buf->start+buf->size; n+=16)
@@ -252,7 +257,7 @@ static void transform_destroy(void *sst)
 {
     struct transform_inst *st=sst;
 
-    memset(st,0,sizeof(*st)); /* Destroy key material */
+    FILLZERO(*st); /* Destroy key material */
     free(st);
 }