From 1ef7a53fa29d058abd3fd5aab8acde016f15df06 Mon Sep 17 00:00:00 2001
From: Paul Bakker
Date: Sat, 20 Jun 2009 10:50:55 +0000
Subject: [PATCH] - Fixed incorrect handling of negative first input value in
mpi_sub_abs() (found by code coverage tests).
---
ChangeLog | 2 ++
library/bignum.c | 5 +++++
2 files changed, 7 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 34e80d586..4a35a21cd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,8 @@ Bug fixes
mpi_read_string() (found by code coverage tests).
* Fixed incorrect handling of one single negative input
value in mpi_add_abs() (found by code coverage tests).
+ * Fixed incorrect handling of negative first input
+ value in mpi_sub_abs() (found by code coverage tests).
= Version 0.11.1 released on 2009-05-17
* Fixed missing functionality for SHA-224, SHA-256, SHA384,
diff --git a/library/bignum.c b/library/bignum.c
index 218e50b5d..9f11a70b9 100644
--- a/library/bignum.c
+++ b/library/bignum.c
@@ -762,6 +762,11 @@ int mpi_sub_abs( mpi *X, mpi *A, mpi *B )
if( X != A )
MPI_CHK( mpi_copy( X, A ) );
+ /*
+ * X should always be positive as a result of unsigned substractions.
+ */
+ X->s = 1;
+
ret = 0;
for( n = B->n - 1; n >= 0; n-- )