00001 /* 00002 * MCE, the real life implementation of McEliece encryption scheme. 00003 * Copyright Projet SECRET, INRIA, Rocquencourt and Bhaskar Biswas and 00004 * Nicolas Sendrier (Bhaskar.Biswas@inria.fr, Nicolas.Sendrier@inria.fr). 00005 * 00006 * This is free software; you can redistribute it and/or modify it 00007 * under the terms of the GNU Lesser General Public License as 00008 * published by the Free Software Foundation; either version 2.1 of 00009 * the License, or (at your option) any later version. 00010 * 00011 * This software is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this software; if not, write to the Free 00018 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 00019 * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 00020 */ 00021 #include <string.h> 00022 #include "sizes.h" 00023 00024 /* This function is aimed at randomizing the cleartext to provide 00025 semantic security. Here, it is a fake and we just make a copy. 00026 00027 In a real conversion the message is first padded with random bytes 00028 and zeroes then shuffled, for instance with a 3 round 00029 "Fiestel-like" scheme. The message of size MESSAGE_BYTES bytes is 00030 transformed into a randomized block of size CLEARTEXT_LENGTH 00031 bits. */ 00032 void randomize(unsigned char * cleartext, unsigned char * message) 00033 { 00034 memcpy(cleartext, message, MESSAGE_BYTES); 00035 } 00036 00037 /* The inverse of randomize. */ 00038 int unrandomize(unsigned char * message, unsigned char * cleartext) 00039 { 00040 memcpy(message, cleartext, MESSAGE_BYTES); 00041 00042 return 1; //Shall put a test in case the function fails. 00043 }