summaryrefslogtreecommitdiff
path: root/usr/src/lib/libresolv2/common/dnssafe/bigsmod.c
blob: 8e44e847734b1ee4f2e974c5b43cd57285bba37f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
 * Copyright (c) 1999 by Sun Microsystems, Inc.
 * All rights reserved.
 */

#pragma ident	"%Z%%M%	%I%	%E% SMI"

/* Copyright (C) RSA Data Security, Inc. created 1987, 1996.  This is an
   unpublished work protected as such under copyright law.  This work
   contains proprietary, confidential, and trade secret information of
   RSA Data Security, Inc.  Use, disclosure or reproduction without the
   express written authorization of RSA Data Security, Inc. is
   prohibited.
 */

#include "port_before.h"
#include "global.h"
#include "bigmath.h"
#include "port_after.h"

UINT2 BigSmod (a, v, n)
UINT2 *a;
unsigned int v;
unsigned int n;
{
  UINT4 r = (UINT4)0;
  register int i;
  unsigned int scale;

  scale = (unsigned int)((UINT4)65536 % (UINT4)v);

  for (i = n-1; i >= 0; i--) {
    r = (r*scale) + (UINT4)a[i];
    r = r % (UINT4)v;
  }
  return ((UINT2)r);
}