util-linux/util-linux-ng-add-loop_fish2-compatability.diff

39 lines
1.7 KiB
Diff

Index: util-linux-ng-2.13rc2+git20070725/mount/lomount.c
===================================================================
--- util-linux-ng-2.13rc2+git20070725.orig/mount/lomount.c
+++ util-linux-ng-2.13rc2+git20070725/mount/lomount.c
@@ -338,13 +338,11 @@ set_loop(const char *device, const char
if (encryption && *encryption) {
// a hint for suse users
- if(!strcmp(encryption, "twofishSL92")) {
- fprintf(stderr, _("twofishSL92 is not supported via cryptoloop, please use dm-crypt to access the volume\n"));
- close(fd);
- close(ffd);
- return 1;
- }
- if (digits_only(encryption)) {
+ if(!phash && (!strcmp(encryption, "twofishSL92") || (!strcmp(encryption, "twofish") && !keysz))) {
+ fprintf(stderr,"Switching to old S.u.S.E. loop_fish2 compatibility mode.\n");
+ fprintf(stderr, _("Warning: This mode is deprecated, support for it will be removed in the future.\n"));
+ loopinfo64.lo_encrypt_type = 3; // LO_CRYPT_FISH
+ } else if (digits_only(encryption)) {
loopinfo64.lo_encrypt_type = atoi(encryption);
} else {
// check for something like twofish256
@@ -405,6 +403,14 @@ set_loop(const char *device, const char
hfunc = sha512_hash_buffer;
if(loopinfo64.lo_encrypt_key_size == 24) hfunc = sha384_hash_buffer;
if(loopinfo64.lo_encrypt_key_size == 32) hfunc = sha512_hash_buffer;
+ } else if(loopinfo64.lo_encrypt_type == 3 ) { // LO_CRYPT_FISH
+ if(!strcmp(encryption, "twofishSL92")) {
+ hfunc = sha512_hash_buffer;
+ loopinfo64.lo_encrypt_key_size = 32;
+ } else {
+ hfunc = phash_rmd160;
+ loopinfo64.lo_encrypt_key_size = 20;
+ }
} else {
hfunc = phash_none;
loopinfo64.lo_encrypt_key_size = keysz?keysz>>3:LO_KEY_SIZE;