svn commit: r239459 - in stable: 7/contrib/opie/libopie 8/contrib/opie/libopie 9/contrib/opie/libopie

Xin LI delphij at FreeBSD.org
Mon Aug 20 18:26:17 UTC 2012


Author: delphij
Date: Mon Aug 20 18:26:16 2012
New Revision: 239459
URL: http://svn.freebsd.org/changeset/base/239459

Log:
  MFC r239169:
  
  RFC 2289 requires all hashes be stored in little endian format before
  folding to 64 bits, while SHA1 code is big endian.  Therefore, a bswap32
  is required before using the value.
  
  Without this change, the implementation does not conform to test vector
  found in RFC 2289.
  
  PR:		bin/170519
  Submitted by:	Arthur Mesh <arthurmesh gmail com> (with changes)

Modified:
  stable/9/contrib/opie/libopie/hash.c
  stable/9/contrib/opie/libopie/hashlen.c
Directory Properties:
  stable/9/contrib/opie/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/7/contrib/opie/libopie/hash.c
  stable/7/contrib/opie/libopie/hashlen.c
  stable/8/contrib/opie/libopie/hash.c
  stable/8/contrib/opie/libopie/hashlen.c
Directory Properties:
  stable/7/contrib/opie/   (props changed)
  stable/8/contrib/opie/   (props changed)

Modified: stable/9/contrib/opie/libopie/hash.c
==============================================================================
--- stable/9/contrib/opie/libopie/hash.c	Mon Aug 20 18:19:06 2012	(r239458)
+++ stable/9/contrib/opie/libopie/hash.c	Mon Aug 20 18:26:16 2012	(r239459)
@@ -17,6 +17,8 @@ you didn't get a copy, you may request o
 $FreeBSD$
 */
 
+#include <sys/endian.h>
+
 #include "opie_cfg.h"
 #include "opie.h"
 
@@ -39,6 +41,13 @@ unsigned algorithm)
       SHA1_Final((unsigned char *)digest, &sha);
       results[0] = digest[0] ^ digest[2] ^ digest[4];
       results[1] = digest[1] ^ digest[3];
+
+      /*
+       * RFC2289 mandates that we convert SHA1 digest from big-endian to little
+       * see Appendix A.
+       */
+      results[0] = bswap32(results[0]);
+      results[1] = bswap32(results[1]);
       };
       break;
     case 4:

Modified: stable/9/contrib/opie/libopie/hashlen.c
==============================================================================
--- stable/9/contrib/opie/libopie/hashlen.c	Mon Aug 20 18:19:06 2012	(r239458)
+++ stable/9/contrib/opie/libopie/hashlen.c	Mon Aug 20 18:26:16 2012	(r239459)
@@ -14,6 +14,8 @@ you didn't get a copy, you may request o
 $FreeBSD$
 */
 
+#include <sys/endian.h>
+
 #include "opie_cfg.h"
 #include "opie.h"
 
@@ -36,6 +38,13 @@ VOIDPTR in AND struct opie_otpkey *out A
       SHA1_Final((unsigned char *)digest, &sha);
       results[0] = digest[0] ^ digest[2] ^ digest[4];
       results[1] = digest[1] ^ digest[3];
+
+      /*
+       * RFC2289 mandates that we convert SHA1 digest from big-endian to little
+       * see Appendix A.
+       */
+      results[0] = bswap32(results[0]);
+      results[1] = bswap32(results[1]);
       break;
     }
     case 4: {


More information about the svn-src-stable-9 mailing list