X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=transform-cbcmac.c;fp=transform-cbcmac.c;h=5e59e212c71857a922459df8e55878299401be40;hb=14f78812a935c8f050f12112c19f359eb12f0686;hp=7e6a1f70f6c2c1ccedd86ffac1cd7c35599afc37;hpb=b2de6bd2d9b5e9047a660e926c4adb17da54fc29;p=secnet.git diff --git a/transform-cbcmac.c b/transform-cbcmac.c index 7e6a1f7..5e59e21 100644 --- a/transform-cbcmac.c +++ b/transform-cbcmac.c @@ -101,8 +101,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; uint8_t *padp; @@ -172,8 +172,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; uint8_t *padp; @@ -191,7 +191,7 @@ static uint32_t transform_reverse(void *sst, struct buffer_if *buf, if (buf->size < 4 + 16 + 16) { *errmsg="msg too short"; - return 1; + return transform_apply_err; } /* CBC */ @@ -203,7 +203,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; + return transform_apply_err; } serpentbe_encrypt(&ti->cryptkey,iv,iv); for (n=buf->start; nstart+buf->size; n+=16) @@ -233,7 +233,7 @@ static uint32_t transform_reverse(void *sst, struct buffer_if *buf, serpentbe_encrypt(&ti->mackey,macacc,macacc); if (!consttime_memeq(macexpected,macacc,16)!=0) { *errmsg="invalid MAC"; - return 1; + return transform_apply_err; } /* PKCS5, stolen from IWJ */ @@ -242,7 +242,7 @@ static uint32_t transform_reverse(void *sst, struct buffer_if *buf, padlen=*padp; if (!padlen || (padlen > PKCS5_MASK+1)) { *errmsg="pkcs5: invalid length"; - return 1; + return transform_apply_err; } buf_unappend(buf,padlen-1);