diff options
author | Ralf S. Engelschall <rse@openssl.org> | 1998-12-21 10:56:39 +0000 |
---|---|---|
committer | Ralf S. Engelschall <rse@openssl.org> | 1998-12-21 10:56:39 +0000 |
commit | 58964a492275ca9a59a0cd9c8155cb2491b4b909 (patch) | |
tree | c7b16876a5789463bbbb468ef4829c8129b3d718 /crypto/x509/x509_cmp.c | |
parent | d02b48c63a58ea4367a0e905979f140b7d090f86 (diff) | |
download | openssl-58964a492275ca9a59a0cd9c8155cb2491b4b909.tar.gz |
Import of old SSLeay release: SSLeay 0.9.0b
Diffstat (limited to 'crypto/x509/x509_cmp.c')
-rw-r--r-- | crypto/x509/x509_cmp.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/crypto/x509/x509_cmp.c b/crypto/x509/x509_cmp.c index 14eebbfcb8..f9d9510ac5 100644 --- a/crypto/x509/x509_cmp.c +++ b/crypto/x509/x509_cmp.c @@ -1,5 +1,5 @@ /* crypto/x509/x509_cmp.c */ -/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written @@ -188,17 +188,27 @@ X509_NAME *b; } #ifndef NO_MD5 -/* I should do a DER encoding of the name and then hash it. */ +/* I now DER encode the name and hash it. Since I cache the DER encoding, + * this is reasonably effiecent. */ unsigned long X509_NAME_hash(x) X509_NAME *x; { unsigned long ret=0; unsigned char md[16]; - char str[256]; + unsigned char str[256],*p,*pp; + int i; + + i=i2d_X509_NAME(x,NULL); + if (i > sizeof(str)) + p=Malloc(i); + else + p=str; + + pp=p; + i2d_X509_NAME(x,&pp); + MD5((unsigned char *)p,i,&(md[0])); + if (p != str) Free(p); - X509_NAME_oneline(x,str,256); - ret=strlen(str); - MD5((unsigned char *)str,ret,&(md[0])); ret=( ((unsigned long)md[0] )|((unsigned long)md[1]<<8L)| ((unsigned long)md[2]<<16L)|((unsigned long)md[3]<<24L) )&0xffffffffL; @@ -226,7 +236,7 @@ ASN1_INTEGER *serial; if (X509_issuer_and_serial_cmp(x509,&x) == 0) return(x509); } - return(x509); + return(NULL); } X509 *X509_find_by_subject(sk,name) |