/* Transform module - 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.
+ */
+
/* For now it's hard-coded to do sequence
number/pkcs5/serpent-cbcmac/serpent with a 256 bit key for each
instance of serpent. We also require key material for the IVs for
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;
uint8_t *padp;
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;
uint8_t *padp;
if (buf->size < 4 + 16 + 16) {
*errmsg="msg too short";
- return 1;
+ return transform_apply_err;
}
/* CBC */
/* Assert bufsize is multiple of blocksize */
if (buf->size&0xf) {
*errmsg="msg not multiple of cipher blocksize";
- return 1;
+ return transform_apply_err;
}
serpentbe_encrypt(&ti->cryptkey,iv,iv);
for (n=buf->start; n<buf->start+buf->size; n+=16)
serpentbe_encrypt(&ti->mackey,macplain,macacc);
}
serpentbe_encrypt(&ti->mackey,macacc,macacc);
- if (!consttime_memeq(macexpected,macacc,16)!=0) {
+ if (!consttime_memeq(macexpected,macacc,16)) {
*errmsg="invalid MAC";
- return 1;
+ return transform_apply_err;
}
/* PKCS5, stolen from IWJ */
padlen=*padp;
if (!padlen || (padlen > PKCS5_MASK+1)) {
*errmsg="pkcs5: invalid length";
- return 1;
+ return transform_apply_err;
}
buf_unappend(buf,padlen-1);
/* First parameter must be a dict */
item=list_elem(args,0);
if (!item || item->type!=t_dict)
- cfgfatal(loc,"userv-ipif","parameter must be a dictionary\n");
+ cfgfatal(loc,"serpent256-cbc","parameter must be a dictionary\n");
dict=item->data.dict;
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);
}