"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/h235auth1.cxx" between
h323plus-1_27_0.tar.gz and h323plus-1_27_1.tar.gz

About: H.323 Plus offers libraries for voice (VoIP) and videoconferencing using H.323.

h235auth1.cxx  (h323plus-1_27_0):h235auth1.cxx  (h323plus-1_27_1)
skipping to change at line 68 skipping to change at line 68
}; };
#ifndef SHA_DIGESTSIZE #ifndef SHA_DIGESTSIZE
#define SHA_DIGESTSIZE 20 #define SHA_DIGESTSIZE 20
#endif #endif
#ifndef SHA_BLOCKSIZE #ifndef SHA_BLOCKSIZE
#define SHA_BLOCKSIZE 64 #define SHA_BLOCKSIZE 64
#endif #endif
#if (OPENSSL_VERSION_NUMBER < 0x10100000L) #if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
namespace { namespace {
class EvpMdContext class EvpMdContext
{ {
mutable EVP_MD_CTX ctx; mutable EVP_MD_CTX ctx;
public: public:
EvpMdContext() EvpMdContext()
{ {
skipping to change at line 142 skipping to change at line 142
for (i = 0 ; i < t ; i++) for (i = 0 ; i < t ; i++)
fprintf(fp, "%02x", s[i]) ; fprintf(fp, "%02x", s[i]) ;
fprintf(fp, "0x") ; fprintf(fp, "0x") ;
} }
#endif #endif
static void truncate(unsigned char* d1, /* data to be truncated */ static void truncate(unsigned char* d1, /* data to be truncated */
char* d2, /* truncated data */ char* d2, /* truncated data */
int len) /* length in bytes to keep */ int len) /* length in bytes to keep */
{ {
int i ; for (int i = 0; i < len; i++)
for (i = 0 ; i < len ; i++) d2[i] = d1[i]; d2[i] = d1[i];
} }
/* Function to compute the digest */ /* Function to compute the digest */
static void hmac_sha (const unsigned char* k, /* secret key */ static void hmac_sha (const unsigned char* k, /* secret key */
int lk, /* length of the key in bytes */ int lk, /* length of the key in bytes */
const unsigned char* d, /* data */ const unsigned char* d, /* data */
int ld, /* length of data in bytes */ int ld, /* length of data in bytes */
char* out, /* output buffer, at least "t" b ytes */ char* out, /* output buffer, at least "t" b ytes */
int t) int t)
{ {
EvpMdContext ictx, octx; EvpMdContext ictx, octx;
unsigned char isha[SHA_DIGESTSIZE], osha[SHA_DIGESTSIZE] ; unsigned char isha[SHA_DIGESTSIZE], osha[SHA_DIGESTSIZE];
unsigned char key[SHA_DIGESTSIZE] ; unsigned char key[SHA_DIGESTSIZE];
char buf[SHA_BLOCKSIZE] ; char buf[SHA_BLOCKSIZE];
int i ; int i;
const EVP_MD * sha1 = EVP_sha1(); const EVP_MD * sha1 = EVP_sha1();
if (lk > SHA_BLOCKSIZE) { if (lk > SHA_BLOCKSIZE) {
EvpMdContext tctx; EvpMdContext tctx;
EVP_DigestInit_ex(tctx, sha1, NULL); EVP_DigestInit_ex(tctx, sha1, NULL);
EVP_DigestUpdate(tctx, k, lk); EVP_DigestUpdate(tctx, k, lk);
EVP_DigestFinal_ex(tctx, key, NULL); EVP_DigestFinal_ex(tctx, key, NULL);
k = key ; k = key;
lk = SHA_DIGESTSIZE ; lk = SHA_DIGESTSIZE;
} }
/**** Inner Digest ****/ /**** Inner Digest ****/
EVP_DigestInit_ex(ictx, sha1, NULL); EVP_DigestInit_ex(ictx, sha1, NULL);
/* Pad the key for inner digest */ /* Pad the key for inner digest */
for (i = 0 ; i < lk ; ++i) buf[i] = (char)(k[i] ^ 0x36); for (i = 0 ; i < lk ; ++i) buf[i] = (char)(k[i] ^ 0x36);
for (i = lk ; i < SHA_BLOCKSIZE ; ++i) buf[i] = 0x36; for (i = lk ; i < SHA_BLOCKSIZE ; ++i) buf[i] = 0x36;
EVP_DigestUpdate(ictx, buf, SHA_BLOCKSIZE) ; EVP_DigestUpdate(ictx, buf, SHA_BLOCKSIZE);
EVP_DigestUpdate(ictx, d, ld) ; EVP_DigestUpdate(ictx, d, ld) ;
EVP_DigestFinal_ex(ictx, isha, NULL) ; EVP_DigestFinal_ex(ictx, isha, NULL);
/**** Outer Digest ****/ /**** Outer Digest ****/
EVP_DigestInit_ex(octx, sha1, NULL); EVP_DigestInit_ex(octx, sha1, NULL);
/* Pad the key for outer digest */ /* Pad the key for outer digest */
for (i = 0 ; i < lk ; ++i) buf[i] = (char)(k[i] ^ 0x5C); for (i = 0 ; i < lk ; ++i) buf[i] = (char)(k[i] ^ 0x5C);
for (i = lk ; i < SHA_BLOCKSIZE ; ++i) buf[i] = 0x5C; for (i = lk ; i < SHA_BLOCKSIZE ; ++i) buf[i] = 0x5C;
EVP_DigestUpdate(octx, buf, SHA_BLOCKSIZE) ; EVP_DigestUpdate(octx, buf, SHA_BLOCKSIZE);
EVP_DigestUpdate(octx, isha, SHA_DIGESTSIZE) ; EVP_DigestUpdate(octx, isha, SHA_DIGESTSIZE);
EVP_DigestFinal_ex(octx, osha, NULL); EVP_DigestFinal_ex(octx, osha, NULL);
/* truncate and print the results */ /* truncate and print the results */
t = t > SHA_DIGESTSIZE ? SHA_DIGESTSIZE : t ; t = t > SHA_DIGESTSIZE ? SHA_DIGESTSIZE : t;
truncate(osha, out, t) ; truncate(osha, out, t);
} }
static void SHA1(const unsigned char * data, unsigned len, unsigned char * hash) static void SHA1(const unsigned char * data, unsigned len, unsigned char * hash)
{ {
const EVP_MD * sha1 = EVP_sha1(); const EVP_MD * sha1 = EVP_sha1();
EvpMdContext ctx; EvpMdContext ctx;
if (EVP_DigestInit_ex(ctx, sha1, NULL)) { if (EVP_DigestInit_ex(ctx, sha1, NULL)) {
EVP_DigestUpdate(ctx, data, len); EVP_DigestUpdate(ctx, data, len);
EVP_DigestFinal_ex(ctx, hash, NULL); EVP_DigestFinal_ex(ctx, hash, NULL);
 End of changes. 8 change blocks. 
15 lines changed or deleted 15 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)