Commit 88ce56f8 authored by Dr. Stephen Henson's avatar Dr. Stephen Henson
Browse files

Various function for commmon operations.

parent 664d83bb
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -3,6 +3,12 @@

 Changes between 0.9.6 and 0.9.7  [xx XXX 2000]

  *) Various new functions. EVP_Digest() combines EVP_Digest{Init,Update,Final}()
     in a single operation. X509_get0_pubkey_bitstr() extracts the public_key
     structure from a certificate. X509_pubkey_digest() digests tha public_key
     contents: this is used in various key identifiers. 
     [Steve Henson]

  *) Tolerate nonRepudiation as being valid for S/MIME signing and certSign
     keyUsage if basicConstraints absent for a CA.
     [Steve Henson]
+1 −1
Original line number Diff line number Diff line
@@ -525,7 +525,7 @@ static int add_ocsp_serial(OCSP_REQUEST **req, char *serial, X509 *issuer,
	if(!*req) *req = OCSP_REQUEST_new();
	if(!*req) goto err;
	iname = X509_get_subject_name(issuer);
	ikey = issuer->cert_info->key->public_key;
	ikey = X509_get0_pubkey_bitstr(issuer);
	sno = s2i_ASN1_INTEGER(NULL, serial);
	if(!sno)
		{
+2 −8
Original line number Diff line number Diff line
@@ -74,7 +74,6 @@
int ASN1_digest(int (*i2d)(), const EVP_MD *type, char *data,
		unsigned char *md, unsigned int *len)
	{
	EVP_MD_CTX ctx;
	int i;
	unsigned char *str,*p;

@@ -83,9 +82,7 @@ int ASN1_digest(int (*i2d)(), const EVP_MD *type, char *data,
	p=str;
	i2d(data,&p);

	EVP_DigestInit(&ctx,type);
	EVP_DigestUpdate(&ctx,str,i);
	EVP_DigestFinal(&ctx,md,len);
	EVP_Digest(str, i, md, len, type);
	OPENSSL_free(str);
	return(1);
	}
@@ -96,16 +93,13 @@ int ASN1_digest(int (*i2d)(), const EVP_MD *type, char *data,
int ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *asn,
		unsigned char *md, unsigned int *len)
	{
	EVP_MD_CTX ctx;
	int i;
	unsigned char *str = NULL;

	i=ASN1_item_i2d(asn,&str, it);
	if (!str) return(0);

	EVP_DigestInit(&ctx,type);
	EVP_DigestUpdate(&ctx,str,i);
	EVP_DigestFinal(&ctx,md,len);
	EVP_Digest(str, i, md, len, type);
	OPENSSL_free(str);
	return(1);
	}
+3 −9
Original line number Diff line number Diff line
@@ -196,10 +196,7 @@ int i2d_RSA_NET(const RSA *a, unsigned char **pp, int (*cb)(), int sgckey)
	i = strlen((char *)buf);
	/* If the key is used for SGC the algorithm is modified a little. */
	if(sgckey) {
		EVP_MD_CTX mctx;
		EVP_DigestInit(&mctx, EVP_md5());
		EVP_DigestUpdate(&mctx, buf, i);
		EVP_DigestFinal(&mctx, buf, NULL);
		EVP_Digest(buf, i, buf, NULL, EVP_md5());
		memcpy(buf + 16, "SGCKEYSALT", 10);
		i = 26;
	}
@@ -287,10 +284,7 @@ static RSA *d2i_RSA_NET_2(RSA **a, ASN1_OCTET_STRING *os,

	i = strlen((char *)buf);
	if(sgckey){
		EVP_MD_CTX mctx;
		EVP_DigestInit(&mctx, EVP_md5());
		EVP_DigestUpdate(&mctx, buf, i);
		EVP_DigestFinal(&mctx, buf, NULL);
		EVP_Digest(buf, i, buf, NULL, EVP_md5());
		memcpy(buf + 16, "SGCKEYSALT", 10);
		i = 26;
	}
+11 −1
Original line number Diff line number Diff line
@@ -90,3 +90,13 @@ int EVP_MD_CTX_copy(EVP_MD_CTX *out, EVP_MD_CTX *in)
    memcpy((char *)out,(char *)in,in->digest->ctx_size);
    return 1;
}

int EVP_Digest(void *data, unsigned int count,
		unsigned char *md, unsigned int *size, const EVP_MD *type)
{
	EVP_MD_CTX ctx;
	EVP_DigestInit(&ctx, type);
	EVP_DigestUpdate(&ctx, data, count);
	EVP_DigestFinal(&ctx, md, size);
	return 1;
}
Loading