Skip to content

Commit

Permalink
gss_krb5: use lcm from kernel lib
Browse files Browse the repository at this point in the history
Replace hardcoded lowest common multiple algorithm by the lcm()
function in kernel lib.

Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
  • Loading branch information
Luis Henriques authored and J. Bruce Fields committed Jan 24, 2014
1 parent d50e613 commit c692554
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions net/sunrpc/auth_gss/gss_krb5_keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
#include <linux/crypto.h>
#include <linux/sunrpc/gss_krb5.h>
#include <linux/sunrpc/xdr.h>
#include <linux/lcm.h>

#ifdef RPC_DEBUG
# define RPCDBG_FACILITY RPCDBG_AUTH
Expand All @@ -72,7 +73,7 @@
static void krb5_nfold(u32 inbits, const u8 *in,
u32 outbits, u8 *out)
{
int a, b, c, lcm;
unsigned long ulcm;
int byte, i, msbit;

/* the code below is more readable if I make these bytes
Expand All @@ -82,17 +83,7 @@ static void krb5_nfold(u32 inbits, const u8 *in,
outbits >>= 3;

/* first compute lcm(n,k) */

a = outbits;
b = inbits;

while (b != 0) {
c = b;
b = a%b;
a = c;
}

lcm = outbits*inbits/a;
ulcm = lcm(inbits, outbits);

/* now do the real work */

Expand All @@ -101,7 +92,7 @@ static void krb5_nfold(u32 inbits, const u8 *in,

/* this will end up cycling through k lcm(k,n)/k times, which
is correct */
for (i = lcm-1; i >= 0; i--) {
for (i = ulcm-1; i >= 0; i--) {
/* compute the msbit in k which gets added into this byte */
msbit = (
/* first, start with the msbit in the first,
Expand Down

0 comments on commit c692554

Please sign in to comment.