Commit 1eda3d64 authored by yiwenshao's avatar yiwenshao

modify ASHE layer again, the initial version that can create table

parent 559f8a45
...@@ -1814,34 +1814,42 @@ const std::vector<udf_func*> udf_list = { ...@@ -1814,34 +1814,42 @@ const std::vector<udf_func*> udf_list = {
/************************************************ASHE********************************************/ /************************************************ASHE********************************************/
ASHE::ASHE(const Create_field &f, const std::string &seed_key) ASHE::ASHE(unsigned int id, const std::string &serial):ashe(1){}
: seed_key(seed_key)
{}
ASHE::ASHE(unsigned int id, const std::string &serial){}
/*the type of filed after the ASHE layer is used.*/
Create_field * Create_field *
ASHE::newCreateField(const Create_field &cf, ASHE::newCreateField(const Create_field &cf,
const std::string &anonname) const{ const std::string &anonname) const{
return NULL; const THD * const thd = current_thd;
Create_field * const f0 = cf.clone(thd->mem_root);
// if (charset != NULL) {
// f0->charset = charset;
// }
if (anonname.size() > 0) {
f0->field_name = make_thd_string(anonname);
}
return f0;
} }
//if first, use seed key to generate //if first, use seed key to generate
Item * Item *
ASHE::encrypt(const Item &ptext, uint64_t IV) const{ ASHE::encrypt(const Item &ptext, uint64_t IV) const{
return NULL; ulonglong pt = const_cast<Item &>(ptext).val_uint();
return new (current_thd->mem_root)
Item_int(static_cast<ulonglong>(pt));
} }
Item * Item *
ASHE::decrypt(const Item &ctext, uint64_t IV) const ASHE::decrypt(const Item &ctext, uint64_t IV) const
{ {
return NULL; long long ct = const_cast<Item &>(ctext).val_uint();
return new (current_thd->mem_root)
Item_int(static_cast<ulonglong>(ct));
} }
ASHE::~ASHE() { ASHE::~ASHE() {
} }
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <crypto/blowfish.hh> #include <crypto/blowfish.hh>
#include <parser/sql_utils.hh> #include <parser/sql_utils.hh>
#include <crypto/SWPSearch.hh> #include <crypto/SWPSearch.hh>
#include "crypto/ASHE.hh"
#include <main/dbobject.hh> #include <main/dbobject.hh>
#include <main/macro_util.hh> #include <main/macro_util.hh>
...@@ -119,7 +120,9 @@ private: ...@@ -119,7 +120,9 @@ private:
class ASHE : public EncLayer { class ASHE : public EncLayer {
public: public:
ASHE(const Create_field &cf, const std::string &seed_key); ASHE(const Create_field &cf, const std::string &seed_key):seed_key(seed_key),ashe(1){
}
// serialize and deserialize // serialize and deserialize
std::string doSerialize() const {return seed_key;} std::string doSerialize() const {return seed_key;}
...@@ -136,6 +139,7 @@ public: ...@@ -136,6 +139,7 @@ public:
Item * decrypt(const Item &c, uint64_t IV) const; Item * decrypt(const Item &c, uint64_t IV) const;
protected: protected:
std::string const seed_key; std::string const seed_key;
const RAW_ASHE ashe;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment