diff options
Diffstat (limited to 'crypto/evp')
| -rw-r--r-- | crypto/evp/bio_b64.c | 14 | ||||
| -rw-r--r-- | crypto/evp/bio_enc.c | 16 | ||||
| -rw-r--r-- | crypto/evp/bio_md.c | 14 | ||||
| -rw-r--r-- | crypto/evp/bio_ok.c | 12 | ||||
| -rw-r--r-- | crypto/evp/evp.h | 14 | ||||
| -rw-r--r-- | crypto/evp/evp_err.c | 3 | ||||
| -rw-r--r-- | crypto/evp/evp_pbe.c | 5 | ||||
| -rw-r--r-- | crypto/evp/evp_pkey.c | 57 | ||||
| -rw-r--r-- | crypto/evp/names.c | 5 | ||||
| -rw-r--r-- | crypto/evp/p5_crpt.c | 3 | ||||
| -rw-r--r-- | crypto/evp/p5_crpt2.c | 3 |
11 files changed, 59 insertions, 87 deletions
diff --git a/crypto/evp/bio_b64.c b/crypto/evp/bio_b64.c index e76387eaece..bd5e24f9939 100644 --- a/crypto/evp/bio_b64.c +++ b/crypto/evp/bio_b64.c @@ -62,11 +62,11 @@ #include <openssl/buffer.h> #include <openssl/evp.h> -static int b64_write(BIO *h, const char *buf, int num); -static int b64_read(BIO *h, char *buf, int size); -/*static int b64_puts(BIO *h, const char *str); */ -/*static int b64_gets(BIO *h, char *str, int size); */ -static long b64_ctrl(BIO *h, int cmd, long arg1, void *arg2); +static int b64_write(BIO *h,char *buf,int num); +static int b64_read(BIO *h,char *buf,int size); +/*static int b64_puts(BIO *h,char *str); */ +/*static int b64_gets(BIO *h,char *str,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)()); @@ -340,7 +340,7 @@ static int b64_read(BIO *b, char *out, int outl) return((ret == 0)?ret_code:ret); } -static int b64_write(BIO *b, const char *in, int inl) +static int b64_write(BIO *b, char *in, int inl) { int ret=inl,n,i; BIO_B64_CTX *ctx; @@ -434,7 +434,7 @@ static int b64_write(BIO *b, const char *in, int inl) return(ret); } -static long b64_ctrl(BIO *b, int cmd, long num, void *ptr) +static long b64_ctrl(BIO *b, int cmd, long num, char *ptr) { BIO_B64_CTX *ctx; long ret=1; diff --git a/crypto/evp/bio_enc.c b/crypto/evp/bio_enc.c index 1b7a21010c6..629bf4b95d9 100644 --- a/crypto/evp/bio_enc.c +++ b/crypto/evp/bio_enc.c @@ -62,14 +62,14 @@ #include <openssl/buffer.h> #include <openssl/evp.h> -static int enc_write(BIO *h, const char *buf, int num); -static int enc_read(BIO *h, char *buf, int size); -/*static int enc_puts(BIO *h, const char *str); */ -/*static int enc_gets(BIO *h, char *str, int size); */ -static long enc_ctrl(BIO *h, int cmd, long arg1, void *arg2); +static int enc_write(BIO *h,char *buf,int num); +static int enc_read(BIO *h,char *buf,int size); +/*static int enc_puts(BIO *h,char *str); */ +/*static int enc_gets(BIO *h,char *str,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)()); +static long enc_callback_ctrl(BIO *h,int cmd,void (*fp)()); #define ENC_BLOCK_SIZE (1024*4) typedef struct enc_struct @@ -224,7 +224,7 @@ static int enc_read(BIO *b, char *out, int outl) return((ret == 0)?ctx->cont:ret); } -static int enc_write(BIO *b, const char *in, int inl) +static int enc_write(BIO *b, char *in, int inl) { int ret=0,n,i; BIO_ENC_CTX *ctx; @@ -279,7 +279,7 @@ static int enc_write(BIO *b, const char *in, int inl) return(ret); } -static long enc_ctrl(BIO *b, int cmd, long num, void *ptr) +static long enc_ctrl(BIO *b, int cmd, long num, char *ptr) { BIO *dbio; BIO_ENC_CTX *ctx,*dctx; diff --git a/crypto/evp/bio_md.c b/crypto/evp/bio_md.c index f21319c04ed..aef928dd8fb 100644 --- a/crypto/evp/bio_md.c +++ b/crypto/evp/bio_md.c @@ -65,11 +65,11 @@ /* BIO_put and BIO_get both add to the digest, * BIO_gets returns the digest */ -static int md_write(BIO *h, char const *buf, int num); -static int md_read(BIO *h, char *buf, int size); -/*static int md_puts(BIO *h, const char *str); */ -static int md_gets(BIO *h, char *str, int size); -static long md_ctrl(BIO *h, int cmd, long arg1, void *arg2); +static int md_write(BIO *h,char *buf,int num); +static int md_read(BIO *h,char *buf,int size); +/*static int md_puts(BIO *h,char *str); */ +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)()); @@ -139,7 +139,7 @@ static int md_read(BIO *b, char *out, int outl) return(ret); } -static int md_write(BIO *b, const char *in, int inl) +static int md_write(BIO *b, char *in, int inl) { int ret=0; EVP_MD_CTX *ctx; @@ -162,7 +162,7 @@ static int md_write(BIO *b, const char *in, int inl) return(ret); } -static long md_ctrl(BIO *b, int cmd, long num, void *ptr) +static long md_ctrl(BIO *b, int cmd, long num, char *ptr) { EVP_MD_CTX *ctx,*dctx,**pctx; const EVP_MD **ppmd; diff --git a/crypto/evp/bio_ok.c b/crypto/evp/bio_ok.c index 4f9b703a36a..e6ff5f2cdb6 100644 --- a/crypto/evp/bio_ok.c +++ b/crypto/evp/bio_ok.c @@ -125,12 +125,12 @@ #include <openssl/evp.h> #include <openssl/rand.h> -static int ok_write(BIO *h, const char *buf, int num); -static int ok_read(BIO *h, char *buf, int size); -static long ok_ctrl(BIO *h, int cmd, long arg1, void *arg2); +static int ok_write(BIO *h,char *buf,int num); +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 long ok_callback_ctrl(BIO *h,int cmd,void (*fp)()); static void sig_out(BIO* b); static void sig_in(BIO* b); @@ -287,7 +287,7 @@ static int ok_read(BIO *b, char *out, int outl) return(ret); } -static int ok_write(BIO *b, const char *in, int inl) +static int ok_write(BIO *b, char *in, int inl) { int ret=0,n,i; BIO_OK_CTX *ctx; @@ -345,7 +345,7 @@ static int ok_write(BIO *b, const char *in, int inl) return(ret); } -static long ok_ctrl(BIO *b, int cmd, long num, void *ptr) +static long ok_ctrl(BIO *b, int cmd, long num, char *ptr) { BIO_OK_CTX *ctx; EVP_MD *md; diff --git a/crypto/evp/evp.h b/crypto/evp/evp.h index c0f982afb1c..54215b09056 100644 --- a/crypto/evp/evp.h +++ b/crypto/evp/evp.h @@ -59,12 +59,8 @@ #ifndef HEADER_ENVELOPE_H #define HEADER_ENVELOPE_H -#ifdef OPENSSL_ALGORITHM_DEFINES -# include <openssl/opensslconf.h> -#else -# define OPENSSL_ALGORITHM_DEFINES -# include <openssl/opensslconf.h> -# undef OPENSSL_ALGORITHM_DEFINES +#ifdef __cplusplus +extern "C" { #endif #ifndef NO_MD2 @@ -151,10 +147,6 @@ #define EVP_PKEY_DSA4 NID_dsaWithSHA1_2 #define EVP_PKEY_DH NID_dhKeyAgreement -#ifdef __cplusplus -extern "C" { -#endif - /* Type needs to be a bit field * Sub-type needs to be for variations on the method, as in, can it do * arbitrary encryption.... */ @@ -176,7 +168,7 @@ typedef struct evp_pkey_st #endif } pkey; int save_parameters; - STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */ + STACK /*X509_ATTRIBUTE*/ *attributes; /* [ 0 ] */ } EVP_PKEY; #define EVP_PKEY_MO_SIGN 0x0001 diff --git a/crypto/evp/evp_err.c b/crypto/evp/evp_err.c index fc149cbb1ad..97953a0fc18 100644 --- a/crypto/evp/evp_err.c +++ b/crypto/evp/evp_err.c @@ -54,8 +54,7 @@ */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes - * made to it will be overwritten when the script next updates this file, - * only reason strings will be preserved. + * made to it will be overwritten when the script next updates this file. */ #include <stdio.h> diff --git a/crypto/evp/evp_pbe.c b/crypto/evp/evp_pbe.c index 187521eb58d..353c3ad667f 100644 --- a/crypto/evp/evp_pbe.c +++ b/crypto/evp/evp_pbe.c @@ -92,8 +92,7 @@ int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen, ERR_add_error_data(2, "TYPE=", obj_tmp); return 0; } - if(!pass) passlen = 0; - else if (passlen == -1) passlen = strlen(pass); + if (passlen == -1) passlen = strlen(pass); pbetmp = (EVP_PBE_CTL *)sk_value (pbe_algs, i); i = (*pbetmp->keygen)(ctx, pass, passlen, param, pbetmp->cipher, pbetmp->md, en_de); @@ -115,7 +114,7 @@ int EVP_PBE_alg_add (int nid, EVP_CIPHER *cipher, EVP_MD *md, EVP_PBE_KEYGEN *keygen) { EVP_PBE_CTL *pbe_tmp; - if (!pbe_algs) pbe_algs = sk_new ((int (*)())pbe_cmp); + if (!pbe_algs) pbe_algs = sk_new (pbe_cmp); if (!(pbe_tmp = (EVP_PBE_CTL*) Malloc (sizeof(EVP_PBE_CTL)))) { EVPerr(EVP_F_EVP_PBE_ALG_ADD,ERR_R_MALLOC_FAILURE); return 0; diff --git a/crypto/evp/evp_pkey.c b/crypto/evp/evp_pkey.c index 892d1e91daa..d5e6f5880ff 100644 --- a/crypto/evp/evp_pkey.c +++ b/crypto/evp/evp_pkey.c @@ -76,7 +76,7 @@ EVP_PKEY *EVP_PKCS82PKEY (PKCS8_PRIV_KEY_INFO *p8) DSA *dsa = NULL; ASN1_INTEGER *privkey; ASN1_TYPE *t1, *t2, *param = NULL; - STACK_OF(ASN1_TYPE) *ndsa = NULL; + STACK *ndsa = NULL; BN_CTX *ctx = NULL; int plen; #endif @@ -119,13 +119,13 @@ EVP_PKEY *EVP_PKCS82PKEY (PKCS8_PRIV_KEY_INFO *p8) /* Check for broken DSA PKCS#8, UGH! */ if(*p == (V_ASN1_SEQUENCE|V_ASN1_CONSTRUCTED)) { - if(!(ndsa = ASN1_seq_unpack_ASN1_TYPE(p, pkeylen, - d2i_ASN1_TYPE, - ASN1_TYPE_free))) { + if(!(ndsa = ASN1_seq_unpack(p, pkeylen, + (char *(*)())d2i_ASN1_TYPE, + ASN1_TYPE_free))) { EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); goto dsaerr; } - if(sk_ASN1_TYPE_num(ndsa) != 2 ) { + if(sk_num(ndsa) != 2 ) { EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); goto dsaerr; } @@ -133,9 +133,9 @@ EVP_PKEY *EVP_PKCS82PKEY (PKCS8_PRIV_KEY_INFO *p8) * SEQUENCE {parameters, priv_key} * SEQUENCE {pub_key, priv_key} */ - - t1 = sk_ASN1_TYPE_value(ndsa, 0); - t2 = sk_ASN1_TYPE_value(ndsa, 1); + + t1 = (ASN1_TYPE *)sk_value(ndsa, 0); + t2 = (ASN1_TYPE *)sk_value(ndsa, 1); if(t1->type == V_ASN1_SEQUENCE) { p8->broken = PKCS8_EMBEDDED_PARAM; param = t1; @@ -152,14 +152,7 @@ EVP_PKEY *EVP_PKCS82PKEY (PKCS8_PRIV_KEY_INFO *p8) goto dsaerr; } privkey = t2->value.integer; - } else { - if (!(privkey=d2i_ASN1_INTEGER (NULL, &p, pkeylen))) { - EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); - goto dsaerr; - } - param = p8->pkeyalg->parameter; - } - if (!param || (param->type != V_ASN1_SEQUENCE)) { + } else if (!(privkey=d2i_ASN1_INTEGER (NULL, &p, pkeylen))) { EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); goto dsaerr; } @@ -193,12 +186,11 @@ EVP_PKEY *EVP_PKCS82PKEY (PKCS8_PRIV_KEY_INFO *p8) EVP_PKEY_assign_DSA(pkey, dsa); BN_CTX_free (ctx); - if(ndsa) sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free); - else ASN1_INTEGER_free(privkey); + sk_pop_free(ndsa, ASN1_TYPE_free); break; dsaerr: BN_CTX_free (ctx); - sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free); + sk_pop_free(ndsa, ASN1_TYPE_free); DSA_free(dsa); EVP_PKEY_free(pkey); return NULL; @@ -302,10 +294,9 @@ static int dsa_pkey2pkcs8(PKCS8_PRIV_KEY_INFO *p8, EVP_PKEY *pkey) ASN1_STRING *params; ASN1_INTEGER *prkey; ASN1_TYPE *ttmp; - STACK_OF(ASN1_TYPE) *ndsa; + STACK *ndsa; unsigned char *p, *q; int len; - p8->pkeyalg->algorithm = OBJ_nid2obj(NID_dsa); len = i2d_DSAparams (pkey->pkey.dsa, NULL); if (!(p = Malloc(len))) { @@ -346,7 +337,7 @@ static int dsa_pkey2pkcs8(PKCS8_PRIV_KEY_INFO *p8, EVP_PKEY *pkey) p8->pkeyalg->parameter->value.sequence = params; p8->pkeyalg->parameter->type = V_ASN1_SEQUENCE; - ndsa = sk_ASN1_TYPE_new_null(); + ndsa = sk_new_null(); ttmp = ASN1_TYPE_new(); if (!(ttmp->value.integer = BN_to_ASN1_INTEGER (pkey->pkey.dsa->pub_key, NULL))) { EVPerr(EVP_F_EVP_PKEY2PKCS8,EVP_R_ENCODE_ERROR); @@ -354,53 +345,53 @@ static int dsa_pkey2pkcs8(PKCS8_PRIV_KEY_INFO *p8, EVP_PKEY *pkey) return 0; } ttmp->type = V_ASN1_INTEGER; - sk_ASN1_TYPE_push(ndsa, ttmp); + sk_push(ndsa, (char *)ttmp); ttmp = ASN1_TYPE_new(); ttmp->value.integer = prkey; ttmp->type = V_ASN1_INTEGER; - sk_ASN1_TYPE_push(ndsa, ttmp); + sk_push(ndsa, (char *)ttmp); p8->pkey->value.octet_string = ASN1_OCTET_STRING_new(); - if (!ASN1_seq_pack_ASN1_TYPE(ndsa, i2d_ASN1_TYPE, + if (!ASN1_seq_pack(ndsa, i2d_ASN1_TYPE, &p8->pkey->value.octet_string->data, &p8->pkey->value.octet_string->length)) { EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); - sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free); + sk_pop_free(ndsa, ASN1_TYPE_free); M_ASN1_INTEGER_free(prkey); return 0; } - sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free); + sk_pop_free(ndsa, ASN1_TYPE_free); break; case PKCS8_EMBEDDED_PARAM: p8->pkeyalg->parameter->type = V_ASN1_NULL; - ndsa = sk_ASN1_TYPE_new_null(); + ndsa = sk_new_null(); ttmp = ASN1_TYPE_new(); ttmp->value.sequence = params; ttmp->type = V_ASN1_SEQUENCE; - sk_ASN1_TYPE_push(ndsa, ttmp); + sk_push(ndsa, (char *)ttmp); ttmp = ASN1_TYPE_new(); ttmp->value.integer = prkey; ttmp->type = V_ASN1_INTEGER; - sk_ASN1_TYPE_push(ndsa, ttmp); + sk_push(ndsa, (char *)ttmp); p8->pkey->value.octet_string = ASN1_OCTET_STRING_new(); - if (!ASN1_seq_pack_ASN1_TYPE(ndsa, i2d_ASN1_TYPE, + if (!ASN1_seq_pack(ndsa, i2d_ASN1_TYPE, &p8->pkey->value.octet_string->data, &p8->pkey->value.octet_string->length)) { EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); - sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free); + sk_pop_free(ndsa, ASN1_TYPE_free); M_ASN1_INTEGER_free (prkey); return 0; } - sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free); + sk_pop_free(ndsa, ASN1_TYPE_free); break; } return 1; diff --git a/crypto/evp/names.c b/crypto/evp/names.c index 620f43feaad..3e8f4603285 100644 --- a/crypto/evp/names.c +++ b/crypto/evp/names.c @@ -114,10 +114,5 @@ void EVP_cleanup(void) { OBJ_NAME_cleanup(OBJ_NAME_TYPE_CIPHER_METH); OBJ_NAME_cleanup(OBJ_NAME_TYPE_MD_METH); - /* The above calls will only clean out the contents of the name - hash table, but not the hash table itself. The following line - does that part. -- Richard Levitte */ - OBJ_NAME_cleanup(-1); - EVP_PBE_cleanup(); } diff --git a/crypto/evp/p5_crpt.c b/crypto/evp/p5_crpt.c index 6bfa2c5acb1..e3dae52d4de 100644 --- a/crypto/evp/p5_crpt.c +++ b/crypto/evp/p5_crpt.c @@ -125,9 +125,6 @@ int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen, salt = pbe->salt->data; saltlen = pbe->salt->length; - if(!pass) passlen = 0; - else if(passlen == -1) passlen = strlen(pass); - EVP_DigestInit (&ctx, md); EVP_DigestUpdate (&ctx, pass, passlen); EVP_DigestUpdate (&ctx, salt, saltlen); diff --git a/crypto/evp/p5_crpt2.c b/crypto/evp/p5_crpt2.c index 717fad68ca8..27a2c518bed 100644 --- a/crypto/evp/p5_crpt2.c +++ b/crypto/evp/p5_crpt2.c @@ -86,8 +86,7 @@ int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen, HMAC_CTX hctx; p = out; tkeylen = keylen; - if(!pass) passlen = 0; - else if(passlen == -1) passlen = strlen(pass); + if(passlen == -1) passlen = strlen(pass); while(tkeylen) { if(tkeylen > SHA_DIGEST_LENGTH) cplen = SHA_DIGEST_LENGTH; else cplen = tkeylen; |
