/[pkg-mixmaster]/trunk/Mix/Src/pgp.c
ViewVC logotype

Diff of /trunk/Mix/Src/pgp.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 268 by disastry, Wed Sep 25 16:14:31 2002 UTC revision 332 by weaselp, Wed Oct 9 20:53:32 2002 UTC
# Line 6  Line 6 
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"
# Line 126  int pgp_mailenc(int mode, BUFFER *msg, c Line 126  int pgp_mailenc(int mode, BUFFER *msg, c
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);
# Line 312  unsigned long crc24(BUFFER * in) Line 312  unsigned long crc24(BUFFER * in)
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 */
# Line 344  int pgp_dearmor(BUFFER *in, BUFFER *out) Line 344  int pgp_dearmor(BUFFER *in, BUFFER *out)
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))
# Line 371  end: Line 373  end:
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  {  {
# Line 440  int pgp_keygen(int algo, int bits, BUFFE Line 443  int pgp_keygen(int algo, int bits, BUFFE
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:

Legend:
Removed from v.268  
changed lines
  Added in v.332

  ViewVC Help
Powered by ViewVC 1.1.5