NoCryptography.cpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* Copyright (C) 2014 Carlos Aguilar Melchor, Joris Barrier, Marc-Olivier Killijian
  2. * This file is part of XPIR.
  3. *
  4. * XPIR is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * XPIR is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with XPIR. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include "NoCryptography.hpp"
  18. NoCryptography::NoCryptography():
  19. HomomorphicCrypto("NoCryptography")
  20. {}
  21. NoCryptography::NoCryptography(const std::string& crypto_name):
  22. HomomorphicCrypto(crypto_name)
  23. {}
  24. AbstractPublicParameters& NoCryptography::getPublicParameters(){ return publicParams; }
  25. unsigned int NoCryptography::getAllCryptoParams(std::set<std::string>& crypto_params_set)
  26. {
  27. crypto_params_set.insert(std::string("NoCryptography"));
  28. return 1;
  29. }
  30. void NoCryptography::setNewParameters(const std::string& crypto_param) {}
  31. std::string& NoCryptography::toString() { return cryptoName; }
  32. char* NoCryptography::encrypt(unsigned int ui, unsigned int d )
  33. {
  34. char* charptr = (char *) malloc(sizeof(char));
  35. *charptr = (char) ui;
  36. return charptr;
  37. }
  38. char* NoCryptography::encrypt(char* data, size_t lkjlkj, unsigned int exponent )
  39. {
  40. unsigned int ciphBytesize = publicParams.getCiphertextBitsize()/8;
  41. char* encrypted_data = (char *) malloc(ciphBytesize);
  42. memcpy(encrypted_data, data, ciphBytesize);
  43. return encrypted_data;
  44. }
  45. char* NoCryptography::encrypt_perftest()
  46. {
  47. return encrypt(1,1);
  48. }
  49. char* NoCryptography::decrypt(char* cipheredData, unsigned int rec_lvl, size_t, size_t)
  50. {
  51. unsigned int clearBytesize = publicParams.getAbsorptionBitsize()/8;
  52. char* clear_data = (char *) malloc(clearBytesize);
  53. memcpy(clear_data, cipheredData, clearBytesize);
  54. return clear_data;
  55. }
  56. unsigned int NoCryptography::getCryptoParams(unsigned int k, std::set<std::string>& crypto_params)
  57. {
  58. crypto_params.insert(std::string("NoCryptography"));
  59. return 1;
  60. }
  61. long NoCryptography::setandgetAbsBitPerCiphertext(unsigned int elt_nbr)
  62. {
  63. return 8*1024;
  64. }
  65. std::string NoCryptography::getSerializedCryptoParams(bool shortversion)
  66. {
  67. return cryptoName;
  68. }
  69. double NoCryptography::estimateAbsTime(std::string crypto_param){
  70. return 1;
  71. }
  72. //NoCryptography::~NoCryptography() {}