[],
[AC_MSG_ERROR([Sorry you need histedit.h (libedit-dev on debian)])])
-AC_CHECK_HEADER([openssl/md5.h],
- [],
- [AC_MSG_ERROR([Sorry you need openssl dev files (libssl-dev on debian)])])
-PKG_CHECK_MODULES([OPENSSL], [openssl])
-
AC_CHECK_MEMBER([struct fiemap_extent.fe_logical],
[AC_DEFINE([HAVE_FIEMAP_H], [], [linux/fiemap.h was found, fiemap ioctl will be used])],
[AC_MSG_NOTICE([linux/fiemap.h was not found or not usable; using local Ceph copy])],
# lib_LTLIBRARIES += libradosgw.a
radosgw_SOURCES = rgw/rgw_main.cc
-radosgw_LDADD = libradosgw.a librados.a libcrush.a -lfcgi $(OPENSSL_LIBS) -lexpat -lpthread -lm -lcrypto++
+radosgw_LDADD = libradosgw.a librados.a libcrush.a -lfcgi -lexpat -lpthread -lm -lcrypto++
radosgw_admin_SOURCES = rgw/rgw_admin.cc
-radosgw_admin_LDADD = libradosgw.a librados.a libcrush.a -lfcgi $(OPENSSL_LIBS) -lexpat -lpthread -lm -lcrypto++
+radosgw_admin_LDADD = libradosgw.a librados.a libcrush.a -lfcgi -lexpat -lpthread -lm -lcrypto++
bin_PROGRAMS += radosgw radosgw_admin
endif
#include <vector>
#include <include/types.h>
-#include <openssl/md5.h>
-
#include "rgw_common.h"
/**
#include "config.h"
-#include <openssl/rand.h>
+#include <cryptopp/osrng.h>
#include "common/common_init.h"
#include "common/armor.h"
unsigned char buf[size];
char tmp_dest[size + 4]; /* so that there's space for the extra '=' characters, and some */
- int ret = RAND_bytes(buf, sizeof(buf));
- if (!ret) {
- cerr << "RAND_bytes failed, entropy problem?" << std::endl;
- return -1;
- }
+ CryptoPP::AutoSeededRandomPool rng;
+ rng.GenerateBlock(buf, sizeof(buf));
- ret = ceph_armor(tmp_dest, &tmp_dest[sizeof(tmp_dest)],
+ int ret = ceph_armor(tmp_dest, &tmp_dest[sizeof(tmp_dest)],
(const char *)buf, ((const char *)buf) + ((size - 1) * 3 + 4 - 1) / 4);
if (ret < 0) {
cerr << "ceph_armor failed" << std::endl;
int gen_rand_alphanumeric(char *dest, int size) /* size should be the required string size + 1 */
{
- int ret = RAND_bytes((unsigned char *)dest, size);
- if (!ret) {
- cerr << "RAND_bytes failed, entropy problem?" << std::endl;
- return -1;
- }
+ CryptoPP::AutoSeededRandomPool rng;
+ rng.GenerateBlock((unsigned char *)dest, size);
int i;
for (i=0; i<size - 1; i++) {
#include "fcgiapp.h"
-#include <openssl/md5.h>
+#include <string.h>
+#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1
+#include <cryptopp/md5.h>
#include <string>
#include <map>
#include "include/types.h"
std::string name;
size_t size;
time_t mtime;
- char etag[MD5_DIGEST_LENGTH * 2 + 1];
+ char etag[CryptoPP::Weak::MD5::DIGESTSIZE * 2 + 1];
void encode(bufferlist& bl) const {
__u8 struct_v = 1;
#include <errno.h>
#include <signal.h>
-#include <openssl/hmac.h>
-#include <openssl/sha.h>
-#include <openssl/md5.h>
+#include <cryptopp/sha.h>
+#include <cryptopp/hmac.h>
#include "fcgiapp.h"
#include "common/BackTrace.h"
using namespace std;
+using namespace CryptoPP;
#define CGI_PRINTF(stream, format, ...) do { \
FCGX_FPrintF(stream, format, __VA_ARGS__); \
/*
* calculate the sha1 value of a given msg and key
*/
-static void calc_hmac_sha1(const char *key, int key_len,
+static int calc_hmac_sha1(const char *key, int key_len,
const char *msg, int msg_len,
char *dest, int *len) /* dest should be large enough to hold result */
{
- char hex_str[128];
- unsigned char *result = HMAC(EVP_sha1(), key, key_len, (const unsigned char *)msg,
- msg_len, (unsigned char *)dest, (unsigned int *)len);
+ if (*len < HMAC<SHA1>::DIGESTSIZE)
+ return -EINVAL;
- buf_to_hex(result, *len, hex_str);
+ char hex_str[HMAC<SHA1>::DIGESTSIZE * 2 + 1];
+
+ HMAC<SHA1> hmac((const unsigned char *)key, key_len);
+ hmac.Update((const unsigned char *)msg, msg_len);
+ hmac.Final((unsigned char *)dest);
+ *len = HMAC<SHA1>::DIGESTSIZE;
+
+ buf_to_hex((unsigned char *)dest, *len, hex_str);
RGW_LOG(15) << "hmac=" << hex_str << endl;
+
+ return 0;
}
/*
const char *key = s->user.secret_key.c_str();
int key_len = strlen(key);
- char hmac_sha1[EVP_MAX_MD_SIZE];
- int len;
- calc_hmac_sha1(key, key_len, auth_hdr.c_str(), auth_hdr.size(), hmac_sha1, &len);
+ char hmac_sha1[HMAC<SHA1>::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;
char b64[64]; /* 64 is really enough */
int ret = ceph_armor(b64, &b64[sizeof(b64)], hmac_sha1, &hmac_sha1[len]);
#include "rgw_user.h"
using namespace std;
+using namespace CryptoPP::Weak;
static int parse_range(const char *range, off_t& ofs, off_t& end)
{
goto done;
}
- char supplied_md5_bin[MD5_DIGEST_LENGTH + 1];
- char supplied_md5[MD5_DIGEST_LENGTH * 2 + 1];
- char calc_md5[MD5_DIGEST_LENGTH * 2 + 1];
- MD5_CTX c;
- unsigned char m[MD5_DIGEST_LENGTH];
+ char supplied_md5_bin[MD5::DIGESTSIZE + 1];
+ char supplied_md5[MD5::DIGESTSIZE * 2 + 1];
+ char calc_md5[MD5::DIGESTSIZE * 2 + 1];
+ unsigned char m[MD5::DIGESTSIZE];
if (supplied_md5_b64) {
RGW_LOG(15) << "supplied_md5_b64=" << supplied_md5_b64 << endl;
- int ret = ceph_unarmor(supplied_md5_bin, &supplied_md5_bin[MD5_DIGEST_LENGTH + 1],
+ int ret = ceph_unarmor(supplied_md5_bin, &supplied_md5_bin[MD5::DIGESTSIZE + 1],
supplied_md5_b64, supplied_md5_b64 + strlen(supplied_md5_b64));
RGW_LOG(15) << "ceph_armor ret=" << ret << endl;
- if (ret != MD5_DIGEST_LENGTH) {
+ if (ret != MD5::DIGESTSIZE) {
err.code = "InvalidDigest";
ret = -EINVAL;
goto done;
}
- buf_to_hex((const unsigned char *)supplied_md5_bin, MD5_DIGEST_LENGTH, supplied_md5);
+ buf_to_hex((const unsigned char *)supplied_md5_bin, MD5::DIGESTSIZE, supplied_md5);
RGW_LOG(15) << "supplied_md5=" << supplied_md5 << endl;
}
- MD5_Init(&c);
+ MD5 hash;
do {
get_data();
if (len > 0) {
- MD5_Update(&c, data, (unsigned long)len);
+ hash.Update((unsigned char *)data, len);
ret = rgwstore->put_obj_data(s->user.user_id, s->bucket_str, s->object_str, data, ofs, len, NULL);
free(data);
if (ret < 0)
}
} while ( len > 0);
- MD5_Final(m, &c);
+ hash.Final(m);
- buf_to_hex(m, MD5_DIGEST_LENGTH, calc_md5);
+ buf_to_hex(m, MD5::DIGESTSIZE, calc_md5);
if (supplied_md5_b64 && strcmp(calc_md5, supplied_md5)) {
err.code = "BadDigest";