#ifdef USE_CRYPTOPP
# define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1
# include <cryptopp/md5.h>
+# include <cryptopp/sha.h>
+# include <cryptopp/hmac.h>
namespace ceph {
namespace crypto {
static inline void init() {
// nothing
}
using CryptoPP::Weak::MD5;
+
+ class HMACSHA1: public CryptoPP::HMAC<CryptoPP::SHA1> {
+ public:
+ HMACSHA1 (const byte *key, size_t length)
+ : CryptoPP::HMAC<CryptoPP::SHA1>(key, length)
+ {
+ }
+ };
}
}
#elif USE_NSS
#include <errno.h>
#include <signal.h>
-#include <cryptopp/sha.h>
-#include <cryptopp/hmac.h>
-
#include "fcgiapp.h"
#include "rgw_common.h"
#include "common/BackTrace.h"
using namespace std;
-using namespace CryptoPP;
+using ceph::crypto::HMACSHA1;
#define CGI_PRINTF(stream, format, ...) do { \
FCGX_FPrintF(stream, format, __VA_ARGS__); \
const char *msg, int msg_len,
char *dest, int *len) /* dest should be large enough to hold result */
{
- if (*len < HMAC<SHA1>::DIGESTSIZE)
+ if (*len < HMACSHA1::DIGESTSIZE)
return -EINVAL;
- char hex_str[HMAC<SHA1>::DIGESTSIZE * 2 + 1];
+ char hex_str[HMACSHA1::DIGESTSIZE * 2 + 1];
- HMAC<SHA1> hmac((const unsigned char *)key, key_len);
+ HMACSHA1 hmac((const unsigned char *)key, key_len);
hmac.Update((const unsigned char *)msg, msg_len);
hmac.Final((unsigned char *)dest);
- *len = HMAC<SHA1>::DIGESTSIZE;
+ *len = HMACSHA1::DIGESTSIZE;
buf_to_hex((unsigned char *)dest, *len, hex_str);
const char *key = s->user.secret_key.c_str();
int key_len = strlen(key);
- char hmac_sha1[HMAC<SHA1>::DIGESTSIZE];
+ char hmac_sha1[HMACSHA1::DIGESTSIZE];
int len = sizeof(hmac_sha1);
if (calc_hmac_sha1(key, key_len, auth_hdr.c_str(), auth_hdr.size(), hmac_sha1, &len) < 0)
return false;