Commit 5c19f0c7 authored by yiwenshao's avatar yiwenshao

main/Analysis.cc the function needSalt(l)in 196,able to decrypt ASHE,wow!

parent 5a424dff
...@@ -14,12 +14,29 @@ std::pair<long,uint64_t> RAW_ASHE::encrypt(unsigned int plaintext){ ...@@ -14,12 +14,29 @@ std::pair<long,uint64_t> RAW_ASHE::encrypt(unsigned int plaintext){
return std::make_pair(ciphertext,IV); return std::make_pair(ciphertext,IV);
} }
std::pair<long,uint64_t> RAW_ASHE::encrypt(unsigned int plaintext,uint64_t inIV){
uint64_t i = Fi(inIV)%RAW_ASHE_MAX, i_1=Fi_1(inIV)%RAW_ASHE_MAX;
long res = (long)i_1 - (long)i;
ciphertext = ((long)plaintext + res)%RAW_ASHE_MAX;
return std::make_pair(ciphertext,inIV);
}
unsigned int RAW_ASHE::decrypt(long ciphertext){ unsigned int RAW_ASHE::decrypt(long ciphertext){
uint64_t i = Fi(IV)%RAW_ASHE_MAX, i_1=Fi_1(IV)%RAW_ASHE_MAX; uint64_t i = Fi(IV)%RAW_ASHE_MAX, i_1=Fi_1(IV)%RAW_ASHE_MAX;
long res = (long)i - (long)i_1; long res = (long)i - (long)i_1;
return (ciphertext + res)%RAW_ASHE_MAX; return (ciphertext + res)%RAW_ASHE_MAX;
} }
unsigned int RAW_ASHE::decrypt(long ciphertext,uint64_t inIV){
uint64_t i = Fi(inIV)%RAW_ASHE_MAX, i_1=Fi_1(inIV)%RAW_ASHE_MAX;
long res = (long)i - (long)i_1;
return (ciphertext + res)%RAW_ASHE_MAX;
}
std::pair<long,std::vector<uint64_t>> RAW_ASHE::sum(std::vector<RAW_ASHE> input){ std::pair<long,std::vector<uint64_t>> RAW_ASHE::sum(std::vector<RAW_ASHE> input){
long res=0; long res=0;
std::vector<uint64_t> ivs; std::vector<uint64_t> ivs;
......
...@@ -16,7 +16,11 @@ public: ...@@ -16,7 +16,11 @@ public:
std::pair<long,uint64_t> encrypt(unsigned int plaintext); std::pair<long,uint64_t> encrypt(unsigned int plaintext);
std::pair<long,uint64_t> encrypt(unsigned int plaintext,uint64_t inIv);
unsigned int decrypt(long ciphertext); unsigned int decrypt(long ciphertext);
unsigned int decrypt(long ciphertext,uint64_t inIv);
uint64_t get_IV(){return IV;}; uint64_t get_IV(){return IV;};
static uint64_t Fi(uint64_t IV){return bf.encrypt(IV)%100000;} static uint64_t Fi(uint64_t IV){return bf.encrypt(IV)%100000;}
......
...@@ -12,8 +12,8 @@ int main(){ ...@@ -12,8 +12,8 @@ int main(){
uint64_t IV = randomValue(); uint64_t IV = randomValue();
if(IV==0) IV=1; if(IV==0) IV=1;
ass.push_back(RAW_ASHE(IV)); ass.push_back(RAW_ASHE(IV));
ass.back().encrypt(seed); ass.back().encrypt(seed,IV);
unsigned int res = ass.back().decrypt(ass.back().get_ciphertext()); unsigned int res = ass.back().decrypt(ass.back().get_ciphertext(),IV);
if(res==seed) std::cout<<"pass"<<std::endl; if(res==seed) std::cout<<"pass"<<std::endl;
else std::cout<<"not pass!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<<std::endl; else std::cout<<"not pass!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<<std::endl;
seed++; seed++;
......
...@@ -192,11 +192,11 @@ OLK EncSet::extract_singleton() const ...@@ -192,11 +192,11 @@ OLK EncSet::extract_singleton() const
return OLK(it->first, it->second.first, it->second.second); return OLK(it->first, it->second.first, it->second.second);
} }
// needsSaltz must have consistent semantics. // needsSaltz must have consistent semantics. shaoyiwen
static bool static bool
needsSalt(SECLEVEL l) needsSalt(SECLEVEL l)
{ {
return l == SECLEVEL::RND; return l == SECLEVEL::RND||l==SECLEVEL::ASHE;
} }
bool bool
......
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