diff options
| author | Sam Varshavchik | 2013-08-19 16:39:41 -0400 |
|---|---|---|
| committer | Sam Varshavchik | 2013-08-25 14:43:51 -0400 |
| commit | 9c45d9ad13fdf439d44d7443ae75da15ea0223ed (patch) | |
| tree | 7a81a04cb51efb078ee350859a64be2ebc6b8813 /libmail/imaphmac.C | |
| parent | a9520698b770168d1f33d6301463bb70a19655ec (diff) | |
| download | courier-libs-9c45d9ad13fdf439d44d7443ae75da15ea0223ed.tar.bz2 | |
Initial checkin
Imported from subversion report, converted to git. Updated all paths in
scripts and makefiles, reflecting the new directory hierarchy.
Diffstat (limited to 'libmail/imaphmac.C')
| -rw-r--r-- | libmail/imaphmac.C | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/libmail/imaphmac.C b/libmail/imaphmac.C new file mode 100644 index 0000000..bbf0740 --- /dev/null +++ b/libmail/imaphmac.C @@ -0,0 +1,45 @@ +/* +** Copyright 2002-2005, Double Precision Inc. +** +** See COPYING for distribution information. +*/ +#include "libmail_config.h" +#include "imaphmac.H" +#include "libhmac/hmac.h" + +static mail::imaphmac md5(hmac_md5, "MD5"); +static mail::imaphmac sha1(hmac_sha1, "SHA1"); +static mail::imaphmac sha256(hmac_sha256, "SHA256"); + +const mail::imaphmac * const mail::imaphmac::hmac_methods[]= + { &sha256, &sha1, &md5, NULL}; + + +mail::imaphmac::imaphmac(const struct hmac_hashinfo &hmacArg, + const char *nameArg) + : hmac(hmacArg), name(nameArg) +{ +} + +mail::imaphmac::~imaphmac() +{ +} + +std::string mail::imaphmac::operator()(std::string password, std::string challenge) const +{ + std::string i, o, b; + + i.insert(i.end(), hmac.hh_L, (char)0); + o.insert(o.end(), hmac.hh_L, (char)0); + b.insert(b.end(), hmac.hh_L, (char)0); + + hmac_hashkey( &hmac, &*password.begin(), password.size(), + (unsigned char *)&*o.begin(), + (unsigned char *)&*i.begin()); + + hmac_hashtext( &hmac, &*challenge.begin(), challenge.size(), + (unsigned char *)&*o.begin(), + (unsigned char *)&*i.begin(), + (unsigned char *)&*b.begin()); + return (b); +} |
