OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
use bcrypt_newhash in encrypt

From: Ted Unangst (tedutedunangst.com)
Date: Tue Sep 16 2014 - 17:17:22 CDT


This doesn't change a whole lot, but I'd like to start using the new
bcrypt api where feasible and move away from the crypt wrappers.

Index: encrypt.c
===================================================================
RCS file: /cvs/src/usr.bin/encrypt/encrypt.c,v
retrieving revision 1.32
diff -u -p -r1.32 encrypt.c
--- encrypt.c 3 Sep 2014 08:26:00 -0000 1.32
+++ encrypt.c 16 Sep 2014 22:13:43 -0000
-105,6 +105,14 print_passwd(char *string, int operation
         int pwd_gensalt(char *, int, login_cap_t *, char);
         void to64(char *, u_int32_t, int n);
 
+ if (operation == DO_BLF) {
+ if (bcrypt_newhash(string, *(int *)extra, buffer,
+ sizeof(buffer)) != 0)
+ errx(1, "bcrypt newhash failed");
+ fputs(buffer, stdout);
+ return;
+ }
+
         switch(operation) {
         case DO_MAKEKEY:
                 /*
-116,11 +124,6 print_passwd(char *string, int operation
                 }
                 strlcpy(msalt, &string[8], sizeof msalt);
                 salt = msalt;
- break;
-
- case DO_BLF:
- strlcpy(buffer, bcrypt_gensalt(*(int *)extra), _PASSWORD_LEN);
- salt = buffer;
                 break;
 
         case DO_DES: