version 1.70, 2014/04/14 00:35:32 |
version 1.71, 2014/04/22 05:44:40 |
|
|
if (comment) { |
if (comment) { |
if (strlcpy(comment, b64 + COMMENTHDRLEN, |
if (strlcpy(comment, b64 + COMMENTHDRLEN, |
COMMENTMAXLEN) >= COMMENTMAXLEN) |
COMMENTMAXLEN) >= COMMENTMAXLEN) |
err(1, "comment too long"); |
errx(1, "comment too long"); |
} |
} |
b64end = strchr(commentend + 1, '\n'); |
b64end = strchr(commentend + 1, '\n'); |
if (!b64end) |
if (!b64end) |
|
|
fd = xopen(filename, O_CREAT|oflags|O_NOFOLLOW|O_WRONLY, mode); |
fd = xopen(filename, O_CREAT|oflags|O_NOFOLLOW|O_WRONLY, mode); |
if (snprintf(header, sizeof(header), "%s%s\n", |
if (snprintf(header, sizeof(header), "%s%s\n", |
COMMENTHDR, comment) >= sizeof(header)) |
COMMENTHDR, comment) >= sizeof(header)) |
err(1, "comment too long"); |
errx(1, "comment too long"); |
writeall(fd, header, strlen(header), filename); |
writeall(fd, header, strlen(header), filename); |
if ((rv = b64_ntop(buf, buflen, b64, sizeof(b64)-1)) == -1) |
if ((rv = b64_ntop(buf, buflen, b64, sizeof(b64)-1)) == -1) |
errx(1, "b64 encode failed"); |
errx(1, "b64 encode failed"); |
|
|
|
|
if (snprintf(commentbuf, sizeof(commentbuf), "%s secret key", |
if (snprintf(commentbuf, sizeof(commentbuf), "%s secret key", |
comment) >= sizeof(commentbuf)) |
comment) >= sizeof(commentbuf)) |
err(1, "comment too long"); |
errx(1, "comment too long"); |
writeb64file(seckeyfile, commentbuf, &enckey, |
writeb64file(seckeyfile, commentbuf, &enckey, |
sizeof(enckey), NULL, 0, O_EXCL, 0600); |
sizeof(enckey), NULL, 0, O_EXCL, 0600); |
explicit_bzero(&enckey, sizeof(enckey)); |
explicit_bzero(&enckey, sizeof(enckey)); |
|
|
memcpy(pubkey.fingerprint, fingerprint, FPLEN); |
memcpy(pubkey.fingerprint, fingerprint, FPLEN); |
if (snprintf(commentbuf, sizeof(commentbuf), "%s public key", |
if (snprintf(commentbuf, sizeof(commentbuf), "%s public key", |
comment) >= sizeof(commentbuf)) |
comment) >= sizeof(commentbuf)) |
err(1, "comment too long"); |
errx(1, "comment too long"); |
writeb64file(pubkeyfile, commentbuf, &pubkey, |
writeb64file(pubkeyfile, commentbuf, &pubkey, |
sizeof(pubkey), NULL, 0, O_EXCL, 0666); |
sizeof(pubkey), NULL, 0, O_EXCL, 0666); |
} |
} |
|
|
if ((secname = strstr(seckeyfile, ".sec")) && strlen(secname) == 4) { |
if ((secname = strstr(seckeyfile, ".sec")) && strlen(secname) == 4) { |
if (snprintf(sigcomment, sizeof(sigcomment), VERIFYWITH "%.*s.pub", |
if (snprintf(sigcomment, sizeof(sigcomment), VERIFYWITH "%.*s.pub", |
(int)strlen(seckeyfile) - 4, seckeyfile) >= sizeof(sigcomment)) |
(int)strlen(seckeyfile) - 4, seckeyfile) >= sizeof(sigcomment)) |
err(1, "comment too long"); |
errx(1, "comment too long"); |
} else { |
} else { |
if (snprintf(sigcomment, sizeof(sigcomment), "signature from %s", |
if (snprintf(sigcomment, sizeof(sigcomment), "signature from %s", |
comment) >= sizeof(sigcomment)) |
comment) >= sizeof(sigcomment)) |
err(1, "comment too long"); |
errx(1, "comment too long"); |
} |
} |
if (embedded) |
if (embedded) |
writeb64file(sigfile, sigcomment, &sig, sizeof(sig), msg, |
writeb64file(sigfile, sigcomment, &sig, sizeof(sig), msg, |