summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/md2/md2_one.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/md2/md2_one.c')
-rw-r--r--src/lib/libcrypto/md2/md2_one.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/lib/libcrypto/md2/md2_one.c b/src/lib/libcrypto/md2/md2_one.c
index 513bf62fdb..7157299d95 100644
--- a/src/lib/libcrypto/md2/md2_one.c
+++ b/src/lib/libcrypto/md2/md2_one.c
@@ -58,22 +58,35 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include "md2.h" 61#include <openssl/md2.h>
62 62
63/* This is a separate file so that #defines in cryptlib.h can 63/* This is a separate file so that #defines in cryptlib.h can
64 * map my MD functions to different names */ 64 * map my MD functions to different names */
65 65
66unsigned char *MD2(d, n, md) 66unsigned char *MD2(unsigned char *d, unsigned long n, unsigned char *md)
67unsigned char *d;
68unsigned long n;
69unsigned char *md;
70 { 67 {
71 MD2_CTX c; 68 MD2_CTX c;
72 static unsigned char m[MD2_DIGEST_LENGTH]; 69 static unsigned char m[MD2_DIGEST_LENGTH];
73 70
74 if (md == NULL) md=m; 71 if (md == NULL) md=m;
75 MD2_Init(&c); 72 MD2_Init(&c);
73#ifndef CHARSET_EBCDIC
76 MD2_Update(&c,d,n); 74 MD2_Update(&c,d,n);
75#else
76 {
77 char temp[1024];
78 unsigned long chunk;
79
80 while (n > 0)
81 {
82 chunk = (n > sizeof(temp)) ? sizeof(temp) : n;
83 ebcdic2ascii(temp, d, chunk);
84 MD2_Update(&c,temp,chunk);
85 n -= chunk;
86 d += chunk;
87 }
88 }
89#endif
77 MD2_Final(md,&c); 90 MD2_Final(md,&c);
78 memset(&c,0,sizeof(c)); /* Security consideration */ 91 memset(&c,0,sizeof(c)); /* Security consideration */
79 return(md); 92 return(md);