Commit 5b823c1b authored by Davide Galassi's avatar Davide Galassi

RSA cipher fix

parent 32238fe7
Pipeline #34486815 passed with stages
in 1 minute and 8 seconds
......@@ -14,9 +14,9 @@
* Structure used for both private and public key.
*/
struct cry_rsa_ctx {
cry_mpi m; /**< Public modulus */
cry_mpi e; /**< Public exponent */
cry_mpi d; /**< Private exponent */
cry_mpi m; /**< Modulus */
cry_mpi e; /**< Encrypt exponent */
cry_mpi d; /**< Decrypt exponent */
int flags; /**< Behaviour flags */
};
......
......@@ -104,7 +104,7 @@ int cry_rsa_encrypt(cry_rsa_ctx *ctx, unsigned char **out, size_t *out_siz,
if ((res = cry_mpi_mod_exp(&c, &m, &ctx->e, &ctx->m)) != 0)
break;
if (cry_mpi_store_bin(&c, *out + (*out_siz - mod_siz),
mod_siz, 1) != mod_siz) {
mod_siz, 1) != 0) {
res = -1;
break;
}
......@@ -156,7 +156,7 @@ int cry_rsa_decrypt(cry_rsa_ctx *ctx, unsigned char **out, size_t *out_siz,
break;
if ((res = cry_mpi_mod_exp(&m, &c, &ctx->d, &ctx->m)) != 0)
break;
if (cry_mpi_store_bin(&m, padded_block, mod_siz, 1) != mod_siz) {
if (cry_mpi_store_bin(&m, padded_block, mod_siz, 1) != 0) {
res = -1;
break;
}
......
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