12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- /* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
- */
- /* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
- rights reserved.
- License to copy and use this software is granted provided that it
- is identified as the "RSA Data Security, Inc. MD5 Message-Digest
- Algorithm" in all material mentioning or referencing this software
- or this function.
- License is also granted to make and use derivative works provided
- that such works are identified as "derived from the RSA Data
- Security, Inc. MD5 Message-Digest Algorithm" in all material
- mentioning or referencing the derived work.
-
- RSA Data Security, Inc. makes no representations concerning either
- the merchantability of this software or the suitability of this
- software for any particular purpose. It is provided "as is"
- without express or implied warranty of any kind.
-
- These notices must be retained in any copies of any part of this
- documentation and/or software.
- */
- #include <stdint.h>
- #include <stdio.h>
- #include <string.h>
- #include "com_BmcType.h"
- #include "com_IPMIDefs.h"
- #include "md5.h"
- #define MD_CTX MD5_CTX
- #define MDInit MD5_Init
- #define MDUpdate MD5_Update
- #define MDFinal MD5_Final
- /*
- INPUT : Test string , buffer of 16 bytes to
- store the digest,length of the string
- OUTPUT : Encrypted message in the buffer.
- RETURN : NONE
- PROCESS :Digests a string and prints the result.
- */
- extern void AuthCodeCalMD5(
- uint8_t *string, /*test string */
- uint8_t *MD5Result, /*result of MD5 digest*/
- uint16_t LengthOfstring /*Length of input string */
- )
- {
- MD_CTX context;
- uint8_t digest[16];
- MDInit (&context);
- MDUpdate (&context, string, LengthOfstring);
- MDFinal (digest, &context);
- memcpy(MD5Result,digest,16);
- }
- unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md)
- {
- MD5_CTX c;
- static unsigned char m[16];
- if (md == NULL) md=m;
- MD5_Init(&c);
- MD5_Update(&c,(unsigned char *)d,n);
- MD5_Final(md,&c);
- // OPENSSL_cleanse(&c,sizeof(c)); /* security consideration */
- return(md);
- }
|