From 73206954d4119b92c4e7f73fc77b85a1f5df5676 Mon Sep 17 00:00:00 2001
From: Paul Bakker
Date: Wed, 6 Jul 2011 14:37:33 +0000
Subject: [PATCH] - Made des_key_check_weak() conform to other functions in
return values. - Added documentation for des_key_check_weak() and
des_key_check_key_parity()
---
include/polarssl/des.h | 5 ++++-
library/des.c | 4 ++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/include/polarssl/des.h b/include/polarssl/des.h
index 5606afbe7..09c00a741 100644
--- a/include/polarssl/des.h
+++ b/include/polarssl/des.h
@@ -77,14 +77,17 @@ void des_key_set_parity( unsigned char key[DES_KEY_SIZE] );
* a parity bit to allow verification.
*
* \param key 8-byte secret key
+ *
+ * \return 0 is parity was ok, 1 if parity was not correct.
*/
int des_key_check_key_parity( const unsigned char key[DES_KEY_SIZE] );
-
/**
* \brief Check that key is not a weak or semi-weak DES key
*
* \param key 8-byte secret key
+ *
+ * \resurn 0 if no weak key was found, 1 if a weak key was identified.
*/
int des_key_check_weak( const unsigned char key[DES_KEY_SIZE] );
diff --git a/library/des.c b/library/des.c
index 303403082..b40baf8fb 100644
--- a/library/des.c
+++ b/library/des.c
@@ -371,9 +371,9 @@ int des_key_check_weak( const unsigned char key[DES_KEY_SIZE] )
for( i = 0; i < WEAK_KEY_COUNT; i++ )
if( memcmp( weak_key_table[i], key, DES_KEY_SIZE) == 0)
- return( 0 );
+ return( 1 );
- return( 1 );
+ return( 0 );
}
static void des_setkey( unsigned long SK[32], const unsigned char key[DES_KEY_SIZE] )