matteofara Posted July 3, 2013 Report Share Posted July 3, 2013 I'm trying to developed in LabView the algorithm used to generete localized key with MD5 defined in the rfc2574. maybe sombody already did it, is this code already available somewhere? thank you A.2.1. Password to Key Sample Code for MD5void password_to_key_md5( u_char *password, /* IN */ u_int passwordlen, /* IN */ u_char *engineID, /* IN - pointer to snmpEngineID */ u_int engineLength,/* IN - length of snmpEngineID */ u_char *key) /* OUT - pointer to caller 16-octet buffer */{ MD5_CTX MD; u_char *cp, password_buf[64]; u_long password_index = 0; u_long count = 0, i; MD5Init (&MD); /* initialize MD5 */ /**********************************************/ /* Use while loop until we've done 1 Megabyte */ /**********************************************/ while (count < 1048576) { cp = password_buf; for (i = 0; i < 64; i++) { /*************************************************/ /* Take the next octet of the password, wrapping */ /* to the beginning of the password as necessary.*/ /*************************************************/ *cp++ = password[password_index++ % passwordlen]; } MD5Update (&MD, password_buf, 64); count += 64; } MD5Final (key, &MD); /* tell MD5 we're done */ /*****************************************************/ /* Now localize the key with the engineID and pass */ /* through MD5 to produce final key */ /* May want to ensure that engineLength <= 32, */ /* otherwise need to use a buffer larger than 64 */ /*****************************************************/ memcpy(password_buf, key, 16); memcpy(password_buf+16, engineID, engineLength); memcpy(password_buf+16+engineLength, key, 16); MD5Init(&MD); MD5Update(&MD, password_buf, 32+engineLength); MD5Final(key, &MD); return;} Quote Link to comment
ShaunR Posted July 3, 2013 Report Share Posted July 3, 2013 Calculating the MD5 Message-Digest of a String or File Quote Link to comment
matteofara Posted July 3, 2013 Author Report Share Posted July 3, 2013 thank you, this is already a big part of the work but not yet the complete function. Quote Link to comment
todd Posted July 3, 2013 Report Share Posted July 3, 2013 LV-native MD5 hash VIs are included in vi.libUtilityMD5Checksum.llb Openg also has MD5, but no RFC 2574 stuff. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.