-/* $OpenBSD: signify.c,v 1.93 2014/12/29 14:16:04 tedu Exp $ */
+/* $OpenBSD: signify.c,v 1.94 2014/12/29 14:23:17 tedu Exp $ */
/*
* Copyright (c) 2013 Ted Unangst <tedu@openbsd.org>
*
#define PKALG "Ed"
#define KDFALG "BK"
-#define FPLEN 8
+#define KEYNUMLEN 8
#define COMMENTHDR "untrusted comment: "
#define COMMENTHDRLEN 19
uint32_t kdfrounds;
uint8_t salt[16];
uint8_t checksum[8];
- uint8_t fingerprint[FPLEN];
+ uint8_t keynum[KEYNUMLEN];
uint8_t seckey[SECRETBYTES];
};
struct pubkey {
uint8_t pkalg[2];
- uint8_t fingerprint[FPLEN];
+ uint8_t keynum[KEYNUMLEN];
uint8_t pubkey[PUBLICBYTES];
};
struct sig {
uint8_t pkalg[2];
- uint8_t fingerprint[FPLEN];
+ uint8_t keynum[KEYNUMLEN];
uint8_t sig[SIGBYTES];
};
struct pubkey pubkey;
struct enckey enckey;
uint8_t xorkey[sizeof(enckey.seckey)];
- uint8_t fingerprint[FPLEN];
+ uint8_t keynum[KEYNUMLEN];
char commentbuf[COMMENTMAXLEN];
SHA2_CTX ctx;
int i, nr;
crypto_sign_ed25519_keypair(pubkey.pubkey, enckey.seckey);
- arc4random_buf(fingerprint, sizeof(fingerprint));
+ arc4random_buf(keynum, sizeof(keynum));
SHA512Init(&ctx);
SHA512Update(&ctx, enckey.seckey, sizeof(enckey.seckey));
memcpy(enckey.pkalg, PKALG, 2);
memcpy(enckey.kdfalg, KDFALG, 2);
enckey.kdfrounds = htonl(rounds);
- memcpy(enckey.fingerprint, fingerprint, FPLEN);
+ memcpy(enckey.keynum, keynum, KEYNUMLEN);
arc4random_buf(enckey.salt, sizeof(enckey.salt));
kdf(enckey.salt, sizeof(enckey.salt), rounds, 1, 1, xorkey, sizeof(xorkey));
memcpy(enckey.checksum, digest, sizeof(enckey.checksum));
explicit_bzero(&enckey, sizeof(enckey));
memcpy(pubkey.pkalg, PKALG, 2);
- memcpy(pubkey.fingerprint, fingerprint, FPLEN);
+ memcpy(pubkey.keynum, keynum, KEYNUMLEN);
if ((nr = snprintf(commentbuf, sizeof(commentbuf), "%s public key",
comment)) == -1 || nr >= sizeof(commentbuf))
errx(1, "comment too long");
msg = readmsg(msgfile, &msglen);
signmsg(enckey.seckey, msg, msglen, sig.sig);
- memcpy(sig.fingerprint, enckey.fingerprint, FPLEN);
+ memcpy(sig.keynum, enckey.keynum, KEYNUMLEN);
explicit_bzero(&enckey, sizeof(enckey));
memcpy(sig.pkalg, PKALG, 2);
uint8_t *sigbuf, *dummybuf;
unsigned long long siglen, dummylen;
- if (memcmp(pubkey->fingerprint, sig->fingerprint, FPLEN) != 0)
+ if (memcmp(pubkey->keynum, sig->keynum, KEYNUMLEN) != 0)
errx(1, "verification failed: checked against wrong key");
siglen = SIGBYTES + msglen;