summaryrefslogtreecommitdiffstats
path: root/crypto/evp
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2000-02-20 23:43:02 +0000
committerRichard Levitte <levitte@openssl.org>2000-02-20 23:43:02 +0000
commitd3442bc780473f0cd4f378bc31130d4579da640b (patch)
treea9e0e2f1ba5080829e22783c739a9cacaa95ebd5 /crypto/evp
parentdab6f09573742df94c4767663565aca3863f8173 (diff)
Move the registration of callback functions to special functions
designed for that. This removes the potential error to mix data and function pointers. Please note that I'm a little unsure how incorrect calls to the old ctrl functions should be handled, in som cases. I currently return 0 and that's it, but it may be more correct to generate a genuine error in those cases.
Diffstat (limited to 'crypto/evp')
-rw-r--r--crypto/evp/bio_b64.c16
-rw-r--r--crypto/evp/bio_enc.c16
-rw-r--r--crypto/evp/bio_md.c17
-rw-r--r--crypto/evp/bio_ok.c17
4 files changed, 66 insertions, 0 deletions
diff --git a/crypto/evp/bio_b64.c b/crypto/evp/bio_b64.c
index 913bafa5f7..bd5e24f993 100644
--- a/crypto/evp/bio_b64.c
+++ b/crypto/evp/bio_b64.c
@@ -69,6 +69,7 @@ static int b64_read(BIO *h,char *buf,int size);
static long b64_ctrl(BIO *h,int cmd,long arg1,char *arg2);
static int b64_new(BIO *h);
static int b64_free(BIO *data);
+static long b64_callback_ctrl(BIO *h,int cmd,void (*fp)());
#define B64_BLOCK_SIZE 1024
#define B64_BLOCK_SIZE2 768
#define B64_NONE 0
@@ -100,6 +101,7 @@ static BIO_METHOD methods_b64=
b64_ctrl,
b64_new,
b64_free,
+ b64_callback_ctrl,
};
BIO_METHOD *BIO_f_base64(void)
@@ -522,3 +524,17 @@ again:
return(ret);
}
+static long b64_callback_ctrl(BIO *b, int cmd, void (*fp)())
+ {
+ long ret=1;
+
+ if (b->next_bio == NULL) return(0);
+ switch (cmd)
+ {
+ default:
+ ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
+ break;
+ }
+ return(ret);
+ }
+
diff --git a/crypto/evp/bio_enc.c b/crypto/evp/bio_enc.c
index 36a601897d..629bf4b95d 100644
--- a/crypto/evp/bio_enc.c
+++ b/crypto/evp/bio_enc.c
@@ -69,6 +69,7 @@ static int enc_read(BIO *h,char *buf,int size);
static long enc_ctrl(BIO *h,int cmd,long arg1,char *arg2);
static int enc_new(BIO *h);
static int enc_free(BIO *data);
+static long enc_callback_ctrl(BIO *h,int cmd,void (*fp)());
#define ENC_BLOCK_SIZE (1024*4)
typedef struct enc_struct
@@ -92,6 +93,7 @@ static BIO_METHOD methods_enc=
enc_ctrl,
enc_new,
enc_free,
+ enc_callback_ctrl,
};
BIO_METHOD *BIO_f_cipher(void)
@@ -368,6 +370,20 @@ again:
return(ret);
}
+static long enc_callback_ctrl(BIO *b, int cmd, void (*fp)())
+ {
+ long ret=1;
+
+ if (b->next_bio == NULL) return(0);
+ switch (cmd)
+ {
+ default:
+ ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
+ break;
+ }
+ return(ret);
+ }
+
/*
void BIO_set_cipher_ctx(b,c)
BIO *b;
diff --git a/crypto/evp/bio_md.c b/crypto/evp/bio_md.c
index 317167f9c4..aef928dd8f 100644
--- a/crypto/evp/bio_md.c
+++ b/crypto/evp/bio_md.c
@@ -72,6 +72,8 @@ static int md_gets(BIO *h,char *str,int size);
static long md_ctrl(BIO *h,int cmd,long arg1,char *arg2);
static int md_new(BIO *h);
static int md_free(BIO *data);
+static long md_callback_ctrl(BIO *h,int cmd,void (*fp)());
+
static BIO_METHOD methods_md=
{
BIO_TYPE_MD,"message digest",
@@ -82,6 +84,7 @@ static BIO_METHOD methods_md=
md_ctrl,
md_new,
md_free,
+ md_callback_ctrl,
};
BIO_METHOD *BIO_f_md(void)
@@ -220,6 +223,20 @@ static long md_ctrl(BIO *b, int cmd, long num, char *ptr)
return(ret);
}
+static long md_callback_ctrl(BIO *b, int cmd, void (*fp)())
+ {
+ long ret=1;
+
+ if (b->next_bio == NULL) return(0);
+ switch (cmd)
+ {
+ default:
+ ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
+ break;
+ }
+ return(ret);
+ }
+
static int md_gets(BIO *bp, char *buf, int size)
{
EVP_MD_CTX *ctx;
diff --git a/crypto/evp/bio_ok.c b/crypto/evp/bio_ok.c
index a04efa7508..e6ff5f2cdb 100644
--- a/crypto/evp/bio_ok.c
+++ b/crypto/evp/bio_ok.c
@@ -130,6 +130,8 @@ static int ok_read(BIO *h,char *buf,int size);
static long ok_ctrl(BIO *h,int cmd,long arg1,char *arg2);
static int ok_new(BIO *h);
static int ok_free(BIO *data);
+static long ok_callback_ctrl(BIO *h,int cmd,void (*fp)());
+
static void sig_out(BIO* b);
static void sig_in(BIO* b);
static void block_out(BIO* b);
@@ -173,6 +175,7 @@ static BIO_METHOD methods_ok=
ok_ctrl,
ok_new,
ok_free,
+ ok_callback_ctrl,
};
BIO_METHOD *BIO_f_reliable(void)
@@ -428,6 +431,20 @@ static long ok_ctrl(BIO *b, int cmd, long num, char *ptr)
return(ret);
}
+static long ok_callback_ctrl(BIO *b, int cmd, void (*fp)())
+ {
+ long ret=1;
+
+ if (b->next_bio == NULL) return(0);
+ switch (cmd)
+ {
+ default:
+ ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
+ break;
+ }
+ return(ret);
+ }
+
static void longswap(void *_ptr, int len)
{
#ifndef L_ENDIAN