void CryptoKey::print(std::ostream &out) const
{
- string a;
- encode_base64(a);
- out << a;
+ out << encode_base64();
}
void CryptoKey::to_str(std::string& s) const
hex2str(secret.c_str(), secret.length(), buf, len);
s = buf;
}
+
+void CryptoKey::encode_formatted(string label, Formatter *f, bufferlist &bl)
+{
+ f->open_object_section(label.c_str());
+ f->dump_string("key", encode_base64());
+ f->close_section();
+ f->flush(bl);
+}
+
+void CryptoKey::encode_plaintext(bufferlist &bl)
+{
+ bl.append(encode_base64());
+}
#include "include/types.h"
#include "include/utime.h"
+#include "common/Formatter.h"
+#include "include/buffer.h"
+
#include <string>
class CephContext;
e.append('\0');
s = e.c_str();
}
+ string encode_base64() const {
+ string s;
+ encode_base64(s);
+ return s;
+ }
void decode_base64(const string& s) {
bufferlist e;
e.append(s);
decode(p);
}
+ void encode_formatted(string label, Formatter *f, bufferlist &bl);
+ void encode_plaintext(bufferlist &bl);
+
// --
int create(CephContext *cct, int type);
void encrypt(CephContext *cct, const bufferlist& in, bufferlist& out, std::string &error) const;