diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/a_digest.c')
| -rw-r--r-- | src/lib/libcrypto/asn1/a_digest.c | 49 |
1 files changed, 32 insertions, 17 deletions
diff --git a/src/lib/libcrypto/asn1/a_digest.c b/src/lib/libcrypto/asn1/a_digest.c index 8ddb65b0dc..4931e222a0 100644 --- a/src/lib/libcrypto/asn1/a_digest.c +++ b/src/lib/libcrypto/asn1/a_digest.c | |||
| @@ -58,34 +58,49 @@ | |||
| 58 | 58 | ||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include <time.h> | 60 | #include <time.h> |
| 61 | #include <sys/types.h> | ||
| 62 | #include <sys/stat.h> | ||
| 63 | 61 | ||
| 64 | #include "cryptlib.h" | 62 | #include "cryptlib.h" |
| 65 | #include "evp.h" | ||
| 66 | #include "x509.h" | ||
| 67 | #include "buffer.h" | ||
| 68 | 63 | ||
| 69 | int ASN1_digest(i2d,type,data,md,len) | 64 | #ifndef NO_SYS_TYPES_H |
| 70 | int (*i2d)(); | 65 | # include <sys/types.h> |
| 71 | EVP_MD *type; | 66 | #endif |
| 72 | char *data; | 67 | |
| 73 | unsigned char *md; | 68 | #include <openssl/evp.h> |
| 74 | unsigned int *len; | 69 | #include <openssl/buffer.h> |
| 70 | #include <openssl/x509.h> | ||
| 71 | |||
| 72 | #ifndef NO_ASN1_OLD | ||
| 73 | |||
| 74 | int ASN1_digest(int (*i2d)(), const EVP_MD *type, char *data, | ||
| 75 | unsigned char *md, unsigned int *len) | ||
| 75 | { | 76 | { |
| 76 | EVP_MD_CTX ctx; | ||
| 77 | int i; | 77 | int i; |
| 78 | unsigned char *str,*p; | 78 | unsigned char *str,*p; |
| 79 | 79 | ||
| 80 | i=i2d(data,NULL); | 80 | i=i2d(data,NULL); |
| 81 | if ((str=(unsigned char *)Malloc(i)) == NULL) return(0); | 81 | if ((str=(unsigned char *)OPENSSL_malloc(i)) == NULL) return(0); |
| 82 | p=str; | 82 | p=str; |
| 83 | i2d(data,&p); | 83 | i2d(data,&p); |
| 84 | 84 | ||
| 85 | EVP_DigestInit(&ctx,type); | 85 | EVP_Digest(str, i, md, len, type, NULL); |
| 86 | EVP_DigestUpdate(&ctx,str,i); | 86 | OPENSSL_free(str); |
| 87 | EVP_DigestFinal(&ctx,md,len); | 87 | return(1); |
| 88 | Free(str); | 88 | } |
| 89 | |||
| 90 | #endif | ||
| 91 | |||
| 92 | |||
| 93 | int ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *asn, | ||
| 94 | unsigned char *md, unsigned int *len) | ||
| 95 | { | ||
| 96 | int i; | ||
| 97 | unsigned char *str = NULL; | ||
| 98 | |||
| 99 | i=ASN1_item_i2d(asn,&str, it); | ||
| 100 | if (!str) return(0); | ||
| 101 | |||
| 102 | EVP_Digest(str, i, md, len, type, NULL); | ||
| 103 | OPENSSL_free(str); | ||
| 89 | return(1); | 104 | return(1); |
| 90 | } | 105 | } |
| 91 | 106 | ||
