| 6 |
details. |
details. |
| 7 |
|
|
| 8 |
OpenPGP messages |
OpenPGP messages |
| 9 |
$Id: pgp.c,v 1.10 2002/09/25 16:14:31 disastry Exp $ */ |
$Id: pgp.c,v 1.16 2002/10/09 20:53:30 weaselp Exp $ */ |
| 10 |
|
|
| 11 |
|
|
| 12 |
#include "mix3.h" |
#include "mix3.h" |
| 126 |
|
|
| 127 |
/* Use the user keyring if pubring == NULL */ |
/* Use the user keyring if pubring == NULL */ |
| 128 |
err = pgp_encrypt(mode, body, to, uid, pass, |
err = pgp_encrypt(mode, body, to, uid, pass, |
| 129 |
pubring ? pubring : PGPPUBRING, secring); |
pubring ? pubring : PGPPUBRING, secring); |
| 130 |
buf_free(plainhdr); |
buf_free(plainhdr); |
| 131 |
buf_free(encrhdr); |
buf_free(encrhdr); |
| 132 |
buf_free(to); |
buf_free(to); |
| 312 |
for (p = 0; p < in->length; p++) |
for (p = 0; p < in->length; p++) |
| 313 |
crc = crc << 8 ^ table[(in->data[p] ^ crc >> 16) & 255]; |
crc = crc << 8 ^ table[(in->data[p] ^ crc >> 16) & 255]; |
| 314 |
#endif |
#endif |
| 315 |
return crc; |
return crc & ((1<<24)-1); |
| 316 |
} |
} |
| 317 |
|
|
| 318 |
/* ASCII armor */ |
/* ASCII armor */ |
| 344 |
crc1 = crc24(out); |
crc1 = crc24(out); |
| 345 |
err = buf_getline(in, line); |
err = buf_getline(in, line); |
| 346 |
if (line->length == 5 && line->data[0] == '=') { /* CRC */ |
if (line->length == 5 && line->data[0] == '=') { /* CRC */ |
| 347 |
line->ptr = 1; |
line->ptr = 1; |
| 348 |
err = decode(line, temp); |
err = decode(line, temp); |
| 349 |
crc2 = (((unsigned long)temp->data[0])<<16) | (((unsigned long)temp->data[1])<<8) | temp->data[2]; |
crc2 = (((unsigned long)temp->data[0])<<16) | (((unsigned long)temp->data[1])<<8) | temp->data[2]; |
| 350 |
if (crc1 == crc2) |
if (crc1 == crc2) |
| 351 |
err = buf_getline(in, line); |
err = buf_getline(in, line); |
| 352 |
else |
else { |
| 353 |
|
errlog(NOTICE, "Message CRC does not match.\n"); |
| 354 |
err = -1; |
err = -1; |
| 355 |
|
} |
| 356 |
} else |
} else |
| 357 |
err = -1; |
err = -1; |
| 358 |
if (err == 0 && bufleft(line, end_pgp)) |
if (err == 0 && bufleft(line, end_pgp)) |
| 373 |
|
|
| 374 |
int pgp_armor(BUFFER *in, int mode) |
int pgp_armor(BUFFER *in, int mode) |
| 375 |
|
|
| 376 |
/* mode = 1: remailer message |
/* mode = 1: remailer message (PGP_ARMOR_REM) |
| 377 |
* 0: normal message, |
* 0: normal message, (PGP_ARMOR_NORMAL) |
| 378 |
* 2: key |
* 2: key (PGP_ARMOR_KEY) |
| 379 |
* 3: nym key |
* 3: nym key (PGP_ARMOR_NYMKEY) |
| 380 |
* 4: nym signature |
* 4: nym signature (PGP_ARMOR_NYMSIG) |
| 381 |
|
* 5: secret key (PGP_ARMOR_SECKEY) |
| 382 |
*/ |
*/ |
| 383 |
|
|
| 384 |
{ |
{ |
| 443 |
switch (algo) { |
switch (algo) { |
| 444 |
#ifdef USE_RSA |
#ifdef USE_RSA |
| 445 |
case PGP_ES_RSA: |
case PGP_ES_RSA: |
| 446 |
|
#ifndef USE_IDEA |
| 447 |
|
errlog(WARNING, "IDEA disabled: OpenPGP RSA key cannot be used for decryption!\n"); |
| 448 |
|
#endif |
| 449 |
return (pgp_rsakeygen(bits, userid, pass, pubring, secring, remail)); |
return (pgp_rsakeygen(bits, userid, pass, pubring, secring, remail)); |
| 450 |
#endif /* USE_RSA */ |
#endif /* USE_RSA */ |
| 451 |
case PGP_E_ELG: |
case PGP_E_ELG: |