Skip to content

Commit

Permalink
simplify zero padding
Browse files Browse the repository at this point in the history
  • Loading branch information
mlschroe committed Nov 22, 2012
1 parent 255887e commit ca6e567
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -2187,7 +2187,7 @@ sign(char *filename, int isfilter, int mode)
else if (mode == MODE_RAWOPENSSLSIGN)
{
int off, enc = sigtoenc(buf + 6, outl);
int bytes, zbytes;
int bytes;
if (enc != ENC_RSA)
{
fprintf(stderr, "Need RSA key for openssl sign\n");
Expand All @@ -2214,14 +2214,14 @@ sign(char *filename, int isfilter, int mode)
fprintf(stderr, "truncated sig\n");
exit(1);
}
/* round up */
zbytes = bytes;
while ((zbytes & (zbytes - 1)) != 0)
zbytes &= zbytes - 1;
if (bytes != zbytes)
zbytes = zbytes * 2;
while (zbytes-- > bytes)
putc(0, fout);
/* zero pad to multiple of 16 */
if ((bytes & 15) != 0 && fwrite("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16 - (bytes & 15), 1, fout) != 1)
{
perror("fwrite");
if (!isfilter)
unlink(outfilename);
exit(1);
}
if (fwrite(buf + 6 + off + 2, bytes, 1, fout) != 1)
{
perror("fwrite");
Expand Down

0 comments on commit ca6e567

Please sign in to comment.