Browse Source

Working on some missing algorithms now

master
David Lanzendörfer 12 months ago
parent
commit
9f7b8f352c
2 changed files with 19 additions and 24 deletions
  1. +2
    -0
      include/netpgp/packet.h
  2. +17
    -24
      src/packet-parse.c

+ 2
- 0
include/netpgp/packet.h View File

@ -372,6 +372,8 @@ typedef enum {
PGP_PKA_RESERVED_DH = 0x15, /* Reserved for Diffie-Hellman
* (X9.42, as defined for
* IETF-S/MIME) */
PGP_PKA_RESERVED_ELLIPTIC_CURVE_V3 = 0x16, /* Reserved for Elliptic
* Curve v3 (pub 18) */
PGP_PKA_PRIVATE00 = 0x64, /* Private/Experimental Algorithm */
PGP_PKA_PRIVATE01 = 0x65, /* Private/Experimental Algorithm */
PGP_PKA_PRIVATE02 = 0x66, /* Private/Experimental Algorithm */


+ 17
- 24
src/packet-parse.c View File

@ -1435,7 +1435,7 @@ parse_pubkey_data(pgp_pubkey_t *key, pgp_region_t *region,
if (!limread(&c, 1, region, stream)) {
return 0;
}
key->alg = c&0x0f;
key->alg = c;
switch (key->alg) {
case PGP_PKA_DSA:
@ -1465,9 +1465,15 @@ parse_pubkey_data(pgp_pubkey_t *key, pgp_region_t *region,
}
break;
case PGP_PKA_RESERVED_ELLIPTIC_CURVE:
case PGP_PKA_RESERVED_ELLIPTIC_CURVE_V3:
// todo
printf("Elliptic curves! TODO!!!\n");
break;
default:
PGP_ERROR_1(&stream->errors, PGP_E_ALG_UNSUPPORTED_PUBLIC_KEY_ALG, "Unsupported Public Key algorithm (%s)", pgp_show_pka(key->alg));
printf("Unsupported Public Key algorithm (%x)", key->alg);
printf("Unsupported Public Key algorithm (%x)\n %s\n", key->alg, pgp_show_pka(key->alg));
return 0;
}
@ -1503,7 +1509,7 @@ parse_pubkey(pgp_content_enum tag, pgp_region_t *region,
/* XXX: this test should be done for all packets, surely? */
if (region->readc != region->length) {
printf("Unconsumed data (%d)", region->length - region->readc);
printf("Unconsumed data (%d)\n", region->length - region->readc);
PGP_ERROR_1(&stream->errors, PGP_E_R_UNCONSUMED_DATA, "Unconsumed data (%d)", region->length - region->readc);
return 0;
}
@ -2869,30 +2875,17 @@ parse_seckey(pgp_content_enum tag, pgp_region_t *region, pgp_stream_t *stream)
break;
case PGP_PKA_DSA:
//if (!limread_mpi(&pkt.u.seckey.key.dsa.x, region, stream) ||
// !pgp_dsa_private_check(&pkt.u.seckey)) {
// ret = 0;
//}
PGP_ERROR_2(&stream->errors,
PGP_E_ALG_UNSUPPORTED_PUBLIC_KEY_ALG,
"Unsupported Public Key algorithm %d (%s)",
pkt.u.seckey.pubkey.alg,
pgp_show_pka(pkt.u.seckey.pubkey.alg));
ret = 0;
if (!limread_mpi(&pkt.u.seckey.key.dsa.x, region, stream) ||
!pgp_dsa_private_check(&pkt.u.seckey)) {
ret = 0;
}
break;
case PGP_PKA_ELGAMAL:
//if (!limread_mpi(&pkt.u.seckey.key.elgamal.x, region, stream) ||
// !pgp_elgamal_private_check(&pkt.u.seckey)) {
// ret = 0;
//}
PGP_ERROR_2(&stream->errors,
PGP_E_ALG_UNSUPPORTED_PUBLIC_KEY_ALG,
"Unsupported Public Key algorithm %d (%s)",
pkt.u.seckey.pubkey.alg,
pgp_show_pka(pkt.u.seckey.pubkey.alg));
ret = 0;
if (!limread_mpi(&pkt.u.seckey.key.elgamal.x, region, stream) ||
!pgp_elgamal_private_check(&pkt.u.seckey)) {
ret = 0;
}
break;
default:


Loading…
Cancel
Save