using namespace std;
#include "common/config.h"
-
-#include <cryptopp/osrng.h>
#include "common/ceph_argparse.h"
#include "common/common_init.h"
#include "rgw_user.h"
#include "rgw_access.h"
#include "rgw_acl.h"
+#include "auth/Crypto.h"
#define SECRET_KEY_LEN 40
int gen_rand_base64(char *dest, int size) /* size should be the required string size + 1 */
{
- unsigned char buf[size];
+ char buf[size];
char tmp_dest[size + 4]; /* so that there's space for the extra '=' characters, and some */
+ int ret;
- CryptoPP::AutoSeededRandomPool rng;
- rng.GenerateBlock(buf, sizeof(buf));
+ ret = get_random_bytes(buf, sizeof(buf));
+ if (ret < 0) {
+ // assuming no threads here, for strerror
+ cerr << "cannot get random bytes: " << strerror(-ret) << std::endl;
+ return -1;
+ }
- int ret = ceph_armor(tmp_dest, &tmp_dest[sizeof(tmp_dest)],
+ 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 */
{
- CryptoPP::AutoSeededRandomPool rng;
- rng.GenerateBlock((unsigned char *)dest, size);
+ int ret = get_random_bytes(dest, size);
+ if (ret < 0) {
+ // assuming no threads here, for strerror
+ cerr << "cannot get random bytes: " << strerror(-ret) << std::endl;
+ return -1;
+ }
int i;
for (i=0; i<size - 1; i++) {