* tfcrypt -- high security Threefish encryption tool.
*
* tfcrypt is copyrighted:
- * Copyright (C) 2012-2018 Andrey Rys. All rights reserved.
+ * Copyright (C) 2012-2019 Andrey Rys. All rights reserved.
*
* tfcrypt is licensed to you under the terms of std. MIT/X11 license:
*
#include "tfcrypt.h"
+enum { TFB64_STOP1 = 1, TFB64_STOPF };
+
void do_edbase64(char **fargv)
{
struct base64_decodestate dstate;
lblock = lrem = do_edcrypt == TFC_DO_DECRYPT ? TFC_B64_DWIDTH : TFC_B64_EWIDTH;
ldone = 0;
if (error_action == TFC_ERRACT_SYNC) rdpos = tfc_fdgetpos(sfd);
-_again: lio = read(sfd, pblk, lrem);
- if (lio == 0) do_stop = YES;
+_again: lio = xread(sfd, pblk, lrem);
+ if (lio == 0) do_stop = TFB64_STOP1;
if (lio != NOSIZE) ldone += lio;
else {
if (errno != EIO && catch_all_errors != YES)
pblk = dstblk;
if (ldone == 0) {
- do_stop = TFC_STOP_FULL;
+ do_stop = TFB64_STOPF;
break;
}
lrem = ldone;
ldone = 0;
-_wagain: lio = write(dfd, pblk, lrem);
+_wagain: lio = xwrite(dfd, pblk, lrem);
if (lio != NOSIZE) ldone += lio;
else xerror(NO, NO, NO, "%s", fargv[1]);
if (do_edcrypt == TFC_DO_ENCRYPT) {
size_t t;
- if (lread >= lblock || do_stop == TFC_STOP_FULL) {
- t = write(dfd, "\n", 1);
+ if (lread >= lblock || do_stop == TFB64_STOPF) {
+ t = xwrite(dfd, "\n", 1);
if (t != NOSIZE) lio += t;
else lio = NOSIZE;
}
}
}
- if (do_edcrypt == TFC_DO_ENCRYPT && do_stop == TFC_STOP_BEGAN) {
+ if (do_edcrypt == TFC_DO_ENCRYPT && do_stop == TFB64_STOP1) {
size_t t = estate.count;
pblk = dstblk + estate.count;
base64_encode_blockend((char *)dstblk, &estate);
lrem = estate.count - t;
ldone = 0;
- do_stop = TFC_STOP_FULL;
+ do_stop = TFB64_STOPF;
goto _wagain;
}