chiark / gitweb /
site: Make return value of transforms be an enum
[secnet.git] / transform-eax.c
index 906d2b30b6c6b15e7a6dcc6dd6feb33716e40ef1..c6da1d33d86ecf87f696c16176492eb951feb778 100644 (file)
@@ -1,6 +1,25 @@
 /*
  * eax-transform.c: EAX-Serpent bulk data transformation
+ */
+/*
+ * This file is part of secnet.
+ * See README for full list of copyright holders.
  *
+ * secnet is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * secnet is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * version 3 along with secnet; if not, see
+ * https://www.gnu.org/licenses/gpl.html.
+ */
+/*
  * We use EAX with the following parameters:
  *
  *   Plaintext:
@@ -148,8 +167,8 @@ static void transform_delkey(void *sst)
     ti->keyed=False;
 }
 
-static uint32_t transform_forward(void *sst, struct buffer_if *buf,
-                                 const char **errmsg)
+static transform_apply_return transform_forward(void *sst,
+        struct buffer_if *buf, const char **errmsg)
 {
     struct transform_inst *ti=sst;
 
@@ -186,8 +205,8 @@ static uint32_t transform_forward(void *sst, struct buffer_if *buf,
     return 0;
 }
 
-static uint32_t transform_reverse(void *sst, struct buffer_if *buf,
-                                 const char **errmsg)
+static transform_apply_return transform_reverse(void *sst,
+        struct buffer_if *buf, const char **errmsg)
 {
     struct transform_inst *ti=sst;
 
@@ -214,7 +233,7 @@ static uint32_t transform_reverse(void *sst, struct buffer_if *buf,
     if (!ok) {
        TEAX_DEBUG(0,0);
        *errmsg="EAX decryption failed";
-       return 1;
+       return transform_apply_err;
     }
     assert(buf->size >= (int)ti->p.tag_length);
     buf->size -= ti->p.tag_length;
@@ -237,7 +256,7 @@ static uint32_t transform_reverse(void *sst, struct buffer_if *buf,
 
  too_short:
     *errmsg="ciphertext or plaintext too short";
-    return 1;
+    return transform_apply_err;
 }
 
 static struct transform_inst_if *transform_create(void *sst)