| OLD | NEW |
| 1 /* crypto/mdc2/mdc2dgst.c */ | 1 /* crypto/mdc2/mdc2dgst.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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 * derivative of this code cannot be changed. i.e. this code cannot simply be | 54 * derivative of this code cannot be changed. i.e. this code cannot simply be |
| 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/des.h> | 62 #include <openssl/des.h> |
| 63 #include <openssl/mdc2.h> | 63 #include <openssl/mdc2.h> |
| 64 #include <openssl/err.h> | |
| 65 #ifdef OPENSSL_FIPS | |
| 66 #include <openssl/fips.h> | |
| 67 #endif | |
| 68 | |
| 69 | 64 |
| 70 #undef c2l | 65 #undef c2l |
| 71 #define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \ | 66 #define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \ |
| 72 l|=((DES_LONG)(*((c)++)))<< 8L, \ | 67 l|=((DES_LONG)(*((c)++)))<< 8L, \ |
| 73 l|=((DES_LONG)(*((c)++)))<<16L, \ | 68 l|=((DES_LONG)(*((c)++)))<<16L, \ |
| 74 l|=((DES_LONG)(*((c)++)))<<24L) | 69 l|=((DES_LONG)(*((c)++)))<<24L) |
| 75 | 70 |
| 76 #undef l2c | 71 #undef l2c |
| 77 #define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ | 72 #define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ |
| 78 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ | 73 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ |
| 79 *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ | 74 *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ |
| 80 *((c)++)=(unsigned char)(((l)>>24L)&0xff)) | 75 *((c)++)=(unsigned char)(((l)>>24L)&0xff)) |
| 81 | 76 |
| 82 static void mdc2_body(MDC2_CTX *c, const unsigned char *in, size_t len); | 77 static void mdc2_body(MDC2_CTX *c, const unsigned char *in, size_t len); |
| 83 FIPS_NON_FIPS_MD_Init(MDC2) | 78 int MDC2_Init(MDC2_CTX *c) |
| 84 { | 79 { |
| 85 c->num=0; | 80 c->num=0; |
| 86 c->pad_type=1; | 81 c->pad_type=1; |
| 87 memset(&(c->h[0]),0x52,MDC2_BLOCK); | 82 memset(&(c->h[0]),0x52,MDC2_BLOCK); |
| 88 memset(&(c->hh[0]),0x25,MDC2_BLOCK); | 83 memset(&(c->hh[0]),0x25,MDC2_BLOCK); |
| 89 return 1; | 84 return 1; |
| 90 } | 85 } |
| 91 | 86 |
| 92 int MDC2_Update(MDC2_CTX *c, const unsigned char *in, size_t len) | 87 int MDC2_Update(MDC2_CTX *c, const unsigned char *in, size_t len) |
| 93 { | 88 { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 MDC2_Init(&c); | 190 MDC2_Init(&c); |
| 196 MDC2_Update(&c,text,strlen(text)); | 191 MDC2_Update(&c,text,strlen(text)); |
| 197 MDC2_Final(&(md[0]),&c); | 192 MDC2_Final(&(md[0]),&c); |
| 198 | 193 |
| 199 for (i=0; i<MDC2_DIGEST_LENGTH; i++) | 194 for (i=0; i<MDC2_DIGEST_LENGTH; i++) |
| 200 printf("%02X",md[i]); | 195 printf("%02X",md[i]); |
| 201 printf("\n"); | 196 printf("\n"); |
| 202 } | 197 } |
| 203 | 198 |
| 204 #endif | 199 #endif |
| OLD | NEW |