ENC: be less fault tolerant

This commit is contained in:
hasufell 2014-06-05 19:12:39 +02:00
parent a35443a56a
commit edf7aaf229
No known key found for this signature in database
GPG Key ID: 220CD1C5BDEED020
2 changed files with 6 additions and 12 deletions

View File

@ -42,7 +42,7 @@
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
bool void
ntru_encrypt_poly( ntru_encrypt_poly(
const fmpz_poly_t msg_bin, const fmpz_poly_t msg_bin,
const fmpz_poly_t pub_key, const fmpz_poly_t pub_key,
@ -53,7 +53,7 @@ ntru_encrypt_poly(
fmpz_poly_t tmp_poly_msg; fmpz_poly_t tmp_poly_msg;
if (!msg_bin || !pub_key || !rnd || !out || !params) if (!msg_bin || !pub_key || !rnd || !out || !params)
return false; NTRU_ABORT_DEBUG("Unexpected NULL parameters");
/* allow aliasing */ /* allow aliasing */
fmpz_poly_init(tmp_poly_msg); fmpz_poly_init(tmp_poly_msg);
@ -66,8 +66,6 @@ ntru_encrypt_poly(
fmpz_poly_mod_unsigned(out, params->q); fmpz_poly_mod_unsigned(out, params->q);
fmpz_poly_clear(tmp_poly_msg); fmpz_poly_clear(tmp_poly_msg);
return true;
} }
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
@ -84,17 +82,16 @@ ntru_encrypt_string(
fmpz_poly_t **poly_array; fmpz_poly_t **poly_array;
if (!msg || !msg->len) if (!msg || !msg->len)
return NULL; NTRU_ABORT_DEBUG("Unexpected NULL parameters");
poly_array = ascii_to_bin_poly_arr(msg, params); poly_array = ascii_to_bin_poly_arr(msg, params);
while (*poly_array[i]) { while (*poly_array[i]) {
if (!ntru_encrypt_poly(*poly_array[i], ntru_encrypt_poly(*poly_array[i],
pub_key, pub_key,
rnd, rnd,
*poly_array[i], *poly_array[i],
params)) params);
NTRU_ABORT("failed encrypting string!\n");
i++; i++;
} }

View File

@ -33,8 +33,6 @@
#include "ntru_poly.h" #include "ntru_poly.h"
#include "ntru_string.h" #include "ntru_string.h"
#include <stdbool.h>
#include <fmpz_poly.h> #include <fmpz_poly.h>
#include <fmpz.h> #include <fmpz.h>
@ -60,9 +58,8 @@
* @param out the output poly which is in the range {0, q-1} * @param out the output poly which is in the range {0, q-1}
* (not ternary!) [out] * (not ternary!) [out]
* @param params ntru_params the ntru context * @param params ntru_params the ntru context
* @return true/false for success/failure
*/ */
bool void
ntru_encrypt_poly( ntru_encrypt_poly(
const fmpz_poly_t msg_tern, const fmpz_poly_t msg_tern,
const fmpz_poly_t pub_key, const fmpz_poly_t pub_key,