OLD | NEW |
1 /* crypto/md2/md2_dgst.c */ | 1 /* crypto/md2/md2_dgst.c */ |
2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * This package is an SSL implementation written | 5 * This package is an SSL implementation written |
6 * by Eric Young (eay@cryptsoft.com). | 6 * by Eric Young (eay@cryptsoft.com). |
7 * The implementation was written so as to conform with Netscapes SSL. | 7 * The implementation was written so as to conform with Netscapes SSL. |
8 * | 8 * |
9 * This library is free for commercial and non-commercial use as long as | 9 * This library is free for commercial and non-commercial use as long as |
10 * the following conditions are aheared to. The following conditions | 10 * the following conditions are aheared to. The following conditions |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 * copied and put under another distribution licence | 55 * copied and put under another distribution licence |
56 * [including the GNU Public Licence.] | 56 * [including the GNU Public Licence.] |
57 */ | 57 */ |
58 | 58 |
59 #include <stdio.h> | 59 #include <stdio.h> |
60 #include <stdlib.h> | 60 #include <stdlib.h> |
61 #include <string.h> | 61 #include <string.h> |
62 #include <openssl/md2.h> | 62 #include <openssl/md2.h> |
63 #include <openssl/opensslv.h> | 63 #include <openssl/opensslv.h> |
64 #include <openssl/crypto.h> | 64 #include <openssl/crypto.h> |
65 #ifdef OPENSSL_FIPS | |
66 #include <openssl/fips.h> | |
67 #endif | |
68 | |
69 #include <openssl/err.h> | |
70 | 65 |
71 const char MD2_version[]="MD2" OPENSSL_VERSION_PTEXT; | 66 const char MD2_version[]="MD2" OPENSSL_VERSION_PTEXT; |
72 | 67 |
73 /* Implemented from RFC1319 The MD2 Message-Digest Algorithm | 68 /* Implemented from RFC1319 The MD2 Message-Digest Algorithm |
74 */ | 69 */ |
75 | 70 |
76 #define UCHAR unsigned char | 71 #define UCHAR unsigned char |
77 | 72 |
78 static void md2_block(MD2_CTX *c, const unsigned char *d); | 73 static void md2_block(MD2_CTX *c, const unsigned char *d); |
79 /* The magic S table - I have converted it to hex since it is | 74 /* The magic S table - I have converted it to hex since it is |
80 * basically just a random byte string. */ | 75 * basically just a random byte string. */ |
81 static MD2_INT S[256]={ | 76 static const MD2_INT S[256]={ |
82 0x29, 0x2E, 0x43, 0xC9, 0xA2, 0xD8, 0x7C, 0x01, | 77 0x29, 0x2E, 0x43, 0xC9, 0xA2, 0xD8, 0x7C, 0x01, |
83 0x3D, 0x36, 0x54, 0xA1, 0xEC, 0xF0, 0x06, 0x13, | 78 0x3D, 0x36, 0x54, 0xA1, 0xEC, 0xF0, 0x06, 0x13, |
84 0x62, 0xA7, 0x05, 0xF3, 0xC0, 0xC7, 0x73, 0x8C, | 79 0x62, 0xA7, 0x05, 0xF3, 0xC0, 0xC7, 0x73, 0x8C, |
85 0x98, 0x93, 0x2B, 0xD9, 0xBC, 0x4C, 0x82, 0xCA, | 80 0x98, 0x93, 0x2B, 0xD9, 0xBC, 0x4C, 0x82, 0xCA, |
86 0x1E, 0x9B, 0x57, 0x3C, 0xFD, 0xD4, 0xE0, 0x16, | 81 0x1E, 0x9B, 0x57, 0x3C, 0xFD, 0xD4, 0xE0, 0x16, |
87 0x67, 0x42, 0x6F, 0x18, 0x8A, 0x17, 0xE5, 0x12, | 82 0x67, 0x42, 0x6F, 0x18, 0x8A, 0x17, 0xE5, 0x12, |
88 0xBE, 0x4E, 0xC4, 0xD6, 0xDA, 0x9E, 0xDE, 0x49, | 83 0xBE, 0x4E, 0xC4, 0xD6, 0xDA, 0x9E, 0xDE, 0x49, |
89 0xA0, 0xFB, 0xF5, 0x8E, 0xBB, 0x2F, 0xEE, 0x7A, | 84 0xA0, 0xFB, 0xF5, 0x8E, 0xBB, 0x2F, 0xEE, 0x7A, |
90 0xA9, 0x68, 0x79, 0x91, 0x15, 0xB2, 0x07, 0x3F, | 85 0xA9, 0x68, 0x79, 0x91, 0x15, 0xB2, 0x07, 0x3F, |
91 0x94, 0xC2, 0x10, 0x89, 0x0B, 0x22, 0x5F, 0x21, | 86 0x94, 0xC2, 0x10, 0x89, 0x0B, 0x22, 0x5F, 0x21, |
(...skipping 22 matching lines...) Expand all Loading... |
114 }; | 109 }; |
115 | 110 |
116 const char *MD2_options(void) | 111 const char *MD2_options(void) |
117 { | 112 { |
118 if (sizeof(MD2_INT) == 1) | 113 if (sizeof(MD2_INT) == 1) |
119 return("md2(char)"); | 114 return("md2(char)"); |
120 else | 115 else |
121 return("md2(int)"); | 116 return("md2(int)"); |
122 } | 117 } |
123 | 118 |
124 FIPS_NON_FIPS_MD_Init(MD2) | 119 int MD2_Init(MD2_CTX *c) |
125 { | 120 { |
126 c->num=0; | 121 c->num=0; |
127 memset(c->state,0,sizeof c->state); | 122 memset(c->state,0,sizeof c->state); |
128 memset(c->cksm,0,sizeof c->cksm); | 123 memset(c->cksm,0,sizeof c->cksm); |
129 memset(c->data,0,sizeof c->data); | 124 memset(c->data,0,sizeof c->data); |
130 return 1; | 125 return 1; |
131 } | 126 } |
132 | 127 |
133 int MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len) | 128 int MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len) |
134 { | 129 { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 for (i=0; i<MD2_BLOCK; i++) | 218 for (i=0; i<MD2_BLOCK; i++) |
224 cp[i]=(UCHAR)p2[i]; | 219 cp[i]=(UCHAR)p2[i]; |
225 md2_block(c,cp); | 220 md2_block(c,cp); |
226 | 221 |
227 for (i=0; i<16; i++) | 222 for (i=0; i<16; i++) |
228 md[i]=(UCHAR)(p1[i]&0xff); | 223 md[i]=(UCHAR)(p1[i]&0xff); |
229 memset((char *)&c,0,sizeof(c)); | 224 memset((char *)&c,0,sizeof(c)); |
230 return 1; | 225 return 1; |
231 } | 226 } |
232 | 227 |
OLD | NEW |