projects
/
onak.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
cscvs to tla changeset 48
[onak.git]
/
keyid.c
diff --git
a/keyid.c
b/keyid.c
index 65a036328295328b1cc2b984b6e44011d6423728..6bb2e19d2a893469c7e68012631f0170a286c418 100644
(file)
--- a/
keyid.c
+++ b/
keyid.c
@@
-13,11
+13,21
@@
#include "md5.h"
#include "sha.h"
#include "md5.h"
#include "sha.h"
+
/**
* get_keyid - Given a public key returns the keyid.
/**
* get_keyid - Given a public key returns the keyid.
- * @publickey: The key to calculate the
fingerprint
for.
+ * @publickey: The key to calculate the
id
for.
*/
uint64_t get_keyid(struct openpgp_publickey *publickey)
*/
uint64_t get_keyid(struct openpgp_publickey *publickey)
+{
+ return (get_packetid(publickey->publickey));
+}
+
+/**
+ * get_packetid - Given a PGP packet returns the keyid.
+ * @packet: The packet to calculate the id for.
+ */
+uint64_t get_packetid(struct openpgp_packet *packet)
{
SHA1_CONTEXT sha_ctx;
uint64_t keyid = 0;
{
SHA1_CONTEXT sha_ctx;
uint64_t keyid = 0;
@@
-26,9
+36,9
@@
uint64_t get_keyid(struct openpgp_publickey *publickey)
unsigned char c;
unsigned char *buff = NULL;
unsigned char c;
unsigned char *buff = NULL;
- assert(p
ublickey
!= NULL);
+ assert(p
acket
!= NULL);
- switch (p
ublickey->publickey
->data[0]) {
+ switch (p
acket
->data[0]) {
case 2:
case 3:
/*
case 2:
case 3:
/*
@@
-38,14
+48,14
@@
uint64_t get_keyid(struct openpgp_publickey *publickey)
*
* We need to ensure it's an RSA key.
*/
*
* We need to ensure it's an RSA key.
*/
- if (p
ublickey->publickey
->data[7] == 1) {
- offset = (p
ublickey->publickey
->data[8] << 8) +
- p
ublickey->publickey
->data[9];
+ if (p
acket
->data[7] == 1) {
+ offset = (p
acket
->data[8] << 8) +
+ p
acket
->data[9];
offset = ((offset + 7) / 8) + 2;
for (keyid = 0, i = 0; i < 8; i++) {
keyid <<= 8;
offset = ((offset + 7) / 8) + 2;
for (keyid = 0, i = 0; i < 8; i++) {
keyid <<= 8;
- keyid += p
ublickey->publickey
->data[offset++];
+ keyid += p
acket
->data[offset++];
}
} else {
fputs("Type 2 or 3 key, but not RSA.\n", stderr);
}
} else {
fputs("Type 2 or 3 key, but not RSA.\n", stderr);
@@
-65,12
+75,12
@@
uint64_t get_keyid(struct openpgp_publickey *publickey)
*/
c = 0x99;
sha1_write(&sha_ctx, &c, sizeof(c));
*/
c = 0x99;
sha1_write(&sha_ctx, &c, sizeof(c));
- c = p
ublickey->publickey
->length >> 8;
+ c = p
acket
->length >> 8;
sha1_write(&sha_ctx, &c, sizeof(c));
sha1_write(&sha_ctx, &c, sizeof(c));
- c = p
ublickey->publickey
->length & 0xFF;
+ c = p
acket
->length & 0xFF;
sha1_write(&sha_ctx, &c, sizeof(c));
sha1_write(&sha_ctx, &c, sizeof(c));
- sha1_write(&sha_ctx, p
ublickey->publickey
->data,
- p
ublickey->publickey
->length);
+ sha1_write(&sha_ctx, p
acket
->data,
+ p
acket
->length);
sha1_final(&sha_ctx);
buff = sha1_read(&sha_ctx);
sha1_final(&sha_ctx);
buff = sha1_read(&sha_ctx);
@@
-84,7
+94,7
@@
uint64_t get_keyid(struct openpgp_publickey *publickey)
break;
default:
fprintf(stderr, "Unknown key type: %d\n",
break;
default:
fprintf(stderr, "Unknown key type: %d\n",
- p
ublickey->publickey
->data[0]);
+ p
acket
->data[0]);
}
return keyid;
}
return keyid;