From: LaMont Jones Date: Fri, 12 Oct 2007 02:51:36 +0000 (-0600) Subject: Merge commit 'origin/master' X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f28f6a8bd4790e8d9b380a6cd14513631d3656b;p=util-linux Merge commit 'origin/master' --- 5f28f6a8bd4790e8d9b380a6cd14513631d3656b diff --cc mount/lomount.c index 37b64137,737194e9..69107910 --- a/mount/lomount.c +++ b/mount/lomount.c @@@ -335,78 -331,14 +335,78 @@@ set_loop(const char *device, const cha break; case LO_CRYPT_XOR: pass = getpass(_("Password: ")); - goto gotpass; - default: - pass = xgetpass(pfd, _("Password: ")); - gotpass: memset(loopinfo64.lo_encrypt_key, 0, LO_KEY_SIZE); - xstrncpy(loopinfo64.lo_encrypt_key, pass, LO_KEY_SIZE); + xstrncpy((char *)loopinfo64.lo_encrypt_key, pass, LO_KEY_SIZE); memset(pass, 0, strlen(pass)); loopinfo64.lo_encrypt_key_size = LO_KEY_SIZE; + break; +#define HASHLENGTH 20 +#if 0 + case LO_CRYPT_FISH2: + case LO_CRYPT_BLOW: + case LO_CRYPT_IDEA: + case LO_CRYPT_CAST128: + case LO_CRYPT_SERPENT: + case LO_CRYPT_MARS: + case LO_CRYPT_RC6: + case LO_CRYPT_3DES: + case LO_CRYPT_DFC: + case LO_CRYPT_RIJNDAEL: + { + char keybits[2*HASHLENGTH]; + char *pass2; + int passwdlen; + int keylength; + int i; + + pass = xgetpass(pfd, _("Password: ")); + passwdlen=strlen(pass); + pass2=malloc(passwdlen+2); + pass2[0]='A'; + strcpy(pass2+1,pass); + rmd160_hash_buffer(keybits,pass,passwdlen); + rmd160_hash_buffer(keybits+HASHLENGTH,pass2,passwdlen+1); + memcpy((char*)loopinfo64.lo_encrypt_key,keybits,2*HASHLENGTH); + memset(pass, 0, passwdlen); + memset(pass2, 0, passwdlen+1); + free(pass2); + keylength=0; + for(i=0; crypt_type_tbl[i].id != -1; i++){ + if(loopinfo64.lo_encrypt_type == crypt_type_tbl[i].id){ + keylength = crypt_type_tbl[i].keylength; + break; + } + } + loopinfo64.lo_encrypt_key_size=keylength; + break; + } +#endif + default: + if (hash_pass) { + char keybits[2*HASHLENGTH]; + char *pass2; + int passwdlen; + + pass = xgetpass(pfd, _("Password: ")); + passwdlen=strlen(pass); + pass2=malloc(passwdlen+2); + pass2[0]='A'; + strcpy(pass2+1,pass); + rmd160_hash_buffer(keybits,pass,passwdlen); + rmd160_hash_buffer(keybits+HASHLENGTH,pass2,passwdlen+1); + memset(pass, 0, passwdlen); + memset(pass2, 0, passwdlen+1); + free(pass2); + + memcpy((char*)loopinfo64.lo_encrypt_key,keybits,keysz/8); + loopinfo64.lo_encrypt_key_size = keysz/8; + } else { + pass = xgetpass(pfd, _("Password: ")); + memset(loopinfo64.lo_encrypt_key, 0, LO_KEY_SIZE); + xstrncpy(loopinfo64.lo_encrypt_key, pass, LO_KEY_SIZE); + memset(pass, 0, strlen(pass)); + loopinfo64.lo_encrypt_key_size = LO_KEY_SIZE; + } } if (ioctl(fd, LOOP_SET_FD, ffd) < 0) {