upgrade to 20030922 snapshot. don't SEGV with certain operation (forward

multiple emails without body), use G1 designation/invocation for 96-char
ISO charsets, and other fixes.
This commit is contained in:
itojun 2003-10-01 22:07:10 +00:00
parent 1b11b40d9b
commit 6d142f6199
4 changed files with 6 additions and 259 deletions

View file

@ -1,8 +1,8 @@
# $NetBSD: Makefile,v 1.24 2003/08/04 12:06:23 itojun Exp $
# $NetBSD: Makefile,v 1.25 2003/10/01 22:07:10 itojun Exp $
DISTNAME= cue-snap-20030714
DISTNAME= cue-snap-20030922
PKGREVISION= 1
PKGNAME= cue-20030714
PKGNAME= cue-20030922
CATEGORIES= mail
MASTER_SITES= ftp://sh.wide.ad.jp/WIDE/free-ware/cue/snap/

View file

@ -1,6 +1,4 @@
$NetBSD: distinfo,v 1.12 2003/08/04 12:06:23 itojun Exp $
$NetBSD: distinfo,v 1.13 2003/10/01 22:07:10 itojun Exp $
SHA1 (cue-snap-20030714.tar.gz) = 96a2e5aaa9ae3efc9f48322d8c1e41831df08fd6
Size (cue-snap-20030714.tar.gz) = 125744 bytes
SHA1 (patch-aa) = 2739bb02e36c5496b51aeea4a4979f49b09f4449
SHA1 (patch-ab) = 1056756d326e3f4e31a7ed92c7ec43fd2026141d
SHA1 (cue-snap-20030922.tar.gz) = dcba38c7cbd25595b08c3298f2d2a443e3a4c53c
Size (cue-snap-20030922.tar.gz) = 129034 bytes

View file

@ -1,13 +0,0 @@
$NetBSD: patch-aa,v 1.1 2003/08/04 12:06:24 itojun Exp $
--- smime.c 2003-07-09 18:07:01.000000000 +0900
+++ smime.c 2003-08-04 21:00:15.000000000 +0900
@@ -962,7 +962,7 @@
xalg->parameter = ASN1_TYPE_new();
BIO_ctrl(p7bio, BIO_C_GET_CIPHER_CTX, 1, (char *)&ctx);
if (EVP_CIPHER_CTX_nid(ctx) == NID_rc2_cbc) {
- EVP_CIPHER *cipher;
+ const EVP_CIPHER *cipher;
STACK *rsk;
PKCS7_RECIP_INFO *ri;
u_char key[EVP_MAX_KEY_LENGTH];

View file

@ -1,238 +0,0 @@
$NetBSD: patch-ab,v 1.1 2003/08/04 12:06:24 itojun Exp $
--- pgp.c 2003-07-08 18:31:47.000000000 +0900
+++ pgp.c 2003-08-04 20:20:27.000000000 +0900
@@ -36,9 +36,11 @@
#include <unistd.h>
#ifdef OPENSSL
+#include <openssl/bn.h>
#include <openssl/rsa.h>
#include <openssl/evp.h>
#include <openssl/rand.h>
+#include <openssl/opensslv.h>
#else /* OPENSSL */
#include <rsa.h>
#include <evp.h>
@@ -62,7 +64,7 @@
static struct pgp_pkt * pgp_parsepkt(u_char **pp, u_char *ep);
static int pgp_makepkt(struct pgp_pkt *pkt, u_char **bufp, int *lenp);
-static EVP_CIPHER * pgp_symalg_cipher(int alg);
+static const EVP_CIPHER * pgp_symalg_cipher(int alg);
static BIGNUM * pgp_decrypt_mpi(EVP_CIPHER_CTX *ctx, u_char **pp, u_short *sum);
static BIGNUM * pgp_parse_mpi(u_char **pp);
@@ -697,7 +699,7 @@
}
}
-static EVP_CIPHER *
+static const EVP_CIPHER *
pgp_symalg_cipher(int alg)
{
switch (alg) {
@@ -717,7 +719,7 @@
return NULL;
}
-static EVP_MD *
+static const EVP_MD *
pgp_hashalg_md(int alg)
{
switch (alg) {
@@ -774,8 +776,8 @@
int
pgp_decrypt_seckey(struct pgp_pkt *pkt, int (*passwd_callback)(char *buf, int size, struct pgp_pkt *pkt))
{
- EVP_CIPHER *cipher;
- EVP_MD *md;
+ const EVP_CIPHER *cipher;
+ const EVP_MD *md;
EVP_CIPHER_CTX ctx;
u_char mdbuf[EVP_MAX_MD_SIZE];
u_int mdlen;
@@ -954,7 +956,7 @@
case PGP_PUB_ELGAMAL_ENC:
{
BIGNUM *yy, *k;
- BN_CTX bn_ctx;
+ BN_CTX *bn_ctx;
DH *dh = ((EVP_PKEY *)seckey->un.pubkey.key)->pkey.dh;
yy = pgp_parse_mpi(&p);
@@ -966,15 +968,15 @@
BN_free(k);
return -1;
}
- BN_CTX_init(&bn_ctx);
- BN_mod_exp(yy, yy, dh->priv_key, dh->p, &bn_ctx);
- BN_mod_inverse(yy, yy, dh->p, &bn_ctx);
- BN_mod_mul(k, k, yy, dh->p, &bn_ctx);
+ bn_ctx = BN_CTX_new();
+ BN_mod_exp(yy, yy, dh->priv_key, dh->p, bn_ctx);
+ BN_mod_inverse(yy, yy, dh->p, bn_ctx);
+ BN_mod_mul(k, k, yy, dh->p, bn_ctx);
len = BN_num_bytes(k);
if ((buf = malloc(len)) == NULL)
return -1;
BN_bn2bin(k, buf);
- BN_CTX_free(&bn_ctx);
+ BN_CTX_free(bn_ctx);
BN_free(k);
BN_free(yy);
/* padding */
@@ -1049,7 +1051,7 @@
{
BIGNUM yy, xx, k, z;
BIGNUM *m;
- BN_CTX bn_ctx;
+ BN_CTX *bn_ctx;
DH *dh = ((EVP_PKEY *)pubkey->un.pubkey.key)->pkey.dh;
u_char *buf;
@@ -1075,11 +1077,11 @@
BN_init(&yy); BN_init(&xx); BN_init(&k); BN_init(&z);
i = BN_num_bits(dh->p) / 2; /* XXX */
- BN_CTX_init(&bn_ctx);
+ bn_ctx = BN_CTX_new();
if (BN_rand(&xx, i, 0, 1)
- && BN_mod_exp(&yy, dh->g, &xx, dh->p, &bn_ctx)
- && BN_mod_exp(&z, dh->pub_key, &xx, dh->p, &bn_ctx)
- && BN_mod_mul(&k, m, &z, dh->p, &bn_ctx)
+ && BN_mod_exp(&yy, dh->g, &xx, dh->p, bn_ctx)
+ && BN_mod_exp(&z, dh->pub_key, &xx, dh->p, bn_ctx)
+ && BN_mod_mul(&k, m, &z, dh->p, bn_ctx)
&& (buf = malloc(BN_num_bytes(&yy) + BN_num_bytes(&k) + 2)) != NULL) {
p = buf;
i = BN_num_bits(&yy);
@@ -1092,7 +1094,7 @@
pkt->dlen = p - buf;
ret = 0;
}
- BN_CTX_free(&bn_ctx);
+ BN_CTX_free(bn_ctx);
BN_free(&yy); BN_free(&xx); BN_free(&k); BN_free(&z);
BN_free(m);
break;
@@ -1106,7 +1108,7 @@
int
pgp_generate_seskey(struct pgp_pkt *pkt)
{
- EVP_CIPHER *cipher;
+ const EVP_CIPHER *cipher;
int keylen;
u_char *p;
int len, i;
@@ -1133,7 +1135,7 @@
int
pgp_decrypt_symdat(struct pgp_pkt *pkt, struct pgp_pkt *seskey)
{
- EVP_CIPHER *cipher;
+ const EVP_CIPHER *cipher;
EVP_CIPHER_CTX ctx;
u_char iv[8];
u_char *p, *decbuf;
@@ -1175,7 +1177,7 @@
int
pgp_encrypt_symdat(struct pgp_pkt *pkt, struct pgp_pkt *seskey)
{
- EVP_CIPHER *cipher;
+ const EVP_CIPHER *cipher;
EVP_CIPHER_CTX ctx;
u_char iv[8], rand[16];
u_char *encbuf;
@@ -1341,7 +1343,7 @@
}
/* XXX: PARSE ASN1! */
-static EVP_MD *
+static const EVP_MD *
pgp_asn1_md(u_char **pp, int len)
{
static const u_char asn1_md2[] = {
@@ -1392,7 +1394,7 @@
u_char *buf;
int ret, len;
u_char *p;
- EVP_MD *md;
+ const EVP_MD *md;
if (pubkey->tag != PGP_TAG_PUBLIC_KEY
|| sign->tag != PGP_TAG_SIGN
@@ -1440,7 +1442,7 @@
BIGNUM *r, *s;
BIGNUM *h;
BIGNUM w, u1, u2, v;
- BN_CTX bn_ctx;
+ BN_CTX *bn_ctx;
dsa = ((EVP_PKEY *)pubkey->un.pubkey.key)->pkey.dsa;
r = pgp_parse_mpi(&p);
@@ -1449,17 +1451,17 @@
if (dsa->p == NULL || dsa->q == NULL || dsa->g == NULL ||
dsa->pub_key == NULL || r == NULL || s == NULL || h == NULL)
goto dsa_err;
- BN_CTX_init(&bn_ctx);
+ bn_ctx = BN_CTX_new();
BN_init(&w); BN_init(&u1); BN_init(&u2); BN_init(&v);
- if (BN_mod_inverse(&w, s, dsa->q, &bn_ctx)
- && BN_mod_mul(&u1, h, &w, dsa->q, &bn_ctx)
- && BN_mod_mul(&u2, r, &w, dsa->q, &bn_ctx)
+ if (BN_mod_inverse(&w, s, dsa->q, bn_ctx)
+ && BN_mod_mul(&u1, h, &w, dsa->q, bn_ctx)
+ && BN_mod_mul(&u2, r, &w, dsa->q, bn_ctx)
&& BN_mod_exp2_mont(&v, dsa->g, &u1, dsa->pub_key, &u2,
- dsa->p, &bn_ctx, NULL)
- && BN_mod(&v, &v, dsa->q, &bn_ctx)
+ dsa->p, bn_ctx, NULL)
+ && BN_mod(&v, &v, dsa->q, bn_ctx)
&& BN_ucmp(&v, r) == 0)
ret = 0;
- BN_CTX_free(&bn_ctx);
+ BN_CTX_free(bn_ctx);
BN_free(&w); BN_free(&u1); BN_free(&u2); BN_free(&v);
dsa_err:
if (r) BN_free(r);
@@ -1532,17 +1534,17 @@
{
DSA *dsa = ((EVP_PKEY *)seckey->un.pubkey.key)->pkey.dsa;
BIGNUM *kinv, *r, s, h;
- BN_CTX bn_ctx;
+ BN_CTX *bn_ctx;
- BN_CTX_init(&bn_ctx);
+ bn_ctx = BN_CTX_new();
kinv = NULL; r = NULL;
BN_init(&s); BN_init(&h);
- if (DSA_sign_setup(dsa, &bn_ctx, &kinv, &r)
+ if (DSA_sign_setup(dsa, bn_ctx, &kinv, &r)
&& BN_bin2bn(sign->un.sign.mdbuf, sign->un.sign.mdlen, &h)
- && BN_mod_mul(&s, dsa->priv_key, r, dsa->q, &bn_ctx)
+ && BN_mod_mul(&s, dsa->priv_key, r, dsa->q, bn_ctx)
&& BN_add(&s, &s, &h)
&& (BN_cmp(&s, dsa->q) < 0 || BN_sub(&s, &s, dsa->q))
- && BN_mod_mul(&s, &s, kinv, dsa->q, &bn_ctx)) {
+ && BN_mod_mul(&s, &s, kinv, dsa->q, bn_ctx)) {
len = BN_num_bytes(r) + BN_num_bytes(&s) + 4;
if ((sbuf = malloc(len)) != NULL) {
sign->dbuf = sign->pbuf = sbuf;
@@ -1558,7 +1560,7 @@
}
}
BN_free(kinv); BN_free(r); BN_free(&s); BN_free(&h);
- BN_CTX_free(&bn_ctx);
+ BN_CTX_free(bn_ctx);
break;
}
default:
@@ -1720,7 +1722,7 @@
int
pgp_hash_data_init(struct pgp_pkt *sign)
{
- EVP_MD *md;
+ const EVP_MD *md;
EVP_MD_CTX *ctx;
if ((md = pgp_hashalg_md(sign->un.sign.hashalg)) == NULL)