Commit 8d8c7266 authored by Dr. Stephen Henson's avatar Dr. Stephen Henson
Browse files

Yet more PKCS#12 integration: add lots of files under crypto/pkcs12 and add

them to the build environment.
parent cfcefcbe
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -5,6 +5,11 @@

 Changes between 0.9.2b and 0.9.3

  *) More PKCS#12 integration. Add new pkcs12 directory with Makefile.ssl and
     modify error routines to work internally. Add error codes and PBE init
     to library startup routines.
     [Steve Henson]

  *) Further PKCS#12 integration. Added password based encryption, PKCS#8 and
     packing functions to asn1 and evp. Changed function names and error
     codes along the way.
+1 −1
Original line number Diff line number Diff line
@@ -133,7 +133,7 @@ SDIRS= \
	des rc2 rc4 rc5 idea bf cast \
	bn rsa dsa dh \
	buffer bio stack lhash rand err objects \
	evp asn1 pem x509 x509v3 conf txt_db pkcs7 comp
	evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp

# Do not edit this manually. Use util/ssldir.pl do change this!
INSTALLTOP=/usr/local/ssl
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ SDIRS= md2 md5 sha mdc2 hmac ripemd \
	des rc2 rc4 rc5 idea bf cast \
	bn rsa dsa dh \
	buffer bio stack lhash rand err objects \
	evp asn1 pem x509 x509v3 conf txt_db pkcs7 comp
	evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp

GENERAL=Makefile README

+68 −0
Original line number Diff line number Diff line
@@ -59,9 +59,12 @@
#include <stdio.h>
#include "cryptlib.h"
#include "asn1_mac.h"
#include "rand.h"

/* PKCS#5 password based encryption structure */

#define PKCS5_SALT_LEN	8

/*
 *ASN1err(ASN1_F_PBEPARAM_NEW,ASN1_R_DEOCDE_ERROR)
 *ASN1err(ASN1_F_D2I_PBEPARAM,ASN1_R_DEOCDE_ERROR)
@@ -114,3 +117,68 @@ PBEPARAM *a;
	ASN1_INTEGER_free (a->iter);
	Free ((char *)a);
}

/* Return an algorithm identifier for a PKCS#5 PBE algorithm */

X509_ALGOR *PKCS5_pbe_set(alg, iter, salt, saltlen)
int alg;
int iter;
unsigned char *salt;
int saltlen;
{
	unsigned char *pdata, *ptmp;
	int plen;
	PBEPARAM *pbe;
	ASN1_OBJECT *al;
	X509_ALGOR *algor;
	ASN1_TYPE *astype;

	if (!(pbe = PBEPARAM_new ())) {
		ASN1err(ASN1_F_ASN1_PBE_SET,ERR_R_MALLOC_FAILURE);
		return NULL;
	}
	ASN1_INTEGER_set (pbe->iter, iter);
	if (!saltlen) saltlen = PKCS5_SALT_LEN;
	if (!(pbe->salt->data = Malloc (saltlen))) {
		ASN1err(ASN1_F_ASN1_PBE_SET,ERR_R_MALLOC_FAILURE);
		return NULL;
	}
	pbe->salt->length = saltlen;
	if (salt) memcpy (pbe->salt->data, salt, saltlen);
	else RAND_bytes (pbe->salt->data, saltlen);
	if (!(plen = i2d_PBEPARAM (pbe, NULL))) {
		ASN1err(ASN1_F_ASN1_PBE_SET,ASN1_R_ENCODE_ERROR);
		return NULL;
	}
	if (!(pdata = Malloc (plen))) {
		ASN1err(ASN1_F_ASN1_PBE_SET,ERR_R_MALLOC_FAILURE);
		return NULL;
	}
	ptmp = pdata;
	i2d_PBEPARAM (pbe, &ptmp);
	PBEPARAM_free (pbe);

	if (!(astype = ASN1_TYPE_new())) {
		ASN1err(ASN1_F_ASN1_PBE_SET,ERR_R_MALLOC_FAILURE);
		return NULL;
	}

	astype->type = V_ASN1_SEQUENCE;
	if (!(astype->value.sequence=ASN1_STRING_new())) {
		ASN1err(ASN1_F_ASN1_PBE_SET,ERR_R_MALLOC_FAILURE);
		return NULL;
	}
	ASN1_STRING_set (astype->value.sequence, pdata, plen);
	Free (pdata);
	
	al = OBJ_nid2obj(alg); /* never need to free al */
	if (!(algor = X509_ALGOR_new())) {
		ASN1err(ASN1_F_ASN1_PBE_SET,ERR_R_MALLOC_FAILURE);
		return NULL;
	}
	ASN1_OBJECT_free(algor->algorithm);
	algor->algorithm = al;
	algor->parameter = astype;

	return (algor);
}
+2 −0
Original line number Diff line number Diff line
@@ -117,6 +117,7 @@ typedef struct err_state_st
#define ERR_LIB_BIO		32
#define ERR_LIB_PKCS7		33
#define ERR_LIB_X509V3		34
#define ERR_LIB_PKCS12		35

#define ERR_LIB_USER		128

@@ -143,6 +144,7 @@ typedef struct err_state_st
#define PROXYerr(f,r) ERR_PUT_error(ERR_LIB_PROXY,(f),(r),ERR_file_name,__LINE__)
#define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),ERR_file_name,__LINE__)
#define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),ERR_file_name,__LINE__)
#define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),ERR_file_name,__LINE__)

/* Borland C seems too stupid to be able to shift and do longs in
 * the pre-processor :-( */
Loading