1f1c316a3SStephan Mueller /* 32-bit compatibility syscall for 64-bit systems for DH operations 2f1c316a3SStephan Mueller * 3f1c316a3SStephan Mueller * Copyright (C) 2016 Stephan Mueller <smueller@chronox.de> 4f1c316a3SStephan Mueller * 5f1c316a3SStephan Mueller * This program is free software; you can redistribute it and/or 6f1c316a3SStephan Mueller * modify it under the terms of the GNU General Public License 7f1c316a3SStephan Mueller * as published by the Free Software Foundation; either version 8f1c316a3SStephan Mueller * 2 of the License, or (at your option) any later version. 9f1c316a3SStephan Mueller */ 10f1c316a3SStephan Mueller 11f1c316a3SStephan Mueller #include <linux/uaccess.h> 12f1c316a3SStephan Mueller 13f1c316a3SStephan Mueller #include "internal.h" 14f1c316a3SStephan Mueller 15f1c316a3SStephan Mueller /* 16f1c316a3SStephan Mueller * Perform the DH computation or DH based key derivation. 17f1c316a3SStephan Mueller * 18f1c316a3SStephan Mueller * If successful, 0 will be returned. 19f1c316a3SStephan Mueller */ 20f1c316a3SStephan Mueller long compat_keyctl_dh_compute(struct keyctl_dh_params __user *params, 21f1c316a3SStephan Mueller char __user *buffer, size_t buflen, 22f1c316a3SStephan Mueller struct compat_keyctl_kdf_params __user *kdf) 23f1c316a3SStephan Mueller { 24f1c316a3SStephan Mueller struct keyctl_kdf_params kdfcopy; 25f1c316a3SStephan Mueller struct compat_keyctl_kdf_params compat_kdfcopy; 26f1c316a3SStephan Mueller 27f1c316a3SStephan Mueller if (!kdf) 28f1c316a3SStephan Mueller return __keyctl_dh_compute(params, buffer, buflen, NULL); 29f1c316a3SStephan Mueller 30f1c316a3SStephan Mueller if (copy_from_user(&compat_kdfcopy, kdf, sizeof(compat_kdfcopy)) != 0) 31f1c316a3SStephan Mueller return -EFAULT; 32f1c316a3SStephan Mueller 33f1c316a3SStephan Mueller kdfcopy.hashname = compat_ptr(compat_kdfcopy.hashname); 34f1c316a3SStephan Mueller kdfcopy.otherinfo = compat_ptr(compat_kdfcopy.otherinfo); 35f1c316a3SStephan Mueller kdfcopy.otherinfolen = compat_kdfcopy.otherinfolen; 364f9dabfaSEric Biggers memcpy(kdfcopy.__spare, compat_kdfcopy.__spare, 374f9dabfaSEric Biggers sizeof(kdfcopy.__spare)); 38f1c316a3SStephan Mueller 39f1c316a3SStephan Mueller return __keyctl_dh_compute(params, buffer, buflen, &kdfcopy); 40f1c316a3SStephan Mueller } 41